Previous | Next |
Media samples are the basic segments of media that the SDK uses to input and output media. A media sample represents a small segment of audio, or a video frame, or a script command. Media samples are either associated with a stream (which is the raw data that goes into the Windows Media file), or an input or output, which is uncompressed data ready for rendering. Media samples are used by both the Reader object and the Writer object; the user gives media samples to the Writer so the writer can generate a Windows Media file, whereas the user receives media samples from the reader.
The actual format of a media sample depends both on the type of data involved and whether the media sample is either part of a stream or an input or output. For video data, a media sample represents a video frame. For an input (or output), the video frame is a fixed-size uncompressed video frame, whose properties can be retrieved from the reader or writer. For an output, the video frame is variable sized, and its properties are stored in the profile associated with the reader or writer. For audio data, the media sample represents a small segment of audio; the properties of the audio, and whether it is compressed or not, again depend on whether it is associated with a stream or with an input or output. If the audio is uncompressed, it is PCM audio; otherwise it is codec-specific data.
Regardless of their type, media samples have several characteristics in common. Media sample data is stored in INSSBuffers, which enables media samples to be used more efficiently among objects, without requiring processor-intensive copying of data. This can be the SDK implemented INSSBuffer, or the user can implement their own version of INSSBuffer. Media samples also have other information associated with them, such as stream number, input/output number, timestamps and flags, that all methods taking media samples also have as arguments.
Stream numbers and input/output numbers are used to identify unique streams of media samples that the SDK is working with. The timestamp represents the moment during the media clip that the media sample should be rendered, stored in 100-nanosecond units. Flags are also passed with media samples, indicating certain properties of the media samples. For instance, flags are used to indicate whether a media sample is a cleanpoint, or a media sample that is valid to seek to.
Previous | Next |