Media​Stream​Sample 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// You can use this class in JavaScript.
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 Buffer

Gets the buffer which encapsulates the MediaStreamSample data.

public : Buffer Buffer { get; }public Buffer Buffer { get; }Public ReadOnly Property Buffer As Buffer// You can use this property in JavaScript.
Value
Buffer Buffer Buffer Buffer

The buffer.

DecodeTimestamp 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// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The decode timestamp.

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 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// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

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

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 Duration

Gets the duration of the sample.

public : TimeSpan Duration { get; set; }public TimeSpan Duration { get; set; }Public ReadWrite Property Duration As TimeSpan// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The duration of the sample.

ExtendedProperties 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// You can use this property in JavaScript.

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 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// You can use this property in JavaScript.
Value
PlatForm::Boolean 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.

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 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// You can use this property in JavaScript.
Value
MediaStreamSampleProtectionProperties MediaStreamSampleProtectionProperties MediaStreamSampleProtectionProperties MediaStreamSampleProtectionProperties

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

Timestamp 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// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The time at which the MediaStreamSample should be rendered.

Methods

CreateFromBuffer(IBuffer, TimeSpan) 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// You can use this method in JavaScript.
Parameters
buffer
IBuffer IBuffer IBuffer IBuffer

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

timestamp
TimeSpan TimeSpan TimeSpan TimeSpan

The presentation time of this sample.

Returns

The sample created from the data in buffer.

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) CreateFromStreamAsync(IInputStream, UInt32, TimeSpan)

Asynchronously creates a MediaStreamSample from an IInputStream.

public : static IAsyncOperation<MediaStreamSample> CreateFromStreamAsync(IInputStream stream, unsigned int 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 )// You can use this method in JavaScript.
Parameters
stream
IInputStream IInputStream IInputStream IInputStream

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

count
unsigned int UInt32 UInt32 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 TimeSpan

The presentation time of this MediaStreamSample.

Returns

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 Processed

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

public : event TypedEventHandler Processed<MediaStreamSample,  object>public event TypedEventHandler Processed<MediaStreamSample,  object>Public Event Processed<MediaStreamSample,  object>// You can use this event in JavaScript.

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