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.
User::LeaveIfError(file.Open(fs, streamFile, EFileRead | EFileShareReadersOnly));
TInt fileSize = 0;
iStreamData = new (ELeave) TUint8[fileSize];
iStreamBuffer = new (ELeave) TPtr8(iStreamData, fileSize, fileSize);
//Now iStreamBuffer contains AMR data
CMMFCodec* codec = CMMFCodec::NewL(TUid::Uid(0x101FAF67));
//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);
// Copy your PCM frame data into srcbuf, for example:
CMMFDescriptorBuffer* dstbuf = CMMFDescriptorBuffer::NewL(320);
//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();
iState = EPlaying;
iPlayerStream = CMdaAudioOutputStream::NewL(*this);
Thanks for any comments.