os/mm/devsoundextensions/drmaudioplayer/DRMPlayUtility/src/drmaudioplayeradaptation.cpp
First public contribution.
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: DRM PlayUtility
19 #include <mmf/common/mmfcontrollerframework.h>
20 #include <mmfaudio.h> // MAudioLoadingObserver
21 #include <AudioOutputMessageTypes.h>
22 #include "drmaudioplayeradaptation.h"
24 // This is the UID defined by custom interface builder
25 const TUid KUidCustomInterfaceBuilderImpl = {0x10207A8E};
27 // -----------------------------------------------------------------------------
30 // -----------------------------------------------------------------------------
32 CDrmAudioPlayerAdaptation* CDrmAudioPlayerAdaptation::NewL( MDrmAudioPlayerCallback& aCallback,
34 TMdaPriorityPreference aPref )
36 CDrmAudioPlayerAdaptation* self = new(ELeave) CDrmAudioPlayerAdaptation( aCallback );
37 CleanupStack::PushL(self);
38 self->ConstructL( aPriority, aPref );
39 CleanupStack::Pop(self);
43 // -----------------------------------------------------------------------------
46 // -----------------------------------------------------------------------------
48 CDrmAudioPlayerAdaptation::CDrmAudioPlayerAdaptation(MDrmAudioPlayerCallback& aCallback)
49 :iCallback(&aCallback)
53 // -----------------------------------------------------------------------------
56 // -----------------------------------------------------------------------------
58 void CDrmAudioPlayerAdaptation::ConstructL( TInt aPriority, TMdaPriorityPreference aPref )
67 iMdaPlayUtil = CMdaAudioPlayerUtility::NewL( *this,
73 // -----------------------------------------------------------------------------
76 // -----------------------------------------------------------------------------
78 CDrmAudioPlayerAdaptation::~CDrmAudioPlayerAdaptation()
81 // Delete DMA play utility
83 iMdaPlayUtil->Close();
88 // -----------------------------------------------------------------------------
91 // -----------------------------------------------------------------------------
93 CDrmAudioPlayerAdaptation* CDrmAudioPlayerAdaptation::NewFilePlayerL( const TDesC& aFileName,
94 MDrmAudioPlayerCallback& aCallback,
96 TMdaPriorityPreference aPref)
99 CDrmAudioPlayerAdaptation* self = new(ELeave) CDrmAudioPlayerAdaptation( aCallback );
100 CleanupStack::PushL(self);
101 self->ConstructNewFilePlayerL( aFileName, aPriority, aPref );
102 CleanupStack::Pop(self);
107 // -----------------------------------------------------------------------------
110 // -----------------------------------------------------------------------------
112 void CDrmAudioPlayerAdaptation::ConstructNewFilePlayerL( const TDesC& aFileName,
114 TMdaPriorityPreference aPref )
122 iMdaPlayUtil = CMdaAudioPlayerUtility::NewFilePlayerL( aFileName,
129 // -----------------------------------------------------------------------------
132 // -----------------------------------------------------------------------------
134 CDrmAudioPlayerAdaptation* CDrmAudioPlayerAdaptation::NewDesPlayerL( const TDesC8& aData,
135 MDrmAudioPlayerCallback& aCallback,
137 TMdaPriorityPreference aPref)
140 CDrmAudioPlayerAdaptation* self = new(ELeave) CDrmAudioPlayerAdaptation( aCallback );
141 CleanupStack::PushL(self);
142 self->ConstructNewDesPlayerL( aData, aPriority, aPref );
143 CleanupStack::Pop(self);
149 // -----------------------------------------------------------------------------
152 // -----------------------------------------------------------------------------
154 void CDrmAudioPlayerAdaptation::ConstructNewDesPlayerL( const TDesC8& aData,
156 TMdaPriorityPreference aPref )
164 iMdaPlayUtil = CMdaAudioPlayerUtility::NewDesPlayerL( aData,
171 // -----------------------------------------------------------------------------
174 // -----------------------------------------------------------------------------
176 CDrmAudioPlayerAdaptation* CDrmAudioPlayerAdaptation::NewDesPlayerReadOnlyL( const TDesC8& aData,
177 MDrmAudioPlayerCallback& aCallback,
179 TMdaPriorityPreference aPref)
182 CDrmAudioPlayerAdaptation* self = new(ELeave) CDrmAudioPlayerAdaptation( aCallback );
183 CleanupStack::PushL(self);
184 self->ConstructNewDesPlayerReadOnlyL( aData, aPriority, aPref );
185 CleanupStack::Pop(self);
191 // -----------------------------------------------------------------------------
194 // -----------------------------------------------------------------------------
196 void CDrmAudioPlayerAdaptation::ConstructNewDesPlayerReadOnlyL( const TDesC8& aData,
198 TMdaPriorityPreference aPref )
201 delete this->iMdaPlayUtil;
202 this->iMdaPlayUtil = NULL;
203 this->iMdaPlayUtil = CMdaAudioPlayerUtility::NewDesPlayerReadOnlyL( aData,
210 // -----------------------------------------------------------------------------
213 // -----------------------------------------------------------------------------
215 void CDrmAudioPlayerAdaptation::OpenFileL(const TDesC &aFileName)
217 iMdaPlayUtil->OpenFileL( aFileName );
221 // -----------------------------------------------------------------------------
224 // -----------------------------------------------------------------------------
226 void CDrmAudioPlayerAdaptation::OpenFileL(const RFile& aFile)
228 iMdaPlayUtil->OpenFileL( aFile );
232 // -----------------------------------------------------------------------------
235 // -----------------------------------------------------------------------------
237 void CDrmAudioPlayerAdaptation::OpenFileL(const TMMSource& aSource)
239 iMdaPlayUtil->OpenFileL( aSource );
243 // -----------------------------------------------------------------------------
246 // -----------------------------------------------------------------------------
248 void CDrmAudioPlayerAdaptation::OpenDesL(const TDesC8& aDes)
250 iMdaPlayUtil->OpenDesL(aDes);
254 // -----------------------------------------------------------------------------
257 // -----------------------------------------------------------------------------
259 void CDrmAudioPlayerAdaptation::OpenUrlL( const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType )
261 iMdaPlayUtil->OpenUrlL( aUrl, aIapId, aMimeType);
265 // -----------------------------------------------------------------------------
268 // -----------------------------------------------------------------------------
270 void CDrmAudioPlayerAdaptation::Play()
272 iMdaPlayUtil->Play();
276 // -----------------------------------------------------------------------------
279 // -----------------------------------------------------------------------------
281 void CDrmAudioPlayerAdaptation::Stop()
283 iMdaPlayUtil->Stop();
286 // -----------------------------------------------------------------------------
289 // -----------------------------------------------------------------------------
291 void CDrmAudioPlayerAdaptation::SetVolume( const TInt aVolume )
293 iMdaPlayUtil->SetVolume( aVolume );
297 // -----------------------------------------------------------------------------
300 // -----------------------------------------------------------------------------
302 void CDrmAudioPlayerAdaptation::SetRepeats( TInt aRepeatNumberOfTimes,
303 const TTimeIntervalMicroSeconds& aTrailingSilence )
305 iMdaPlayUtil->SetRepeats( aRepeatNumberOfTimes, aTrailingSilence );
309 // -----------------------------------------------------------------------------
312 // -----------------------------------------------------------------------------
314 void CDrmAudioPlayerAdaptation::SetVolumeRamp( const TTimeIntervalMicroSeconds& aRampDuration )
316 iMdaPlayUtil->SetVolumeRamp( aRampDuration );
320 // -----------------------------------------------------------------------------
323 // -----------------------------------------------------------------------------
325 const TTimeIntervalMicroSeconds& CDrmAudioPlayerAdaptation::Duration()
327 return iMdaPlayUtil->Duration();
331 // -----------------------------------------------------------------------------
334 // -----------------------------------------------------------------------------
336 TInt CDrmAudioPlayerAdaptation::MaxVolume()
338 return iMdaPlayUtil->MaxVolume();
342 // API Additions since version 7.0
344 // -----------------------------------------------------------------------------
347 // -----------------------------------------------------------------------------
349 TInt CDrmAudioPlayerAdaptation::Pause()
351 return iMdaPlayUtil->Pause();
355 // -----------------------------------------------------------------------------
358 // -----------------------------------------------------------------------------
360 void CDrmAudioPlayerAdaptation::Close()
362 iMdaPlayUtil->Close();
366 // -----------------------------------------------------------------------------
369 // -----------------------------------------------------------------------------
371 TInt CDrmAudioPlayerAdaptation::GetPosition(TTimeIntervalMicroSeconds& aPosition)
373 return iMdaPlayUtil->GetPosition(aPosition);
377 // -----------------------------------------------------------------------------
380 // -----------------------------------------------------------------------------
382 void CDrmAudioPlayerAdaptation::SetPosition( const TTimeIntervalMicroSeconds& aPosition )
384 iMdaPlayUtil->SetPosition(aPosition);
388 // -----------------------------------------------------------------------------
391 // -----------------------------------------------------------------------------
393 TInt CDrmAudioPlayerAdaptation::SetPriority( TInt aPriority, TMdaPriorityPreference aPref )
395 return iMdaPlayUtil->SetPriority( aPriority, aPref );
399 // -----------------------------------------------------------------------------
402 // -----------------------------------------------------------------------------
404 TInt CDrmAudioPlayerAdaptation::GetVolume(TInt& aVolume)
406 return iMdaPlayUtil->GetVolume(aVolume);
410 // -----------------------------------------------------------------------------
413 // -----------------------------------------------------------------------------
415 TInt CDrmAudioPlayerAdaptation::GetNumberOfMetaDataEntries( TInt& aNumEntries )
417 return iMdaPlayUtil->GetNumberOfMetaDataEntries( aNumEntries);
421 // -----------------------------------------------------------------------------
424 // -----------------------------------------------------------------------------
426 CMMFMetaDataEntry* CDrmAudioPlayerAdaptation::GetMetaDataEntryL( const TInt aMetaDataIndex )
428 return iMdaPlayUtil->GetMetaDataEntryL(aMetaDataIndex);
432 // -----------------------------------------------------------------------------
435 // -----------------------------------------------------------------------------
437 TInt CDrmAudioPlayerAdaptation::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart,
438 const TTimeIntervalMicroSeconds& aEnd)
440 return iMdaPlayUtil->SetPlayWindow(aStart,aEnd);
444 // -----------------------------------------------------------------------------
447 // -----------------------------------------------------------------------------
449 TInt CDrmAudioPlayerAdaptation::ClearPlayWindow()
451 return iMdaPlayUtil->ClearPlayWindow();
455 // -----------------------------------------------------------------------------
458 // -----------------------------------------------------------------------------
460 TInt CDrmAudioPlayerAdaptation::SetBalance( const TInt aBalance )
462 return iMdaPlayUtil->SetBalance(aBalance);
466 // -----------------------------------------------------------------------------
469 // -----------------------------------------------------------------------------
471 TInt CDrmAudioPlayerAdaptation::GetBalance(TInt& aBalance)
473 return iMdaPlayUtil->GetBalance(aBalance);
477 // -----------------------------------------------------------------------------
480 // -----------------------------------------------------------------------------
482 TInt CDrmAudioPlayerAdaptation::GetBitRate(TUint& aBitRate)
484 return iMdaPlayUtil->GetBitRate(aBitRate);
488 // -----------------------------------------------------------------------------
491 // -----------------------------------------------------------------------------
493 void CDrmAudioPlayerAdaptation::RegisterForAudioLoadingNotification(MAudioLoadingObserver& aCallback)
495 iMdaPlayUtil->RegisterForAudioLoadingNotification(aCallback);
499 // -----------------------------------------------------------------------------
502 // -----------------------------------------------------------------------------
504 void CDrmAudioPlayerAdaptation::GetAudioLoadingProgressL( TInt& aPercentageProgress )
506 iMdaPlayUtil->GetAudioLoadingProgressL(aPercentageProgress);
510 // -----------------------------------------------------------------------------
513 // -----------------------------------------------------------------------------
515 const CMMFControllerImplementationInformation& CDrmAudioPlayerAdaptation::ControllerImplementationInformationL()
517 return iMdaPlayUtil->ControllerImplementationInformationL();
521 // -----------------------------------------------------------------------------
524 // -----------------------------------------------------------------------------
526 TInt CDrmAudioPlayerAdaptation::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination,
528 const TDesC8& aDataTo1,
529 const TDesC8& aDataTo2,
532 return iMdaPlayUtil->CustomCommandSync( aDestination,
541 // -----------------------------------------------------------------------------
544 // -----------------------------------------------------------------------------
546 TInt CDrmAudioPlayerAdaptation::CustomCommandSync( const TMMFMessageDestinationPckg& aDestination,
548 const TDesC8& aDataTo1,
549 const TDesC8& aDataTo2 )
551 return iMdaPlayUtil->CustomCommandSync( aDestination,
559 // -----------------------------------------------------------------------------
562 // -----------------------------------------------------------------------------
564 void CDrmAudioPlayerAdaptation::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination,
566 const TDesC8& aDataTo1,
567 const TDesC8& aDataTo2,
569 TRequestStatus& aStatus)
571 iMdaPlayUtil->CustomCommandAsync( aDestination,
581 // -----------------------------------------------------------------------------
584 // -----------------------------------------------------------------------------
586 void CDrmAudioPlayerAdaptation::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination,
588 const TDesC8& aDataTo1,
589 const TDesC8& aDataTo2,
590 TRequestStatus& aStatus)
592 iMdaPlayUtil->CustomCommandAsync( aDestination,
600 // -----------------------------------------------------------------------------
603 // -----------------------------------------------------------------------------
605 TBool CDrmAudioPlayerAdaptation::IsValidCustomCommandDestination(TUid aDestinationUid, TDesC8& aParam)
607 TBool retValue(ETrue);
609 if( aDestinationUid == KUidInterfaceMMFDRMControl)
613 else if( aDestinationUid == KUidCustomInterfaceBuilderImpl )
615 TRAPD(err, retValue = CheckCustomInterfaceBuilderImplL(aParam));
623 TBool CDrmAudioPlayerAdaptation::CheckCustomInterfaceBuilderImplL(const TDesC8& aParam)
625 TBool retValue(ETrue);
626 RDesReadStream stream(aParam);
627 CleanupClosePushL(stream);
629 paramUid.iUid = stream.ReadInt32L();
630 CleanupStack::PopAndDestroy(&stream);
631 if ( paramUid == KUidAudioOutput )
639 // -----------------------------------------------------------------------------
642 // -----------------------------------------------------------------------------
644 void CDrmAudioPlayerAdaptation::MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& aDuration )
646 iCallback->MdapcInitComplete( aError, aDuration );
650 // -----------------------------------------------------------------------------
653 // -----------------------------------------------------------------------------
655 void CDrmAudioPlayerAdaptation::MapcPlayComplete( TInt aError )
657 iCallback->MdapcPlayComplete( aError );