×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    60

    conver PcmToAmr and AmrToPcm dosen`t work...help

    Hi every body,
    I am new on Qt for symbian. I want to convert Pcm to Amr and then Amr to Pcm with this class but it dose not work.
    Any body can help me?

    PCM__AMR.h

    #ifndef PCMTOAMR_H
    #define PCMTOAMR_H

    #include <mmf/server/MmfCodec.h>
    #include <mmf/server/mmfdatabuffer.h>
    #include <mmf/plugin/mmfcodecimplementationuids.hrh>
    #include <e32cmn.h>

    class TAmrEncParams
    {
    public:
    inline TAmrEncParams();

    public:
    TInt iMode; // encoding mode 0-7 (0=MR475,1=MR515,...,7=MR122, default 7)
    TInt iDTX; // DTX (discontinuous transmission) flag (true/false)
    };

    class PCM__AMR
    {
    public:
    PCM__AMR();
    ~PCM__AMR();

    TDesC8* ConvertPcm2AmrL(const TDesC8& aPcmData);
    TDesC8* ConvertAmr2PcmL(const TDesC8& aAmrData);
    };

    #endif // PCMTOAMR_H


    PCM__AMR.cpp

    #include "PCM__AMR.h"
    #include <MdaAudioSampleEditor.h>

    #define MODE 0
    #define KAmrFrameSize 13
    #define KPcmBufferSize 320

    PCM__AMR::PCM__AMR(){}

    PCM__AMR::~PCM__AMR(){}

    TDesC8* PCM__AMR::ConvertPcm2AmrL(const TDesC8& aPcmData)
    {
    TInt s = aPcmData.Size();

    const TUid KMMFCodecAMREncode = {0x101FAF68};
    const TUid KUidConfig = {KUidMmfCodecAudioSettings}; // 0x10203622

    TAmrEncParams iEncoderParams;
    iEncoderParams.iMode = MODE; // AMR-NB mode between 0...7
    iEncoderParams.iDTX = EFalse; // DTX mode

    CMMFCodec* codec = CMMFCodec::NewL(KMMFCodecAMREncode);
    codec->ConfigureL(KUidConfig, (const TDesC8 &)iEncoderParams);

    // Source Buffer
    CMMFDescriptorBuffer* iPcm16Buffer = CMMFDescriptorBuffer::NewL(KPcmBufferSize);
    iPcm16Buffer->Data().Copy(aPcmData);

    // Destination Buffer
    CMMFDescriptorBuffer* iAmrBuffer = CMMFDescriptorBuffer::NewL(KAmrFrameSize);
    TCodecProcessResult result = codec->ProcessL(*iPcm16Buffer, *iAmrBuffer);
    // now the dstbuf contains an AMR frame data

    if((result.iStatus == TCodecProcessResult::EProcessComplete)
    && (result.iSrcBytesProcessed == KPcmBufferSize)
    && (result.iDstBytesAdded == KAmrFrameSize))
    {
    // return result
    return &(iAmrBuffer->Data());
    }
    else
    return NULL;
    }

    TDesC8* PCM__AMR::ConvertAmr2PcmL(const TDesC8& aAmrData)
    {
    TInt size = aAmrData.Length();

    const TUid KMMFCodecPcmDecod = {0x101FAF67}; // KAdvancedUidCodecAMRToPCM16
    const TUid KUidConfig = {KUidMmfCodecAudioSettings}; // 0x10203622

    TAmrEncParams iDecoderParams;
    iDecoderParams.iMode = MODE; // AMR-NB mode between 0...7
    iDecoderParams.iDTX = EFalse; // DTX mode

    CMMFCodec* codec = CMMFCodec::NewL(KMMFCodecPcmDecod);
    codec->ConfigureL(KUidConfig, (const TDesC8 &)iDecoderParams);

    // Source Buffer
    CMMFDescriptorBuffer* iAmrBuffer = CMMFDescriptorBuffer::NewL(KAmrFrameSize);
    iAmrBuffer->Data().Copy(aAmrData); // Copy your PCM frame data into srcbuf

    // Destination Buffer
    CMMFDescriptorBuffer* iPcm16Buffer = CMMFDescriptorBuffer::NewL(KPcmBufferSize);
    TCodecProcessResult result = codec->ProcessL(*iAmrBuffer, *iPcm16Buffer);

    // now the dstbuf contains an AMR frame data

    if((result.iStatus == TCodecProcessResult::EProcessComplete)
    && (result.iSrcBytesProcessed == KAmrFrameSize)
    && (result.iDstBytesAdded == KPcmBufferSize))
    {
    // return buffer
    return &(iPcm16Buffer->Data());
    }
    else
    return NULL;
    }

    TAmrEncParams::TAmrEncParams() :
    iMode(7), iDTX(0) {}

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    60

    Re: conver PcmToAmr and AmrToPcm dosen`t work...help

    Hi, every body
    This class is work and i made a mistake.
    sorry....

Similar Threads

  1. Replies: 1
    Last Post: 2009-10-25, 13:06
  2. MDA Image Conver 2 panic
    By Shilpa13 in forum Symbian
    Replies: 0
    Last Post: 2008-01-04, 10:26
  3. MDA Image conver 2 error
    By bballbeng in forum Symbian
    Replies: 0
    Last Post: 2006-08-27, 15:21
  4. Replies: 0
    Last Post: 2004-10-18, 18:06
  5. MDA Image Conver 2
    By MiKeL in forum Symbian
    Replies: 0
    Last Post: 2004-09-20, 11:07

Posting Permissions

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