×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    4

    PCM to AMR encoder

    Hi,
    I am trying to implement audio streaming in Nokia 6630 using symbian 8.0. I could do it successfully for PCM format. Now I want to convert the data to AMR.
    I found this piece of code in one of the forum to convert PCM to AMR
    // Uid of PCM16toAMR codec is 0x101FAF68
    CMMFCodec* codec = CMMFCodec::NewL(TUid::Uid(0x101FAF68));
    CleanupStack::PushL(codec);
    CMMFDescriptorBuffer* srcbuf = CMMFDescriptorBuffer::NewL(320);
    CleanupStack::PushL(srcbuf);
    // Copy your PCM frame data into srcbuf, for example: srcbuf->Data().Copy(pcmbuf);
    CMMFDescriptorBuffer* dstbuf = CMMFDescriptorBuffer::NewL(32);
    CleanupStack::PushL(dstbuf);
    TCodecProcessResult result = codec->ProcessL(*srcbuf, *dstbuf):
    // now the dstbuf contains an AMR frame data
    CleanupStack::PopAndDestroy(dstbuf);
    CleanupStack::PopAndDestroy(srcbuf);
    CleanupStack::PopAndDestroy(codec);

    But the CMMFCodec::ProcessL() is a pure virtual function which needs to be implemented. But I don't know what is the processing included in that? Can anyone help me please?

    kavitha

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142
    check few posts down from here, and you'kll find post from sten that works strait away, just remember to add all needed headers & libraries accordingly.

    yucca

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    4
    Thanks yucca for ur response.
    I have included the following:
    mmf\server\mmfcodec.h
    mmf\server\mmfdatabuffer.h
    mmf\plugin\mmfcodecimplementationuids.hrh
    and the Library:
    MMFServerBaseClasses.lib

    But still i get a syntax error near CMMFCodec::ProcessL(). Can u tell me where I went wrong?

    kavitha

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi kavijohn,

    it is correct that CMMFCodec::ProcessL() is pure virtual, because concrete codec plugins are derived from this class. Look what the SDK says:

    "Codec plugins are derived from CMMFCodec and can be used by controller plugins to convert data from one data type to another."
    ...
    "The functions in the CMMFCodec base class, from which a specific CMMFCodec must derive, are: CMMFCodec::NewL() and CMMFCodec::ProcessL(). Optional additions are CMMFCodec::ConfigureL() and CMMFCodec::ResetL()."

    So now should be clear, that CMMFCodec is just base class. You choose the implementation when NewL() method is called by using fourCC or better concrete codec UID.
    Bye
    STeN

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi for second time,

    I probably found what confuse you. You probably looked into mmf\common\mmfcodec.h file and found here definition of CMMFCodec class. Ok it should look, that its methods ProcessL() and ConfigureL() dont do anything.Let me explain it.

    When you want do build your own codec you will use CMMFCodec class as base and you will write code like this:

    // Declares an example of MMF plug-in codec
    class CMMFExCodec : public CMMFCodec
    {
    public:
    // Construction
    static CMMFCodec* NewL(TAny* aInitParams);
    // Implement CMMFCodec
    TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst);

    private:
    ... const CMMFDataBuffer* iSrc;
    CMMFDataBuffer* iDst;
    };

    Notice, that factory NewL() methods still returns pointer to the base class CMMFCodec! But it returns the pointer to concrete implementation through it, the NewL() method could look like this:

    // Factory function
    CMMFCodec* CMMFExCodec ::NewL(TAny* )
    {
    CMMFExCodec * self=new(ELeave) CMMFExCodec ();
    return self;
    }

    EXACLTY IN THE SAME way is implemented CMMFCodec class - it returns the pointer to instance of concrete codec implementation specified by its uid for example, BUT if uid is false it simply return pointer to 'this', so you cannot use ProcessL() method !!!!

    If something still unclear ask
    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
  •