mmfenh/advancedaudiocontroller/audiocontrollerpluginsvariant/3gpDataSourceAdapter/Inc/3gpDataSourceAdapter.h
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Class definition for the 3gpDataSourceAdapter functions.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C3GPDATASOURCEADAPTER_H
       
    21 #define C3GPDATASOURCEADAPTER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "DataSourceAdapter.h"
       
    25 //#include <mmf/server/mmfdatasource.h>
       
    26 //#include <caf/caf.h>
       
    27 #include <MultimediaDataSource.h>
       
    28 #include <mmf/server/mmfdatasink.h>
       
    29 #include <mp4lib.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 // CLASS DEFINITIONS
       
    34 
       
    35 /**
       
    36 *  This class provides C3gpDataSourceAdapter functions.
       
    37 *
       
    38 *  @lib C3gpDataSourceAdapter.lib
       
    39 *  @since 3.2
       
    40 */
       
    41 class C3gpDataSourceAdapter : 
       
    42 	public CDataSourceAdapter,
       
    43 	public MDataSink,
       
    44 	public M3GPMP4LibAsyncObserver,
       
    45 	public MMultimediaDataSourceObserver
       
    46     {
       
    47 	public:  // Constructors and destructor
       
    48 
       
    49         /**
       
    50         * Two-phased constructor.
       
    51         */
       
    52         IMPORT_C static C3gpDataSourceAdapter* NewL();
       
    53 
       
    54         /**
       
    55         * Destructor.
       
    56         */
       
    57         IMPORT_C virtual ~C3gpDataSourceAdapter();
       
    58 
       
    59 		// From MMultimediaDataSourceObserver
       
    60         IMPORT_C virtual void BufferFilled(CMMFBuffer* aBuffer);
       
    61         IMPORT_C virtual void Event(TUid aEvent);
       
    62         IMPORT_C virtual TInt GetBitRate(TUint& aBitRate);
       
    63 		
       
    64 		
       
    65 		// From CDataSourceAdapter
       
    66 		IMPORT_C virtual void FillBufferL( CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId);
       
    67 		IMPORT_C virtual void SourcePrimeL();
       
    68 		IMPORT_C virtual void SourceStopL();
       
    69         IMPORT_C virtual TInt SeekToTime(TUint aTimeMs, TUint& aFoundTimeMs);
       
    70 		IMPORT_C virtual void SetDataSourceL(MDataSource* aDataSource,
       
    71 											MMultimediaDataSourceObserver* aMMultimediaDataSourceObserver,
       
    72 											MAsyncEventHandler* aMAsyncEventHandler);
       
    73 
       
    74 		// From MDataSink
       
    75 		// The following functions are declared as pure virtual in MDataSink, therefore
       
    76 		// declared here.  However, they are not implemented.
       
    77 		IMPORT_C virtual void BufferFilledL ( CMMFBuffer* aBuffer );
       
    78 		IMPORT_C virtual void EmptyBufferL( CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId );
       
    79 		IMPORT_C virtual TFourCC SinkDataTypeCode( TMediaId aMediaId );
       
    80 		IMPORT_C virtual TBool CanCreateSinkBuffer();
       
    81 		IMPORT_C virtual CMMFBuffer* CreateSinkBufferL( TMediaId aMediaId, TBool& aReference );
       
    82 		IMPORT_C virtual void ConstructSinkL( const TDesC8& aInitData );
       
    83 		
       
    84 		// New
       
    85         IMPORT_C virtual TInt ReadHeader(TUint32& aAudioLength, TUint32& aAudioType, 
       
    86                                          TUint8& aFramesPerSample, TUint32& aTimeScale, TUint32& aAverateBitRate);
       
    87                                          
       
    88 		IMPORT_C virtual TInt ReadAudioSpecificConfig(TUint8* aDecSpecInfo, TUint32 aDecSpecInfoSizeIn, TUint32* aDecSpecInfoSizeOut);
       
    89 
       
    90         IMPORT_C virtual TBool IsPositonSeekable();		
       
    91 		
       
    92 		
       
    93 		// From M3GPMP4LibAsyncObserver
       
    94 	    void M3GPMP4LibAudioFramesAvailable(MP4Err aError,
       
    95         								    mp4_u32 aAudioSize, 
       
    96         									mp4_u32 aTimeStamp, 
       
    97         									mp4_u32 aReturnedFrames,
       
    98  					                        mp4_u32 aTimestamp2);
       
    99 
       
   100         void M3GPMP4LibVideoFrameAvailable(MP4Err aError,
       
   101         								   mp4_u32 aFrameSize, 
       
   102         								   mp4_u32 aTimeStamp, 
       
   103         								   mp4_bool aKeyFrame, 
       
   104         								   mp4_u32 aTimestamp2);
       
   105 
       
   106 
       
   107 	private:
       
   108 
       
   109         class CAsyncProxyFillBuffer : public CActive
       
   110             {
       
   111             public: // may want to export constructor and fillbuffer for 3gpdatasourceadapter
       
   112                 CAsyncProxyFillBuffer(C3gpDataSourceAdapter& a3gpDataSourceAdapter);
       
   113             	~CAsyncProxyFillBuffer();
       
   114             	void ReadSync();
       
   115             
       
   116             protected:	
       
   117                 void RunL();
       
   118                 TInt RunError(TInt aError);
       
   119                 void DoCancel();
       
   120 
       
   121             private:
       
   122                 TRequestStatus* iRequestStatus;
       
   123                 C3gpDataSourceAdapter& i3gpDataSourceAdapter;
       
   124             };
       
   125 	
       
   126         /**
       
   127         * C++ default constructor.
       
   128         */
       
   129 		C3gpDataSourceAdapter();
       
   130 
       
   131         /**
       
   132         * By default Symbian 2nd phase constructor is private.
       
   133         */
       
   134 		void ConstructL();
       
   135 
       
   136         void PrepareMP4ParserL();
       
   137         TInt TranslateMP4Err(MP4Err aError);
       
   138         CMMFDataBuffer* CreateSourceBufferOfSizeL(TUint aSize);
       
   139         void StartReadingSourceL();
       
   140         TInt ReadAsync();
       
   141         TInt ReadSyncL();
       
   142 		void ResetVariables();
       
   143 
       
   144         // currently filling buffer
       
   145         CMMFBuffer* iFillingBuffer;
       
   146 
       
   147         MP4Handle iMP4Handle;
       
   148 
       
   149 		// for getting data out from MP4Lib and keeping the extra data that cannot fit into shared buffers
       
   150         CMMFDataBuffer* iParserBuf;
       
   151         
       
   152         TUint iSourceReadPosition;
       
   153 
       
   154 		ContentAccess::CData* iCafHandle;
       
   155 		CMMFDataBuffer* iSrcBuf;
       
   156 		TBool iContinueReading;
       
   157 		CMMFClip* iClip;
       
   158         MDataSink* iControllerMDataSink;
       
   159 		RPointerArray<CMMFBuffer> iQueuedAsyncBuffers;
       
   160 		TInt iBufferIndex;
       
   161 		TMediaId iMediaId;
       
   162 		TBool iQueValid;
       
   163 		CAsyncProxyFillBuffer*	iAsyncProxyFillBuffer;
       
   164 
       
   165 		TBool iReadMp4LibSync;
       
   166 		TBool iRestartSyncRead;
       
   167 	    TBool iLastBufferWrittenToMp4Lib;
       
   168 		TBool iMp4HeaderAvail;
       
   169 		mp4_u32 iAudioType;
       
   170 		MMultimediaDataSourceObserver* iControllerMMultimediaDataSourceObserver;
       
   171 };
       
   172 
       
   173 #endif 		// C3GPDATASOURCEADAPTER_H
       
   174 
       
   175 // End of File