sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @internalTechnology 
sl@0: */
sl@0: 
sl@0: #ifndef MMFDATAPATH2_H
sl@0: #define MMFDATAPATH2_H
sl@0: 
sl@0: #include <mmf/common/mmfcontroller.h>
sl@0: #include <mmf/server/mmfdatasource.h>
sl@0: #include <mmf/server/mmfdatasink.h>
sl@0: #include <mmf/server/mmfcodec.h>
sl@0: #include <mmf/server/mmfbuffer.h>
sl@0: #include <mmf/common/mmfutilities.h>
sl@0: #include <mmf/server/mmfformat.h>
sl@0: #include <mmf/server/mmfsubthreadbase.h>
sl@0: #include <mmf/server/mmfdatapath.h>
sl@0: 
sl@0: /**
sl@0: 
sl@0: This class is an extended version of CMMFDataPath. CMMFDataPath is extended to implement the loop play 
sl@0: functionality in the controller. This class overrides some of the virual functions of CMMFDataPath in order to
sl@0: implement the loop play functionality. All the controller plugins that require loop play functionality should
sl@0: use CMMFDataPath2 in place of CMMFDataPath.
sl@0: 
sl@0: @see CMMFDataPath
sl@0: */
sl@0: class CMMFDataPath2 : public CMMFDataPath
sl@0: 	{
sl@0: public:
sl@0: 	//CMMFDataPath2 constructor if codec Uid is not already known by CMMFController
sl@0: 	//and there is no data path ambiguity - ie only one data path is possible
sl@0: 	IMPORT_C static CMMFDataPath2* NewL(MAsyncEventHandler& aEventHandler); 
sl@0: 
sl@0: 	//CMMFDataPath2 constructor if codec Uid is not already known by CMMFController
sl@0: 	//and there is ambiguity ie more than one possible data path TMediaId used to select path 
sl@0: 	IMPORT_C static CMMFDataPath2* NewL(TMediaId aMediaId, MAsyncEventHandler& aEventHandler); 
sl@0: 
sl@0: 	//CMMFDataPath2 constructor if codec Uid is already known by CMMFController
sl@0: 	//and there is no data path ambiguity - ie only one data path is possible
sl@0: 	IMPORT_C static CMMFDataPath2* NewL(TUid aCodecUid, MAsyncEventHandler& aEventHandler); 
sl@0: 
sl@0: 	//CMMFDataPath2 constructor if codec Uid is already known by CMMFController
sl@0: 	//and there is ambiguity ie more than one possible data path TMediaId used to select path 
sl@0: 	IMPORT_C static CMMFDataPath2* NewL(TUid aCodecUid, TMediaId aMediaId, MAsyncEventHandler& aEventHandler);
sl@0: 
sl@0: 	virtual ~CMMFDataPath2();
sl@0: 	virtual void BufferFilledL(CMMFBuffer* aBuffer); //called by the CMMFDataPath's MDataSource when it has filled the buffer
sl@0: 	
sl@0: 	virtual void PrimeL();
sl@0: 	virtual void PlayL();
sl@0: 	virtual void Pause();
sl@0: 	virtual void Stop();
sl@0: 	virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
sl@0: 	virtual TTimeIntervalMicroSeconds Position() const;
sl@0: 	// Called when source and sink needs to be de-referenced
sl@0: 	virtual void ResetL();
sl@0: 	void RunL();
sl@0: 	// Set Repeats.
sl@0: 	IMPORT_C void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
sl@0: 	IMPORT_C void SetDrmProperties(MDataSource* iDrmSource, TBool *aDisableAutoIntent);
sl@0: 	IMPORT_C void RetainRepeatInfo();
sl@0: 	IMPORT_C void PreEmptionPause();
sl@0: 	
sl@0: protected:
sl@0: 	CMMFDataPath2(TMediaId aMediaId, MAsyncEventHandler& aEventHandler);
sl@0: 	void ConstructL(TUid aCodecUid = KNullUid);
sl@0: 	void FillSourceBufferL();
sl@0: 	void DoFillSourceBufferL();
sl@0: 	TTimeIntervalMicroSeconds CalculateAudioOutputPosition() const;
sl@0: 	//called when trailing silence playback is complete
sl@0: 	static TInt RepeatTrailingSilenceTimerComplete(TAny* aDataPath);
sl@0: 	TInt DoRepeatTrailingSilenceTimerCompleteL();
sl@0: 	void PlaySilence();
sl@0: 	void DoStopL();
sl@0: 	void DoPauseL();
sl@0: 	void DoCancel();
sl@0: 	TTimeIntervalMicroSeconds OutputPosition() const;
sl@0: 	void DoPreEmptionPauseL();
sl@0: 	
sl@0: 	
sl@0: protected:
sl@0: 	/**
sl@0:     The number of times to repeat the audio sample. 
sl@0:     */
sl@0:     TInt iNumberOfTimesToRepeat;
sl@0:     
sl@0:     /**
sl@0:     The number of times played. 
sl@0:     */
sl@0:     TInt iNumberOfTimesPlayed;
sl@0: 	/**
sl@0:     The time interval of the trailing silence in microseconds.
sl@0: 	*/
sl@0: 	TTimeIntervalMicroSeconds iTrailingSilence;
sl@0: 
sl@0: 	/**
sl@0:     The time interval of the trailing silence left to play in microseconds.
sl@0: 	*/
sl@0: 	TTimeIntervalMicroSeconds iTrailingSilenceLeftToPlay;
sl@0: 	
sl@0: 	/**
sl@0:     The time left for the play will be completed in a particular repeat
sl@0: 	*/
sl@0: 	TTimeIntervalMicroSeconds iTimeLeftToPlayComplete;
sl@0: 
sl@0: 	/**
sl@0: 	Timer used for trailing silences when repeating
sl@0: 	*/
sl@0: 	CPeriodic* iRepeatTrailingSilenceTimer;
sl@0: 	//This variable stores the devsound time played when the play is repositioned
sl@0: 	TTimeIntervalMicroSeconds iDevSoundRepositionTime;
sl@0: 	//states when the silence period between repeats needs to be verified
sl@0: 	TBool iVerifyPlayComplete;
sl@0: 	
sl@0: 	//For Drm implementation during repeats
sl@0: 	MDataSource* iDrmSource;
sl@0: 	TBool* iDisableAutoIntent;
sl@0: 	TBool iRetainRepeatInfo;
sl@0: 	TBool iGetTimePlayedSupported;
sl@0: 	TBool iIsResumeSupported;
sl@0: 	TBool iIsUsingResumeSupport;
sl@0: 	TBool iPauseCalledInsilence;
sl@0: 	}; 
sl@0: 
sl@0: #endif