×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    52

    reading file header to descriptor

    HI,
    I am trying to read the header of a AMR (6 bytes total) or WAV (2 or 4 bytes at a time) file into a descriptor, but I can't seem to get it working. I have tried usinh a HBufC, but this only works (sort of) with the WAV file.

    Basically I need to extract the information contained in the file header, 2, 4 or 6 bytes at a time.

    Does anyone know how I could do this?

    Thanks,
    Miranda

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    could you put your code here? I think there is no reason, why it works with wav and not with amr...


    I could put here class for AMR frame header,may be usefull...

    // count of amr types
    #define AMR_NUMTYPES 16


    class TAMRFrameHeader : public CBase
    {

    public:

    ///
    /// C++ constructor
    ///
    TAMRFrameHeader();

    ///
    /// C++ constructor with unpacking header
    /// param : aHeader - 8 bit frame header
    ///
    TAMRFrameHeader( TUint8 aHeader );

    ///
    /// C++ constructor
    /// param : aType - frame type
    /// param : aQuality - frame quality
    ///
    TAMRFrameHeader( TUint8 aType, TUint8 aQuality);

    ///
    /// C++ destructor
    ///
    ~TAMRFrameHeader() {};

    ///
    /// pack and return fram header in TUint8
    ///
    void Pack( TUint8& aHeader );

    ///
    /// unpack header from TUint8 into class itself
    ///
    void Unpack( TUint8 aHeader );

    ///
    /// is header valid according to rfc 3267?
    ///
    TBool IsValid( TUint8 aHeader );

    ///
    /// return amr frame type
    ///
    TInt8 Type();

    ///
    /// return amr frame type textual description
    ///
    TPtrC8& TypeDescription();

    ///
    /// return quality
    ///
    TInt8 Quality();
    private:

    TInt8 iType;
    TInt8 iQuality;
    TPtrC8 iAmrTypes[ AMR_NUMTYPES ];
    };

    // --------------------------------------------------------
    // C++ constructor
    // --------------------------------------------------------
    TAMRFrameHeader::TAMRFrameHeader()
    {
    iType = 0;
    iQuality = 0;
    iAmrTypes[0].Set( _L8( "4.75kbps" ) );
    iAmrTypes[1].Set( _L8( "5.15kbps" ) );
    iAmrTypes[2].Set( _L8( "5.90kbps" ) );
    iAmrTypes[3].Set( _L8( "6.70kbps" ) );
    iAmrTypes[4].Set( _L8( "7.40kbps" ) );
    iAmrTypes[5].Set( _L8( "7.95kbps" ) );
    iAmrTypes[6].Set( _L8( "10.20kbps" ) );
    iAmrTypes[7].Set( _L8( "12.20kbps" ) );
    iAmrTypes[8].Set( _L8( "AMR Silence" ) );
    iAmrTypes[9].Set( _L8( "GSM-EFR Silence" ) );
    iAmrTypes[10].Set( _L8( "TDMA-EFR Silence" ) );
    iAmrTypes[11].Set( _L8( "PDC-EFR Silence" ) );
    iAmrTypes[12].Set( _L8( "Future Use" ) );
    iAmrTypes[13].Set( _L8( "Future Use" ) );
    iAmrTypes[14].Set( _L8( "Future Use" ) );
    iAmrTypes[15].Set( _L8( "No data" ) );
    };

    // --------------------------------------------------------
    // C++ constructor with unpacking header
    // --------------------------------------------------------
    TAMRFrameHeader::TAMRFrameHeader( TUint8 aHeader )
    {
    TAMRFrameHeader::TAMRFrameHeader();
    Unpack( aHeader );
    }

    // --------------------------------------------------------
    // C++ constructor
    // --------------------------------------------------------
    TAMRFrameHeader::TAMRFrameHeader( TUint8 aType, TUint8 aQuality)
    {
    TAMRFrameHeader::TAMRFrameHeader();
    iType = aType;
    iQuality = aQuality;
    }

    // --------------------------------------------------------
    //
    // pack and return fram header in TUint8
    //
    // +-+-+-+-+-+-+-+-+
    // |P| FT |Q|P|P|
    // +-+-+-+-+-+-+-+-+
    //
    // P fields must be zero
    // FT frame type
    // Q quality
    //
    // --------------------------------------------------------
    void TAMRFrameHeader::Pack( TUint8& aHeader )
    {
    aHeader = ( ( iType & 0xf) << 3 ) && ( ( iQuality & 0x1 ) << 2 );
    }

    // --------------------------------------------------------
    // unpack header from TUint8 into class itself
    // --------------------------------------------------------
    void TAMRFrameHeader::Unpack( TUint8 aHeader )
    {
    iType = ( aHeader >> 3 ) & 0xf;
    iQuality = ( aHeader >> 2 ) & 0x1;
    }

    // --------------------------------------------------------
    // is header valid according to rfc 3267?
    // P bits must be 0!
    // --------------------------------------------------------
    TBool TAMRFrameHeader::IsValid( TUint8 aHeader )
    {
    // 10000011b = 0x83
    return ( (aHeader & 0x83) ? EFalse : ETrue );
    }

    // --------------------------------------------------------
    // return amr frame type
    // --------------------------------------------------------
    TInt8 TAMRFrameHeader::Type()
    {
    return iType;
    }

    // --------------------------------------------------------
    // return amr frame type textual description
    // --------------------------------------------------------
    TPtrC8& TAMRFrameHeader::TypeDescription()
    {
    return iAmrTypes[ iType ];
    }

    // --------------------------------------------------------
    // return quality
    // --------------------------------------------------------
    TInt8 TAMRFrameHeader::Quality()
    {
    return iQuality;
    }

    Bye STEN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×