Methods (30)
Namespace: CSCore.MediaFoundation

Syntax

public class MFSample : MFAttributes

Base Type

Summary

Represents a media sample, which is a container object for media data. For video, a sample typically contains one video frame. For audio data, a sample typically contains multiple audio samples, rather than a single sample of audio.

Uses

Used by

Methods

MFSample()

Initializes a new instance of the MFSample class.

public void MFSample()

Remarks

Calls the MFCreateSample function.

MFSample(IntPtr ptr)

Initializes a new instance of the MFSample class.

public void MFSample(IntPtr ptr)

Parameters

ptr

IntPtr

The native pointer of the COM object.

AddBuffer(MFMediaBuffer buffer)

Adds a buffer to the end of the list of buffers in the sample.

public void AddBuffer(MFMediaBuffer buffer)

Parameters

buffer

MFMediaBuffer

The MFMediaBuffer to add.

AddBufferNative(MFMediaBuffer buffer)

Adds a buffer to the end of the list of buffers in the sample.

public Int32 AddBufferNative(MFMediaBuffer buffer)

Parameters

buffer

MFMediaBuffer

The MFMediaBuffer to add.

Returns

HRESULT

ConvertToContiguousBuffer()

Converts a sample with multiple buffers into a sample with a single buffer.

public MFMediaBuffer ConvertToContiguousBuffer()

Returns

A MFMediaBuffer instance. The caller must release the instance.

ConvertToContiguousBufferNative(MFMediaBuffer& buffer)

Converts a sample with multiple buffers into a sample with a single buffer.

public Int32 ConvertToContiguousBufferNative(MFMediaBuffer& buffer)

Parameters

buffer

MFMediaBuffer&

Receives a MFMediaBuffer instance. The caller must release the instance.

Returns

HRESULT

CopyToBuffer(MFMediaBuffer buffer)

Copies the sample data to a buffer. This method concatenates the valid data from all of the buffers of the sample, in order.

public void CopyToBuffer(MFMediaBuffer buffer)

Parameters

buffer

MFMediaBuffer

The MFMediaBuffer object of the destination buffer. The buffer must be large enough to hold the valid data in the sample. To get the size of the data in the sample, call GetTotalLength.

CopyToBufferNative(MFMediaBuffer buffer)

Copies the sample data to a buffer. This method concatenates the valid data from all of the buffers of the sample, in order.

public Int32 CopyToBufferNative(MFMediaBuffer buffer)

Parameters

buffer

MFMediaBuffer

The MFMediaBuffer object of the destination buffer. The buffer must be large enough to hold the valid data in the sample. To get the size of the data in the sample, call GetTotalLength.

Returns

HRESULT

GetBufferByIndex(Int32 index)

Gets a buffer from the sample, by index.

public MFMediaBuffer GetBufferByIndex(Int32 index)

Parameters

index

Int32

Index of the buffer. To find the number of buffers in the sample, call GetBufferCount. Buffers are indexed from zero.

Returns

The MFMediaBuffer instance. The caller must release the object.

Remarks

Note: In most cases, it is safer to use the ConvertToContiguousBuffer method. If the sample contains more than one buffer, the ConvertToContiguousBuffer method replaces them with a single buffer, copies the original data into that buffer, and returns the new buffer to the caller. The copy operation occurs at most once. On subsequent calls, no data is copied.

GetBufferByIndexNative(Int32 index, MFMediaBuffer& buffer)

Gets a buffer from the sample, by index.

public Int32 GetBufferByIndexNative(Int32 index, MFMediaBuffer& buffer)

Parameters

index

Int32

Index of the buffer. To find the number of buffers in the sample, call GetBufferCount. Buffers are indexed from zero.

buffer

MFMediaBuffer&

Receives the MFMediaBuffer instance. The caller must release the object.

Returns

HRESULT

Remarks

Note: In most cases, it is safer to use the ConvertToContiguousBuffer method. If the sample contains more than one buffer, the ConvertToContiguousBuffer method replaces them with a single buffer, copies the original data into that buffer, and returns the new buffer to the caller. The copy operation occurs at most once. On subsequent calls, no data is copied.

GetBufferCount()

Retrieves the number of buffers in the sample.

public Int32 GetBufferCount()

Returns

The number of buffers in the sample. A sample might contain zero buffers.

GetBufferCountNative(Int32& bufferCount)

Retrieves the number of buffers in the sample.

public Int32 GetBufferCountNative(Int32& bufferCount)

Parameters

bufferCount

Int32&

Receives the number of buffers in the sample. A sample might contain zero buffers.

Returns

HRESULT

GetSampleDuration()

Retrieves the presentation time of the sample.

public Int64 GetSampleDuration()

Returns

The presentation time, in 100-nanosecond units.

GetSampleDurationNative(Int64& hnsSampleDuration)

Retrieves the presentation time of the sample.

public Int32 GetSampleDurationNative(Int64& hnsSampleDuration)

Parameters

hnsSampleDuration

Int64&

Receives the presentation time, in 100-nanosecond units.

Returns

HRESULT

GetSampleFlags()

Currently no flags are defined. Instead, metadata for samples is defined using attributes. To get attibutes from a sample, use the MFAttributes object, which MFSample inherits.

public MFSampleFlags GetSampleFlags()

Returns

Returns the None.

GetSampleFlagsNative(MFSampleFlags& sampleFlags)

Currently no flags are defined. Instead, metadata for samples is defined using attributes. To get attibutes from a sample, use the MFAttributes object, which MFSample inherits.

public Int32 GetSampleFlagsNative(MFSampleFlags& sampleFlags)

Parameters

sampleFlags

MFSampleFlags&

Receives the value None.

Returns

HRESULT

GetSampleTime()

Retrieves the presentation time of the sample.

public Int64 GetSampleTime()

Returns

Presentation time, in 100-nanosecond units.

GetSampleTimeNative(Int64& hnsSampleTime)

Retrieves the presentation time of the sample.

public Int32 GetSampleTimeNative(Int64& hnsSampleTime)

Parameters

hnsSampleTime

Int64&

Presentation time, in 100-nanosecond units.

Returns

HRESULT

GetTotalLength()

Retrieves the total length of the valid data in all of the buffers in the sample. The length is calculated as the sum of the values retrieved by the GetCurrentLength method.

public Int32 GetTotalLength()

Returns

The total length of the valid data, in bytes.

GetTotalLengthNative(Int32& totalLength)

Retrieves the total length of the valid data in all of the buffers in the sample. The length is calculated as the sum of the values retrieved by the GetCurrentLength method.

public Int32 GetTotalLengthNative(Int32& totalLength)

Parameters

totalLength

Int32&

Receives the total length of the valid data, in bytes.

Returns

HRESULT

RemoveAllBuffers()

Removes all of the buffers from the sample.

RemoveAllBuffersNative()

Removes all of the buffers from the sample.

public Int32 RemoveAllBuffersNative()

Returns

HRESULT

RemoveBufferByIndex(Int32 index)

Removes a buffer at a specified index from the sample.

public void RemoveBufferByIndex(Int32 index)

Parameters

index

Int32

Index of the buffer. To find the number of buffers in the sample, call GetBufferCount. Buffers are indexed from zero.

RemoveBufferByIndexNative(Int32 index)

Removes a buffer at a specified index from the sample.

public Int32 RemoveBufferByIndexNative(Int32 index)

Parameters

index

Int32

Index of the buffer. To find the number of buffers in the sample, call GetBufferCount. Buffers are indexed from zero.

Returns

HRESULT

SetSampleDuration(Int64 hnsSampleDuration)

Sets the duration of the sample.

public void SetSampleDuration(Int64 hnsSampleDuration)

Parameters

hnsSampleDuration

Int64

Duration of the sample, in 100-nanosecond units.

SetSampleDurationNative(Int64 hnsSampleDuration)

Sets the duration of the sample.

public Int32 SetSampleDurationNative(Int64 hnsSampleDuration)

Parameters

hnsSampleDuration

Int64

Duration of the sample, in 100-nanosecond units.

Returns

HRESULT

SetSampleFlags(MFSampleFlags flags)

Currently no flags are defined. Instead, metadata for samples is defined using attributes. To set attibutes on a sample, use the MFAttributes object, which IMFSample inherits.

public void SetSampleFlags(MFSampleFlags flags)

Parameters

flags

MFSampleFlags

Must be None.

SetSampleFlagsNative(MFSampleFlags flags)

Currently no flags are defined. Instead, metadata for samples is defined using attributes. To set attibutes on a sample, use the MFAttributes object, which IMFSample inherits.

public Int32 SetSampleFlagsNative(MFSampleFlags flags)

Parameters

flags

MFSampleFlags

Must be None.

Returns

HRESULT

SetSampleTime(Int64 hnsSampleTime)

Sets the presentation time of the sample.

public void SetSampleTime(Int64 hnsSampleTime)

Parameters

hnsSampleTime

Int64

The presentation time, in 100-nanosecond units.

SetSampleTimeNative(Int64 hnsSampleTime)

Sets the presentation time of the sample.

public Int32 SetSampleTimeNative(Int64 hnsSampleTime)

Parameters

hnsSampleTime

Int64

The presentation time, in 100-nanosecond units.

Returns

HRESULT

Class Diagram

public classMFSampleAddBufferAddBufferNativeConvertToContiguousBufferConvertToContiguousBufferNativeCopyToBufferCopyToBufferNativeGetBufferByIndexGetBufferByIndexNativeGetBufferCountGetBufferCountNativeGetSampleDurationGetSampleDurationNativeGetSampleFlagsGetSampleFlagsNativeGetSampleTimeGetSampleTimeNativeGetTotalLengthGetTotalLengthNativeRemoveAllBuffersRemoveAllBuffersNativeRemoveBufferByIndexRemoveBufferByIndexNativeSetSampleDurationSetSampleDurationNativeSetSampleFlagsSetSampleFlagsNativeSetSampleTimeSetSampleTimeNativeMFSampleMFSamplepublic classMFAttributesCompareCompareItemCompareItemNativeCompareNativeCopyAllItemsCopyAllItemsNativeDeleteAllItemsDeleteAllItemsNativeDeleteItemDeleteItemNativeExistsGetGetGetAllocatedBlobNativeGetAllocatedStringNativeGetBlobGetBlobGetBlobNativeGetBlobSizeGetBlobSizeNativeGetCountGetCountNativeGetDoubleGetDoubleNativeGetGuidGetGuidNativeGetItemGetItemByIndexGetItemByIndexNativeGetItemNativeGetItemTypeGetItemTypeNativeGetStringGetStringLengthGetStringLengthNativeGetStringNativeGetUINT32GetUINT32NativeGetUINT64GetUINT64NativeGetUnknownNativeLockStoreLockStoreNativeSetSetSetBlobSetBlobNativeSetDoubleSetDoubleNativeSetGuidSetGuidNativeSetItemSetItemNativeSetStringSetStringNativeSetUINT32SetUINT32NativeSetUINT64SetUINT64NativeSetUnknownNativeUnlockStoreUnlockStoreNativeMFAttributesMFAttributesMFAttributesCount { get; }Item { get; set; }public classMediaFoundationDecoderDisposeDisposeFinalizeReadMediaFoundationDecoderMediaFoundationDecoderMediaFoundationDecoderCanSeek { get; }Length { get; }Position { get; set; }WaveFormat { get; }public classMediaFoundationExceptionTryMediaFoundationExceptionMediaFoundationException

save

reset

Drag to pan - Use Mousewheel + Ctrl to zoom