#include <mmf/server/mmfdatapath.h>
class CMMFDataPath : public CActive |
Public Member Enumerations | |
---|---|
enum | TDataPathState { EStopped, EPrimed, EPlaying, ERecording, EConverting } |
Protected Member Enumerations | |
---|---|
enum | TNeedBuffer { ENoBuffers, ENeedSinkBuffer, ENeedSourceBuffer } |
enum | TTransferState { EWaitSink, EWaitSource, EInitializeSink, EInitializeSource, ..., EEndOfData } |
Protected Member Functions | |
---|---|
CMMFDataPath(TMediaId, MAsyncEventHandler &) | |
TInt | AudioSamplesPlayed() |
TInt | AudioSamplesRecorded() |
TTimeIntervalMicroSeconds | CalculateAudioInputPosition() |
TTimeIntervalMicroSeconds | CalculateAudioOutputPosition() |
IMPORT_C void | ConstructL(TUid) |
virtual IMPORT_C void | ConstructSinkL(const TDesC8 &) |
virtual IMPORT_C void | ConstructSourceL(const TDesC8 &) |
TInt | DetermineBuffersToUseL(void) |
virtual IMPORT_C void | EndOfData() |
TTimeIntervalMicroSeconds | InputPosition() |
TTimeIntervalMicroSeconds | OutputPosition() |
Inherited Attributes | |
---|---|
CActive::iStatus |
Inherited Enumerations | |
---|---|
CActive:TPriority |
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.
TBool | iAllDataSentToSink | [protected] |
Indicates that all data has been sent to the sink.
TTimeIntervalMicroSeconds | iCachedSourceDuration | [protected] |
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.
TCodecProcessResult | iCodecProcessResult | [protected] |
Result of processing the codec.
CCompleteCallback * | iCompleteCallback | [protected] |
Pointer to internal callback completion class
TUint | iCurrentSinkFrameNumber | [protected] |
The sink's position in terms of frames or some other time fixed parameter.
TUint | iCurrentSourceFrameNumber | [protected] |
The source's position in terms of frames or some other time fixed parameter.
TUint | iDataPathCompletedErrorCode | [protected] |
Datapath completed because of an error; usually KErrNone.
TBool | iDataPathCreated | [protected] |
Set to ETrue when the data path has a source and a sink and can send data from the source to the sink.
MDataSink * | iDataSink | [protected] |
The sink of data for which the CMMFDataPath is a MDataSource for
MDataSource * | iDataSource | [protected] |
The source of data to which the CMMFDataPath is a MDataSink for.
TBool | iNoMoreSourceData | [protected] |
Indicates that all data has been obtained from the source (ETrue if there is no more source data).
TBool | iObtainingAsyncSinkBuffer | [protected] |
Indicates asynchrous buffers from AudioOutput.
TBool | iObtainingAsyncSourceBuffer | [protected] |
Indicates asynchrous buffers from AudioInput.
TTimeIntervalMicroSeconds | iPlayWindowEndPosition | [protected] |
End position of the play window.
TTimeIntervalMicroSeconds | iPlayWindowStartPosition | [protected] |
Start position of the play window.
TInt | iReferenceAudioSamplesPlayed | [protected] |
Holds the number of samples played on audio output at a point where we want to reference play duration from.
TInt | iReferenceAudioSamplesRecorded | [protected] |
Holds the number of samples recorded from audio input at a point where we want to reference record duration from.
CMMFBuffer * | iSinkBuffer | [protected] |
This is set to point to whichever sink buffer is in use.
TBool | iSinkBufferWithSink | [protected] |
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.
TBool | iSinkCanReceive | [protected] |
Set to true when the sink is able to accept data. EFalse otherwise.
TBool | iSnkBufRef | [protected] |
ETrue if sink buffer is reference to object owned by someone else
CMMFBuffer * | iSourceBuffer | [protected] |
This is the pointer to whichever source buffer is in use
TBool | iSourceBufferWithSource | [protected] |
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.
TFourCC | iSourceFourCC | [protected] |
The source's data type. Same as the codec output data type.
TBool | iSrcBufRef | [protected] |
ETrue if the source buffer is reference to object owned by someone else.
TTimeIntervalMicroSeconds | iStartPosition | [protected] |
The position audio will start playing from. When stopping, this is set to iPlayWindowStartPosition. When pausing, this is set to the current position.
TTransferState | iTransferState | [protected] |
Current transfer state.
See also: TTransferState
TBool | iUseSuppliedCodecUid | [protected] |
Set to true if data path has to use a supplied codec in its construction.
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.
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.
CMMFDataPath | ( | TMediaId | aMediaId, |
MAsyncEventHandler & | aEventHandler | ||
) | [protected, inline] |
IMPORT_C void | AddDataSinkL | ( | MDataSink * | aSink | ) | [virtual] |
Adds a data sink to the datapath and, if the source already exists, tries to establish a connection between the source and sink.
Parameter | Description |
---|---|
aSink | The data sink to add to the data path. |
IMPORT_C void | AddDataSourceL | ( | MDataSource * | aSource | ) | [virtual] |
Adds a data source to the datapath and, if the sink already exists, tries to establish a connection between the source and sink.
Parameter | Description |
---|---|
aSource | The data source to add to the data path. |
IMPORT_C void | BufferEmptiedL | ( | CMMFBuffer * | aBuffer | ) | [virtual] |
Indicates the data sink has emptied the buffer.
Called by the CMMFDataPath's MDataSink when it has emptied the buffer
Parameter | Description |
---|---|
aBuffer | The emptied buffer. |
IMPORT_C void | BufferFilledL | ( | CMMFBuffer * | aBuffer | ) | [virtual] |
Indicates the data source has filled the specified buffer.
Called by the CMMFDataPath's MDataSource when it has filled the buffer.
Parameter | Description |
---|---|
aBuffer | A pointer to the filled buffer. |
TTimeIntervalMicroSeconds | CalculateAudioInputPosition | ( | ) | const [protected] |
TTimeIntervalMicroSeconds | CalculateAudioOutputPosition | ( | ) | const [protected] |
IMPORT_C TBool | CanCreateSinkBuffer | ( | ) | [virtual] |
Tests whether the data path can create a sink buffer.
The default implementation returns false.
Returns: ETrue if the data path can create a sink buffer. EFalse if the data path cannot create a sink buffer.
IMPORT_C TBool | CanCreateSourceBuffer | ( | ) | [virtual] |
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.
Returns: ETrue if the data path can create a source buffer. EFalse if the data path cannot create a source buffer.
IMPORT_C void | ClearPlayWindowL | ( | ) | [virtual] |
Sets the play window to the full length of clip.
IMPORT_C void | ConstructL | ( | TUid | aCodecUid = KNullUid | ) | [protected] |
Takes UID of codec on construction, and if not an NULL codec sets the datapath up for codec instantiation.
Parameter | Description |
---|---|
aCodecUid | The UID of the codec. |
IMPORT_C void | ConstructSinkL | ( | const TDesC8 & | aInitData | ) | [protected, virtual] |
Constructs a sink.
Overridable constuction specific to this datasource.
The default implementation leaves with KErrNotSupported.
Parameter | Description |
---|---|
aInitData | The initialisation data. |
IMPORT_C void | ConstructSourceL | ( | const TDesC8 & | aInitData | ) | [protected, virtual] |
Constructs a source.
The default implementation leaves with KErrNotSupported.
Parameter | Description |
---|---|
aInitData | The initialisation data. |
IMPORT_C CMMFBuffer * | CreateSinkBufferL | ( | TMediaId | aMediaId | ) | [virtual] |
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.
Parameter | Description |
---|---|
aMediaId | An optional mediaID parameter when there are multiple buffers arriving of different media types. |
Returns: Returns NULL in this instance as datapath can't create sink buffers
IMPORT_C CMMFBuffer * | CreateSinkBufferL | ( | TMediaId | aMediaId, |
TBool & | aReference | |||
) | [virtual] |
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.
Parameter | Description |
---|---|
aMediaId | An optional mediaID parameter when there are multiple buffers arriving for different media types. |
aReference | A boolean indicating buffer ownership. |
Returns: Returns NULL in this instance as datapath can't create sink buffers.
IMPORT_C CMMFBuffer * | CreateSourceBufferL | ( | TMediaId | aMediaId | ) | [virtual] |
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.
Parameter | Description |
---|---|
aMediaId | An optional mediaID parameter when there are multiple buffers arriving of different media types. |
Returns: A pointer to a newly created buffer. Returns NULL in this instance as datapath can't create source buffers
IMPORT_C CMMFBuffer * | CreateSourceBufferL | ( | TMediaId | aMediaId, |
TBool & | aReference | |||
) | [virtual] |
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.
Parameter | Description |
---|---|
aMediaId | An optional mediaID parameter when there are multiple buffers arriving of different media types. |
aReference | A boolean indicating buffer ownership. ETrue if the MDataSource owns the buffer, EFalse if the caller owns the buffer. |
Returns: A pointer to a newly created buffer. Returns NULL in this instance as datapath can't create source buffers.
IMPORT_C void | DoCancel | ( | ) | [virtual] |
Reimplemented from CActive::DoCancel()
Cancels the clip.
The default implementation is empty.
Passes error handling and general messages up to clients.
Parameter | Description |
---|---|
aEventType | Category code for the event. Category codes can be used as unique identifers. |
aErrorCode | Standard error code. |
Returns: The event code sent to client.
IMPORT_C void | EmptyBufferL | ( | CMMFBuffer * | aBuffer, |
MDataSource * | aSupplier, | |||
TMediaId | aMediaId | |||
) | [virtual] |
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.
Parameter | Description |
---|---|
aBuffer | The buffer to empty. |
aSupplier | The MDataSource supplying this buffer. |
aMediaId | An optional mediaID parameter when there are multiple buffers arriving of different media types. |
IMPORT_C void | EndOfData | ( | ) | [protected, virtual] |
Forces and end of data state on the datapath
IMPORT_C void | FillBufferL | ( | CMMFBuffer * | aBuffer, |
MDataSink * | aConsumer, | |||
TMediaId | aMediaId | |||
) | [virtual] |
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.
Parameter | Description |
---|---|
aBuffer | The buffer to fill. |
aConsumer | The MDataSink supplying this buffer. |
aMediaId | An optional mediaID parameter when there are multiple buffers arriving of different media types |
IMPORT_C CMMFDataPath * | NewL | ( | MAsyncEventHandler & | aEventHandler | ) | [static] |
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.
Parameter | Description |
---|---|
aEventHandler | Installs an event handler to provide message passing between clients and sources/sinks. |
Returns: Newly constructed data path object.
IMPORT_C CMMFDataPath * | NewL | ( | TMediaId | aMediaId, |
MAsyncEventHandler & | aEventHandler | |||
) | [static] |
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.
Parameter | Description |
---|---|
aMediaId | Optional media ID parameter when there are multiple media types. |
aEventHandler | Installs an event handler to provide message passing between clients and sources/sinks. |
Returns: A newly constructed data path object.
IMPORT_C CMMFDataPath * | NewL | ( | TUid | aCodecUid, |
MAsyncEventHandler & | aEventHandler | |||
) | [static] |
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
Parameter | Description |
---|---|
aCodecUid | Optional mediaID parameter when there are multiple media types |
aEventHandler | Installs an event handler to provide message passing between clients and sources/sinks. |
Returns: A newly constructed data path object.
IMPORT_C CMMFDataPath * | NewL | ( | TUid | aCodecUid, |
TMediaId | aMediaId, | |||
MAsyncEventHandler & | aEventHandler | |||
) | [static] |
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.
Parameter | Description |
---|---|
aCodecUid | The codec UID. |
aMediaId | Optional mediaID parameter when there are multiple media types. |
aEventHandler | Installs an event handler to provide message passing between clients and sources/sinks. |
Returns: A newly constructed data path object.
IMPORT_C void | Pause | ( | ) | [virtual] |
Pauses playing.
Sends KMMFErrorCategoryDataPathGeneralError to the client if an error occurs.
IMPORT_C void | PlayL | ( | ) | [virtual] |
Starts an active scheduler 'play' loop.
Can only play from the primed state.
IMPORT_C TTimeIntervalMicroSeconds | Position | ( | ) | const [virtual] |
Gets the data path position.
Returns: The data path position.
IMPORT_C void | PrimeL | ( | ) | [virtual] |
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().
IMPORT_C void | ResetL | ( | ) | [virtual] |
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.
Reimplemented from CActive::RunError(TInt)
Handles errors coming from attached sources and passes them to the clients.
Parameter | Description |
---|---|
aError | Standard error code (KErrNone = No Error). |
Returns: The event code returned to the data path. KErrNone if end of file is encountered.
IMPORT_C void | RunL | ( | ) | [virtual] |
Reimplemented from CActive::RunL()
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.
IMPORT_C void | SetPlayWindowL | ( | const TTimeIntervalMicroSeconds & | aStart, |
const TTimeIntervalMicroSeconds & | aEnd | |||
) | [virtual] |
Sets the play window absolutely (i.e. the parameters are relative to the start of the entire clip).
Parameter | Description |
---|---|
aStart | The offset from the start of the Clip |
aEnd | The offset from the end of the clip (if this is less than aStart, then the two will be inverted). |
IMPORT_C void | SetPositionL | ( | const TTimeIntervalMicroSeconds & | aPosition | ) | [virtual] |
Sets the data path position.
Parameter | Description |
---|---|
aPosition | The data path position. |