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