Sample Extension Types

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

Sample extensions, also called data unit extensions (DUEs) or buffer properties, are items of data that are attached to the media samples in the data section of the ASF file. Several types of sample extensions are defined in the Windows Media Format SDK. You can also create your own extension types.

To use sample extensions, you must identify the extension type in the stream configuration data of the profile. Call the IWMStreamConfig2::AddDataUnitExtension method to configure a stream to accept samples with extended data.

Individual sample extensions must be added to the input samples by calling the INSSBuffer3::SetProperty method. When reading samples, you can call the INSSBuffer3::GetProperty method to retrieve the extension data. You can also use the methods of the INSSBuffer4 interface to enumerate the data unit extensions attached to a sample.

The following table lists the predefined data unit extension identifiers, and describes the data that is attached to samples for each.

Sample extension GUID Description
WM_SampleExtensionGUID_OutputCleanPoint The data indicates whether the sample is a cleanpoint. A value of zero indicates that the sample is not a cleanpoint. A non-zero value indicates that it is a cleanpoint. This sample data unit extension (DUE) type is used to keep track of cleanpoints when writing precompressed media streams that were encoded with third-party codecs.
WM_SampleExtensionGUID_Timecode The data is a WMT_TIMECODE_EXTENSION_DATA structure containing SMPTE time code data associated with the sample.The size for this DUE is always WM_SampleExtension_Timecode_Size, which is 14 bytes.
WM_SampleExtensionGUID_FileName This type of sample extension is used for file streams. The data in a file stream sample is a piece of a data file. The data in the sample extension specifies the name of the file from which the content in the sample was taken.The file name is a wide-character string containing the file name in name.extension format without any path information.
WM_SampleExtensionGUID_ContentType The data identifies the type of content that the sample contains. This type of sample extension is used with interlaced video streams.All interlaced content uses the WM_CT_INTERLACED flag combined by a bitwise OR with either WM_CT_BOTTOM_FIELD_FIRST, WM_CT_TOP_FIELD_FIRST, or WM_CT_REPEAT_FIRST_FIELD.
The field order is not used in the encoding process, but is maintained with the compressed samples so that it can be passed to the rendering hardware. Playing interlaced content with the incorrect field order introduces artifacts such as motion jitter in the video.
The size for this DUE is always WM_SampleExtension_ContentType_Size.
WM_SampleExtensionGUID_PixelAspectRatio The data indicates the pixel aspect ratio of the content in the sample. This applies only to video.This extension type is used to identify the aspect ratio of non-square pixels. For more information, see To Read and Write Video Streams with Non-Square Pixels.
Aspect ratio values are stored as a word whose low byte is the X aspect and whose high byte is the Y aspect. For example, 16:9 is stored as 0x0910.
The size for this DUE is always WM_SampleExtension_PixelAspectRatio_Size, which is 2 bytes.
WM_SampleExtensionGUID_SampleDuration The data indicates the duration, in milliseconds, of the sample contained in the buffer object. On playback, if this DUE is set the reader object will use it to overwrite the existing sample duration value.This DUE is set automatically by the SDK run-time components on video streams with bit rates of 100 kbps or greater, where the overhead of the DUE information is not significant. It is not set for streams with bit rates under 100 kbps. Applications should not set this DUE manually because the writer (on high-bit-rate streams) will overwrite the value with its own data.
The size for this DUE is always WM_SampleExtension_SampleDuration_Size, which is 2 bytes.
WM_SampleExtensionGUID_ChromaLocation The data indicates the type of chroma subsampling used in the I420 video format.The value of this extension is set to one of the follow values:
  • WM_CL_INTERLACED420
  • WM_CL_PROGRESSIVE420
This data unit extension is not configured in the profile. It is included in samples output from the decoder.
The size of this DUE is always WM_SampleExtension_ChromaLocation_Size, which is 1 byte.
WM_SampleExtensionGUID_ColorSpaceInfo The data provides information about the color space used for the current video frame.The value of this extension is a WMT_COLORSPACEINFO_EXTENSION_DATA structure.
This data unit extension is not configured in the profile. It is included in samples output from the decoder.
The size of this DUE is always WM_SampleExtension_ColorSpaceInfo_Size, which is 3 bytes.
WM_SampleExtensionGUID_UserDataInfo The data is custom user data.The first four bytes of the data contain the size of the custom data.
The next byte contains the type of user data provided in the sample extension. The following types are supported:
  • 0x1F - Sequence level user data
  • 0x1E - Entry-point level user data
  • 0x1D - Frame level user data
  • 0x1C - Field level user data
  • 0x1B - Slice level user data
The sixth and subsequent bytes contain the user data. There are as many bytes of user data as specified by the number in the first four bytes.
This data unit extension is not configured in the profile. It is included in samples that are output from the decoder.
WM_SampleExtensionGUID_SampleProtectionSalt The data is encrypted by sample. This sample extension type is used for content that is imported from a non-ASF file format and a rights protection scheme other than Windows Media DRM.When importing protected content, each sample must include a unique salt. Typically, this value is a monotonically increasing counter.

Programming Reference