MediaStreamSample MediaStreamSample MediaStreamSample MediaStreamSample Class

Definition

Represents a media sample used by the MediaStreamSource.

public : sealed class MediaStreamSample : IMediaStreamSample
public sealed class MediaStreamSample : IMediaStreamSample
Public NotInheritable Class MediaStreamSample Implements IMediaStreamSample
// This class does not provide a public constructor.
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
var buffer = mediaStreamSample.buffer;
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
var timeSpan = mediaStreamSample.decodeTimestamp;
mediaStreamSample.decodeTimestamp = timeSpan;
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
var bool = mediaStreamSample.discontinuous;
mediaStreamSample.discontinuous = bool;
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
var timeSpan = mediaStreamSample.duration;
mediaStreamSample.duration = timeSpan;
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
var mediaStreamSamplePropertySet = mediaStreamSample.extendedProperties;

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
var bool = mediaStreamSample.keyFrame;
mediaStreamSample.keyFrame = bool;
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
var mediaStreamSampleProtectionProperties = mediaStreamSample.protection;
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
var timeSpan = mediaStreamSample.timestamp;
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
var mediaStreamSample = Windows.Media.Core.MediaStreamSample.createFromBuffer(buffer, timestamp);
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 )
Windows.Media.Core.MediaStreamSample.createFromStreamAsync(stream, count, timestamp).done( /* Your success and error handlers */ );
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 TypedEventHandler Processed( Of ( Of MediaStreamSample ), ( Of object ))
function onProcessed(eventArgs){/* Your code */}


mediaStreamSample.addEventListener("processed", onProcessed);
mediaStreamSample.removeEventListener("processed", onProcessed);

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