File Reading Features

[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.]

Reading ASF files is one of the primary features of the Windows Media Format SDK. Two types of reading are supported: asynchronous and synchronous. Asynchronous file reading is handled by the reader object. The synchronous reader object is used to read files synchronously. For more information about the different reading objects, see Reader Object and Synchronous Reader Object.

In the most basic asynchronous file reading scenario, you must implement a callback method that the reader object will call when samples are ready. After you begin reading a file, your application waits for the samples to be delivered to your callback method. Asynchronous reading is useful for player applications, and supports features not available with synchronous reading. If your application needs to read files from a network location, or interact with a server running Windows Media Services, you must use the reader object. The disadvantage of the reader object is that a separate thread is used for each output delivered. Additionally, the reader object is not as flexible as the synchronous reader in how it can deliver samples.

With the synchronous reader you do not need to use any callback methods. Instead, you select a portion of the file to read and retrieve the samples one at a time with method calls. The synchronous reader is well suited to the needs of content-editing applications, where quick access to specific samples is essential. Because no callback methods are used by the synchronous reader, you can create applications to read ASF files with a minimum of coding overhead. However, the synchronous reader cannot open a file from a network location, or interact with a server running Windows Media Services, or read files protected with DRM.

The following topics discuss the features of the reader and the synchronous reader.

Topic Description
User Allocated Sample Support Discusses buffer allocation in the reader and synchronous reader, and how user allocation can improve performance.
Output Format Enumeration Discusses output format enumeration.


In addition, the following topics from the writing features section also apply to file reading:


Reading ASF Files