Playing AMR file or descriptor. (Playing is possible only in Emulator)

Login to reply to this topic.
Wed, 2005-08-17 13:32
Joined: 2005-07-16
Forum posts: 127
//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.

Thu, 2005-08-18 05:03
Joined: 2003-04-01
Forum posts: 142
Re: Playing AMR file or descriptor. (Playing is possible only in
If I remember right nokia removed some AMR support with teh FP1, if you would try this code in 6600, it propably would work just fine. Anyway best way (that works in all OS 7.0 & OS 8.0 devices) to play AMR files is propably using streaming, check other discussion threads and you'll find quite a lot of information of this topic in this forum as well as in forum nokia discussion board.

yucca
Thu, 2005-08-18 08:32
Joined: 2005-07-16
Forum posts: 127
Re: Playing AMR file or descriptor. (Playing is possible only in
Hi yucca,

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.
Thu, 2005-08-18 10:57
Joined: 2003-04-01
Forum posts: 142
Re: Playing AMR file or descriptor. (Playing is possible only in
I posted some code in forum nokia today, so have alook in here: http://discussion.forum.nokia.com/forum/showthread.php?s=&threadid=65718

yucca
Thu, 2005-08-18 11:29
Joined: 2005-07-16
Forum posts: 127
I don't know how to thank you.
Hello yucca,

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
Thu, 2005-08-18 12:11
Joined: 2005-07-16
Forum posts: 127
Re: Playing AMR file or descriptor. (Playing is possible only in
Hello yucca,

#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
Fri, 2005-08-19 07:38
Joined: 2005-07-16
Forum posts: 127
CMdaAudioPlayerUtility can play amr file in Nokia6600
Hello,

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
Sat, 2005-08-20 08:14
Joined: 2003-04-01
Forum posts: 142
Re: Playing AMR file or descriptor. (Playing is possible only in
what sort of behaviour are you getting in your target device ?

Any errors shown ?

yucca
  • Login to reply to this topic.