mmfenh/enhancedmediaclient/Plugins/CacheSource/inc/CacheSource.h
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     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:  Definition of the S60 Audio Stream Source custom command msg cods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CACHESOURCE_H
       
    20 #define CACHESOURCE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <DataSourceConfigIntfc.h>
       
    24 #include <MultimediaDataSource.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MDataSource;
       
    28 class CSinkQueueItem;
       
    29 class CReadWriteRequestAO;
       
    30 class CDataSourceConfigIntfc;
       
    31 class CMMFDataBuffer;
       
    32 // CLASS DECLARATION
       
    33 
       
    34 class CMDataSourceObserver : public MMultimediaDataSourceObserver
       
    35     {
       
    36     public:
       
    37       static CMDataSourceObserver* NewL(
       
    38             CMultimediaDataSource* aDataSource
       
    39             ,CMultimediaDataSource* aParent );
       
    40         
       
    41         virtual ~CMDataSourceObserver();
       
    42 
       
    43     private:
       
    44         CMDataSourceObserver(CMultimediaDataSource* aDataSource ,CMultimediaDataSource* aParent);
       
    45         void ConstructL();
       
    46         
       
    47         void BufferFilled( CMMFBuffer* aBuffer );
       
    48         
       
    49         // KStreamControlEventSeekingSupportChanged
       
    50         // KStreamControlEventRandomSeekingSupportChanged
       
    51         // KMultimediaDataSourceObserverEventSourceSizeChanged
       
    52         void Event( TUid aEvent );
       
    53         // Returns BITRATE. This is used for calculation how much of data need to be
       
    54         // buffered by the source before filling observer buffers.
       
    55         TInt GetBitRate( TUint& aBitRate );
       
    56         
       
    57         CMultimediaDataSource* iDataSource;
       
    58         CMultimediaDataSource* iParent;
       
    59     };
       
    60 
       
    61 
       
    62 class CCacheSource : public CMultimediaDataSource
       
    63                             //,public MCacheCopyEngineObserver
       
    64     {
       
    65     public:
       
    66         IMPORT_C static CCacheSource* NewL( CMultimediaDataSource* aDataSource, CDataSourceConfigIntfc* aDataSourceConfig );
       
    67         
       
    68         // From CMultimediaDataSource begins
       
    69         TInt SetObserver( MMultimediaDataSourceObserver& aObserver );
       
    70         TInt GetObserver( MMultimediaDataSourceObserver*& aObserver );
       
    71         void Event( TUid aEvent );
       
    72         TInt SetDataTypeCode(TFourCC aSourceFourCC );
       
    73         TInt GetDataTypeCode(TFourCC& aSourceFourCC );
       
    74         TInt GetSize( TUint& aSize );
       
    75         TInt Open();
       
    76         TInt Close();
       
    77         TInt Prime();
       
    78         TInt Play();
       
    79         TInt Stop();
       
    80         TInt FillBuffer( CMMFBuffer* aBuffer);
       
    81         
       
    82 
       
    83         // From MCustomInterface
       
    84         TAny* CustomInterface( TUid aInterfaceUid );
       
    85 
       
    86        /* Seeking Interface */
       
    87         // Returns true if byte position can be reset to zero.
       
    88         // Valid in all states
       
    89         TInt GetSeekingSupport( TBool& aSeekSupport );
       
    90         // Returns true if byte position can be set anywhere between zero and
       
    91         // GetSize().
       
    92         // Valid in all states
       
    93         TInt GetRandomSeekingSupport( TBool& aSeekSupport );
       
    94         // Moves read position pointer to byte location requested by the observer
       
    95         // between zero and GetSize(). If the size specified is out of range, this
       
    96         // function returns KErrArgument.
       
    97         TInt Seek( TUint aPosInBytes );
       
    98         // From CMultimediaDataSource ends
       
    99         
       
   100         TInt ServiceBufferFilled( CMMFBuffer* aBuffer );
       
   101         void ReadRequestComplete(CReadWriteRequestAO* aRequest,TRequestStatus& aStatus);
       
   102         ~CCacheSource();
       
   103     private:
       
   104  
       
   105         CCacheSource(CMultimediaDataSource* aDataSource, CDataSourceConfigIntfc* aDataSourceConfig);
       
   106         
       
   107         void ConstructL (void);
       
   108         
       
   109         TInt EmptySinkQueue();
       
   110         TInt AppendBufferToSinkQueue( CMMFBuffer* aBuffer );
       
   111         TInt ServiceFillBuffer();
       
   112         
       
   113     private: // Data
       
   114         
       
   115         // Queue of data buffers from client
       
   116         TSglQue<CSinkQueueItem>* iSinkQueue;
       
   117         // Reference to MMultimedia data source
       
   118         MMultimediaDataSourceObserver* iObserver;
       
   119         
       
   120         CMDataSourceObserver* iDataSourceObserver;
       
   121         // Parent DataSource to Talk to
       
   122         CMultimediaDataSource* iDataSource;
       
   123         // Sink item Counter
       
   124         TInt iSnkItemsCount;
       
   125         //Temp File to Store Data
       
   126         RFile iFile;
       
   127         //Session to File server.
       
   128         RFs iFs;
       
   129         //File Name and Path for the Temp file
       
   130         TFileName iFileName;
       
   131         //Last Buffer Flag
       
   132         TBool iLastBufferWritten;
       
   133         //Size of the Temp File
       
   134         TInt iFileSize;
       
   135         // Number of bytes copied to controller so far
       
   136         TUint iSnkBytes;
       
   137 
       
   138         CMMFDataBuffer* iTransferBuffer;
       
   139         
       
   140         CDataSourceConfigIntfc* iDataSourceConfig;
       
   141         
       
   142         CReadWriteRequestAO* iReadRequest;
       
   143         CReadWriteRequestAO* iWriteRequest;
       
   144         
       
   145         CDataSourceConfigIntfc::TCacheType iCacheType;
       
   146         CMMFDataBuffer* iDataBuffer;
       
   147         HBufC*          iCacheLocation;
       
   148         TInt            iAbsBufferStart;
       
   149         TInt            iAbsBufferEnd;
       
   150         TInt            iBufferReadPos;
       
   151         TInt            iSeekStart;
       
   152         TInt            iSeekEnd;
       
   153         TInt            iAbsBufferReadPos;
       
   154 
       
   155     };
       
   156 
       
   157 #endif // CACHESOURCE_H
       
   158 
       
   159     //  End of File