00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __MMF_RAW_FORMAT_H__
00017 #define __MMF_RAW_FORMAT_H__
00018
00019
00020 #include <mmfformat.h>
00021 #include <mmfdatabuffer.h>
00022 #include <mmfclip.h>
00023 #include <implementationproxy.h>
00024 #include <mmfutilities.h>
00025
00026
00027
00028
00029
00030 class CMMFRawFormatRead : public CMMFFormatDecode, public MAsyncEventHandler
00031 {
00032 public:
00033
00034 static CMMFFormatDecode* NewL(MDataSource* aSource);
00035 ~CMMFRawFormatRead();
00036
00037
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
00051 void BufferFilledL(CMMFBuffer* aBuffer);
00052
00053
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
00068 TInt SendEventToClient(const TMMFEvent& ) {return KErrNone;}
00069
00070 private:
00071
00072 void ConstructL(MDataSource* aSource);
00073
00074 CMMFDataBuffer* CreateSourceBufferOfSizeL(TUint aSize);
00075 void DoReadL(TInt aReadPosition);
00076 void NegotiateSourceBufferL(CMMFBuffer& aBuffer);
00077 void CalculateFrameTimeInterval();
00078
00079 protected:
00080 MDataSource* iClip;
00081 MDataSink* iDataPath;
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
00098
00099
00100
00101 class CMMFRawFormatWrite : public CMMFFormatEncode, public MAsyncEventHandler
00102 {
00103 public:
00104
00105 static CMMFFormatEncode* NewL(MDataSink* aSink);
00106 ~CMMFRawFormatWrite();
00107
00108
00109 CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference);
00110 TFourCC SinkDataTypeCode(TMediaId aMediaId);
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
00122 void BufferEmptiedL(CMMFBuffer* aBuffer);
00123
00124
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
00140 TInt SendEventToClient(const TMMFEvent& ) {return KErrNone;}
00141
00142 private:
00143
00144 void ConstructL(MDataSink* aSink);
00145
00146 CMMFDataBuffer* CreateSinkBufferOfSizeL(TUint aSize);
00147 void CalculateFrameTimeInterval();
00148 void DoReadL(TInt aReadPosition);
00149 void DoWriteL(TInt aWritePosition);
00150
00151 private:
00152 MDataSink* iClip;
00153 MDataSource* iDataPath;
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;
00177 TBool iSourceWillSampleConvert;
00178 TInt iMaximumClipSize;
00179 };
00180
00181 #endif
00182