00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __MMF_RAW_FORMAT_H__
00032 #define __MMF_RAW_FORMAT_H__
00033
00034
00035 #include <mmfformat.h>
00036 #include <mmfdatabuffer.h>
00037 #include <mmfaudiooutput.h>
00038 #include <mmfclip.h>
00039 #include <implementationproxy.h>
00040 #include <mmfutilities.h>
00041
00042
00043
00044
00045
00046 class CMMFRawFormatRead : public CMMFFormatDecode, public MAsyncEventHandler
00047 {
00048 public:
00049
00050 static CMMFFormatDecode* NewL(MDataSource* aSource);
00051 ~CMMFRawFormatRead();
00052
00053
00054 void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId);
00055 CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, TBool &aReference);
00056 CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, CMMFBuffer& aSinkBuffer, TBool &aReference);
00057 TFourCC SourceDataTypeCode(TMediaId aMediaId);
00058 TInt SetSourceDataTypeCode(TFourCC aSourceFourCC, TMediaId aMediaId);
00059 TInt SourceThreadLogon(MAsyncEventHandler& aEventHandler);
00060 void SourceThreadLogoff();
00061 void SourcePrimeL();
00062 void SourcePlayL();
00063 void SourcePauseL();
00064 void SourceStopL();
00065
00066
00067 void BufferFilledL(CMMFBuffer* aBuffer);
00068
00069
00070 TUint Streams(TUid aMediaType) const;
00071 TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const;
00072 TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const;
00073 TUint NumChannels() {return iChannels;};
00074 TUint SampleRate() {return iSampleRate;};
00075 TUint BitRate() {return iSampleRate * iBitsPerSample;};
00076 TInt SetNumChannels(TUint aChannels);
00077 TInt SetSampleRate(TUint aSampleRate);
00078 void GetSupportedSampleRatesL(RArray<TUint>& aSampleRates);
00079 void GetSupportedNumChannelsL(RArray<TUint>& aNumChannels);
00080 void GetSupportedDataTypesL(TMediaId aMediaId, RArray<TFourCC>& aDataTypes);
00081 void SuggestSourceBufferSize(TUint aSuggestedBufferSize);
00082
00083
00084 TInt SendEventToClient(const TMMFEvent& ) {return KErrNone;}
00085
00086 private:
00087
00088 void ConstructL(MDataSource* aSource);
00089
00090 CMMFDataBuffer* CreateSourceBufferOfSizeL(TUint aSize);
00091 void DoReadL(TInt aReadPosition);
00092 void NegotiateSourceBufferL(CMMFBuffer& aBuffer);
00093 void CalculateFrameTimeInterval();
00094
00095 protected:
00096 MDataSource* iClip;
00097 MDataSink* iDataPath;
00098 TFourCC iFourCC;
00099
00100 private:
00101 CMMFDataBuffer* iBuffer;
00102 TUint iStartPosition;
00103 TUint iPos;
00104 TUint iChannels;
00105 TUint iSampleRate;
00106 TUint iBitsPerSample;
00107 TTimeIntervalMicroSeconds iFrameTimeInterval;
00108 TUint iFrameSize;
00109 TUint iClipLength;
00110 };
00111
00112
00113
00114
00115
00116
00117 class CMMFRawFormatWrite : public CMMFFormatEncode, public MAsyncEventHandler
00118 {
00119 public:
00120
00121 static CMMFFormatEncode* NewL(MDataSink* aSink);
00122 ~CMMFRawFormatWrite();
00123
00124
00125 CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference);
00126 TFourCC SinkDataTypeCode(TMediaId aMediaId);
00127 TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId);
00128 TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler);
00129 void SinkThreadLogoff();
00130 void Negotiate(MDataSource& aSource);
00131 void SinkPrimeL();
00132 void SinkPlayL();
00133 void SinkPauseL();
00134 void SinkStopL();
00135 void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);
00136
00137
00138 void BufferEmptiedL(CMMFBuffer* aBuffer);
00139
00140
00141 TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const;
00142 TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const;
00143 TInt SetNumChannels(TUint aChannels);
00144 TInt SetSampleRate(TUint aSampleRate);
00145 TUint NumChannels() {return iChannels;};
00146 TUint SampleRate() {return iSampleRate;};
00147 TUint BitRate() {return iSampleRate * iBitsPerSample;};
00148 TInt64 BytesPerSecond() ;
00149 void GetSupportedSampleRatesL(RArray<TUint>& aSampleRates);
00150 void GetSupportedNumChannelsL(RArray<TUint>& aNumChannels);
00151 void GetSupportedDataTypesL(TMediaId aMediaId, RArray<TFourCC>& aDataTypes);
00152 void SetMaximumClipSize(TInt aBytes);
00153 void CropL(TTimeIntervalMicroSeconds aPosition, TBool aToEnd ) ;
00154
00155
00156 TInt SendEventToClient(const TMMFEvent& ) {return KErrNone;}
00157
00158 private:
00159
00160 void ConstructL(MDataSink* aSink);
00161
00162 CMMFDataBuffer* CreateSinkBufferOfSizeL(TUint aSize);
00163 void CalculateFrameTimeInterval();
00164 void DoReadL(TInt aReadPosition);
00165 void DoWriteL(TInt aWritePosition);
00166
00167 private:
00168 MDataSink* iClip;
00169 MDataSource* iDataPath;
00170 TFourCC iFourCC;
00171 CMMFDataBuffer* iBuffer;
00172 TBool iClipAlreadyExists;
00173 TBool iBufferCreated;
00174 TBool iFileHasChanged;
00175 TUint iStartPosition;
00176 TUint iDataLength;
00177 TUint iPos;
00178 TUint iMaxPos;
00179 TUint iChannels;
00180 TUint iSampleRate;
00181 TUint iSourceChannels;
00182 TUint iSourceSampleRate;
00183 TFourCC iSourceFourCC;
00184 TUint iBitsPerSample;
00185 TTimeIntervalMicroSeconds iFrameTimeInterval;
00186 TUint iFrameSize;
00187 TUint iClipLength;
00188 TUint iDataSize;
00189 CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory;
00190 CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter;
00191 CMMFDataBuffer* iConvertBuffer;
00192 CMMFBuffer* iBufferToEmpty;
00193 TBool iSourceWillSampleConvert;
00194 TInt iMaximumClipSize;
00195 };
00196
00197 #endif
00198