public class MFSourceReader : ComObject
Implemented by the Microsoft Media Foundation source reader object.
MFSourceReader(IntPtr ptr)
Initializes a new instance of the MFSourceReader class.
public void MFSourceReader(IntPtr ptr)
Parameters
ptr
IntPtrThe native pointer of the COM object.
MFSourceReader(String url)
Initializes a new instance of the MFSourceReader class based on a given url.
public void MFSourceReader(String url)
Parameters
url
StringThe URL.
Flush(Int32 streamIndex)
Flushes one or more streams.
FlushNative(Int32 streamIndex)
Flushes one or more streams.
public Int32 FlushNative(Int32 streamIndex)
Parameters
streamIndex
Int32The stream to flush. For more information, see .
Returns
HRESULT
GetCurrentMediaType(Int32 streamIndex)
Gets the current media type for a stream.
GetCurrentMediaTypeNative(Int32 streamIndex, MFMediaType& mediaType)
Gets the current media type for a stream.
public Int32 GetCurrentMediaTypeNative(Int32 streamIndex, MFMediaType& mediaType)
Parameters
streamIndex
Int32Specifies which stream to query. For more information, see .
mediaType
MFMediaType&Receives the MFMediaType. The caller must dispose the MFMediaType.
Returns
HRESULT
GetNativeMediaType(Int32 streamIndex, Int32 mediatypeIndex)
Gets a format that is supported natively by the media source.
public MFMediaType GetNativeMediaType(Int32 streamIndex, Int32 mediatypeIndex)
Parameters
streamIndex
Int32Specifies which stream to query. For more information, see .
mediatypeIndex
Int32The zero-based index of the media type to retrieve.
Returns
The MFMediaType. The caller must dispose the MFMediaType.
GetNativeMediaTypeNative(Int32 streamIndex, Int32 mediatypeIndex, MFMediaType& mediaType)
Gets a format that is supported natively by the media source.
public Int32 GetNativeMediaTypeNative(Int32 streamIndex, Int32 mediatypeIndex, MFMediaType& mediaType)
Parameters
streamIndex
Int32Specifies which stream to query. For more information, see .
mediatypeIndex
Int32The zero-based index of the media type to retrieve.
mediaType
MFMediaType&Receives the MFMediaType. The caller must dispose the object.
Returns
HRESULT
GetPresentationAttribute(Int32 streamIndex, Guid guidAttribute)
Gets an attribute from the underlying media source.
public PropertyVariant GetPresentationAttribute(Int32 streamIndex, Guid guidAttribute)
Parameters
streamIndex
Int32The stream or object to query. For more information, see .
guidAttribute
GuidA Guid that identifies the attribute to retrieve. For more information, see .
Returns
A PropertyVariant that receives the value of the attribute. Call the Dispose method to free the PropertyVariant.
GetPresentationAttributeNative(Int32 streamIndex, Guid guidAttribute, PropertyVariant& variant)
Gets an attribute from the underlying media source.
public Int32 GetPresentationAttributeNative(Int32 streamIndex, Guid guidAttribute, PropertyVariant& variant)
Parameters
streamIndex
Int32The stream or object to query. For more information, see .
guidAttribute
GuidA Guid that identifies the attribute to retrieve. For more information, see .
variant
PropertyVariant&Receives a PropertyVariant that receives the value of the attribute. Call the Dispose method to free the PropertyVariant.
Returns
HRESULT
GetServiceForStream(Int32 streamIndex, Guid guidService, Guid riid)
Queries the underlying media source or decoder for an interface.
public IntPtr GetServiceForStream(Int32 streamIndex, Guid guidService, Guid riid)
Parameters
streamIndex
Int32The stream or object to query. For more information, see .
guidService
GuidA service identifier Guid. If the value is Empty, the method calls QueryInterface to get the requested interface. Otherwise, the method calls the IMFGetService::GetService method. For a list of service identifiers, see .
riid
GuidThe interface identifier (IID) of the interface being requested.
Returns
A pointer to the requested interface. The caller must release the interface.
GetServiceForStreamNative(Int32 streamIndex, Guid guidService, Guid riid, IntPtr& service)
Queries the underlying media source or decoder for an interface.
public Int32 GetServiceForStreamNative(Int32 streamIndex, Guid guidService, Guid riid, IntPtr& service)
Parameters
streamIndex
Int32The stream or object to query. For more information, see .
guidService
GuidA service identifier Guid. If the value is Empty, the method calls QueryInterface to get the requested interface. Otherwise, the method calls the IMFGetService::GetService method. For a list of service identifiers, see .
riid
GuidThe interface identifier (IID) of the interface being requested.
service
IntPtr&Receives a pointer to the requested interface. The caller must release the interface.
Returns
HRESULT
GetStreamSelection(Int32 streamIndex)
Queries whether a stream is selected.
public NativeBool GetStreamSelection(Int32 streamIndex)
Parameters
streamIndex
Int32The stream to query. For more information, see .
Returns
True if the stream is selected and will generate data; False if the stream is not selected and will not generate data.
GetStreamSelectionNative(Int32 streamIndex, NativeBool& selectedRef)
Queries whether a stream is selected.
public Int32 GetStreamSelectionNative(Int32 streamIndex, NativeBool& selectedRef)
Parameters
streamIndex
Int32The stream to query. For more information, see .
selectedRef
NativeBool&Receives True if the stream is selected and will generate data. Receives False if the stream is not selected and will not generate data.
Returns
HRESULT
ReadSample(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp)
Reads the next sample from the media source.
public MFSample ReadSample(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp)
Parameters
streamIndex
Int32Index of the stream.The stream to pull data from. For more information, see .
controlFlags
Int32A bitwise OR of zero or more flags from the SourceReaderControlFlags enumeration.
actualStreamIndex
Int32&Receives the zero-based index of the stream.
streamFlags
MFSourceReaderFlags&Receives a bitwise OR of zero or more flags from the MFSourceReaderFlags enumeration.
timestamp
Int64&Receives the time stamp of the sample, or the time of the stream event indicated in streamFlags. The time is given in 100-nanosecond units.
Returns
The MFSample instance or null. If this parameter receives a non-null value, the caller must release the received MFSample.
ReadSampleNative(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp, MFSample& sample)
Reads the next sample from the media source.
public Int32 ReadSampleNative(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp, MFSample& sample)
Parameters
streamIndex
Int32Index of the stream.The stream to pull data from. For more information, see .
controlFlags
Int32A bitwise OR of zero or more flags from the SourceReaderControlFlags enumeration.
actualStreamIndex
Int32&Receives the zero-based index of the stream.
streamFlags
MFSourceReaderFlags&Receives a bitwise OR of zero or more flags from the MFSourceReaderFlags enumeration.
timestamp
Int64&Receives the time stamp of the sample, or the time of the stream event indicated in streamFlags. The time is given in 100-nanosecond units.
sample
MFSample&Receives the MFSample instance or null. If this parameter receives a non-null value, the caller must release the received MFSample.
Returns
HRESULT
SetCurrentMediaType(Int32 streamIndex, MFMediaType mediaType)
Sets the media type for a stream. This media type defines the format that the MFSourceReader produces as output. It can differ from the native format provided by the media source. See Remarks for more information.
SetCurrentMediaTypeNative(Int32 streamIndex, IntPtr reserved, MFMediaType mediaType)
Sets the media type for a stream. This media type defines the format that the MFSourceReader produces as output. It can differ from the native format provided by the media source. See Remarks for more information.
public Int32 SetCurrentMediaTypeNative(Int32 streamIndex, IntPtr reserved, MFMediaType mediaType)
Parameters
streamIndex
Int32The stream to configure. For more information, see .
reserved
IntPtrReserved. Set to Zero.
mediaType
MFMediaTypeThe media type to set.
Returns
HRESULT
SetCurrentPosition(Guid guidTimeFormat, PropertyVariant position)
Seeks to a new position in the media source.
public void SetCurrentPosition(Guid guidTimeFormat, PropertyVariant position)
Parameters
guidTimeFormat
GuidA GUID that specifies the time format. The time format defines the units for the varPosition parameter. Pass Empty for "100-nanosecond units". Some media sources might support additional values.
position
PropertyVariantThe position from which playback will be started. The units are specified by the guidTimeFormat parameter. If the guidTimeFormat parameter is Empty, set the variant type to VT_I8.
SetCurrentPositionNative(Guid guidTimeFormat, PropertyVariant position)
Seeks to a new position in the media source.
public Int32 SetCurrentPositionNative(Guid guidTimeFormat, PropertyVariant position)
Parameters
guidTimeFormat
GuidA GUID that specifies the time format. The time format defines the units for the varPosition parameter. Pass Empty for "100-nanosecond units". Some media sources might support additional values.
position
PropertyVariantThe position from which playback will be started. The units are specified by the guidTimeFormat parameter. If the guidTimeFormat parameter is Empty, set the variant type to VT_I8.
Returns
HRESULT
SetStreamSelection(Int32 streamIndex, NativeBool selected)
Selects or deselects one or more streams.
public void SetStreamSelection(Int32 streamIndex, NativeBool selected)
Parameters
streamIndex
Int32The stream to set. For more information, see .
selected
NativeBoolSpecify True to select streams or False to deselect streams. If a stream is deselected, it will not generate data.
SetStreamSelectionNative(Int32 streamIndex, NativeBool selected)
Selects or deselects one or more streams.
public Int32 SetStreamSelectionNative(Int32 streamIndex, NativeBool selected)
Parameters
streamIndex
Int32The stream to set. For more information, see .
selected
NativeBoolSpecify True to select streams or False to deselect streams. If a stream is deselected, it will not generate data.
Returns
HRESULT
CanSeek
Gets a value indicating whether this instance can seek.
public Boolean CanSeek { get; }
MediaSourceCharacteristics
Gets the media source characteristics.
public MFMediaSourceCharacteristics MediaSourceCharacteristics { get; }