ILMMpgDmx Interface

Data types:

typedef enum DemuxFlagConstants
{
   DemuxFlag_IgnoreCorruptedPackets = 1, /* Ignore corrupted packets */

}
DemuxFlagConstants;

Interface Properties:

Type

Property name

Description

ILMMpgDmxCallback *

CallbackObj

The demultiplexer will call this user callback with event notifications and with the user data packets.

VARIANT_BOOL

CallInSame
Thread

 Enables or disables the calling of the ILMMpgDmxCallback notifications in the same thread that set the CallbackObj property. Possible values are:

 

 

Value

Meaning

 

 

VARIANT_TRUE

The ILMMpgDmxCallback method will be called in the same thread that set CallbackObj. This option is safer, but it will reduce the performance. This is the default.

 

 

VARIANT_FALSE

The ILMMpgDmxCallback method might be called in other threads. This is recommended because of the reduced overhead. Use this option whenever possible.

VARIANT_BOOL

IsStreaming

(Read-only) This property tells you whether you are streaming.

 

 

Value

Meaning

 

 

VARIANT_TRUE

You are streaming data.

 

 

VARIANT_FALSE

You are playing a file

long

Flags

This property is a collection of flags that will influence the demuxer-s behavior. The following flags are defined:

 

 

Value

Meaning

 

 

DemuxFlag_Ignore
CorruptedPackets

[0001] If this flag is set, the corrupted packets are discarded. If this flag is not set, the corrupted packets are sent downstream to the decoders. The default value is ON (the corrupted packets are discarded).

double

StreamPosition

(Read-only) This property tells you the current stream position, in seconds. The current stream position is position of the video and audio playing on the screen (if the demux is in a play graph).

This property is designed to work together with the ConvertPTSToStreamPosition method. See the ConvertPTSToStreamPosition method for more details on how to use this method.

Interface Methods:

HRESULT GetKlvParser (long streamPID, ILMKlvParser **pVal);

Parameters

streamPID

The stream PID for which you want to receive the KLV parser interface.

pVal

A pointer to pointer to an ILMKlvParser interface. This pointer will be updated by the method if successful.

Description

Use this method to facilitate parsing of KLV data conforming to SMPTE 336M-2001. There might be more than one private data stream and you should use a different parser for each stream. You identify each stream by its PID (-Packet IDentifier-). The PID is usually the same as the streamPID passed to ILMMpgDmxCallback::DataAvailable, but you can pass any value as the streamPID.

The ILMKlvParser interface can be used to easily enumerate the KLV keys and for getting the KLV data. It will keep track of incomplete keys and will enumerate them when you get sufficient data.

Returns

S_OK if successful

E_POINTER if ppszFilename is NULL.

E_OUTOFMEMORY if there is not enough memory to create the interface.

 

HRESULT ConvertPTSToStreamPosition(double PTS, double *pStreamPosition);

Parameters

PTS

The PTS you are trying to convert.

pStreamPosition

A pointer to a double value. This pointer will be updated by the method if successful.

Description

Use this method to convert a PTS for the current mpeg stream into a stream position (in seconds). The PTS must have come from the current stream, otherwise the conversion will be incorrect. In other words, you cannot use a mpeg demux instance to convert PTS timestamps coming from a stream inside another MPEG demux.

This method it is intended to be used to find the correct display time for extra data samples received thru ILMMpgDmxCallback::DataAvailable as follows:
1) call ConvertPTSToStreamPosition(PTS, &PTSStreamPosition) to fill PTSStreamPosition with the desired stream position.
2) call get_StreamPosition(&currentStreamPosition) to find the current stream position. (The "get_" prefix was added as it is usually done in C++ programs)
3) Determine when to display the data:

    a) if PTSStreamPosition >= currentStreamPosition, then the data is early (the usual case) and you need to wait for PTSStreamPosition - currentStreamPosition seconds before displaying it.
    b) if PTSStreamPosition < currentStreamPosition, then the data is late and you should display it right away. This is usually an indication that the video and extra data streams are not multiplexed properly.

Returns

S_OK if successful

S_FALSE if it fails (in this case, *pCurrentPosition will be set to -1)