Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 08:33, 1 August 2007.

Implementing Drm player in Symbian

From Forum Nokia Wiki

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

 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZdrmQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX