Playing AMR file or descriptor. (Playing is possible only in Emulator)
| Wed, 2005-08-17 13:32 | |
|
//I have implemented the AMR playing functionalities in CAudioPlayerEngine class
//Declaration of required constants //I hardcoded the amr file, you could use some file browser or you can get amr data from the descriptor array. _LIT(KAmrFile, "\\system\\apps\\AudioPlayer\\test.amr"); //Cosntants needed for playing the amr file/descriptor const TUid KMMFExControllerUID = {0x101F5022}; const TUid KMMFExDesFormatUID = {0x101FAF66}; const TUint32 KMMFFourCCCodeAMR = {0x524d4120}; void CAudioPlayerEngine::ConstructL() { //Declare "CMdaAudioRecorderUtility* iAmrPlayer" in the header file iAmrPlayer = CMdaAudioRecorderUtility::NewL(*this,NULL,EMdaPriorityNormal,EMdaPriorityPreferenceTimeAndQuality); } void CAudioPlayerEngine::PlayAmrL() { /* This method shows how amr file can be played from the descriptor. AMR file is first read from the file to iStreamBuffer which is a TPtr8 to the descriptor data. Then OpenDesL method is used to play the file. */ RFs fs; CleanupClosePushL(fs); // PUSH User::LeaveIfError(fs.Connect()); RFile file; CleanupClosePushL(file); // PUSH TFileName streamFile(KAmrFile); User::LeaveIfError(CompleteWithAppPath(streamFile)); User::LeaveIfError(file.Open(fs, streamFile, EFileRead | EFileShareReadersOnly)); TInt fileSize = 0; file.Size(fileSize); //Declare in header file "TUint8* iSteamData" iStreamData = new (ELeave) TUint8[fileSize]; //Declare in header file "TPtr8* iStreamBuffer" iStreamBuffer = new (ELeave) TPtr8(iStreamData, fileSize, fileSize); file.Read(*iStreamBuffer); //OpenDesL method opens the amr stored in the descriptor buffer, as soon as the opening completes, //MoscoStateChangeEvent(..) callback method is called iAmrPlayer->OpenDesL(*iStreamBuffer,KMMFExControllerUID,KMMFExControllerUID, KMMFExDesFormatUID,KMMFFourCCCodeAMR); CleanupStack::PopAndDestroy(2); /* This is another method for playing amr file. amr file is directly played from the file itself. In both cases CMdaAudioRecorderUtility class is used. */ /* TFileName amrFile(KAmrFile); User::LeaveIfError(CompleteWithAppPath(amrFile)); iAmrPlayer->OpenFileL(amrFile,KMMFExControllerUID,KMMFExControllerUID, KMMFExDesFormatUID,KMMFFourCCCodeAMR); */ } void CAudioPlayerEngine::MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) { //Checking the curren state. Current state has to be EOpen and aErrorCode has to be KErrNone. if((aErrorCode == KErrNone) && (aCurrentState == iAmrPlayer->EOpen)) { iState = EPlaying; iAmrPlayer->PlayL(); } } //Above solution is working only with emulator. I don't kknow why. I am trying to play amr in the Nokia7610 device. It could not //play the file. I am using Symbian OS 7.0 and SDK 2.0. Only emulator can play it. I really appreciate any help regarding this. |
|






Forum posts: 142
yucca
Forum posts: 127
I have been searching for AMR streaming example. But I am unable to find any. Could you please give me some sample code. I am really stuck with this problem for logn time. If you want, you can send it to my email: shagor.evtek@gmail.com.
Thank you again, yucca.
Forum posts: 142
yucca
Forum posts: 127
I really appreciate for your kindness. However I tried to put your code in my application. I have been facing some problem. I have got few questions:
In this method, ConvertAmr2PcmL(const TDesC8& aAmrData,TDes8& aDestBuffer)
I get : result.iStatus EDstNotFilled
TCodecProcessResult result = iOCodec->ProcessL(*iAmrBuffer,*iPcm16Buffer);;
So it's not playing amr file.
If you want I can send you the whole application. I guess it would be easier for you to point out the problem.
Hope to hearing from you.
Regards,
shagor
Forum posts: 127
#include <amrcodec.h>
TAmrEncParams params;
params.iMode = 0;
iOCodec->ConfigureL(TUid::Uid(0x101FAF67),(const TDesC8&)params );
TCodecProcessResult result = iOCodec->ProcessL(*iAmrBuffer,*iPcm16Buffer);
I used the above technique for Configuring. I get error "Feature not supported(-5). It gets this error as soon as it calls ConfigureL(..).
I don't know what to do.
I put the whole application including one test.amr file in the following location:
http://users.evtek.fi/~muhammki/AudioStreamExample.zip
It would be so kind of you to take a look the application.
I used: Symbian OS: 7.0s
SDK 2.0
Forum posts: 127
I had tested for playing AMR file in Nokia6600 using CMdaAudioPlayerUtility class. It worked quite nice. I could not play it in Nokia7610.
I guess streaming amr is the most working solution which can play in all devices. I have been trying the app using stream. I am following one example given by yucca. I have not still got it working.
I put the whole application including one test.amr file in the following location:
http://users.evtek.fi/~muhammki/AudioStreamExample.zip
I really appreciate if anybody can solve it.
Regards,
shagor
Forum posts: 142
Any errors shown ?
yucca