public class MFSample : MFAttributes
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.
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
IntPtrThe native pointer of the COM object.
AddBuffer(MFMediaBuffer buffer)
Adds a buffer to the end of the list of buffers in the sample.
AddBufferNative(MFMediaBuffer buffer)
Adds a buffer to the end of the list of buffers in the sample.
public Int32 AddBufferNative(MFMediaBuffer buffer)
Parameters
buffer
MFMediaBufferThe MFMediaBuffer to add.
Returns
HRESULT
ConvertToContiguousBuffer()
Converts a sample with multiple buffers into a sample with a single buffer.
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
MFMediaBufferThe 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
MFMediaBufferThe 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
Int32Index 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
Int32Index 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.
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.
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.
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.
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.
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.
RemoveBufferByIndexNative(Int32 index)
Removes a buffer at a specified index from the sample.
public Int32 RemoveBufferByIndexNative(Int32 index)
Parameters
index
Int32Index 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.
SetSampleDurationNative(Int64 hnsSampleDuration)
Sets the duration of the sample.
public Int32 SetSampleDurationNative(Int64 hnsSampleDuration)
Parameters
hnsSampleDuration
Int64Duration 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.
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
MFSampleFlagsMust be None.
Returns
HRESULT
SetSampleTime(Int64 hnsSampleTime)
Sets the presentation time of the sample.
SetSampleTimeNative(Int64 hnsSampleTime)
Sets the presentation time of the sample.
public Int32 SetSampleTimeNative(Int64 hnsSampleTime)
Parameters
hnsSampleTime
Int64The presentation time, in 100-nanosecond units.
Returns
HRESULT