×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    224

    Converting from AMR to PCM16 does not work!!!

    Hi everybody,

    I have been trying to play AMR file. I used lots of different way to do it. I could not success from any of it. Finally I used CMMFCodec to convert AMR to PCM16 then play the stream.

    But Conversion did not work. I took the code snippet from this Forum. I would really appreciate if somebody tell me what I am doing wrong.

    void PlayStreamL()
    {
    RFs fs;
    CleanupClosePushL(fs);
    User::LeaveIfError(fs.Connect());
    RFile file;
    CleanupClosePushL(file);

    TFileName streamFile(KAmrFile);
    User::LeaveIfError(CompleteWithAppPath(streamFile));
    User::LeaveIfError(file.Open(fs, streamFile, EFileRead | EFileShareReadersOnly));

    TInt fileSize = 0;
    file.Size(fileSize);
    iStreamData = new (ELeave) TUint8[fileSize];

    iStreamBuffer = new (ELeave) TPtr8(iStreamData, fileSize, fileSize);
    file.Read(*iStreamBuffer);

    //Now iStreamBuffer contains AMR data

    CMMFCodec* codec = CMMFCodec::NewL(TUid::Uid(0x101FAF67));
    CleanupStack::PushL(codec);

    //Program crashes here because 320 is smaller the the AMR file size, I also increased it. I read that AMR frame size should be 320.
    CMMFDescriptorBuffer* srcbuf = CMMFDescriptorBuffer::NewL(320);
    CleanupStack::PushL(srcbuf);
    // Copy your PCM frame data into srcbuf, for example:
    srcbuf->Data().Copy(*iStreamBuffer);
    CMMFDescriptorBuffer* dstbuf = CMMFDescriptorBuffer::NewL(320);
    CleanupStack::PushL(dstbuf);

    //Does not process the AMR data, I get the result.iStatus as EDistNotFilled.
    TCodecProcessResult result = codec->ProcessL(*srcbuf, *dstbuf);
    // dstbuf is empty.

    TDesC8 temp = dstbuf->Data();
    HBufC8* buf = temp.Alloc();
    *iStreamBuffer = buf->Des();

    CleanupStack::PopAndDestroy(dstbuf);
    CleanupStack::PopAndDestroy(srcbuf);
    CleanupStack::PopAndDestroy(codec);

    CleanupStack::PopAndDestroy(2);

    iState = EPlaying;
    iPlayerStream = CMdaAudioOutputStream::NewL(*this);
    iPlayerStream->Open(&iStreamSettings);
    }

    Thanks for any comments.

  2. #2
    Regular Contributor
    Join Date
    Jun 2005
    Location
    Philippines
    Posts
    163

    Unhappy Re: Converting from AMR to PCM16 does not work!!!

    Has anyone solved this? I get EDstNotFilled or EProcessIncomplete errors. I tried giving an output of 1 for EProcessComplete, 2 for EDstNotFilled, and 3 for EProcessIncomplete. My program gives an output of 2 most of the time, 3 every now and then, and 1 least of the time. This is what happens when I try to convert AMR to PCM16.

Posting Permissions

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