Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: mmfdatapath.h
Link against: mmfserverbaseclasses.lib

This item is not part of the S60 3rd Edition SDK for Symbian OS, Feature Pack 2.

Class CMMFDataPath

class CMMFDataPath : public CActive, public MDataSink, public MDataSource, public MAsyncEventHandler;

Description

Abstract utility class that moves data from a single data source to a single data sink, via a codec if required.

All functions are exported form the DLL and are virtual to allow plugins to define their own data paths.

Derivation

Members

Defined in CMMFDataPath:
AddDataSinkL(), AddDataSourceL(), BufferEmptiedL(), BufferFilledL(), CMMFDataPath(), CanCreateSinkBuffer(), CanCreateSourceBuffer(), ClearPlayWindowL(), ConstructL(), ConstructSinkL(), ConstructSourceL(), CreateSinkBufferL(), CreateSinkBufferL(), CreateSourceBufferL(), CreateSourceBufferL(), DoCancel(), DoSendEventToClient(), EConverting, EEndOfData, EInitializeSink, EInitializeSource, ENeedSinkBuffer, ENeedSinkData, ENeedSourceBuffer, ENeedSourceData, ENeedToMatchSourceToSink, ENoBuffers, EPlaying, EPrimed, ERecording, ESendDataToSink, EStopped, EWaitSink, EWaitSource, EmptyBufferL(), EndOfData(), FillBufferL(), NewL(), NewL(), NewL(), NewL(), Pause(), PlayL(), Position(), PrimeL(), ResetL(), RunError(), RunL(), SendEventToClient(), SetBlockLength(), SetPlayWindowL(), SetPositionL(), SinkDataTypeCode(), SourceDataTypeCode(), State(), Stop(), TDataPathState, TNeedBuffer, TTransferState, iAllDataSentToSink, iBuffersToUse, iCachedSourceDuration, iCodec, iCodecProcessResult, iCompleteCallback, iCurrentSinkFrameNumber, iCurrentSourceFrameNumber, iDataPathCompletedErrorCode, iDataPathCreated, iDataSink, iDataSource, iEventHandler, iMediaId, iNoMoreSourceData, iObtainingAsyncSinkBuffer, iObtainingAsyncSourceBuffer, iPauseCalled, iPlayWindowEndPosition, iPlayWindowStartPosition, iReferenceAudioSamplesPlayed, iReferenceAudioSamplesRecorded, iSinkBuffer, iSinkBufferWithSink, iSinkCanReceive, iSinkFourCC, iSnkBufRef, iSourceBuffer, iSourceBufferWithSource, iSourceFourCC, iSrcBufRef, iStartPosition, iState, iTransferState, iUseSuppliedCodecUid, ~CMMFDataPath()

Inherited from CActive:
Cancel(), Deque(), EPriorityHigh, EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, Extension_(), IsActive(), IsAdded(), Priority(), SetActive(), SetPriority(), TPriority, iStatus

Inherited from CBase:
Delete(), operator new()

Inherited from MDataSink:
DataSinkType(), NegotiateL(), NewSinkL(), SetSinkDataTypeCode(), SetSinkPrioritySettings(), SinkCustomCommand(), SinkPauseL(), SinkPlayL(), SinkPrimeL(), SinkStopL(), SinkThreadLogoff(), SinkThreadLogon()

Inherited from MDataSource:
DataSourceType(), NegotiateSourceL(), NewSourceL(), SetSourceDataTypeCode(), SetSourcePrioritySettings(), SourceCustomCommand(), SourcePauseL(), SourcePlayL(), SourcePrimeL(), SourceSampleConvert(), SourceStopL(), SourceThreadLogoff(), SourceThreadLogon()


Construction and destruction


NewL()

static IMPORT_C CMMFDataPath *NewL(MAsyncEventHandler &aEventHandler);

Description

Allocates and constructs a data path.

Use this function if the codec UID is not already known by CMMFController and there is no data path ambiguity - ie only one data path is possible.

Will create codec via fourCC.

Parameters

MAsyncEventHandler &aEventHandler

Installs an event handler to provide message passing between clients and sources/sinks.

Return value

CMMFDataPath *

Newly constructed data path object.


NewL()

static IMPORT_C CMMFDataPath *NewL(TMediaId aMediaId, MAsyncEventHandler &aEventHandler);

Description

Allocates and constructs a data path according to the specified media ID.

Use this function if the codec UID is not already known by CMMFController and there is ambiguity with the data path ie. there is more than one possible data path.

Parameters

TMediaId aMediaId

Optional media ID parameter when there are multiple media types.

MAsyncEventHandler &aEventHandler

Installs an event handler to provide message passing between clients and sources/sinks.

Return value

CMMFDataPath *

A newly constructed data path object.


NewL()

static IMPORT_C CMMFDataPath *NewL(TUid aCodecUid, MAsyncEventHandler &aEventHandler);

Description

Allocates and constructs a data path according to the specified codec UID.

Use this function if the codec UID is already known by CMMFController and there is no data path ambiguity ie. only one data path is possible will create codec explicitly using the supplied codec Uid

Parameters

TUid aCodecUid

Optional mediaID parameter when there are multiple media types

MAsyncEventHandler &aEventHandler

Installs an event handler to provide message passing between clients and sources/sinks.

Return value

CMMFDataPath *

A newly constructed data path object.


NewL()

static IMPORT_C CMMFDataPath *NewL(TUid aCodecUid, TMediaId aMediaId, MAsyncEventHandler &aEventHandler);

Description

Allocates and constructs a data path according to the specified codec UID.

Use this function if the codec UID is already known by CMMFController and there is ambiguity ie. more than one possible data path. TMediaId used to select the path.

Parameters

TUid aCodecUid

The codec UID.

TMediaId aMediaId

Optional mediaID parameter when there are multiple media types.

MAsyncEventHandler &aEventHandler

Installs an event handler to provide message passing between clients and sources/sinks.

Return value

CMMFDataPath *

A newly constructed data path object.


~CMMFDataPath()

virtual IMPORT_C ~CMMFDataPath();

Description

Standard destructor.


CMMFDataPath()

protected: inline CMMFDataPath(TMediaId aMediaId, MAsyncEventHandler &aEventHandler);

Description

Parameters

TMediaId aMediaId

MAsyncEventHandler &aEventHandler


ConstructL()

protected: IMPORT_C void ConstructL(TUid aCodecUid=TUid::Null());

Description

Takes UID of codec on construction, and if not an NULL codec sets the datapath up for codec instantiation.

Parameters

TUid aCodecUid

The UID of the codec.

[Top]


Member functions


ResetL()

virtual IMPORT_C void ResetL();

Description

Deletes buffers if this datapath's sources and sinks own the buffers returned by PrimeL(). Typically if buffers are created asychronously, the datapath doesn't own the buffer so leaves cleanup handling to the owner sources/sinks.

Called when source and sink needs to be de-referenced. Sets iDataPathCreated, iSinkCanReceive, iSnkBufRef and iSrcBufRef to EFalse; sets iState to EStopped.


EmptyBufferL()

virtual IMPORT_C void EmptyBufferL(CMMFBuffer *aBuffer, MDataSource *aSupplier, TMediaId aMediaId);

Description

Clears the specified buffer.

Pure virtual dummy implementation, not needed by datapath comes from MDataSink - CMMFData path is a sink to its MDataSource.

This is only required for an active push MDataSource requesting a buffer empty.

Parameters

CMMFBuffer *aBuffer

The buffer to empty.

MDataSource *aSupplier

The MDataSource supplying this buffer.

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving of different media types.


BufferFilledL()

virtual IMPORT_C void BufferFilledL(CMMFBuffer *aBuffer);

Description

Indicates the data source has filled the specified buffer.

Called by the CMMFDataPath's MDataSource when it has filled the buffer.

Parameters

CMMFBuffer *aBuffer

A pointer to the filled buffer.


CanCreateSinkBuffer()

virtual IMPORT_C TBool CanCreateSinkBuffer();

Description

Tests whether the data path can create a sink buffer.

The default implementation returns false.

Return value

TBool

ETrue if the data path can create a sink buffer. EFalse if the data path cannot create a sink buffer.


CreateSinkBufferL()

virtual IMPORT_C CMMFBuffer *CreateSinkBufferL(TMediaId aMediaId);

Description

Creates a sink buffer according to the specifed media ID.

Intended for synchronous usage (buffers supplied by datapath for an MDataSink). This method is essentially a dummy implementation of an MDataSink pure virtual.

The default implementation returns NULL.

Parameters

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving of different media types.

Return value

CMMFBuffer *

Returns NULL in this instance as datapath can't create sink buffers


CreateSinkBufferL()

virtual IMPORT_C CMMFBuffer *CreateSinkBufferL(TMediaId aMediaId, TBool &aReference);

Description

Creates a sink buffer according to the specifed media ID and reference.

Intended for asynchronous usage (buffers supplied by Devsound device). This method is essentially a dummy implementation of an MDataSink pure virtual.

The default implementation returns NULL.

Parameters

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving for different media types.

TBool &aReference

A boolean indicating buffer ownership.

Return value

CMMFBuffer *

Returns NULL in this instance as datapath can't create sink buffers.


SinkDataTypeCode()

virtual IMPORT_C TFourCC SinkDataTypeCode(TMediaId aMediaId);

Description

Gets the sink's data type for the specified media ID.

Parameters

TMediaId aMediaId

An optional parameter to specifiy the specific stream when datasource contains more than one stream of data

Return value

TFourCC

The sink's data type.


FillBufferL()

virtual IMPORT_C void FillBufferL(CMMFBuffer *aBuffer, MDataSink *aConsumer, TMediaId aMediaId);

Description

Fills the specified buffer.

Pure virtual dummy implementation, not needed by datapath comes from MDataSink - CMMFData path is a source to its MDataSink

Only required for an active pull MDataSink requesting a buffer fill. The default implementation is empty.

Parameters

CMMFBuffer *aBuffer

The buffer to fill.

MDataSink *aConsumer

The MDataSink supplying this buffer.

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving of different media types


BufferEmptiedL()

virtual IMPORT_C void BufferEmptiedL(CMMFBuffer *aBuffer);

Description

Indicates the data sink has emptied the buffer.

Called by the CMMFDataPath's MDataSink when it has emptied the buffer

Parameters

CMMFBuffer *aBuffer

The emptied buffer.


CanCreateSourceBuffer()

virtual IMPORT_C TBool CanCreateSourceBuffer();

Description

Tests whether the data path can create a source buffer.

Would expect datapath to always return NULL, so this is a default implementation of a pure virtual from MDataSink.

The default implementation returns EFalse.

Return value

TBool

ETrue if the data path can create a source buffer. EFalse if the data path cannot create a source buffer.


CreateSourceBufferL()

virtual IMPORT_C CMMFBuffer *CreateSourceBufferL(TMediaId aMediaId);

Description

Creates a source buffer.

Intended for synchronous usage (buffers supplied by datapath for a MDataSource) This method is essentially a dummy implementation of an MDataSource pure virtual.

The default implementation leaves with KErrNotSupported and returns NULL.

Parameters

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving of different media types.

Return value

CMMFBuffer *

A pointer to a newly created buffer. Returns NULL in this instance as datapath can't create source buffers


CreateSourceBufferL()

virtual IMPORT_C CMMFBuffer *CreateSourceBufferL(TMediaId aMediaId, TBool &aReference);

Description

Creates a source buffer according to the specifed media ID and reference.

Intended for asynchronous usage (buffers supplied by datapath for a MDataSource) This method is essentially a dummy implementation of an MDataSource pure virtual.

The default implementation leaves with KErrNotSupported and returns NULL.

Parameters

TMediaId aMediaId

An optional mediaID parameter when there are multiple buffers arriving of different media types.

TBool &aReference

A boolean indicating buffer ownership. ETrue if the MDataSource owns the buffer, EFalse if the caller owns the buffer.

Return value

CMMFBuffer *

A pointer to a newly created buffer. Returns NULL in this instance as datapath can't create source buffers.


SourceDataTypeCode()

virtual IMPORT_C TFourCC SourceDataTypeCode(TMediaId aMediaId);

Description

Gets the source data type for the specified media ID.

Parameters

TMediaId aMediaId

An optional parameter to specifiy specific stream when datasource contains more than one stream of data.

Return value

TFourCC

The source data type.


AddDataSourceL()

virtual IMPORT_C void AddDataSourceL(MDataSource *aSource);

Description

Adds a data source to the datapath and, if the sink already exists, tries to establish a connection between the source and sink.

Parameters

MDataSource *aSource

The data source to add to the data path.


AddDataSinkL()

virtual IMPORT_C void AddDataSinkL(MDataSink *aSink);

Description

Adds a data sink to the datapath and, if the source already exists, tries to establish a connection between the source and sink.

Parameters

MDataSink *aSink

The data sink to add to the data path.


PrimeL()

virtual IMPORT_C void PrimeL();

Description

Allocates buffers in preparation to play.

Must be called before calling PlayL().

iSnkBufRef and iSrcBufRef contain ETrue if these buffers are created and owned by a MDataSource or MDataSink For clean-up purposes, datapath only cleans up buffers allocated directly by PrimeL().


PlayL()

virtual IMPORT_C void PlayL();

Description

Starts an active scheduler 'play' loop.

Can only play from the primed state.


Pause()

virtual IMPORT_C void Pause();

Description

Pauses playing.

Sends KMMFErrorCategoryDataPathGeneralError to the client if an error occurs.


Stop()

virtual IMPORT_C void Stop();

Description

Stops playing.

Resets datapath position - currently does not clean up buffers. Sends KMMFErrorCategoryDataPathGeneralError to the client if an error occurs.


Position()

virtual IMPORT_C TTimeIntervalMicroSeconds Position() const;

Description

Gets the data path position.

Return value

TTimeIntervalMicroSeconds

The data path position.


SetPositionL()

virtual IMPORT_C void SetPositionL(const TTimeIntervalMicroSeconds &aPosition);

Description

Sets the data path position.

Parameters

const TTimeIntervalMicroSeconds &aPosition

The data path position.


SetPlayWindowL()

virtual IMPORT_C void SetPlayWindowL(const TTimeIntervalMicroSeconds &aStart, const TTimeIntervalMicroSeconds &aEnd);

Description

Sets the play window absolutely (i.e. the parameters are relative to the start of the entire clip).

Parameters

const TTimeIntervalMicroSeconds &aStart

The offset from the start of the Clip

const TTimeIntervalMicroSeconds &aEnd

The offset from the end of the clip (if this is less than aStart, then the two will be inverted).


ClearPlayWindowL()

virtual IMPORT_C void ClearPlayWindowL();

Description

Sets the play window to the full length of clip.


State()

virtual IMPORT_C TInt State();

Description

Returns the current data path state.

Return value

TInt


RunL()

virtual IMPORT_C void RunL();

Description

Runs the clip depending on the current data path and transfer state.

For example, fills the sink buffer if TDataPathState is EPlaying and TTransferState is ENeedSinkData.


DoCancel()

virtual IMPORT_C void DoCancel();

Description

Cancels the clip.

The default implementation is empty.


RunError()

virtual IMPORT_C TInt RunError(TInt aError);

Description

Handles errors coming from attached sources and passes them to the clients.

Parameters

TInt aError

Standard error code (KErrNone = No Error).

Return value

TInt

The event code returned to the data path. KErrNone if end of file is encountered.


DoSendEventToClient()

IMPORT_C TInt DoSendEventToClient(TUid aEventType, TInt aErrorCode);

Description

Passes error handling and general messages up to clients.

Parameters

TUid aEventType

Category code for the event. Category codes can be used as unique identifers.

TInt aErrorCode

Standard error code.

Return value

TInt

The event code sent to client.


SetBlockLength()

IMPORT_C TInt SetBlockLength(TUint aBlockLength);

Description

Parameters

TUint aBlockLength

Return value

TInt


ConstructSourceL()

protected: virtual IMPORT_C void ConstructSourceL(const TDesC8 &aInitData);

Description

Constructs a source.

The default implementation leaves with KErrNotSupported.

Parameters

const TDesC8 &aInitData

The initialisation data.


ConstructSinkL()

protected: virtual IMPORT_C void ConstructSinkL(const TDesC8 &aInitData);

Description

Constructs a sink.

Overridable constuction specific to this datasource.

The default implementation leaves with KErrNotSupported.

Parameters

const TDesC8 &aInitData

The initialisation data.


EndOfData()

protected: virtual IMPORT_C void EndOfData();

Description

Forces and end of data state on the datapath


SendEventToClient()

private: virtual IMPORT_C TInt SendEventToClient(const TMMFEvent &aEvent);

Description

Passes error handling and general messages to clients.

Parameters

const TMMFEvent &aEvent

TMMFEvent supplied by callee (typically DoSendEventToClient)

Return value

TInt

The Event Message sent to the datapath event handler

[Top]


Member enumerations


Enum TDataPathState

TDataPathState

Description

Indicates the state of the data path.

Mimics typical MultiMedia behaviour of stopped, primed and playing

EStopped

Stopped.

EPrimed

Primed.

EPlaying

Playing.

ERecording

Recording.

EConverting

Converting.


Enum TTransferState

protected: TTransferState

Description

Indicates the transfer state.

Buffers maybe be filled, emptied, or have "one" shot initialisatings performed upon them.

TTransferState is used within the datapath RunL which drives databuffer exchange.

EWaitSink

Waiting on a BufferEmptied callback from sink

EWaitSource

Waiting on a BufferFilled callback from source

EInitializeSink

Initialize the sink.

EInitializeSource

Initialize the source.

ENeedSourceData

Source buffer does not contain data.

ENeedSinkData

Sink buffer does not contain data.

ENeedToMatchSourceToSink

There is more source data to send to the sink and need to match sink and source.

ESendDataToSink

Outstanding data to send to sink.

EEndOfData

End of data.


Enum TNeedBuffer

protected: TNeedBuffer

Description

This indicates what buffers are required in order to operate. If a real Codec is in use, buffers are required from both source and sink, else only one is required and source is preferred.

ENoBuffers

No buffers needed.

ENeedSinkBuffer

Sink buffer needed.

ENeedSourceBuffer

Source buffer needed.

[Top]


Member data


iEventHandler

protected: MAsyncEventHandler & iEventHandler;

Description

Event handler.


iDataSource

protected: MDataSource * iDataSource;

Description

The source of data to which the CMMFDataPath is a MDataSink for.


iDataSink

protected: MDataSink * iDataSink;

Description

The sink of data for which the CMMFDataPath is a MDataSource for


iSinkCanReceive

protected: TBool iSinkCanReceive;

Description

Set to true when the sink is able to accept data. EFalse otherwise.


iSinkFourCC

protected: TFourCC iSinkFourCC;

Description

The sink's data type. Same as the codec input data type.


iSourceFourCC

protected: TFourCC iSourceFourCC;

Description

The source's data type. Same as the codec output data type.


iMediaId

protected: TMediaId iMediaId;

Description

Identifies which media type and stream within MDataSource.


iCodec

protected: CMMFCodec * iCodec;

Description

Codec in use. Null Codec is signified by == NULL


iCodecProcessResult

protected: TCodecProcessResult iCodecProcessResult;

Description

Result of processing the codec.


iDataPathCreated

protected: TBool iDataPathCreated;

Description

Set to ETrue when the data path has a source and a sink and can send data from the source to the sink.


iState

protected: TDataPathState iState;

Description

Current data path state.

See also:


iTransferState

protected: TTransferState iTransferState;

Description

Current transfer state.

See also:


iUseSuppliedCodecUid

protected: TBool iUseSuppliedCodecUid;

Description

Set to true if data path has to use a supplied codec in its construction.


iSinkBuffer

protected: CMMFBuffer * iSinkBuffer;

Description

This is set to point to whichever sink buffer is in use.


iSourceBuffer

protected: CMMFBuffer * iSourceBuffer;

Description

This is the pointer to whichever source buffer is in use


iCurrentSourceFrameNumber

protected: TUint iCurrentSourceFrameNumber;

Description

The source's position in terms of frames or some other time fixed parameter.


iCurrentSinkFrameNumber

protected: TUint iCurrentSinkFrameNumber;

Description

The sink's position in terms of frames or some other time fixed parameter.


iNoMoreSourceData

protected: TBool iNoMoreSourceData;

Description

Indicates that all data has been obtained from the source (ETrue if there is no more source data).


iAllDataSentToSink

protected: TBool iAllDataSentToSink;

Description

Indicates that all data has been sent to the sink.


iDataPathCompletedErrorCode

protected: TUint iDataPathCompletedErrorCode;

Description

Datapath completed because of an error; usually KErrNone.


iPlayWindowStartPosition

protected: TTimeIntervalMicroSeconds iPlayWindowStartPosition;

Description

Start position of the play window.


iPlayWindowEndPosition

protected: TTimeIntervalMicroSeconds iPlayWindowEndPosition;

Description

End position of the play window.


iStartPosition

protected: TTimeIntervalMicroSeconds iStartPosition;

Description

The position audio will start playing from. When stopping, this is set to iPlayWindowStartPosition. When pausing, this is set to the current position.


iCachedSourceDuration

protected: TTimeIntervalMicroSeconds iCachedSourceDuration;

Description

This value can be used to obtain the duration of the source when playing or converting. This is an optimisation as this value will not change if we are playing or converting.


iSrcBufRef

protected: TBool iSrcBufRef;

Description

ETrue if the source buffer is reference to object owned by someone else.


iSnkBufRef

protected: TBool iSnkBufRef;

Description

ETrue if sink buffer is reference to object owned by someone else


iObtainingAsyncSourceBuffer

protected: TBool iObtainingAsyncSourceBuffer;

Description

Indicates asynchrous buffers from AudioInput.


iObtainingAsyncSinkBuffer

protected: TBool iObtainingAsyncSinkBuffer;

Description

Indicates asynchrous buffers from AudioOutput.


iPauseCalled

protected: TBool iPauseCalled;

Description

Indicates DoPauseL() has been called.


iSourceBufferWithSource

protected: TBool iSourceBufferWithSource;

Description

Flag to indicate that a buffer is with the source.

This is necessary as it is imperrative that when a buffer is with the source, it must not be referenced in any way. The reason for this is that it is not mandated that sources maintain buffer references. For example, it is valid for DevSound to return recorded data in a different buffer to the one supplied to it.


iSinkBufferWithSink

protected: TBool iSinkBufferWithSink;

Description

Flag to indicate that a buffer is with the sink.

This are necessary as it is imperrative that when a buffer is with the sink, it must not be referenced in any way. The reason for this is that it is not mandated that sinks maintain buffer references. For example, it is valid for DevSound to request more audio data in a different buffer to the one supplied to it.


iReferenceAudioSamplesPlayed

protected: TInt iReferenceAudioSamplesPlayed;

Description

Holds the number of samples played on audio output at a point where we want to reference play duration from.


iReferenceAudioSamplesRecorded

protected: TInt iReferenceAudioSamplesRecorded;

Description

Holds the number of samples recorded from audio input at a point where we want to reference record duration from.


iCompleteCallback

protected: CCompleteCallback * iCompleteCallback;

Description

Pointer to internal callback completion class


iBuffersToUse

protected: TInt iBuffersToUse;

Description

Holds the outcome of the call to DetermineBuffersToUseL