Media​Stream​Sample Media​Stream​Sample Media​Stream​Sample Class

Definition

Represents a media sample used by the MediaStreamSource.

public sealed class MediaStreamSample : IMediaStreamSamplepublic sealed class MediaStreamSample : IMediaStreamSamplePublic NotInheritable Class MediaStreamSample Implements IMediaStreamSample
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

See the MediaStreamSource Sample for an example of using Media Stream Source in a Universal Windows app.

Properties

Buffer Buffer Buffer

Gets the buffer which encapsulates the MediaStreamSample data.

public Buffer Buffer { get; }public Buffer Buffer { get; }Public ReadOnly Property Buffer As Buffer
Value
Buffer Buffer Buffer

The buffer.

Attributes

DecodeTimestamp DecodeTimestamp DecodeTimestamp

Gets and sets the decode timestamp for this MediaStreamSample.

public TimeSpan DecodeTimestamp { get; set; }public TimeSpan DecodeTimestamp { get; set; }Public ReadWrite Property DecodeTimestamp As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

The decode timestamp.

Attributes

Remarks

The default value of DecodeTimestamp is the same value as the Timestamp property on the MediaStreamSample object. Certain media formats may require the DecodeTimestamp property to be assigned a value that is different from the presentation timestamp given by the Timestamp property, but for most formats the two properties will be the same.

Discontinuous Discontinuous Discontinuous

Gets or sets a value to indicate that the previous MediaStreamSample in the sequence is missing.

public PlatForm::Boolean Discontinuous { get; set; }public bool Discontinuous { get; set; }Public ReadWrite Property Discontinuous As bool
Value
bool bool bool

true if the previous MediaStreamSample in the sequence is missing; otherwise, false. The default value is false.

Attributes

Remarks

Applications should set this property to true when the previous MediaStreamSample in the sequence is missing. An example of a situation when this can occur is when samples are received over a lossy network connection. The default value is false.

Duration Duration Duration

Gets the duration of the sample.

public TimeSpan Duration { get; set; }public TimeSpan Duration { get; set; }Public ReadWrite Property Duration As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

The duration of the sample.

Attributes

ExtendedProperties ExtendedProperties ExtendedProperties

Gets the extended property set which enables getting and setting properties on the MediaStreamSample.

public MediaStreamSamplePropertySet ExtendedProperties { get; }public MediaStreamSamplePropertySet ExtendedProperties { get; }Public ReadOnly Property ExtendedProperties As MediaStreamSamplePropertySet
Attributes

Remarks

The ExtendedProperties is used for less common properties which are not directly accessible on the MediaStreamSamplePropertySet object. The properties are accessed through their GUID values. For example, the video stride property is accessed through the GUID value “0x644b4e48, 0x1e02, 0x4516, 0xb0, 0xeb, 0xc0, 0x1c, 0xa9, 0xd4, 0x9a, 0xc6”, which is the GUID for MF_MT_DEFAULT_STRIDE.

KeyFrame KeyFrame KeyFrame

Gets or sets a value that indicates the MediaStreamSample contains a keyframe.

public PlatForm::Boolean KeyFrame { get; set; }public bool KeyFrame { get; set; }Public ReadWrite Property KeyFrame As bool
Value
bool bool bool

true if the MediaStreamSample contains a frame that can be decoded independently from other frames; otherwise, false. The default value is false.

Attributes

Remarks

This flag should be set to true when the MediaStreamSample contains an audio or video frame which can be independently decoded from other frames. Such frames are sometimes referred to as cleanpoints, I-frames, IDR-frames or key frames.

Protection Protection Protection

Gets a MediaStreamSampleProtectionProperties object, which is used for getting and setting properties that are specific to the Digital Rights Management (DRM) protection of the MediaStreamSample.

public MediaStreamSampleProtectionProperties Protection { get; }public MediaStreamSampleProtectionProperties Protection { get; }Public ReadOnly Property Protection As MediaStreamSampleProtectionProperties
Value
MediaStreamSampleProtectionProperties MediaStreamSampleProtectionProperties MediaStreamSampleProtectionProperties

A collection of properties that are specific to the Digital Rights Management (DRM) protection of the MediaStreamSample.

Attributes

Timestamp Timestamp Timestamp

Gets the time at which a sample should be rendered. This is also referred to as the presentation time.

public TimeSpan Timestamp { get; }public TimeSpan Timestamp { get; }Public ReadOnly Property Timestamp As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

The time at which the MediaStreamSample should be rendered.

Attributes

Methods

CreateFromBuffer(IBuffer, TimeSpan) CreateFromBuffer(IBuffer, TimeSpan) CreateFromBuffer(IBuffer, TimeSpan)

Creates a MediaStreamSample from an IBuffer.

public static MediaStreamSample CreateFromBuffer(IBuffer buffer, TimeSpan timestamp)public static MediaStreamSample CreateFromBuffer(IBuffer buffer, TimeSpan timestamp)Public Static Function CreateFromBuffer(buffer As IBuffer, timestamp As TimeSpan) As MediaStreamSample
Parameters
buffer
IBuffer IBuffer IBuffer

The buffer that contains the media data used to create the MediaStreamSample.

timestamp
TimeSpan TimeSpan TimeSpan

The presentation time of this sample.

Returns

The sample created from the data in buffer.

Attributes

Remarks

For certain formats, the decode time and the presentation time of a MediaStreamSample are different. The decode time can be accessed through the DecodeTimestamp property.

CreateFromStreamAsync(IInputStream, UInt32, TimeSpan) CreateFromStreamAsync(IInputStream, UInt32, TimeSpan) CreateFromStreamAsync(IInputStream, UInt32, TimeSpan)

Asynchronously creates a MediaStreamSample from an IInputStream.

public static IAsyncOperation<MediaStreamSample> CreateFromStreamAsync(IInputStream stream, UInt32 count, TimeSpan timestamp)public static IAsyncOperation<MediaStreamSample> CreateFromStreamAsync(IInputStream stream, UInt32 count, TimeSpan timestamp)Public Static Function CreateFromStreamAsync(stream As IInputStream, count As UInt32, timestamp As TimeSpan) As IAsyncOperation( Of MediaStreamSample )
Parameters
stream
IInputStream IInputStream IInputStream

The stream that contains the media data used to create the MediaStreamSample.

count
System.UInt32 System.UInt32 System.UInt32

The length of the data in the sample. This is the number of bytes that will be read from stream.

timestamp
TimeSpan TimeSpan TimeSpan

The presentation time of this MediaStreamSample.

Returns

When this method completes, it returns the new file as a MediaStreamSample.

Attributes

Remarks

For certain formats, the decode time and the presentation time of a MediaStreamSample are different. The decode time can be accessed through the DecodeTimestamp property.

Events

Processed Processed Processed

Occurs when the MediaStreamSample has been processed by the media pipeline.

public event TypedEventHandler Processedpublic event TypedEventHandler ProcessedPublic Event Processed
Attributes

Remarks

When this event has been raised, it is safe to reuse the IBuffer from this MediaStreamSample in a new MediaStreamSample. This allows an application to have a pool of buffers which are reused across multiple MediaStreamSample objects, rather than allocating a new buffer for each new MediaStreamSample.

The event is informational. Applications are not required to have a handler for this event.

See Also