ILMMpgDmx Interface

Data Types:

DemuxFlagConstants

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

StreamFlagConstants

typedef enum StreamFlagConstants 
{ 
   StreamFlag_IsImportant = 0x1, /* This stream is important. The demux will not start streaming until samples from this stream are received */ 
} StreamFlagConstants; 

The demux will send the EC_LOADSTATUS (0x43) event to the DirectShow graph and set lParam1 to a LOADSTATUSConstant enum value. These notifications might be sent before the graph is built, providing an opportunity to get a pointer to the demux interface in order to set the demux callback. For more information about when these notifications are sent, refer to the LOADSTATUSConstant enum documentation.

LOADSTATUSConstant

typedef enum LOADSTATUSConstant 
{ 
   AM_LOADSTATUS_PROGRAM_PACKET_RECEIVED = 0x100, /* This notification is sent when the demux identifies the number and type of elementary streams present in the current program. */ 
   AM_LOADSTATUS_PROGRAM_COUNT_DETECTED = 0x102, /* This event is fired when the demux identifies the number of programs available in the MPEG2 stream */ 
   AM_LOADSTATUS_PROGRAM_INFO_DETECTED = 0x103, /* This event is fired when the demux extra information on the programs is available in the MPEG2 stream */ 
} LOADSTATUSConstant; 

FindSampleConstants

typedef enum FindSampleConstants 
{ 
   FindSample_NearestKeyFrame = 0,  /* Search for nearest key frame.  */ 
   FindSample_NextKeyFrame = 1,     /* Search for next key frame.     */ 
   FindSample_PreviousKeyFrame = 2, /* Search for previous key frame. */ 
} FindSampleConstants; 

ProgramInfoConstants

typedef enum ProgramInfoConstants 
{ 
   ProgramInfo_ProgramMapPID = 0, 
   ProgramInfo_Name	 = ( ProgramInfo_ProgramMapPID + 1 ), 
   ProgramInfo_StreamCount = ( ProgramInfo_Name + 1 ), 
   ProgramInfo_SummaryInfo = ( ProgramInfo_StreamCount + 1 ), 
   ProgramInfo_DetailedInfo = ( ProgramInfo_SummaryInfo + 1 ) 
} ProgramInfoConstants; 

Interface Properties:

Type Name Description
ILMMpgDmxCallback
CallbackObj The demultiplexer calls this user callback with event notifications and with the user data packets.
VARIANT_BOOL CallInSameThread Enables or disables the calling of the ILMMpgDmxCallback notifications in the same thread that set the CallbackObj property. The default value is VARIANT_TRUE. Possible values are:
    Value Meaning
    VARIANT_TRUE Call the notifications in the same thread that set the callback. This reduces the performance and requires the application to process messages, otherwise the callback will not get called. It is the default and is required for platforms that have problem with multithreading. VB 6.0 and dotnet applications should use this mode.
    VARIANT_FALSE Call the notifications in any thread of the process. Use this setting for best performance in platforms that can handle this. This is the recommended mode for C/C++ applications.
VARIANT_BOOL IsStreaming (Read-only) This property tells you whether you are streaming. Possible values are:
    Value Meaning
    VARIANT_TRUE You are streaming.
    VARIANT_FALSE You are playing a file.
long Flags This property is a collection of flags that influence the demuxer's behavior. The default value is DemuxFlag_IgnoreCorruptedPackets. The following flags are defined:
    Value Meaning
    DemuxFlag_IgnoreCorruptedPackets Ignore corrupted packets. Use this property to minimize the amount of corrupted frames being displayed. When this option is turned on, the video is cleaner but can freeze in streaming situations while the demux is waiting for a good frame. When this option is turned off, the video is smoother, but has more corrupted frames when the stream has lost packets and there is greater instability (more likely to crash). The default is on (the corrupted packets are not displayed).
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.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double StartStreamOffset (Read only) This property represents the start of the stream in bytes. It can change if the source filter uses circular buffer and the playback is stopped and restarted.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double BaseStreamOffset (Read only) This property represents the base stream offset in bytes. The base stream position is the position of the last seek operation.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double CurrentStreamOffset This property tells you the current offset in bytes for the main elementary stream. This property is the file offset for the most recently delivered media sample. You can get or set this property. Setting this property is equivalent to a seeking operation.

NOTE 1: When setting this property it is possible to use negative values to indicate a position relative to the live stream position.  Ex: A value of -1024 will be interpreted as 1024 bytes behind the live stream.

NOTE 2: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double FirstStreamOffset (Read only) This property represents the offset of the first sample present in the circular buffer queue.  Any samples before this position have been overwritten.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double LastStreamOffset (Read only) This property represents the offset of the last byte in the stream. It also represents the length of the stream.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double CurrentStreamPTS This property tells you the current stream position in PTS units for the main elementary stream. 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 1: When setting this property it is possible to use negative values to specify position relative to the LIVE stream.  Ex: A value of -90,000 will be interpreted as last sample time stamp - 90,000, which would be 1 second behind the actual live stream time.  See   Introduction to the LEADTOOLS MPEG-2 Transport Module for more information on presentation time stamps.

NOTE 2: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

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.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

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

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double LastStreamPTS (Read only) This property represents the last stream position in PTS units. The last stream PTS is the timestamp of the last sample available in the circular buffer queue.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

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.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double BaseStreamTime (Read only) This property represents the base stream position in seconds. The base stream position is the position in seconds of the last seek operation.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double CurrentStreamTime This property tells you the current stream position in seconds for the main elementary stream. This property is the time stamp for the most recently delivered media sample. You can get or set this property. Setting this property is equivalent to a seeking operation.

NOTE 1: When setting this property it is possible to use negative values to indicate a position relative to the live stream position.  For example, a value of -0.5 will be interpreted as 0.5 seconds behind the live stream (in other words, -0.5 is equivalent to a 0.5 sec latency). The demux will maintain this latency during the playback. A higher latency will reduce the playback jitter caused by compressed packets not arriving slightly late due to network delays. For fixed bitrate H264 streams, this latency should be higher than the ILMH264Encoder.MaxFrameDuration / 1000 (because the demux latency is calculated in seconds, while the H264 Encoder MaxFrameDuration is calculated in milliseconds). See Configuring the H.264 Encoder for Streaming for more information.

NOTE 2: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double FirstStreamTime (Read only) This property represents the first stream position in seconds. It is the timestamp for the first sample present in the circular buffer queue. Any samples before this position have been overwritten.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double LastStreamTime (Read only) This property represents the last stream position in seconds. It is the time of the last sample available in the circular buffer queue.

NOTE: This position is updated only when the RefreshPosition method is called. If you do not call RefreshPosition, this property will not change its value.

double DurationCheckInterval Gets or sets the frequency (in seconds) with which the duration is updated. This property determines how often the internal first and last stream properties are updated. When a circular buffer is used, the internal FirstStreamXXX properties are updated after DurationCheckInterval seconds. Then the internal LastStreamXXX properties are updated DurationCheckInterval seconds later. After DurationCheckInterval seconds the first stream properties are recalculated and so on. The default value is 5 seconds.

See Programming With MPEG2 Demux for more information.

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. This property takes StreamPID as the index parameter. You can use the GetStreamInfo method to enumerate the streams and obtain the possible values for StreamPID. This is a write-only property and it is useful only while the stream is rendered (i.e., while you set the SourceFile property of the Playback or Convert object). It is pointless to call this property after the SourceFile has returned. Use this property to reduce the amount of time to start playback if you are not interested in data containing from some streams. By default, StreamFlag_IsImportant is considered to be on, so the demux will wait until data from this stream arrives before starting the playback. This could cause undesired delays. If you wish to reduce the amount of time it takes to the smallest possible value, you can enumerate all the streams present in the MPEG2 stream and set the StreamFlags for all streams except the video stream to 0. But if you do this, you run the risk that some of the streams that you deemed as not important might not be detected. This is designed to work together with the (EC_LOADSTATUS, AM_LOADSTATUS_PROGRAM_PACKET_RECEIVED) event notification. See Programming With MPEG2 Demux for more information.

The following flags are defined:

    Value Meaning
    StreamFlag_IsImportant If set, this flag is considered important and the demux will wait until it receives some data for it before starting playback. If the data does not come within a certain amount of time (picked by the demux), the stream might still be dropped.

If not set, the demux will not wait for data from this stream. A pin will be created only if data for this stream is received before all the important streams are identified. So you might still get a pin for this stream, but it is less likely than if the stream was deemed important.

VARIANT_BOOL AutoLive Indicates whether the demux should automatically show the live stream. If this property is set to VARIANT_TRUE (AutoLive is enabled), then the demux will automatically jump ahead to the live stream position when it detects it has fallen behind live by more than AutoLiveTolerance seconds. You should enable this feature only if you are streaming. Note that if you enable this property, it will override any seeking commands. If you wish to seek to a position other than live, you should set this property to VARIANT_FALSE and then perform the seeking operation. The default value is VARIANT_FALSE (AutoLive is disabled). The check of the latency to live is made whenever a new LastStream position is detected. This check occurs every 2 * DurationCheckInterval seconds. The following values are defined:
    Value Meaning
    VARIANT_TRUE The demux will always try to keep up with the live stream and will automatically jump ahead if it falls behind too much. The playback might not be smooth if the network packets do not come at regular intervals.
    VARIANT_FALSE The demux will play at the normal rate and will allow data to be buffered more if necessary in order to achieve a smooth playback.
double AutoLiveTolerance When AutoLive is set to VARIANT_TRUE, this property indicates by how many seconds playback is allowed to drift back (maximum latency) compared to the live stream. If AutoLive is VARIANT_FALSE, this property is ignored. It is not recommended to set this property to a value that is very low, because playback can become too jerky due to constant playback adjustments.

The default value is 0.5.

For more information on how to control latency, refer to Reducing Playback Latency

double MinBufferingAmount When AutoLive is set to VARIANT_TRUE, this property indicates the minimum amount of buffering (in seconds) during playback. This also represents the minimum latency. The demux will automatically simulate a pausing of the graph when the amount of data buffered at the demux level falls below this amount. This property is used to achieve smooth playback. When too little data is buffered, the video playback can be jerky.

The default value is 0.1.

For more information on how to control latency, refer to Reducing Playback Latency

 long ProgramCount (Read-only) Gets the number of programs. A program can encapsulate one or more elementary streams (audio, video, KLV). Most files have only one program. But some files (for example, those captured from HDTV cards) can have multiple programs, each program corresponding to a particular TV channel.

If this property is > 1, then the file has more than one program and you can select which program to play using the CurrentProgram property. Also, the demux will show a property page when there are more than one program. You can also select which program to play/convert using the property page.

If this property is 1, the CurrentProgram property is ignored and there is no property page.

During the initial stage of building the graph or loading the file, this property is available after the EVENTTYPE_PROGRAMCOUNT notification is received. If you are using the LEADTOOLS multimedia toolkit to build the graph, you can read it when you receive the EC_LOADSTATUS / ltmmEC_LOADSTATUS with the AM_LOADSTATUS_PROGRAM_COUNT_DETECTED / ltmmAM_LOADSTATUS_PROGRAM_COUNT_DETECTED notification.

For optimal performance, change the CurrentProgram property while processing the events mentioned above to avoid reconnecting the output pins and rebuilding the graph.

Use the GetProgramInfoAsLong and GetProgramInfoAsString methods  to get more information about each program.

 long CurrentProgram Indicates which program should be selected. The value is 0-based, which means allowed values are 0 to ProgramCount - 1. If this property changes, the number of output pins can change and the graph may need to be rebuilt.

It is best to stop the graph before changing this property and rebuild the graph. If the graph is running, the graph will be automatically stopped.

If any output pins are connected when this property is changed, an EVENTTYPE_REBUILDNEEDED notification is sent.

By default, this property is set to 0, which means the demux will play the first available program.               

FileTypeConstants  FileType (Read-only) Gets the type of file. This is an information-only property allowing you to find out more information about the file. Use it to find out whether the file is a MPEG-2 Transport, MPEG-2 Program or another file format (usually raw elementary stream). See the FileTypeConstants enumeration for more details.               
double  VideoShift The amount of time (in seconds) by which the video stream should be shifted compared to the other streams. Use this property to fix audio/video synchronization problems. This property can be changed during playback. If you see that the audio and video do not match, increase or decrease this value until audio and video becomes synchronized.

Note:  Use this only with bad streams that are not synchronized properly.

The default value for this property is 0.

InputConnectionStateConstants InputConnectionState (Read-only) Determines the state of the input connection.

Interface Methods:

HRESULT GetKlvSubkeyParser(VARIANT Key, ILMKlvParser **pVal);

Parameters

Key A variant value that holds the group's key.
pVal

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

Description

Get a ILMKlvParser interface for a certain group, Use this method to facilitate parsing of KLV data conforming to SMPTE 336M-2001.

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

Returns

S_OK if successful, < 0 if an error occurred.

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 keeps track of incomplete keys and enumerates 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 gets 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 through ILMMpgDmxCallback::DataAvailable as follows:

  1. Call ConvertPTSToStreamPosition(PTS, &PTSStreamPosition) to fill PTSStreamPosition with the desired stream position.
  2. Call get_StreamPosition(¤tStreamPosition) to find the current stream position. (Add the "get_" prefix as it is usually done in C++ programs)
  3. Determine when to display the data:
    • if PTSStreamPosition >= currentStreamPosition, then the data is early (the usual case) and you need to wait for PTSStreamPosition - currentStreamPosition seconds before displaying it.
    • 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.

You can also use this method in a conversion graph to convert a PTS received through ILMMpgDmxCallback::DataAvailable to a stream position for the ILMMpg2MxT::WritePrivateData or ILMMpg2MxT::WriteKlvData methods. In this case, you would do something like this:

/* This code assumes m_pMpgMux and m_pMpgDmx are declared and initialized somewhere else */ 
 
ILMMpgDmx *m_pMpgDmx; 
ILMMpg2MxT *m_pMpgMux; 
 
HRESULT STDMETHODCALLTYPE CMPEG2DemuxCallback::DataAvailable 
(  
   /* [in] */ VARIANT *pData, 
   /* [in] */ long lDataSize, 
   /* [in] */ FileTypeConstants fileType, 
   /* [in] */ long streamPID, 
   /* [in] */ long streamType, 
   /* [in] */ PTSTypeConstants PTSType, 
   /* [in] */ double PTS, 
   /* [in] */ long flags 
) 
{ 
   if(flags & DataFlag_EndOfStream) 
      return m_pMpgMux->ClosePrivateData(); 
 
   /* convert the PTS to StreamPosition. This ensures video and KLV data is synchronized after conversion */ 
   double streamPosition; 
   m_pMpgDmx->ConvertPTSToStreamPosition(PTS, &streamPosition); 
 
   /* Write the KLV data without modifying it */ 
   UINT uMuxFlags = Mpg2MxT_WriteFlag_PTSValid | Mpg2MxT_WriteFlag_PTSInSeconds | ((flags & DataFlag_IsSyncPoint) ? Mpg2MxT_WriteFlag_SyncPoint : 0); 
   return m_pMpgMux->WritePrivateData(uMuxFlags, streamPosition, *pData, lDataSize); 
} 

Returns

S_OK if successful

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

HRESULT ConvertStreamPositionToOffset(double streamPosition, double *pOffset);

Parameters

streamPosition

The stream position you are trying to convert (in seconds from the beginning of the stream). This value must be >= 0.

pOffset

A pointer to a double value. This pointer gets updated with the file offset if  the method is successful.

Description

Use this method to find the file offset of the start sample corresponding to a stream position (in seconds). The stream position must be from the current stream; otherwise, the conversion will be incorrect. In other words, you cannot use a mpeg demux instance to convert a stream position coming from a stream inside another MPEG demux.

This method is intended to be used in conjunction with FindSample to find the offset of a key frame. For example, to find the first key frame following 0.7sec point, you would call FindNextKeyFrame(pDemux, 0.7), where FindNextKeyFrame is like this:

double FindNextKeyFrame(ILMMpgDmx *pDemux, double startPosition) 
{ 
   double startOffset, keyFrameOffset; 
   // find the offset corresponding to the start position 
   pDemux->ConvertStreamPositionToOffset(startPosition, offset); 
   // find the offset of the key frame following startOffset + 1 
   // I added 1 to startOffset just in case there is a key frame at 0.7s 
   // If I do not add 1 and there is a key frame at 0.7s, FindNextKeyFrame would return 0.7 
   if(pDemux->FindSample(startOffset + 1, FindSample_NextKeyFrame, &keyFrameOffset) == S_OK) 
   { 
      // find the stream position corresponding to the key frame offset 
      pDemux->ConvertOffsetToStreamPosition(keyFrameOffset, &keyFramePosition); 
      return keyFramePosition; 
   } 
   else 
   { 
      return -1; // there is no key frame following this point 
   } 
} 

Returns

S_OK if successful

<> S_OK if the function fails (in this case pOffset will be left unchanged).

HRESULT ConvertOffsetToStreamPosition(double offset, double *pStreamPosition);

Parameters

offset

The file offset (this value must be >= 0).

pStreamPosition

A pointer to a double value. This pointer gets updated with the stream position (in seconds) if the method is successful.

Description

Use this method to find the stream position (in seconds) of the first sample following a file offset. The stream position 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 a stream position coming from a stream inside another MPEG demux.

This method is intended to be used in conjunction with FindSample to find the stream position of a key frame. See the ConvertStreamPositionToOffset method for more information and for an example.

Returns

S_OK if successful

<> S_OK if the function fails (in this case pStreamPosition will be left unchanged).

HRESULT RefreshPosition(long Flags);

Parameters

Flags

(Reserved for future) The flags for which bits to update. Pass 0.

Description

Updates the values of the position properties  (BaseStreamXXX, CurrentStreamXXX, StartStreamXXX, FirstStreamXXX, LastStreamXXX), where XXX indicates be PTS, Time and Offset version of the properties.

This method is intended to be used to update all PTS, Time and Offset properties.

Important note: You MUST call this method, otherwise properties like CurrentStreamPTS, CurrentStreamTime and CurrentStreamOffset never get updated.

Here is the complete list of properties updated by this method:

BaseStreamPTS, CurrentStreamPTS, StartStreamPTS, FirstStreamPTS, LastStreamPTS

BaseStreamTime, CurrentStreamTime, StartStreamTime, FirstStreamTime, LastStreamTime

BaseStreamOffset, CurrentStreamOffset, StartStreamOffset, FirstStreamOffset, LastStreamOffset
 

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 gets updated by the method if successful.

Description

Converts 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 holds the converted PTS value result. This pointer gets updated by the method if successful.

Description

Converts 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. This value should be between 0 and StreamCount - 1.
pStreamID A pointer to the long variable that will hold the stream Program identifier. The value pointed to gets 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-29 (page 66) of ISO/IEC 13818-1 : 2000 spec). The value pointed to gets updated by the method if successful.

A few common stream types are listed in the following table for convenience:

  Value Meaning
  0x02 MPEG-2 Video
  0x03 MPEG-2 Audio
  0x06 PES packets containing private data (usually KLV stream)
  0x0F AAC Audio
  0x10 MPEG-4 Video
  0x1B H.264 Video
  0x81 User data (can be AC3/LPCM audio)
pStreamDescriptor

A pointer to the variant variable that will hold the stream's descriptor data. The descriptor data is contained in the program map table (Section 2.4.4.8 of ISO/IEC 13818-1 : 2000 spec). It refers to the descriptor data associated to the stream immediately following the ES_info_length in the spec mentioned above.

The value pointed to gets 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. Use the StreamCount property to determine the number of available elementary streams in the MPEG-2 stream.

It is best to call this method after receiving the EC_LOADSTATUS notification event with the AM_LOADSTATUS_PROGRAM_PACKET_RECEIVED parameter. See the Programming with the MPEG-2 Transport Demultiplexer topic for more details.

Returns

S_OK if successful

S_FALSE if it fails

HRESULT FindSample(double startOffset, FindSampleConstants searchFlags, double *pKeyFrameOffset);

Parameters

startOffset

A double value containing offset from where to start searching.

searchFlags

A FindSampleConstants flags parameter indicating which sample to sample to search for.

pKeyFrameOffset

A pointer to the double variable that will receive the offset where the sample starts.

Description

Finds a particular video sample relative to a starting offset. The method is used to search for the nearest, previous or the following key frame relative to a starting offset.

The method will fail if there is no video stream.

Use the ConvertStreamPositionToOffset and ConvertOffsetToStreamPosition methods to convert between the file offset and the stream position (in seconds). Refer to ConvertStreamPositionToOffset for an example of how to use this method.

Returns

S_OK if successful

S_FALSE if there is no video stream or the video sample could not be found

VFW_E_NO_ALLOCATOR: the input pin is not connected

E_OUTOFMEMORY: out of memory

HRESULT GetProgramInfoAsLong(long nProgramIndex, ProgramInfoConstants nAttributeIndex, long* pVal);

Parameters

nProgramIndex

The index of the program whose information should be retrieved. 0-based, allowed values = 0 to ProgramCount - 1

nAttributeIndex

A ProgramInfoConstants index parameter indicating attribute to retrieve.

pVal

A pointer to the integer variable that will receive the value.

Description

Gets more information about a particular program. Note that not all ProgramInfoConstants values are supported. See the ProgramInfoConstants enumeration to see which attributes can have integer values.

You can use the ProgramCount property to find out how many programs are in the file. This determines the allowable values for the nProgramIndex parameter.

There might be updated information about the program info when the EVENTTYPE_PROGRAMINFO or AM_LOADSTATUS_PROGRAM_INFO_DETECTED notification is received.

Returns

S_OK if successful

DISP_E_BADINDEX if nProgramIndex is invalid.

E_INVALIDARG: nAttributeIndex is invalid or does not point to an attribute that has a corresponding long value.

HRESULT GetProgramInfoAsString(long nProgramIndex, ProgramInfoConstants nAttributeIndex, BSTR* pVal);

Parameters

nProgramIndex

The index of the program whose information should be retrieved. 0-based, allowed values = 0 to ProgramCount - 1

nAttributeIndex

A ProgramInfoConstants index parameter indicating attribute to retrieve.

pVal

A pointer to a BSTR variable that will receive the value. If successful, the string returned should be freed using the SysFreeString windows function.

Description

Gets more information about a particular program. Note that not all ProgramInfoConstants values might supported. See the ProgramInfoConstants enumeration to see which attributes can have string values.

You can use the ProgramCount property to find out how many programs are in the file. This determines the allowable values for the nProgramIndex parameter.

There might be updated information about the program info when the EVENTTYPE_PROGRAMINFO or AM_LOADSTATUS_PROGRAM_INFO_DETECTED notification is received. For example, detailed information like the channel name is received less often than the information about the number of programs. So when you first get the summary of detailed info, the program name might be generic if the demux has not yet encountered the extra information. Later on, when more information is received, the EVENTTYPE_PROGRAMINFO or AM_LOADSTATUS_PROGRAM_INFO_DETECTED notifications are sent so you know that there might be updated information. If you created menu items in your application indicating which programs are available, you might want to call this method again and update the information you displayed in the menu or status areas.

Returns

S_OK if successful

DISP_E_BADINDEX if nProgramIndex is invalid.

E_INVALIDARG: nAttributeIndex is invalid or does not point to an attribute that has a corresponding long value.

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Filters C API Help