diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/mmfrawformat_8h-source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/mmfrawformat_8h-source.html Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,194 @@ + +
+00001 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +00002 // All rights reserved. +00003 // This component and the accompanying materials are made available +00004 // under the terms of "Eclipse Public License v1.0" +00005 // which accompanies this distribution, and is available +00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". +00007 // +00008 // Initial Contributors: +00009 // Nokia Corporation - initial contribution. +00010 // +00011 // Contributors: +00012 // +00013 // Description: +00014 // +00015 +00016 #ifndef __MMF_RAW_FORMAT_H__ +00017 #define __MMF_RAW_FORMAT_H__ +00018 +00019 // MMF framework headers +00020 #include <mmfformat.h> +00021 #include <mmfdatabuffer.h> +00022 #include <mmfclip.h> +00023 #include <implementationproxy.h> +00024 #include <mmfutilities.h> +00025 +00026 /* Audio decoder plug-in to read .RAW audio. +00027 It implements MDataSource to pass data to the controller, and MDataSink to read data from +00028 the source clip. +00029 Also implements MAsyncEventHandler to send an event to the client */ +00030 class CMMFRawFormatRead : public CMMFFormatDecode, public MAsyncEventHandler +00031 { +00032 public: +00033 // Factory function +00034 static CMMFFormatDecode* NewL(MDataSource* aSource); +00035 ~CMMFRawFormatRead(); +00036 +00037 //from MDataSource +00038 void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId); +00039 CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, TBool &aReference); +00040 CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& aSinkBuffer, TBool &aReference); +00041 TFourCC SourceDataTypeCode(TMediaId aMediaId); +00042 TInt SetSourceDataTypeCode(TFourCC aSourceFourCC, TMediaId aMediaId); +00043 TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler); +00044 void SourceThreadLogoff(); +00045 void SourcePrimeL(); +00046 void SourcePlayL(); +00047 void SourcePauseL(); +00048 void SourceStopL(); +00049 +00050 //from MDataSink +00051 void BufferFilledL(CMMFBuffer* aBuffer); +00052 +00053 // from CMMFFormatDecode +00054 TUint Streams(TUid aMediaType) const; +00055 TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const; +00056 TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const; +00057 TUint NumChannels() {return iChannels;}; +00058 TUint SampleRate() {return iSampleRate;}; +00059 TUint BitRate() {return iSampleRate * iBitsPerSample;}; +00060 TInt SetNumChannels(TUint aChannels); +00061 TInt SetSampleRate(TUint aSampleRate); +00062 void GetSupportedSampleRatesL(RArray<TUint>& aSampleRates); +00063 void GetSupportedNumChannelsL(RArray<TUint>& aNumChannels); +00064 void GetSupportedDataTypesL(TMediaId aMediaId, RArray<TFourCC>& aDataTypes); +00065 void SuggestSourceBufferSize(TUint aSuggestedBufferSize); +00066 +00067 //from MAsyncEventHandler +00068 TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;} +00069 +00070 private: +00071 // Construction +00072 void ConstructL(MDataSource* aSource); +00073 // Helper functions +00074 CMMFDataBuffer* CreateSourceBufferOfSizeL(TUint aSize); +00075 void DoReadL(TInt aReadPosition); +00076 void NegotiateSourceBufferL(CMMFBuffer& aBuffer); +00077 void CalculateFrameTimeInterval(); +00078 +00079 protected: +00080 MDataSource* iClip; //for decode format MDatasource; for encode format MDataSink +00081 MDataSink* iDataPath; //for decode format MDataSink; for encode format MDataSource +00082 TFourCC iFourCC; +00083 +00084 private: +00085 CMMFDataBuffer* iBuffer; +00086 TUint iStartPosition; +00087 TUint iPos; +00088 TUint iChannels; +00089 TUint iSampleRate; +00090 TUint iBitsPerSample; +00091 TTimeIntervalMicroSeconds iFrameTimeInterval; +00092 TUint iFrameSize; +00093 TUint iClipLength; +00094 }; +00095 +00096 +00097 /* Audio encoder plug-in to write .RAW audio. +00098 It implements MDataSink to get data from the controller, and MDataSource to write data to +00099 the target clip. +00100 Also implements MAsyncEventHandler to send an event to the client */ +00101 class CMMFRawFormatWrite : public CMMFFormatEncode, public MAsyncEventHandler +00102 { +00103 public: +00104 // Factory function +00105 static CMMFFormatEncode* NewL(MDataSink* aSink); +00106 ~CMMFRawFormatWrite(); +00107 +00108 //from MDataSink +00109 CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference); +00110 TFourCC SinkDataTypeCode(TMediaId aMediaId); //returns FourCC code for the mediaId +00111 TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId); +00112 TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler); +00113 void SinkThreadLogoff(); +00114 void Negotiate(MDataSource& aSource); +00115 void SinkPrimeL(); +00116 void SinkPlayL(); +00117 void SinkPauseL(); +00118 void SinkStopL(); +00119 void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId); +00120 +00121 //from MDataSource +00122 void BufferEmptiedL(CMMFBuffer* aBuffer); +00123 +00124 // from CMMFFormatEncode +00125 TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const; +00126 TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const; +00127 TInt SetNumChannels(TUint aChannels); +00128 TInt SetSampleRate(TUint aSampleRate); +00129 TUint NumChannels() {return iChannels;}; +00130 TUint SampleRate() {return iSampleRate;}; +00131 TUint BitRate() {return iSampleRate * iBitsPerSample;}; +00132 TInt64 BytesPerSecond() ; +00133 void GetSupportedSampleRatesL(RArray<TUint>& aSampleRates); +00134 void GetSupportedNumChannelsL(RArray<TUint>& aNumChannels); +00135 void GetSupportedDataTypesL(TMediaId aMediaId, RArray<TFourCC>& aDataTypes); +00136 void SetMaximumClipSize(TInt aBytes); +00137 void CropL(TTimeIntervalMicroSeconds aPosition, TBool aToEnd ) ; +00138 +00139 //from MAsyncEventHandler +00140 TInt SendEventToClient(const TMMFEvent& /*aEvent*/) {return KErrNone;} +00141 +00142 private: +00143 // construction +00144 void ConstructL(MDataSink* aSink); +00145 // helper functions +00146 CMMFDataBuffer* CreateSinkBufferOfSizeL(TUint aSize); +00147 void CalculateFrameTimeInterval(); +00148 void DoReadL(TInt aReadPosition); +00149 void DoWriteL(TInt aWritePosition); +00150 +00151 private: +00152 MDataSink* iClip; //for decode format MDatasource; for encode format MDataSink +00153 MDataSource* iDataPath; //for decode format MDataSink; for encode format MDataSource +00154 TFourCC iFourCC; +00155 CMMFDataBuffer* iBuffer; +00156 TBool iClipAlreadyExists; +00157 TBool iBufferCreated; +00158 TBool iFileHasChanged; +00159 TUint iStartPosition; +00160 TUint iDataLength; +00161 TUint iPos; +00162 TUint iMaxPos; +00163 TUint iChannels; +00164 TUint iSampleRate; +00165 TUint iSourceChannels; +00166 TUint iSourceSampleRate; +00167 TFourCC iSourceFourCC; +00168 TUint iBitsPerSample; +00169 TTimeIntervalMicroSeconds iFrameTimeInterval; +00170 TUint iFrameSize; +00171 TUint iClipLength; +00172 TUint iDataSize; +00173 CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory; +00174 CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter; +00175 CMMFDataBuffer* iConvertBuffer; +00176 CMMFBuffer* iBufferToEmpty; //pointer to store buffr to empty - needed if buffer passed to clip is different +00177 TBool iSourceWillSampleConvert; +00178 TInt iMaximumClipSize; +00179 }; +00180 +00181 #endif +00182 +