Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Implementing Drm player in Symbian

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: tote_b5 (30 Jul 2007)
Last edited: hamishwillee (30 May 2013)

Contents

Header File

#ifndef __SampleDrmplayerUtility_H__
#define __SampleDrmplayerUtility_H__
 
// INCLUDE FILES
#include <e32base.h>
#include <e32std.h>
#include <etel.h>
#include <etel3rdparty.h>
#include <drmaudiosampleplayer.h>
 
//FORWARD DECLARATION
 
class MDrmAudioPlayerCallback;
 
// Following two lines are added to Uplink audio on the voice call channel
#define KAudioPriority 80
#define KAudioPreference 0x00060001
 
class CSampleDrmplayerUtility : public CActive, public MDrmAudioPlayerCallback
{
public: // Constructors and destructors
 
//=================================================================
// NewL
// Two-phased constructor.
// Creates a CSampleDrmplayerUtility object using two phase construction,
// and returns a pointer to the created object.
// @return A pointer to the created instance of CSampleDrmplayerUtility.
//=================================================================
//
static CSampleDrmplayerUtility* NewL();
void RunL();
void DoCancel();
 
//=================================================================
// NewLC
// Two-phased constructor.
// Creates a CSampleDrmplayerUtility object using two phase construction,
// and returns a pointer to the created object.
// @return A pointer to the created instance of CSampleDrmplayerUtility.
//=================================================================
//
static CSampleDrmplayerUtility* NewLC();
 
//=================================================================
// CSampleDrmplayerUtility
// C++ default Destructor.
// Destroys the object and release all memory objects.
// @Return
//=================================================================
virtual ~CSampleDrmplayerUtility();
 
private: // Constructors and destructors
//=================================================================
// CSampleDrmplayerUtility
// C++ default constructor can NOT contain any code, that might leave.
// @Return
//=================================================================
CSampleDrmplayerUtility();
 
//=================================================================
// ConstructL
// Symbian 2nd phase constructor can leave.
//=================================================================
//
void ConstructL();
 
// FOR DRMPLAYER CALLBACKS
 
void MdapcInitComplete (TInt aError, const TTimeIntervalMicroSeconds &
aDuration );
void MdapcPlayComplete (TInt aError);
 
 
public: // APIs exposed to other parties
 
void Playmusic();
void Answercall();
void Stop();
 
private:
 
CDrmPlayerUtility* iMdaAudioPlayerUtility;
CTelephony *iTelephony;
CTelephony::TCallId iCallid;
 
};
 
#endif // __SampleDrmplayerUtility_H__

Source File

#include <e32std.h>			// For system wide contents
#include <eikmenup.h>
#include <eikapp.h>
#include <aknutils.h>
#include <aknnotewrappers.h>
 
#include "SampleDrmplayerUtility.h"
 
// CONSTANTS
 
const TTimeIntervalMicroSeconds MaxRecordLength(10000000);
#define KAudioPrefVoiceRec 0x00060001
const TInt KAudioPriorityAudioPlaybackStreaming = 80;
 
_LIT( KSampleDrmTestFile, "C:\\Data\\Sounds\\Digital\\Baba.amr" );
 
// ========================= MEMBER FUNCTIONS ==================================
 
//=================================================================
// CSampleDrmplayerUtility
// C++ default constructor can NOT contain any code, that might leave.
// @Return
//=================================================================
CSampleDrmplayerUtility::CSampleDrmplayerUtility()
:CActive(EPriorityStandard) {
// No implementation required
}
 
//=================================================================
// NewL
// Two-phased constructor.
// Creates a SampleDrmplayerUtility object using two phase construction,
// and returns a pointer to the created object.
// @return A pointer to the created instance of SampleDrmplayerUtility.
//=================================================================
//
CSampleDrmplayerUtility* CSampleDrmplayerUtility::NewL()
{
CSampleDrmplayerUtility* self = NewLC();
CleanupStack::Pop( self );
return self;
}
 
//=================================================================
// NewLC
// Two-phased constructor.
// Creates a SampleDrmplayerUtility object using two phase construction,
// and returns a pointer to the created object.
// @return A pointer to the created instance of SampleDrmplayerUtility.
//=================================================================
//
CSampleDrmplayerUtility* CSampleDrmplayerUtility::NewLC()
{
CSampleDrmplayerUtility* self = new ( ELeave ) CSampleDrmplayerUtility();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
 
//=================================================================
// ~SampleDrmplayerUtility
// C++ default Destructor.
// @Return
//=================================================================
CSampleDrmplayerUtility::~CSampleDrmplayerUtility()
{
Stop();
Cancel();
 
delete iTelephony;
delete iMdaAudioPlayerUtility;
}
 
//=================================================================
// ConstructL
// Symbian 2nd phase constructor can leave.
//=================================================================
//
void CSampleDrmplayerUtility::ConstructL()
{
CActiveScheduler::Add(this);
 
TBuf<128> iFileName;
iFileName.Append(KSampleDrmTestFile);
 
iMdaAudioPlayerUtility=CDrmPlayerUtility::NewFilePlayerL
(iFileName,*this,80,(TMdaPriorityPreference)0x00060001);
iTelephony=CTelephony::NewL();
}
 
 
void CSampleDrmplayerUtility::Playmusic()
{
if(!iMdaAudioPlayerUtility)
{
iMdaAudioPlayerUtility = CDrmPlayerUtility::NewFilePlayerL
( KSampleDrmTestFile, *this, 80, (TMdaPriorityPreference)0x00060001 );
}
 
User::LeaveIfNull( iMdaAudioPlayerUtility );
iMdaAudioPlayerUtility->Play();
}
 
 
void CSampleDrmplayerUtility::Answercall()
{
iTelephony->AnswerIncomingCall(iStatus,iCallid);
SetActive();
}
 
void CSampleDrmplayerUtility::Stop()
{
iMdaAudioPlayerUtility->Stop();
}
 
//end of file
 
 
void CSampleDrmplayerUtility::RunL()
{
CEikonEnv::InfoWinL(_L("Call Answered"),_L(""));
}
 
void CSampleDrmplayerUtility::DoCancel()
{
CTelephony::CancelAsync( CTelephony::EAnswerIncomingCallCancel );
}
 
 
 
void CSampleDrmplayerUtility::MdapcInitComplete(TInt aError, const
TTimeIntervalMicroSeconds & aDuration )
{
TBuf<10> err1;
err1.AppendNum(aError);
CEikonEnv::InfoWinL(_L("initialisation completed"),err1);
}
 
void CSampleDrmplayerUtility::MdapcPlayComplete(TInt aError)
{
TBuf<10> err2;
err2.AppendNum(aError);
CEikonEnv::InfoWinL(_L("play completed"),err2);
}

Usage and Call of Functions

CSampleDrmplayerUtility* iDrmplayer;
iDrmplayer = CSampleDrmplayerUtility::NewL();
iDrmplayer->Answercall();
iDrmplayer->Playmusic();
iDrmplayer->Stop();
if(iDrmplayer)
{
delete iDrmplayer;
iDrmplayer=NULL;
}


Internal links

This page was last modified on 30 May 2013, at 04:34.
38 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×