Fields (2) Methods (24)
Namespace: CSCore.MediaFoundation

Syntax

public class MFSinkWriter : ComObject

Base Type

Summary

Implemented by the Microsoft Media Foundation sink writer object.

Uses

Used by

Fields

MF_SINK_WRITER_ALL_STREAMS

Stream index to selected all streams.

public const Int32 MF_SINK_WRITER_ALL_STREAMS

Constant Value

-2

MF_SINK_WRITER_MEDIASINK

MFSINKWRITER_MEDIASINK constant.

public const Int32 MF_SINK_WRITER_MEDIASINK

Constant Value

-1

Methods

MFSinkWriter(MFByteStream byteStream, MFAttributes attributes)

Initializes a new instance of the MFSinkWriter class with a underlying byteStream.

public void MFSinkWriter(MFByteStream byteStream, MFAttributes attributes)

Parameters

byteStream

MFByteStream

The underlying MFByteStream to use.

attributes

MFAttributes

Attributes to configure the MFSinkWriter. For more information, see . Use null/nothing as the default value.

MFSinkWriter(IntPtr ptr)

Initializes a new instance of the MFSinkWriter class.

public void MFSinkWriter(IntPtr ptr)

Parameters

ptr

IntPtr

The native pointer of the COM object.

AddStream(MFMediaType targetMediaType)

Adds a stream to the sink writer.

public Int32 AddStream(MFMediaType targetMediaType)

Parameters

targetMediaType

MFMediaType

The target mediatype which specifies the format of the samples that will be written to the file. It does not need to match the input format. To set the input format, call SetInputMediaType.

Returns

The zero-based index of the new stream.

public Int32 AddStreamNative(MFMediaType targetMediaType, Int32& streamIndex)

Parameters

targetMediaType

MFMediaType

The target mediatype which specifies the format of the samples that will be written to the file. It does not need to match the input format. To set the input format, call SetInputMediaType.

streamIndex

Int32&

Receives the zero-based index of the new stream.

Returns

HRESULT

BeginWriting()

Initializes the sink writer for writing.

BeginWritingNative()

Initializes the sink writer for writing.

public Int32 BeginWritingNative()

Returns

HRESULT

FinalizeWriting()

Completes all writing operations on the sink writer.

public void FinalizeWriting()

Remarks

Renamed from 'Finalize' to 'FinalizeWriting' to suppress "CS0465 warning".

FinalizeWritingNative()

Completes all writing operations on the sink writer.

public Int32 FinalizeWritingNative()

Returns

HRESULT

Flush(Int32 streamIndex)

Flushes one or more streams.

public void Flush(Int32 streamIndex)

Parameters

streamIndex

Int32

The zero-based index of the stream to flush, or MFSINKWRITERALLSTREAMS to flush all of the streams.

FlushNative(Int32 streamIndex)

Flushes one or more streams.

public Int32 FlushNative(Int32 streamIndex)

Parameters

streamIndex

Int32

The zero-based index of the stream to flush, or MFSINKWRITERALLSTREAMS to flush all of the streams.

Returns

HRESULT

GetServiceForStream(Int32 streamIndex, Guid guidService, Guid riid)

Queries the underlying media sink or encoder for an interface.

public IntPtr GetServiceForStream(Int32 streamIndex, Guid guidService, Guid riid)

Parameters

streamIndex

Int32

The zero-based index of a stream to query, or MFSINKWRITER_MEDIASINK to query the media sink itself.

guidService

Guid

A service identifier GUID, or Empty. If the value is Empty, the method calls QueryInterface to get the requested interface. Otherwise, the method calls IMFGetService::GetService. 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& pObject)

Queries the underlying media sink or encoder for an interface.

public Int32 GetServiceForStreamNative(Int32 streamIndex, Guid guidService, Guid riid, IntPtr& pObject)

Parameters

streamIndex

Int32

The zero-based index of a stream to query, or MFSINKWRITER_MEDIASINK to query the media sink itself.

guidService

Guid

A service identifier GUID, or Empty. If the value is Empty, the method calls QueryInterface to get the requested interface. Otherwise, the method calls IMFGetService::GetService. For a list of service identifiers, see .

riid

Guid

The interface identifier (IID) of the interface being requested.

pObject

IntPtr&

Receives a pointer to the requested interface. The caller must release the interface.

Returns

HRESULT

GetStatistics(Int32 streamIndex)

Gets statistics about the performance of the sink writer.

public MFSinkWriterStatistics GetStatistics(Int32 streamIndex)

Parameters

streamIndex

Int32

The zero-based index of a stream to query, or MFSINKWRITERALLSTREAMS to query the media sink itself.

Returns

Statistics about the performance of the sink writer.

GetStatisticsNative(Int32 streamIndex, MFSinkWriterStatistics& statistics)

Gets statistics about the performance of the sink writer.

public Int32 GetStatisticsNative(Int32 streamIndex, MFSinkWriterStatistics& statistics)

Parameters

streamIndex

Int32

The zero-based index of a stream to query, or MFSINKWRITERALLSTREAMS to query the media sink itself.

statistics

MFSinkWriterStatistics&

Receives statistics about the performance of the sink writer.

Returns

HRESULT

NotifyEndOfSegment(Int32 streamIndex)

Notifies the media sink that a stream has reached the end of a segment.

public void NotifyEndOfSegment(Int32 streamIndex)

Parameters

streamIndex

Int32

The zero-based index of a stream, or MFSINKWRITERALLSTREAMS to signal that all streams have reached the end of a segment.

NotifyEndOfSegmentNative(Int32 streamIndex)

Notifies the media sink that a stream has reached the end of a segment.

public Int32 NotifyEndOfSegmentNative(Int32 streamIndex)

Parameters

streamIndex

Int32

The zero-based index of a stream, or MFSINKWRITERALLSTREAMS to signal that all streams have reached the end of a segment.

Returns

HRESULT

PlaceMarker(Int32 streamIndex, IntPtr context)

Places a marker in the specified stream.

public void PlaceMarker(Int32 streamIndex, IntPtr context)

Parameters

streamIndex

Int32

The zero-based index of the stream.

context

IntPtr

Pointer to an application-defined value. The value of this parameter is returned to the caller in the pvContext parameter of the caller's IMFSinkWriterCallback::OnMarker callback method. The application is responsible for any memory allocation associated with this data. This parameter can be NULL.

PlaceMarkerNative(Int32 streamIndex, IntPtr context)

Places a marker in the specified stream.

public Int32 PlaceMarkerNative(Int32 streamIndex, IntPtr context)

Parameters

streamIndex

Int32

The zero-based index of the stream.

context

IntPtr

Pointer to an application-defined value. The value of this parameter is returned to the caller in the pvContext parameter of the caller's IMFSinkWriterCallback::OnMarker callback method. The application is responsible for any memory allocation associated with this data. This parameter can be NULL.

Returns

HRESULT

SendStreamTick(Int32 streamIndex, Int64 timeStamp)

Indicates a gap in an input stream.

public void SendStreamTick(Int32 streamIndex, Int64 timeStamp)

Parameters

streamIndex

Int32

The zero-based index of the stream.

timeStamp

Int64

The position in the stream where the gap in the data occurs. The value is given in 100-nanosecond units, relative to the start of the stream.

public Int32 SendStreamTickNative(Int32 streamIndex, Int64 timeStamp)

Parameters

streamIndex

Int32

The zero-based index of the stream.

timeStamp

Int64

The position in the stream where the gap in the data occurs. The value is given in 100-nanosecond units, relative to the start of the stream.

Returns

HRESULT

public void SetInputMediaType(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)

Parameters

streamIndex

Int32

The zero-based index of the stream. The index is returned by the AddStream method.

inputMediaType

MFMediaType

The input media type that specifies the input format.

encodingParameters

MFAttributes

An attribute store. Use the attribute store to configure the encoder. This parameter can be NULL.

public Int32 SetInputMediaTypeNative(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)

Parameters

streamIndex

Int32

The zero-based index of the stream. The index is returned by the AddStream method.

inputMediaType

MFMediaType

The input media type that specifies the input format.

encodingParameters

MFAttributes

An attribute store. Use the attribute store to configure the encoder. This parameter can be NULL.

Returns

HRESULT

WriteSample(Int32 streamIndex, MFSample sample)

Delivers a sample to the sink writer.

public void WriteSample(Int32 streamIndex, MFSample sample)

Parameters

streamIndex

Int32

The zero-based index of the stream for this sample.

sample

MFSample

The sample to write.

Remarks

You must call BeginWriting before calling this method.

WriteSampleNative(Int32 streamIndex, MFSample sample)

Delivers a sample to the sink writer.

public Int32 WriteSampleNative(Int32 streamIndex, MFSample sample)

Parameters

streamIndex

Int32

The zero-based index of the stream for this sample.

sample

MFSample

The sample to write.

Returns

HRESULT

Remarks

You must call BeginWriting before calling this method.