Methods (22) Properties (2)
Namespace: CSCore.MediaFoundation

Syntax

public class MFSourceReader : ComObject

Base Type

Summary

Implemented by the Microsoft Media Foundation source reader object.

Uses

Used by

Methods

MFSourceReader(IntPtr ptr)

Initializes a new instance of the MFSourceReader class.

public void MFSourceReader(IntPtr ptr)

Parameters

ptr

IntPtr

The 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

String

The URL.

Flush(Int32 streamIndex)

Flushes one or more streams.

public void Flush(Int32 streamIndex)

Parameters

streamIndex

Int32

The stream to flush. For more information, see .

FlushNative(Int32 streamIndex)

Flushes one or more streams.

public Int32 FlushNative(Int32 streamIndex)

Parameters

streamIndex

Int32

The stream to flush. For more information, see .

Returns

HRESULT

GetCurrentMediaType(Int32 streamIndex)

Gets the current media type for a stream.

public MFMediaType GetCurrentMediaType(Int32 streamIndex)

Parameters

streamIndex

Int32

Specifies which stream to query. For more information, see .

Returns

The MFMediaType. The caller must dispose the MFMediaType.

public Int32 GetCurrentMediaTypeNative(Int32 streamIndex, MFMediaType& mediaType)

Parameters

streamIndex

Int32

Specifies 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

Int32

Specifies which stream to query. For more information, see .

mediatypeIndex

Int32

The 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

Int32

Specifies which stream to query. For more information, see .

mediatypeIndex

Int32

The 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

Int32

The stream or object to query. For more information, see .

guidAttribute

Guid

A 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.

public Int32 GetPresentationAttributeNative(Int32 streamIndex, Guid guidAttribute, PropertyVariant& variant)

Parameters

streamIndex

Int32

The stream or object to query. For more information, see .

guidAttribute

Guid

A 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

Int32

The stream or object to query. For more information, see .

guidService

Guid

A 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

Guid

The 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

Int32

The stream or object to query. For more information, see .

guidService

Guid

A 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

Guid

The 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

Int32

The 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.

public Int32 GetStreamSelectionNative(Int32 streamIndex, NativeBool& selectedRef)

Parameters

streamIndex

Int32

The 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

public MFSample ReadSample(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp)

Parameters

streamIndex

Int32

Index of the stream.The stream to pull data from. For more information, see .

controlFlags

Int32

A 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.

public Int32 ReadSampleNative(Int32 streamIndex, Int32 controlFlags, Int32& actualStreamIndex, MFSourceReaderFlags& streamFlags, Int64& timestamp, MFSample& sample)

Parameters

streamIndex

Int32

Index of the stream.The stream to pull data from. For more information, see .

controlFlags

Int32

A 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.

public void SetCurrentMediaType(Int32 streamIndex, MFMediaType mediaType)

Parameters

streamIndex

Int32

The stream to configure. For more information, see .

mediaType

MFMediaType

The media type to set.

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

Int32

The stream to configure. For more information, see .

reserved

IntPtr

Reserved. Set to Zero.

mediaType

MFMediaType

The 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

Guid

A 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

PropertyVariant

The 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.

public Int32 SetCurrentPositionNative(Guid guidTimeFormat, PropertyVariant position)

Parameters

guidTimeFormat

Guid

A 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

PropertyVariant

The 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

Int32

The stream to set. For more information, see .

selected

NativeBool

Specify True to select streams or False to deselect streams. If a stream is deselected, it will not generate data.

public Int32 SetStreamSelectionNative(Int32 streamIndex, NativeBool selected)

Parameters

streamIndex

Int32

The stream to set. For more information, see .

selected

NativeBool

Specify True to select streams or False to deselect streams. If a stream is deselected, it will not generate data.

Returns

HRESULT

Properties

CanSeek

Gets a value indicating whether this instance can seek.

public Boolean CanSeek { get; }

MediaSourceCharacteristics

Gets the media source characteristics.

public MFMediaSourceCharacteristics MediaSourceCharacteristics { get; }