williamr@2: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __MMF_SERVER_FORMAT_H__ williamr@2: #define __MMF_SERVER_FORMAT_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: const TUint KMMFFormatDefaultFrameSize = 0x1000; //4K williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Base class from which source formats can be derived from. The intended usage is for controllers that can support more williamr@2: than one type of format. The class is an MDataSource as far as the data path is concerned but is an MDataSink to the clip williamr@2: that is the source of the actual data. williamr@2: williamr@2: All CMMFFormatDecode plugin DLLs must include interface_uid = KMmfUidPluginInterfaceFormatDecode in their .rss files. williamr@2: */ williamr@2: class CMMFFormatDecode : public CBase, public MDataSource, public MDataSink williamr@2: { williamr@2: public: williamr@2: // ECOM creation. williamr@2: IMPORT_C static CMMFFormatDecode* NewL( TUid aUid, MDataSource* aSource ); williamr@2: williamr@2: IMPORT_C static CMMFFormatDecode* NewL( const TDesC& aFileName, MDataSource* aSource, const TDesC& aPreferredSupplier ) ; williamr@2: IMPORT_C static CMMFFormatDecode* NewL( const TDesC8& aSourceHeader, MDataSource* aSource, const TDesC& aPreferredSupplier ) ; williamr@2: IMPORT_C static CMMFFormatDecode* NewL( MDataSource* aSource, const TDesC& aPreferredSupplier ) ; williamr@2: williamr@2: IMPORT_C static CMMFFormatDecode* NewL( const TDesC& aFileName, MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) ; williamr@2: IMPORT_C static CMMFFormatDecode* NewL( const TDesC8& aSourceHeader, MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) ; williamr@2: IMPORT_C static CMMFFormatDecode* NewL( MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) ; williamr@2: williamr@2: /** williamr@2: Destructor. williamr@2: */ williamr@2: virtual ~CMMFFormatDecode() {REComSession::DestroyedImplementation(iDtor_ID_Key);}; williamr@2: williamr@2: /** williamr@2: Returns the ECom plugin UID of this format. williamr@2: williamr@2: @return The plugin UID. williamr@2: */ williamr@2: TUid ImplementationUid() const {return iImplementationUid;} williamr@2: williamr@2: /** williamr@2: Gets the number of streams of the specified media type. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaType williamr@2: The UID of the media type, for example KUidMediaTypeAudio or KUidMediaTypeVideo. williamr@2: williamr@2: @return The number of streams of multimedia data in the format for the specified media type. williamr@2: For example, for a WAV or mp3 audio file this procedure would return 1 for a media williamr@2: type of audio and 0 for a media type of video. More complex multimedia formats (for williamr@2: example AVI and mp4) can support multiple streams of both video and audio. williamr@2: */ williamr@2: virtual TUint Streams(TUid aMediaType) const = 0; williamr@2: williamr@2: /** williamr@2: Returns the time interval for one frame for the specified media type. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: In the case of video, a frame would usually be one frame of video. In the case of williamr@2: audio, a frame may correspond to a frame of audio, if the particular audio data type williamr@2: is framed eg mp3. There are two definitions of a frame. A format frame, which may williamr@2: consist of several frames of a particular framed audio data type. This may be the case, williamr@2: for example for GSM610 (a low quality audio data type used in telephony) where a frame williamr@2: is only 65 bytes large. In this case a format frame consists of several GSM610 data type williamr@2: frames as passing the data out 65 bytes at a time would be inefficient. In the case of williamr@2: non-framed data such as pcm, a frame can be an arbitrary size determined by the format plugin. williamr@2: williamr@2: @param aMediaType williamr@2: The media type id. williamr@2: williamr@2: @return The frame time interval williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const = 0; williamr@2: williamr@2: williamr@2: /** williamr@2: Returns the duration of the clip for the specified media type. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaType williamr@2: The media type ID. williamr@2: williamr@2: @return The duration of the clip. williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const = 0; williamr@2: williamr@2: /** williamr@2: Request from CMMFDataPath to fill the specified buffer. williamr@2: The CMMFFormat needs to break this down into one or more reads from the clip williamr@2: (from MDataSource - CMMFFormatDecode is a MDataSource to a CMMFDataPath consumer). williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: This method is the means by which data is obtained from the data source. aBuffer is williamr@2: the buffer that needs filling from the source data stream as identified by aMediaId. The williamr@2: format should read the frame number of the buffer via the buffer's CMMFBuffer::FrameNumber() williamr@2: method. From this the format should be able to determine the actual position of the data on williamr@2: the data source. The technique here depends on the nature of the format. For a linear audio williamr@2: format, the position can be obtained by a simple calculation of the frame size, the header size williamr@2: and where appropriate the datatype. williamr@2: williamr@2: For non-linear formats either an index table of frame number and location will need to be williamr@2: created in the NewL() or some form of approximating algorithm will be required. Some formats have williamr@2: an index table as part of the format e.g. AVI. If no random access is required then no index table williamr@2: is required, the format can keep track of the current read position and increment it on each access, williamr@2: and reset it if the frame number is reset to 0 or 1. Given that for non-linear i.e. variable bit rate williamr@2: formats, the size of the data read may vary from frame to frame, then the format should either set williamr@2: the request size of the buffer for the required frame or call the source's ReadBufferL() (either williamr@2: CMMFClip::ReadBufferL(), CMMFDescriptor ::ReadBufferL() or CMMFFile::ReadBufferL()) function that williamr@2: takes the aLength parameter. williamr@2: williamr@2: It is the responsibility of the format decode to determine the size and position of the source data williamr@2: for each frame. For linear audio formats, the format decode should fill the buffer up to its maximum williamr@2: length. For multimedia formats e.g. mp4, AVI etc, the format decode is effectively acting as a demultiplexor, williamr@2: and must obtain the appropriate data from the source depending on the aMediaId. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer to fill. williamr@2: @param aConsumer williamr@2: The consumer. williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: */ williamr@2: virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId)=0; williamr@2: williamr@2: /** williamr@2: @internalAll williamr@2: williamr@2: Indicates data has been added to the file. williamr@2: williamr@2: @param aBuffer williamr@2: The emptied buffer. williamr@2: */ williamr@2: inline virtual void BufferEmptiedL(CMMFBuffer* aBuffer); williamr@2: williamr@2: /** williamr@2: Tests whether a source buffer can be created. williamr@2: williamr@2: The format knows what type of source buffer it requires so default returns ETrue. williamr@2: It doesn't usually need to set the size of this buffer. williamr@2: williamr@2: @return A boolean indicating whether a buffer can be created. ETrue if the buffer can be created, williamr@2: EFalse otherwise. williamr@2: */ williamr@2: virtual TBool CanCreateSourceBuffer() {return ETrue;} williamr@2: williamr@2: /** williamr@2: Creates a source buffer. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: This function should create a buffer of length 0, the maximum length should be equal to the maximum williamr@2: possible frame size. In the case of non framed data it should be set to an arbitrary size, which is williamr@2: effectively a trade off between being too small which will affect performance as more source reads williamr@2: are required, and being too large which will give very coarse positioning granularity. For pcm data, williamr@2: a buffer size of 4K is a good compromise. The same compromise also applies when deciding to put multiple williamr@2: audio frames into one format frame. The sink buffer size may also effect the format buffer size and williamr@2: the controller may use this to suggest a buffer size to the format by calling the format's SuggestSourceBufferSize() williamr@2: method. Alternatively the MDataSource::CreateSourceBufferL() function that takes the additional aSinkBuffer williamr@2: parameter may also be used when deciding the source buffer maximum size of the created source buffer. williamr@2: williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: @param aReference williamr@2: If ETrue the MDataSource owns the buffer. If EFalse, then the caller owns the buffer. This williamr@2: should normally be set to EFalse as format plugins do not create the reference buffer. williamr@2: williamr@2: @return The created source buffer. williamr@2: */ williamr@2: virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, TBool &aReference)=0; williamr@2: williamr@2: /** williamr@2: Returns the source data type code for the specified media type ID. williamr@2: williamr@2: Used by the CMMFDataPath for codec matching. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: williamr@2: @return The source data type code. williamr@2: */ williamr@2: virtual TFourCC SourceDataTypeCode(TMediaId aMediaId)=0; williamr@2: williamr@2: /** williamr@2: @internalAll williamr@2: williamr@2: Adds a buffer to a clip. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer to which the clip is added. williamr@2: @param aSupplier williamr@2: The data source. williamr@2: @param aMediaId williamr@2: The Media ID. williamr@2: */ williamr@2: inline virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId); williamr@2: williamr@2: /** williamr@2: Indicates the data source has filled the buffer. williamr@2: williamr@2: Called by the CMMFFormat's MDataSource when it has filled the buffer. williamr@2: The default implementation below would need overriding in cases where multiple williamr@2: clip reads were required to fill the buffer from the data path. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer to which the clip is added. williamr@2: */ williamr@2: virtual void BufferFilledL(CMMFBuffer* aBuffer) {iDataPath->BufferFilledL(aBuffer);} williamr@2: williamr@2: /** williamr@2: Tests whether a sink buffer can be created. williamr@2: williamr@2: Format would normally pass its own buffer onto the CMMFClip, so williamr@2: this may not be required. The default returns EFalse. williamr@2: williamr@2: @return A boolean indicating if the sink buffer can be created. ETrue if buffer can be created, EFalse otherwise. williamr@2: */ williamr@2: virtual TBool CanCreateSinkBuffer() {return EFalse;} williamr@2: williamr@2: /** williamr@2: Creates a sink buffer for the specified media ID. The default version returns NULL. williamr@2: williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: @param aReference williamr@2: If ETrue the MDataSink owns the buffer. williamr@2: If EFalse, then the caller owns the buffer. williamr@2: @return The CMMFBuffer sink buffer. williamr@2: */ williamr@2: inline virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference); williamr@2: williamr@2: /** williamr@2: Returns the sink data type code for the specified media type ID. williamr@2: This would be the same as the source data type four CC although williamr@2: the clip is not going to need this info. williamr@2: williamr@2: @param aMediaId williamr@2: The media type id. williamr@2: williamr@2: @return The sink data type code. williamr@2: */ williamr@2: inline virtual TFourCC SinkDataTypeCode(TMediaId aMediaId); williamr@2: williamr@2: /** williamr@2: Gets the number of meta data entries. williamr@2: williamr@2: Meta Data support. The decode format is only capable of reading meta data entries from the clip. williamr@2: williamr@2: This is an optional method, used to return the number of meta data entries present in the format. williamr@2: A meta data entry is a format-specific field such as authorship, copyright, security details etc. williamr@2: The function is optional as many formats do not provide support for such additional meta data fields. williamr@2: williamr@2: The default leaves with KErrNotSupported. williamr@2: williamr@2: @param aNumberOfEntries williamr@2: A reference to the number of meta data entries supported by the format. On return, contains williamr@2: the number of meta data entries. williamr@2: */ williamr@2: inline virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries); williamr@2: williamr@2: /** williamr@2: Returns the specified meta data entry. williamr@2: williamr@2: This method is optional as many formats do not provide support for such additional meta data fields. williamr@2: williamr@2: The default leaves with KErrNotSupported. williamr@2: williamr@2: @param aIndex williamr@2: The zero based meta data entry index to retrieve. williamr@2: williamr@2: @return The meta data entry. williamr@2: */ williamr@2: inline virtual CMMFMetaDataEntry* MetaDataEntryL(TInt aIndex); williamr@2: williamr@2: //audio format methods williamr@2: williamr@2: /** williamr@2: Sets the number of channels. williamr@2: williamr@2: The default returns KErrNotSupported. williamr@2: williamr@2: There would normally be no need to override this function as the format decode plugin can normally williamr@2: determine for itself the number of channels. It is only necessary to override this in cases where the williamr@2: format decode plugin cannot determine for itself the number of channels. This function should not be williamr@2: used if the audio clip already exists; that is, in the "Open and Append" scenario, when the function's williamr@2: behaviour is undefined. williamr@2: williamr@2: @param aChannels williamr@2: The number of channels. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetNumChannels(TUint aChannels); williamr@2: williamr@2: /** williamr@2: Sets the sample rate. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: There would normally be no need to override this function as the format decode can normally determine williamr@2: the sample rate for itself. It is only necessary to override this in cases where the format decode plugin williamr@2: cannot determine for itself the sample rate. williamr@2: williamr@2: @param aSampleRate williamr@2: The sample rate. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetSampleRate(TUint aSampleRate); williamr@2: williamr@2: /** williamr@2: Sets the bit rate. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: This method is mainly provided for variable bit rate formats, such as mp3, where the bit rate can williamr@2: not be directly calculated from the sample rate. There would normally be no need to override this williamr@2: function as the format decode can normally determine the sample rate for itself. It is only necessary williamr@2: to override this in cases where the format decode plugin cannot determine for itself the sample rate. williamr@2: williamr@2: @param aBitRate williamr@2: The bit rate in bits per second. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetBitRate(TUint aBitRate); williamr@2: williamr@2: /** williamr@2: Returns the number of channels. williamr@2: williamr@2: The default implementation returns 0. williamr@2: williamr@2: @return The number of channels. williamr@2: */ williamr@2: virtual TUint NumChannels() {return 0;} williamr@2: williamr@2: /** williamr@2: Gets the sample rate. williamr@2: williamr@2: The default implementation returns 0. williamr@2: williamr@2: @return The sample rate. williamr@2: */ williamr@2: virtual TUint SampleRate() {return 0;} williamr@2: williamr@2: /** williamr@2: Gets the bit rate. williamr@2: williamr@2: The default implementation returns 0. williamr@2: williamr@2: This method is mainly provided for variable bit rate formats, such as mp3, where the bit rate williamr@2: can not be directly calculated from the sample rate. This function needs overriding for any format williamr@2: decode that supports audio. williamr@2: williamr@2: @return The bit rate. williamr@2: */ williamr@2: virtual TUint BitRate() {return 0;} williamr@2: williamr@2: /** williamr@2: Gets the supported sample rates. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: This should return an array of sample rates supported by the format where applicable. Note williamr@2: that this refers to the possible sample rates supported by the format, not the actual sample rate, williamr@2: which will be one of the supported sample rates. The implementation of this function is optional. williamr@2: williamr@2: @param aSampleRates williamr@2: Reference to an array of supported sample rates. williamr@2: */ williamr@2: inline virtual void GetSupportedSampleRatesL(RArray& aSampleRates); williamr@2: williamr@2: /** williamr@2: Gets the supported bit rates. williamr@2: williamr@2: The default leaves with KErrNotSupported. williamr@2: williamr@2: This should return an array of bit rates supported by the format where applicable. Note that this williamr@2: refers to the possible bit rates supported by the format, not the actual bit rate, which will be williamr@2: one of the supported bit rates. The implementation of this function is optional. williamr@2: williamr@2: @param aBitRates williamr@2: Reference to an array of supported bit rates. williamr@2: */ williamr@2: inline virtual void GetSupportedBitRatesL(RArray& aBitRates); williamr@2: williamr@2: /** williamr@2: Gets the supported number of channels. williamr@2: williamr@2: The default leaves with KErrNotSupported. williamr@2: williamr@2: The implementation of this procedure should return an array of channels supported by the format williamr@2: where applicable. Note that this refers to the possible number of channels supported by the format, williamr@2: not the actual number of channels, which will be one of the supported channels. For example, for a williamr@2: format decode plugin capable of supporting mono and stereo the procedure would return an array of williamr@2: length two the first array member containing the value 1 and the second containing the value 2. The williamr@2: implementation of this function is optional. williamr@2: williamr@2: @param aNumChannels williamr@2: A reference to an array of supported number of channels. williamr@2: */ williamr@2: inline virtual void GetSupportedNumChannelsL(RArray& aNumChannels); williamr@2: williamr@2: /** williamr@2: Gets the supported data types for the given media type id. williamr@2: williamr@2: The default leaves with KErrNotSupported. williamr@2: williamr@2: The implementation of this procedure should return an array of data types supported by the format where williamr@2: applicable. Note that this refers to the possible data types that may be supported by the format, not the williamr@2: actual data type of the format, which will be one of the supported data types. For example, for a format williamr@2: decode plugin capable of supporting pcm16 and GSM610 the procedure would return an array of length two the williamr@2: first array member containing the fourCC code ' P16' and the second containing the value GSM6. The williamr@2: implementation of this function is optional. williamr@2: williamr@2: @param aMediaId williamr@2: The media type id. williamr@2: @param aDataTypes williamr@2: A reference to an array of supported data types. williamr@2: */ williamr@2: inline virtual void GetSupportedDataTypesL(TMediaId aMediaId, RArray& aDataTypes); williamr@2: williamr@2: /** williamr@2: Used by the sink to suggest a source buffer size. williamr@2: williamr@2: This is an optional function provided so that a controller can suggest a buffer williamr@2: size for the format. The controller should not assume that the format will accept williamr@2: the suggested buffer size and there is no obligation on behalf of the format to williamr@2: use the suggested buffer size. williamr@2: williamr@2: @param aSuggestedBufferSize williamr@2: A recommended buffer size that the format should create. williamr@2: */ williamr@2: inline virtual void SuggestSourceBufferSize(TUint aSuggestedBufferSize); williamr@2: williamr@2: /** williamr@2: Used to set the format's position. williamr@2: williamr@2: Subsequent data reads should ignore the FrameNumber in the CMMFBuffer and use this williamr@2: setting to determine what data to provide. williamr@2: williamr@2: The actual position the format sets itself may vary from this setting to ensure williamr@2: that it is aligned to the sample boundaries ensuring consistent data output. williamr@2: williamr@2: If not supported, positional information should be extracted from the FrameNumber in CMMFBuffer williamr@2: williamr@2: @param aPosition williamr@2: The position the format should use. williamr@2: */ williamr@2: inline virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition); williamr@2: williamr@2: williamr@2: /** williamr@2: Supplies the current position. williamr@2: williamr@2: Subsequent data reads will commence from this position. williamr@2: williamr@2: @return The current position in microseconds. williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds PositionL() {User::Leave(KErrNotSupported);return TTimeIntervalMicroSeconds(0);} williamr@2: williamr@2: protected: williamr@2: //ConstructSourceL should never be called. The CMMFFormatDecode NewL functions should williamr@2: //always be used to instantiate a CMMFFormatDecode object (not MDataSource::NewL) williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: virtual void ConstructSourceL( const TDesC8& /*aInitData*/ ) {User::Leave(KErrNotSupported);} williamr@2: williamr@2: //ConstructSinkL should never be called. The CMMFFormatDecode NewL functions should williamr@2: //always be used to instantiate a CMMFFormatDecode object (not MDataSink::NewL) williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: virtual void ConstructSinkL( const TDesC8& /*aInitData*/ ) {User::Leave(KErrNotSupported);} williamr@2: williamr@2: /** williamr@2: Default constructor williamr@2: */ williamr@2: CMMFFormatDecode() : MDataSource(KUidMmfFormatDecode), MDataSink(KUidMmfFormatDecode) {}; williamr@2: williamr@2: // Creates and initialises format plugin. williamr@2: static CMMFFormatDecode* CreateFormatL(TUid aImplementationUid, MDataSource* aSource); williamr@2: protected: williamr@2: williamr@2: /** williamr@2: The clip is the source for the decode format. williamr@2: */ williamr@2: MDataSource* iClip; williamr@2: williamr@2: /** williamr@2: The data path is the sink for the decode format. williamr@2: */ williamr@2: MDataSink* iDataPath; williamr@2: private: williamr@2: TUid iDtor_ID_Key; // do not move - referenced inline in ~CMMFFormatDecode() williamr@2: TUid iImplementationUid; // do not move - referenced inline in ImplementationUid() williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: Extension class to allow derived classes to support custom interfaces williamr@2: williamr@2: @publishedPartner williamr@2: @prototype williamr@2: */ williamr@2: williamr@2: class CMMFFormatDecode2 : public CMMFFormatDecode williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Gets a custom interface. williamr@2: williamr@2: @param aInterfaceId williamr@2: The Uid of the particular interface required. williamr@2: williamr@2: @return Custom interface pointer. NULL if the requested interface is not supported. williamr@2: */ williamr@2: virtual TAny* CustomInterface(TUid aInterfaceId)=0; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Base class from which sink formats can be derived from. williamr@2: williamr@2: The intended usage is for controllers that can support more than one type of format. williamr@2: The class is an MDataSink as far as the data path is concerned but is an MDataSource to the clip williamr@2: that is the sink of the actual data. All CMMFFormatEncode plugin DLLs must include williamr@2: interface_uid = KMmfUidPluginInterfaceFormatEncode in their .rss files. williamr@2: */ williamr@2: class CMMFFormatEncode : public CBase, public MDataSource, public MDataSink williamr@2: { williamr@2: public: williamr@2: // ECOM creation. williamr@2: IMPORT_C static CMMFFormatEncode* NewL( TUid aUid, MDataSink* aSink ); williamr@2: IMPORT_C static CMMFFormatEncode* NewL( const TDesC& aFileName, MDataSink* aSink, const TDesC& aPreferredSupplier ) ; williamr@2: IMPORT_C static CMMFFormatEncode* NewL( const TDesC8& aSourceHeader, MDataSink* aSink, const TDesC& aPreferredSupplier ) ; williamr@2: IMPORT_C static CMMFFormatEncode* NewL( MDataSink* aSink, const TDesC& aPreferredSupplier ) ; williamr@2: williamr@2: /** williamr@2: Destructor. williamr@2: */ williamr@2: virtual ~CMMFFormatEncode() {REComSession::DestroyedImplementation(iDtor_ID_Key);} williamr@2: williamr@2: // returns ECOM plugin uid of this format williamr@2: /** williamr@2: Gets the ECom plugin UID of this format. williamr@2: williamr@2: @return The plugin UID. williamr@2: */ williamr@2: TUid ImplementationUid() const {return iImplementationUid;} williamr@2: williamr@2: /** williamr@2: Returns the time interval for one frame for the specified media type. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaType williamr@2: The media type ID. williamr@2: @return The frame time interval in microseconds. williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds FrameTimeInterval(TMediaId aMediaType) const = 0; williamr@2: williamr@2: /** williamr@2: Returns the duration of the sink clip for the specified media type. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaType williamr@2: The media type ID. williamr@2: williamr@2: @return The duration of the sink clip. williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds Duration(TMediaId aMediaType) const = 0; williamr@2: williamr@2: /** williamr@2: @internalAll williamr@2: williamr@2: Request from CMMFDataPath to fill the specified buffer. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer to fill. williamr@2: @param aConsumer williamr@2: The consumer. williamr@2: @param aMediaId williamr@2: The media ID. williamr@2: */ williamr@2: inline virtual void FillBufferL(CMMFBuffer* aBuffer, MDataSink* aConsumer, TMediaId aMediaId); williamr@2: williamr@2: /** williamr@2: Called by the clip when it has added the data to the file. williamr@2: williamr@2: @param aBuffer williamr@2: The emptied buffer. williamr@2: */ williamr@2: virtual void BufferEmptiedL(CMMFBuffer* aBuffer) {iDataPath->BufferEmptiedL(aBuffer);} williamr@2: williamr@2: /** williamr@2: Tests whether a source buffer can be created. williamr@2: williamr@2: The default implementation returns EFalse. williamr@2: williamr@2: @return A boolean indicating if the buffer can be created. ETrue if buffer can be created, EFalse otherwise. williamr@2: */ williamr@2: virtual TBool CanCreateSourceBuffer() {return EFalse;} williamr@2: williamr@2: /** williamr@2: Creates a source buffer. The default returns NULL. williamr@2: williamr@2: @param aMediaId williamr@2: The media type id. williamr@2: @param aReference williamr@2: If ETrue the MDataSource owns the buffer. williamr@2: If EFalse, then the caller owns the buffer. williamr@2: williamr@2: @return Source buffer. williamr@2: */ williamr@2: inline virtual CMMFBuffer* CreateSourceBufferL(TMediaId aMediaId, TBool &aReference); williamr@2: williamr@2: /** williamr@2: Returns the source data type code for the specified media type ID. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaId williamr@2: The media type id. williamr@2: williamr@2: @return The source data type code. williamr@2: */ williamr@2: inline virtual TFourCC SourceDataTypeCode(TMediaId aMediaId); williamr@2: williamr@2: /** williamr@2: Adds a buffer to a clip. williamr@2: williamr@2: Called by CMMFDataPath. williamr@2: (from MDataSink - CMMFFormatEncode is a MDataSink to a CMMFDataPath) williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer to which the clip is added. williamr@2: @param aSupplier williamr@2: The data source. williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: */ williamr@2: virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId)=0; williamr@2: williamr@2: /** williamr@2: @internalAll williamr@2: williamr@2: Called by the CMMFDataPath's MDataSource when it has filled the buffer. williamr@2: williamr@2: @param aBuffer williamr@2: The buffer that has been filled. williamr@2: */ williamr@2: inline virtual void BufferFilledL(CMMFBuffer* aBuffer); williamr@2: williamr@2: /** williamr@2: Tests whether a sink buffer can be created. williamr@2: williamr@2: Format would normally pass its own buffer onto the CMMFClip, so williamr@2: this may not be required. The default returns ETrue. williamr@2: williamr@2: @return A boolean indicating if the buffer can be created. ETrue if buffer can be created, EFalse otherwise. williamr@2: */ williamr@2: virtual TBool CanCreateSinkBuffer() {return ETrue;} williamr@2: williamr@2: /** williamr@2: Creates a sink buffer for the specified media ID. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: @param aReference williamr@2: If ETrue then MDataSink owns the buffer. williamr@2: If EFalse, then the caller owns the buffer. williamr@2: williamr@2: @return A pointer to the CMMFBuffer sink buffer. williamr@2: */ williamr@2: virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference)=0; williamr@2: williamr@2: /** williamr@2: Returns the sink data type code for the specified media type ID. williamr@2: williamr@2: This would be the same as the source data type four CC although the clip williamr@2: is not going to need this info. williamr@2: williamr@2: This is a virtual function that each derived class must implement. williamr@2: williamr@2: @param aMediaId williamr@2: The media type ID. williamr@2: williamr@2: @return The sink data type code. williamr@2: */ williamr@2: virtual TFourCC SinkDataTypeCode(TMediaId aMediaId) = 0; williamr@2: williamr@2: /** williamr@2: This function is used to truncate the sink ie. a CMMFClip, williamr@2: williamr@2: If aToEnd = ETrue the sink is cropped from the aPosition to the end of the clip. williamr@2: If aToEnd = EFalse then the sink is cropped from the start of the clip to aPosition. williamr@2: williamr@2: This function would be called by the CMMFController. The default implementation leaves williamr@2: with KErrNotSupported. williamr@2: williamr@2: @param aPosition williamr@2: The position within the clip. williamr@2: @param aToEnd williamr@2: Flag to determine which part of the clip to delete. williamr@2: */ williamr@2: inline virtual void CropL(TTimeIntervalMicroSeconds aPosition, TBool aToEnd = ETrue); williamr@2: williamr@2: williamr@2: /** williamr@2: Gets the number of meta data entries. williamr@2: williamr@2: The encode format is capable of reading and writing meta data to the clip. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aNumberOfEntries williamr@2: On return, contains the number of meta data entries. williamr@2: */ williamr@2: inline virtual void GetNumberOfMetaDataEntriesL(TInt& aNumberOfEntries); williamr@2: williamr@2: /** williamr@2: Returns the specified meta data entry. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aIndex williamr@2: The zero based meta data entry index to retrieve. williamr@2: williamr@2: @return The meta data entry. williamr@2: */ williamr@2: inline virtual CMMFMetaDataEntry* MetaDataEntryL(TInt aIndex); williamr@2: williamr@2: /** williamr@2: Adds the specified meta data entry to the clip. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aNewEntry williamr@2: The meta data entry to add. williamr@2: */ williamr@2: inline virtual void AddMetaDataEntryL(const CMMFMetaDataEntry& aNewEntry); williamr@2: williamr@2: /** williamr@2: Removes the specified meta data entry. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: @param aIndex williamr@2: The zero based meta data entry index to remove. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt RemoveMetaDataEntry(TInt aIndex); williamr@2: williamr@2: /** williamr@2: Replaces the specified meta data entry with the entry supplied in aNewEntry. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aIndex williamr@2: The zero based meta data entry index to replace. williamr@2: @param aNewEntry williamr@2: The meta data entry to replace. williamr@2: */ williamr@2: inline virtual void ReplaceMetaDataEntryL(TInt aIndex, const CMMFMetaDataEntry& aNewEntry); williamr@2: williamr@2: //audio format methods williamr@2: williamr@2: /** williamr@2: Sets the number of channels. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: @param aChannels williamr@2: The number of channels. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetNumChannels(TUint aChannels); williamr@2: williamr@2: /** williamr@2: Sets the sample rate. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: @param aSampleRate williamr@2: The sample rate. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetSampleRate(TUint aSampleRate); williamr@2: williamr@2: /** williamr@2: Sets the bit rate. williamr@2: williamr@2: The default implementation returns KErrNotSupported. williamr@2: williamr@2: @param aBitRate williamr@2: The bit rate. williamr@2: williamr@2: @return An error code indicating if the function call was successful. KErrNone on success, otherwise williamr@2: another of the system-wide error codes. williamr@2: */ williamr@2: inline virtual TInt SetBitRate(TUint aBitRate); williamr@2: williamr@2: /** williamr@2: Returns the number of channels. williamr@2: williamr@2: The default implementation returns 0. williamr@2: williamr@2: @return The number of channels. williamr@2: */ williamr@2: virtual TUint NumChannels() {return 0;} williamr@2: williamr@2: /** williamr@2: Returns the sample rate. williamr@2: williamr@2: The default implementation returns 0. williamr@2: williamr@2: @return The sample rate. williamr@2: */ williamr@2: virtual TUint SampleRate() {return 0;} williamr@2: williamr@2: /** williamr@2: Returns the default sample rate. williamr@2: williamr@2: The default returns 0. williamr@2: williamr@2: @return The default sample rate. williamr@2: */ williamr@2: virtual TUint GetDefaultSampleRate() {return 0;} williamr@2: williamr@2: /** williamr@2: Returns the bit rate. williamr@2: williamr@2: The default returns 0. williamr@2: williamr@2: @return The bit rate. williamr@2: */ williamr@2: virtual TUint BitRate() {return 0;} williamr@2: williamr@2: /** williamr@2: Returns the bytes per second. williamr@2: williamr@2: The default returns 0. williamr@2: williamr@2: @return The bytes per second. williamr@2: */ williamr@2: virtual TInt64 BytesPerSecond() {return 0;} williamr@2: williamr@2: /** williamr@2: Gets the supported sample rates. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aSampleRates williamr@2: A reference to an array of supported sample rates. williamr@2: */ williamr@2: inline virtual void GetSupportedSampleRatesL(RArray& aSampleRates); williamr@2: williamr@2: /** williamr@2: Gets the supported bit rates. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aBitRates williamr@2: A reference to an array of supported bit rates. williamr@2: */ williamr@2: inline virtual void GetSupportedBitRatesL(RArray& aBitRates); williamr@2: williamr@2: /** williamr@2: Gets the supported number of channels. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aNumChannels williamr@2: A reference to an array of supported number of channels. williamr@2: */ williamr@2: inline virtual void GetSupportedNumChannelsL(RArray& aNumChannels); williamr@2: williamr@2: /** williamr@2: Gets the supported data types for the given media type ID. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aMediaId williamr@2: The media type id. williamr@2: @param aDataTypes williamr@2: A reference to an array of supported data types. williamr@2: */ williamr@2: inline virtual void GetSupportedDataTypesL(TMediaId aMediaId, RArray& aDataTypes); williamr@2: williamr@2: /** williamr@2: Sets the maximum clip size. williamr@2: williamr@2: The default implementation leaves with KErrNotSupported. williamr@2: williamr@2: @param aBytes williamr@2: The maximum clip size. williamr@2: */ williamr@2: inline virtual void SetMaximumClipSizeL(TInt aBytes); williamr@2: williamr@2: /** williamr@2: Returns the maximum clip size. williamr@2: williamr@2: The default returns 0. williamr@2: williamr@2: @return The maximum clip size. williamr@2: */ williamr@2: virtual TInt MaximumClipSize() { return 0;} williamr@2: williamr@2: /** williamr@2: Used to set the format's position. williamr@2: williamr@2: Subsequent data reads should ignore the FrameNumber in the CMMFBuffer and use this williamr@2: setting to determine what data to provide. williamr@2: williamr@2: The actual position the format sets itself may vary to this setting to ensure williamr@2: that it is aligned to the sample boundaries ensuring consistent data output. williamr@2: williamr@2: If not supported, positional information should be extracted from the FrameNumber in CMMFBuffer williamr@2: williamr@2: @param aPosition williamr@2: The position the format should use. williamr@2: */ williamr@2: inline virtual void SetPositionL(const TTimeIntervalMicroSeconds& aPosition); williamr@2: williamr@2: williamr@2: /** williamr@2: Supplies the current position. williamr@2: williamr@2: Subsequent data reads will commence from this position. williamr@2: williamr@2: @return The current position in microseconds. williamr@2: */ williamr@2: virtual TTimeIntervalMicroSeconds PositionL() {User::Leave(KErrNotSupported);return TTimeIntervalMicroSeconds(0);} williamr@2: williamr@2: williamr@2: protected: williamr@2: //ConstructSourceL should never be called. The CMMFFormatEncode NewL functions should williamr@2: //always be used to instantiate a CMMFFormatEncode object (not MDataSource::NewL) williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: virtual void ConstructSourceL( const TDesC8& /*aInitData*/ ) {User::Leave(KErrNotSupported);} williamr@2: //ConstructSinkL should never be called. The CMMFFormatEncode NewL functions should williamr@2: //always be used to instantiate a CMMFFormatEncode object (not MDataSink::NewL) williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: virtual void ConstructSinkL( const TDesC8& /*aInitData*/ ) {User::Leave(KErrNotSupported);} williamr@2: williamr@2: /** williamr@2: Default constructor williamr@2: */ williamr@2: CMMFFormatEncode() : MDataSource(KUidMmfFormatEncode), MDataSink(KUidMmfFormatEncode) {}; williamr@2: williamr@2: // Creates and initialises format plugin. williamr@2: static CMMFFormatEncode* CreateFormatL(TUid aImplementationUid, MDataSink* aSink); williamr@2: protected: williamr@2: williamr@2: /** williamr@2: The Data path is the source for the encode format. williamr@2: */ williamr@2: MDataSource* iDataPath; williamr@2: williamr@2: /** williamr@2: The clip is the sink for the encode format. williamr@2: */ williamr@2: MDataSink* iClip; williamr@2: private: williamr@2: TUid iDtor_ID_Key; // do not move - referenced inline in ~CMMFFormatDecode() williamr@2: TUid iImplementationUid; // do not move - referenced inline in ImplementationUid() williamr@2: }; williamr@2: williamr@2: williamr@2: class CMMFFormatPluginSelectionParameters; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Provides an internal utility function to choose a format plugin from ECom. williamr@2: */ williamr@2: class MMFFormatEcomUtilities williamr@2: { williamr@2: public: williamr@2: //Internal utility function to choose a format plugin from ECOM williamr@2: static TUid SelectFormatPluginL(const CMMFFormatPluginSelectionParameters& aSelectParams); williamr@2: williamr@2: // Internal utility function to instantiate each format decode plugin in turn williamr@2: // until we find one that works williamr@2: static CMMFFormatDecode* SelectFormatDecodePluginL(const CMMFFormatPluginSelectionParameters& aSelectParams, MDataSource* aSource); williamr@2: williamr@2: static CMMFFormatDecode* SelectFormatDecodePluginL(const CMMFFormatPluginSelectionParameters& aSelectParams, MDataSource* aSource, TBool& aSupportsCustomInterfaces); williamr@2: }; williamr@2: williamr@2: #include "mmfformat.inl" williamr@2: williamr@2: #endif