Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Resolving the encoding mode of an AMR file using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Created: User:Technical writer 2 (04 Jul 2007)
Last edited: hamishwillee (14 Jun 2012)


Resolving the encoding mode of an AMR file


The frame length of an AMR file varies according to the encoding mode (bit rate) of the AMR data. The frame length must be known when using APIs like Audio Proxy Server (APS) for playing back an AMR file, since the APS play data queue must contain exactly one frame per buffer.
Information about the AMR encoding mode can be extracted from the first byte of each frame. The following code example demonstrates how to do this.
Note that AMR files always begin with a 6-byte header ("#!AMR\n"), followed by the frame data.


    #define KAMRHeaderLength 6
    // Table containing AMR-NB frame lengths for each encoding mode
    const TInt KAMRFrameLenTable[8] = { 13, 14, 16, 18, 20, 21, 27, 32 };
    * void ResolveAMRFrameLengthL
    * Parameters:
    *   aFs         File server session
    *   aAMRFile    Path and file name of an AMR-NB file
    *   aFrameLen   On return, contains the frame length
    void ResolveAMRFrameLengthL( RFs& aFs, const TDesC& aAMRFile, TInt& aFrameLen )
      RFile file;   
      User::LeaveIfError( file.Open(aFs, aAMRFile, EFileRead|EFileStream) );
      // Skip the header part
      TBuf8<KAMRHeaderLength> header;
      TInt ret = file.Read( header, KAMRHeaderLength );   
      if( ret == KErrNone )
        file.Read( header, 1 ); // read 1st byte of the first frame
        if( header.Length() )
          // Resolve AMR mode (0..7) and frame length from the table
          TInt mode = (header[0] & 0x38) >> 3; // 0x38 == 00111000
          aFrameLen = KAMRFrameLenTable[mode];

This page was last modified on 14 June 2012, at 07:49.
23 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.