public class MFSinkWriter : ComObject
Implemented by the Microsoft Media Foundation sink writer object.
MF_SINK_WRITER_ALL_STREAMS
Stream index to selected all streams.
public const Int32 MF_SINK_WRITER_ALL_STREAMS
Constant Value
MF_SINK_WRITER_MEDIASINK
MFSINKWRITER_MEDIASINK constant.
public const Int32 MF_SINK_WRITER_MEDIASINK
Constant Value
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
MFByteStreamThe underlying MFByteStream to use.
attributes
MFAttributesAttributes 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
IntPtrThe native pointer of the COM object.
AddStream(MFMediaType targetMediaType)
Adds a stream to the sink writer.
public Int32 AddStream(MFMediaType targetMediaType)
Parameters
targetMediaType
MFMediaTypeThe 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.
AddStreamNative(MFMediaType targetMediaType, Int32& streamIndex)
Adds a stream to the sink writer.
public Int32 AddStreamNative(MFMediaType targetMediaType, Int32& streamIndex)
Parameters
targetMediaType
MFMediaTypeThe 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.
FinalizeWritingNative()
Completes all writing operations on the sink writer.
public Int32 FinalizeWritingNative()
Returns
HRESULT
Flush(Int32 streamIndex)
Flushes one or more streams.
FlushNative(Int32 streamIndex)
Flushes one or more streams.
public Int32 FlushNative(Int32 streamIndex)
Parameters
streamIndex
Int32The 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
Int32The zero-based index of a stream to query, or MFSINKWRITER_MEDIASINK to query the media sink itself.
guidService
GuidA 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
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& pObject)
Queries the underlying media sink or encoder for an interface.
public Int32 GetServiceForStreamNative(Int32 streamIndex, Guid guidService, Guid riid, IntPtr& pObject)
Parameters
streamIndex
Int32The zero-based index of a stream to query, or MFSINKWRITER_MEDIASINK to query the media sink itself.
guidService
GuidA 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
GuidThe 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
Int32The 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
Int32The 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.
NotifyEndOfSegmentNative(Int32 streamIndex)
Notifies the media sink that a stream has reached the end of a segment.
public Int32 NotifyEndOfSegmentNative(Int32 streamIndex)
Parameters
streamIndex
Int32The 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
Int32The zero-based index of the stream.
context
IntPtrPointer 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
Int32The zero-based index of the stream.
context
IntPtrPointer 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
Int32The zero-based index of the stream.
timeStamp
Int64The 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.
SendStreamTickNative(Int32 streamIndex, Int64 timeStamp)
Indicates a gap in an input stream.
public Int32 SendStreamTickNative(Int32 streamIndex, Int64 timeStamp)
Parameters
streamIndex
Int32The zero-based index of the stream.
timeStamp
Int64The 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
SetInputMediaType(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)
Sets the input format for a stream on the sink writer.
public void SetInputMediaType(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)
Parameters
streamIndex
Int32The zero-based index of the stream. The index is returned by the AddStream method.
inputMediaType
MFMediaTypeThe input media type that specifies the input format.
encodingParameters
MFAttributesAn attribute store. Use the attribute store to configure the encoder. This parameter can be NULL.
SetInputMediaTypeNative(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)
Sets the input format for a stream on the sink writer.
public Int32 SetInputMediaTypeNative(Int32 streamIndex, MFMediaType inputMediaType, MFAttributes encodingParameters)
Parameters
streamIndex
Int32The zero-based index of the stream. The index is returned by the AddStream method.
inputMediaType
MFMediaTypeThe input media type that specifies the input format.
encodingParameters
MFAttributesAn 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.
WriteSampleNative(Int32 streamIndex, MFSample sample)
Delivers a sample to the sink writer.
public Int32 WriteSampleNative(Int32 streamIndex, MFSample sample)
Parameters
streamIndex
Int32The zero-based index of the stream for this sample.
sample
MFSampleThe sample to write.
Returns
HRESULT
Remarks
You must call BeginWriting before calling this method.