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

 

 

VARIANT_TRUE

 

 

VARIANT_FALSE

VARIANT_BOOL

IsStreaming

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

 

 

Value

 

 

VARIANT_TRUE

 

 

VARIANT_FALSE

long

Flags

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

 

 

Value

 

 

DemuxFlag_Ignore
CorruptedPackets

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.

double

CurrentStreamPTS

This property tells you the current stream position in PTS units. You can get or set this property. The current stream PTS is the current presentation timestamp that controls audio / video sample presentation.  This property is the presentation time stamp for the most recently delivered media sample.

NOTE: When setting this property it is possible to use negative values to 'backup' in the stream.  Ex: A value of -90000 will be interpreted as last sample time stamp - 90000, which would be 1 second behind the actual live stream time.  See   Introduction to the LEADTOOLS DVR Module for more information on presentation time stamps.

double

BaseStreamPTS

(Read only) This property represents the base stream position in PTS units. The base stream position is the position after a seek operation. This property is also time adjusted to account for discontinuities in media samples. 

double

FirstStreamPTS

(Read only) This property represents the first stream position in PTS units. is the timestamp for the oldest delivered sample in the circular buffer queue.  Any samples delivered prior to the base stream PTS have been overwritten.

double

LastStreamPTS

(Read only) This property represents the last stream position in PTS units. The last stream PTS is the timestamp of the most recently delivered sample in the circular buffer queue.

double

StartStreamPTS

(Read only) This property represents the start stream position in PTS units. The start stream PTS is presentation timestamp of the first sample delivered at the start of streaming.

double

DurationCheckInterval

Gets or sets the frequency (in seconds)with which the duration is updated.

long

StreamCount

Gets the number of streams described in the last program map.

long

StreamFlags[StreamPID]

This property is a collection of flags that will determine how the stream is handled by the demultiplexor. The following flags are defined:

 

 

Value

 

 

StreamFlag_HasSystem

 

 

StreamFlag_HasMPEG2

 

 

StreamFlag_HasH264

 

 

StreamFlag_HasMPEG4VisualObject

 

 

StreamFlag_HasMPEG4VisualObjectPlane

 

 

StreamFlag_HasMPEG4VisualObjectLayer

 

 

StreamFlag_HasMPEGAudio

 

 

StreamFlag_HasAC3Audio

 

 

StreamFlag_StartsWithMPEGAudio

 

 

StreamFlag_StartsWithAC3Audio

 

 

StreamFlag_StartsMPEG2Video

 

 

StreamFlag_StartsH264Video

 

 

StreamFlag_StartsMPEG4Video

 

 

StreamFlag_StartsMPEG1System

 

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)

 

HRESULT RefreshPosition(long Flags);

Parameters

Flags

The flags for which bits to update.

Description

Update the values of the position properties (CurrentStreamPTS, StartStreamPTS, FirstStreamPTS, LastStreamPTS)

This method it is intended to be used to update all PTS values
 

Returns

S_OK if successful

S_FALSE if it fails

 

HRESULT ConvertPTSToFrame(double PTS, double *pFrame);

Parameters

PTS

The PTS value to be converted.

pFrame

A pointer to a double variable that will hold the converted frame number result. This pointer will be updated by the method if successful.

Description

Convert a PTS value to a frame number.

Use this method to convert a PTS value for the current mpeg stream to a frame number. 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.

Returns

S_OK if successful

S_FALSE if it fails

 

HRESULT ConvertFrameToPTS(double Frame, double *pPTS);

Parameters

Frame

A double value containing the frame number to convert.

pPTS

A pointer to the double variable that will hold the converted PTS value result. This pointer will be updated by the method if successful.

Description

Convert a frame number value to a PTS value.

Use this method to convert a frame number for the current mpeg stream to a PTS value.

Returns

S_OK if successful

S_FALSE if it fails

 

HRESULT GetStreamInfo(long StreamIndex, long *pStreamPID, long *pStreamType, VARIANT *pStreamDescriptor);

Parameters

StreamIndex

A long value containing the stream index of the desired information.

pStreamID

A pointer to the long variable that will hold the stream Program identifier. The value pointed to will be updated by the method if successful.

pStreamType

A pointer to the long variable that will hold the stream type value (stream_type values can be found in Table 2-36 (page 63) of ISO/IEC 13818-1 spec). The value pointed to will be updated by the method if successful.

pStreamDescriptor

A pointer to a VARIANT type variable that will hold the stream descriptor block. The value pointed to will be updated by the method if successful.

Description

Gets information for a specific stream.

Use this method to get the stream's PID, type and descriptor.

Returns

S_OK if successful

S_FALSE if it fails