MediaStreamSample MediaStreamSample MediaStreamSample MediaStreamSample Class

Represents a media sample used by the MediaStreamSource.

Syntax

Declaration

public sealed class MediaStreamSamplepublic sealed class MediaStreamSamplePublic NotInheritable Class MediaStreamSample

Remarks

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

Properties summary

Gets the buffer which encapsulates the MediaStreamSample data.

Gets and sets the decode timestamp for this MediaStreamSample.

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

Gets the duration of the sample.

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

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

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.

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

Methods summary

Creates a MediaStreamSample from an IBuffer.

Asynchronously creates a MediaStreamSample from an IInputStream.

Events summary

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

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

    Property Value

  • 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

    Property Value

    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 bool Discontinuous { get; set; }public bool Discontinuous { get; set; }Public ReadWrite Property Discontinuous As bool

    Property Value

    • bool
      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

    Property Value

  • 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

    Property Value

    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 bool KeyFrame { get; set; }public bool KeyFrame { get; set; }Public ReadWrite Property KeyFrame As bool

    Property Value

    • bool
      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

    Property Value

  • 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

    Property Value

Methods

  • CreateFromBuffer(Windows.Storage.Streams.IBuffer,Windows.Foundation.TimeSpan)
    CreateFromBuffer(Windows.Storage.Streams.IBuffer,Windows.Foundation.TimeSpan)
    CreateFromBuffer(Windows.Storage.Streams.IBuffer,Windows.Foundation.TimeSpan)
    CreateFromBuffer(Windows.Storage.Streams.IBuffer,Windows.Foundation.TimeSpan)

    Creates a MediaStreamSample from an IBuffer.

    public static MediaStreamSample CreateFromBuffer(Windows.Storage.Streams.IBuffer buffer,Windows.Foundation.TimeSpan timestamp)public static MediaStreamSample CreateFromBuffer(Windows.Storage.Streams.IBuffer buffer,Windows.Foundation.TimeSpan timestamp)Public Static Function CreateFromBuffer(buffer As Windows.Storage.Streams.IBuffer,timestamp As Windows.Foundation.TimeSpan) As MediaStreamSample

    Parameters

    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.

  • CreateFromStreamAsync(Windows.Storage.Streams.IInputStream,System.UInt32,Windows.Foundation.TimeSpan)
    CreateFromStreamAsync(Windows.Storage.Streams.IInputStream,System.UInt32,Windows.Foundation.TimeSpan)
    CreateFromStreamAsync(Windows.Storage.Streams.IInputStream,System.UInt32,Windows.Foundation.TimeSpan)
    CreateFromStreamAsync(Windows.Storage.Streams.IInputStream,System.UInt32,Windows.Foundation.TimeSpan)

    Asynchronously creates a MediaStreamSample from an IInputStream.

    public static IAsyncOperation<MediaStreamSample> CreateFromStreamAsync(Windows.Storage.Streams.IInputStream stream,System.UInt32 count,Windows.Foundation.TimeSpan timestamp)public static IAsyncOperation<MediaStreamSample> CreateFromStreamAsync(Windows.Storage.Streams.IInputStream stream,System.UInt32 count,Windows.Foundation.TimeSpan timestamp)Public Static Function CreateFromStreamAsync(stream As Windows.Storage.Streams.IInputStream,count As System.UInt32,timestamp As Windows.Foundation.TimeSpan) As IAsyncOperation( Of MediaStreamSample )

    Parameters

    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 Processedpublic event TypedEventHandler ProcessedPublic Event Processed

    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.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Media.Core.dll