What does ASF look like under the hood?

If ASF was the first car, then up till now we have been marveling at its revolutionary effects. We have learned that it is more convenient than a horse, and that it will transform transportation and industry. But we still know nothing about how the car actually works. To find that out, we would be best served by rolling up our sleeves, opening up the hood, and getting some engine grease on our elbows. So roll up your sleeves. It's time to look at ASF from the inside.

Objects

As has been mentioned, ASF is a file format that organizes data in a particular way. The first thing to notice about how ASF organizes data is that ASF files are made up of a collection of data objects. Objects are like Legos. (For those of you who didn't have Legos when you were growing up, they're small toy bricks that snap together.) Each Lego block is like an object. Various Legos can be stuck together to make bigger objects, such as walls, foundations, and roofs. The bigger, aggregate blocks can then be stuck together to make even bigger objects, such as houses. You can mix, match, and re-use various Lego walls, foundations, and roofs to come up with all sorts of different houses. Legos are fun for the entire family. So is object-oriented programming (at least for families of engineers).

Every object in an ASF file follows a certain basic format. Every individual Lego, and every group of Legos, has the same basic characteristics: flat, shiny surfaces; evenly spaced, round protrusions on top; and matching holes on the bottom. Similarly, all ASF objects share the same basic characteristics. These shared characteristics are three fields: (1) a 16-byte-long field containing a GUID; (2) an 8-byte-long field containing the size of the object; and (3) a field as long as the second field (minus 24 bytes) containing data of some kind or other. What on earth is a GUID? Perhaps a picture would help. GUID stands for globally unique identifier. You may have heard of UUIDs -- universally unique identifiers. They're the same thing. In fact, if someone starts talking about IUIDs -- inter-galactically unique identifiers -- don't worry. They're probably still talking about GUIDs.

GUIDs are unique identifiers of objects. Just as your social security number is of fixed length (9 digits) and uniquely identifies you, a GUID is of fixed length (16 bytes) and uniquely identifies an object. However, this analogy breaks down upon closer scrutiny. For example, whereas the government issues all social security numbers and maintains all of them in government databases, no central agency issues or maintains GUIDs. Your computer, in conjunction with your network card, generates the GUID. Every GUID so generated is guaranteed to be unique.

The data field of an ASF object can contain any kind of information. This includes other objects. In other words, some objects serve just as a container of other objects. This nesting can be many levels deep.

All ASF files contain two fundamental objects: the header object, and the data object. (Be careful not to confuse the data object, a description of which follows, with the data field of every object previously described.) A third fundamental object -- the index object -- is optional (although it is strongly recommended).

The header object is a container object, and it holds other objects. The data object and the index object are basic objects; they do not contain other objects.

The Header Object.

The header object precedes the data object in an ASF file. The header object contains administrative information about the multimedia content, and not the content itself. The header object always comes before the data object. The purpose of the header is to let the client know what to expect when it starts receiving the data. Without the header, it would be difficult, if not impossible, for the client to know what the bits and bytes in the data objects mean.

The header object contains smaller objects. Each of these smaller objects contains information of one sort or another about the data. The first of these is the file properties object. It stores some basic information about the entire file, for example, the time the file was created and the number of different types of data streams contained in the file. This information is stored in the data field of the file properties object. The data field of the file properties object, and of every other object in the header object, is divided up into predefined fields bearing specific meaning. This definition is laid out in the ASF Specification.

Following the file properties object in the header object are the stream properties objects. There is one such object for every type of data stream in the file. As the name suggests, each stream properties object contains information about a particular data stream. For example, each contains a field indicating when the stream is supposed to start playing at the client end (the presentation time).

Each stream properties object within the header object contains the same 15 or so generic fields. These generic fields are applicable to every type of data stream. For example, the stream properties objects for video, audio, and text would each have a field storing the starting presentation time for that particular data stream.

In addition, each stream properties object contains type-specific data. For two different stream properties objects, the division of the type-specific data into particular fields is different. For example, the stream properties object for an audio stream would contain a type-specific data field storing the samples per second for that stream. The stream properties object for a video stream would not contain this field; however, it would contain fields for the height and width of the video frames.

ASF defines seven core media types: audio, video, image, timecode, text, MIDI, and command. For each of these core media types, ASF predefines the type-specific data. So if an ASF file contains an audio stream, the type-specific data in the stream properties object for that audio stream will follow the field definition provided by ASF.

Every ASF file contains one file properties object, followed by one stream properties object for every type of data stream contained in the file. In addition to these mandatory objects, the header object can also contain one or more optional objects. Whether an ASF file contains one or more of these optional header objects is determined by the production tool that creates the file.

There are a number of different kinds of optional header objects. Collectively, these provide a rich body of information about the data. It is these objects that allow for the efficient delivery and rendering of powerful and complex multimedia presentations. Among the optional header objects are objects for describing the content in the file, for providing information about the software components needed for processing particular kinds of data (For example, a video "codec" for decompressing compressed video data), and for prioritizing the various types of data streams (for example, audio could be given a higher priority than video in the event of network loss of data).

The Data Object.

The data object contains the actual multimedia content. For example, if an ASF file contains a video clip, the data object in that file contains the actual pictures and sounds of the video. The data field of the data object is divided up into a series of ASF "data packets." Each packet follows the same form. There is a packet header, and the packet data. The packet header contains a set of fields that store information that aids in the streaming delivery of the data. The actual multimedia content is stored in the packet data.

Each individual data packet within the data object contains only one type of multimedia data stream. For example, a packet could contain video data, audio data, text data, or image data, but no packet could contain more than one type of data. Although all of one type of a data stream (say, all of the video content) could be stored in a single packet, normally many packets are used to store this data. The framework is flexible. One packet could contain a single video frame, another could contain a part of a video frame, and a third could contain multiple video frames. Often, one packet is used to store one video frame. The packets in the data object of an ASF file are sorted by send time. In other words, the position of each packet in the data object is determined by its send time (the time at which the packet is to be sent by the server over the network toward the client). This means that the data in an ASF file is interleaved. With an interleaved file, a video packet could follow an audio packet, which could follow a text packet which could follow another video packet. Interleaving the data optimizes that data for playback at the client end.

The Index Object.

In addition to the header object and the data object, an ASF file could optionally contain an index object. The index object describes one or more indexes into the various data streams. An index into a data stream allows for very fast and direct access into that stream. For example, an index for a video stream would permit efficient fast forwarding and fast reversing.

Phew! That's it for looking under ASF's hood. What have we learned? We have learned that an ASF file is like a textbook. Just as a textbook is made up of a collection of pages of common size, weight, and texture, an ASF file is made up of a collection of objects of common basic structure. Whereas the textbook contains a front section (title page, copyright information, and table of contents) describing the contents of the text, the ASF file contains a header object describing the multimedia data in the file. Whereas the textbook follows the front section with a series of chapters containing the content, the ASF file follows the header object with a data object storing a series of data packets containing the multimedia data. Whereas the textbook may conclude with an index allowing for quick and direct access into the chapters, the ASF file may conclude with an index object allowing for quick and direct access into the data packets.

Now that we popped open the ASF hood and discovered a textbook lying there, we can ask: What makes ASF a good book?

 

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.