mmfenh/enhancedmediaclient/Plugins/ProgDLSource/inc/ProgDLMultimediaSource.h
changeset 16 43d09473c595
parent 14 80975da52420
child 22 128eb6a32b84
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Header of ProgDLMultimediaSource.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __PROGDLMULTIMEDIASOURCE_H_
       
    22 #define __PROGDLMULTIMEDIASOURCE_H_
       
    23 
       
    24 
       
    25 #include <centralrepository.h>  
       
    26 
       
    27 class CReadWriteRequest;
       
    28 class CTransferBufferCopy;
       
    29 class MGenericFile;
       
    30 
       
    31 
       
    32 
       
    33 
       
    34 /**
       
    35 @publishedAll
       
    36 @released
       
    37 
       
    38 MultiMedia framework class.  Represents a physical file.
       
    39 This may be source file from which data is read or destination to which data is written.
       
    40 Intended to be used by controller plugin developers for source and sink plugins.*/
       
    41 
       
    42 class CProgDLMultimediaSource : public CMultimediaDataSource
       
    43     {
       
    44     public:
       
    45         // From MDataSource
       
    46         IMPORT_C static CProgDLMultimediaSource* NewL(MDataSource& aDataSource);
       
    47         
       
    48         // From CMultimediaDataSource begins
       
    49         TInt SetObserver( MMultimediaDataSourceObserver& aObserver );
       
    50         TInt GetObserver( MMultimediaDataSourceObserver*& aObserver );
       
    51         void Event( TUid aEvent );
       
    52         TInt SetDataTypeCode(TFourCC aSourceFourCC );
       
    53         TInt GetDataTypeCode(TFourCC& aSourceFourCC );
       
    54         TInt GetSize( TUint& aSize );
       
    55         TInt Open();
       
    56         TInt Close();
       
    57         TInt Prime();
       
    58         TInt Play();
       
    59         TInt Stop();
       
    60         TInt FillBuffer( CMMFBuffer* aBuffer);
       
    61         TInt Seek( TUint aPosInBytes );
       
    62         TInt GetSeekingSupport( TBool& aSeekSupport );
       
    63         TInt GetRandomSeekingSupport( TBool& aSeekSupport );
       
    64         // From CMultimediaDataSource ends
       
    65         
       
    66         TInt GetDRMProtection( TBool& aIsProtected );
       
    67         TInt EvaluateIntent( ContentAccess::TIntent aIntent ) const;
       
    68         TInt ExecuteIntent( ContentAccess::TIntent aIntent );
       
    69         TInt SetAgentProperty( ContentAccess::TAgentProperty aProperty,
       
    70             TInt aValue);
       
    71         const TDesC& UniqueId() const;
       
    72         // From MCustomInterface
       
    73         TAny* CustomInterface( TUid aInterfaceUid );
       
    74         void SourceCustomCommand(TMMFMessage& aMessage);
       
    75 
       
    76         void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId ) ;
       
    77         
       
    78        
       
    79     public :
       
    80         virtual ~CProgDLMultimediaSource() ;
       
    81         //	static MDataSource* NewSourceL(/*TUid aType*/) ;
       
    82         
       
    83         void SetTransferBuffer (TBool aTBuffer) ;
       
    84         TBool CanUseTransferBuffer () ;
       
    85         TInt ReadRequestStatus(CReadWriteRequest* aRequest,TRequestStatus& aStatus);
       
    86         
       
    87     protected:
       
    88     /**
       
    89     Indicates for which purpose the object instance is being created
       
    90         */
       
    91         enum TMMFileMode
       
    92             {
       
    93             /** The object is created for being a source */
       
    94             ESourceMode,
       
    95                 /** The object is created for being a sink */
       
    96                 ESinkMode
       
    97             };
       
    98 
       
    99         void ConstructL(const TDesC8& aInitData, TMMFileMode aFileMode) ;
       
   100         void ConstructL();
       
   101         CProgDLMultimediaSource(MDataSource& aDataSource);
       
   102         
       
   103         void StoreRequestL( CReadWriteRequest* aRequest ) ;
       
   104         void CancelRequests();
       
   105         
       
   106         TInt EmptySinkQueue();
       
   107         CTransferBufferCopy* ObtainCopyOfTransferBufferL(TInt aMaxLength);
       
   108         
       
   109         // Calculate BufferedDataSize
       
   110         void CalculateBufferedDataSize();
       
   111         void StateChanged(TState newState);
       
   112         
       
   113         // A common function that implements FillBuffer requests
       
   114         TInt AppendBufferToSinkQueue( CMMFBuffer* aBuffer,
       
   115             MMultimediaDataSourceObserver* aObserver,
       
   116             MDataSink* aConsumer,TBool aTop);
       
   117 
       
   118         TInt ServiceFillBuffer();
       
   119     private:
       
   120         
       
   121         // New Functions
       
   122         const TDesC& FileName() const ;
       
   123         const TDesC& Extension() const ;
       
   124         const TDesC& FilePath() const ;
       
   125         const TDesC& FileDrive() const ;
       
   126         const TFileName FullName() const;
       
   127         RFile& FileL() ;
       
   128         
       
   129     private:
       
   130         class CProgDLMultimediaSourceAsyncEventHandler : public MAsyncEventHandler
       
   131             {
       
   132             public:
       
   133                 CProgDLMultimediaSourceAsyncEventHandler(CProgDLMultimediaSource* aParent);
       
   134                 virtual ~CProgDLMultimediaSourceAsyncEventHandler();
       
   135             public:
       
   136                 virtual TInt SendEventToClient(const TMMFEvent& aEvent);
       
   137             private:
       
   138                 CProgDLMultimediaSource* iParent;
       
   139             };
       
   140         
       
   141         class CCAFParameters : public CBase
       
   142             {
       
   143             public:
       
   144                 CCAFParameters() : iUniqueId(NULL), iEnableUI(EFalse) {}
       
   145                 ~CCAFParameters() {	delete iUniqueId;	}
       
   146             public:
       
   147                 HBufC* iUniqueId;
       
   148                 TBool iEnableUI;
       
   149             };
       
   150         
       
   151         void GetAudioConfiguration();
       
   152         TInt ReOpenCAF();
       
   153         
       
   154     private:
       
   155         MGenericFile* iFile;
       
   156         RFs iFsSession;
       
   157         
       
   158         TBool iFileHandle;
       
   159         RFile iHandle;
       
   160         TBool iReserved;
       
   161         
       
   162         TFileName iFullFileName ;
       
   163         HBufC* iFileName ;
       
   164         HBufC* iFileExt ;
       
   165         HBufC* iFilePath ;
       
   166         HBufC* iFileDrive ;
       
   167         CCAFParameters* iCAFParameters;
       
   168         
       
   169         
       
   170         
       
   171         
       
   172         
       
   173         TFourCC  iSinkFourCC ;
       
   174         TFourCC  iSourceFourCC ;
       
   175         
       
   176         // Queue of buffers from controller
       
   177         TSglQue<CSinkQueueItem>* iSinkQueue;
       
   178         //MDataSink* iConsumer;
       
   179         // Sink item Counter
       
   180         TInt iSnkItemsCount;
       
   181         // Observer bit rate in bps
       
   182         //Keeps track of the read position within the file. Needed in order to enable passing of the
       
   183         //read position to the CReadRequest to manage the LastBuffer flag.
       
   184         //NB: Continuous reads once EOF has been reached will result in iPosition going > iDLFileSize,
       
   185         //but this causes no ill effects
       
   186         TUint iSnkBytes;
       
   187         
       
   188         TInt iDownloadSize;
       
   189         
       
   190         // Transfer bit rate in bps
       
   191         TUint   iTransferRate;  
       
   192         
       
   193         TUint   iObserverBitRate;
       
   194         
       
   195         // Buffering size in bytes
       
   196         TUint   iBufferedDataSize;
       
   197         
       
   198         TInt iDLFileSize; //holds the cached file size
       
   199         TMMFMessage* iMessage;
       
   200         
       
   201         MMultimediaDataSourceObserver* iObserver;
       
   202         RPointerArray<CReadWriteRequest> iRequests;
       
   203         
       
   204         MAsyncEventHandler *iEventHandler;
       
   205         
       
   206         RPointerArray<CTransferBufferCopy> iTransferBufferCopies;
       
   207         TBool   isDownloadComplete;
       
   208         
       
   209         TBool iReOpenCAF;
       
   210         
       
   211         TInt iFileSize;
       
   212 
       
   213         // Pointer to the Preset Repository
       
   214 		CRepository* iAudioConfigRepository;
       
   215         TBufferingConfig iPrimaryBufferingConfig;
       
   216         TBufferingConfig iSecondaryBufferingConfig;
       
   217         TUint iInitialBufferingPercentage;
       
   218         TInt iReadRequestPending;
       
   219         MDataSource* iParentDataSource;
       
   220         HBufC8* iInitData;           
       
   221     };
       
   222     
       
   223 #endif