Streaming
Contents
Overview
Streaming involves sending movies from a server
to a client over a network such as the Internet. The server breaks the
movie into packets that can be sent over the network. At the receiving
end, the packets are reassembled by the client and the movie is played
as it comes in.
QuickTime movies can be real-time streamed using:
- RTP (Realtime Transport Protocol)
Streaming is different from Fast-Start download in that the client plays
the movie as it comes in over the network, rather than downloading the
entire movie and playing it as it is being downloaded. A streaming movie
is never actually downloaded; its packets are played as they come in,
then discarded.
QuickTime supports RTP streaming of video, audio, text, and MIDI.
RTP is used for real-time streaming. Movie packets are sent in real time,
so that a one-minute movie is sent over the network in one minute. The
packets are time-stamped, so they can be displayed in time-synchronized
order. Because packets are sent in real time, RTP streaming works with
live content in addition to pre-recorded movies and can even carry a mixture
of the two. RTP can be used for live transmission and multicast, this
allows the user to view long movies or continuous transmissions without
having to store more than a few seconds of data locally. Using RTP transmission
under RTSP control, a user can skip to any point in a movie on a server
without downloading the intervening material.
RTP streams can be incorporated in a movie using streaming tracks.
A streaming track is a track in a QuickTime movie that contains the URL
of the streaming content. A QuickTime movie that contains streaming tracks
can also include non-streaming tracks whose media exist on the client's
computer. This allows a live transmission, or data stored on the Internet,
to be incorporated into a movie along with material stored on locally
or distributed over CD-ROM.
RTP uses UDP protocol, which doesn't attempt to retransmit lost packets.
This allows multicasts as well as live streams, both cases where retransmission
would not be practical.
Application
Considerations
An application receives streaming content by opening a movie and playing
it. In general, opening a streaming movie is like opening any QuickTime
movie. You can open a streaming movie by opening a movie file that contains
streaming tracks, a session description file (.SDP) or a URL.
If you open a streaming movie from a URL or an SDP file, the Movie Toolbox
will call the appropriate movie importer. If you open a movie file that
contains streaming tracks, stream importers will be called.
Applications that can already play QuickTime movies need to take the
following points into account to reliably support real-time streaming
movies:
- Open movies with high-level Movie Toolbox calls or a movie importer.
- Do not assume that the track structure of the movie you play reflects
the track structure of the original movie; a streaming track can contain
sound, video, text, MIDI, or all of these.
- Use a movie controller to play the movie, or make sure to Pre-Preroll
in addition to Prerolling a movie to set up any streams before playing
the movie.
- Display status messages returned by the movie controller.
- Be prepared to deal with network errors when your application plays
a movie.
- Be prepared for movie characteristics to change dynamically; the height,
width, duration, and whether or not the movie has audio or video can
all change as the movie plays.
- Do not assume that the movie will begin immediately.
Track
Structure
Unlike other QuickTime movies, streaming movies consist of two distinct
movie filesÑone on the server and the other on the client machineÑoften
with different track structures. You sometimes need to distinguish between
the server movie and the client movie. The media of each track in the
server movie is transmitted as a separate RTP stream. On the client side,
multiple RTP streams can be combined into a single streaming track.
If you open a movie from a URL, for example, the movie importer may create
a client movie that contains only a streaming ('strm') track. Unlike most
other QuickTime track types, a streaming track can contain multiple media
streams of different types. A streaming track in a client movie may contain
the URL of a server movie with audio, video, text, or MIDI tracks.

The client movie file never contains audio or video media from the server
movie; they are displayed and discarded. If a client movie is saved, the
saved movie contains information such as the URL of the server movie and
the currently displayed movie time. The client movie can also contain
local tracks and local media, but the media samples in the server movie
remain on the server except when playing.
Preroll
and Pre-Preroll
Before any movie is played, QuickTime needs to allocate buffers and open
appropriate media handlers. This process is called prerolling the movie.
Before a streaming movie can be played, additional steps need to be taken,
such as establishing RTP streams between the client and the server. This
setup process is called pre-prerolling. Pre-prerolling is performed automatically
when a streaming movie is played using a movie controller. If your application
uses movie controllers to play movies, you do not need to take any special
steps to pre-preroll a streaming movie.
If you are playing movies using the Movie Toolbox (without a Movie Controller),
you will need to pre-preroll the movie to set up the network connections
for a streaming movie before you can preroll or play the movie. Pre-prerolling
does nothing unless a movie contains streaming content, so it's safe to
do for all movies.
Pre-prerolling can be done either synchronously or asynchronously, depending
on whether you specify a completion procedure. If called asynchronously,
control will return almost immediately even if the movie contains streaming
content. This allows your application to perform other tasks while awaiting
the completion of the pre-prerolling. You will need to periodically to
grant time to the Movie Toolbox for the task of pre-prerolling when using
it asynchronously. When pre-prerolling is finished, your completion procedure
will be called. In the simplest case, the completion procedure will want
to preroll and start the movie.
Reacting
to Changes in Movie Characteristics
One feature of streamed movies is that their characteristics may change
dynamically during playback. For example, when you open a movie from a
URL you may not know the actual height and width of the movie, its duration
or how many streams it contains. You also might not know if the movie
has a sound track, or whether it is an audio-only movie.
QuickTime will assign default values to these characteristics if they
are unknown.
QuickTime can notify your application when the movie characteristics
become known or are changed and in most cases, your application will want
to reflect such changes. Changes in the movie size and other movie characteristics
are announced and can be handled in a action filter procedure.
Duration
Changes
The duration of a streaming movie or a streaming track may not be initially
known. A track or movie whose duration is not known is assigned an indefinite
duration: 0x7FFFFFF
. If you do not treat this as a special case, a streaming movie will appear
to your application as a very long movie. Once the pre-preroll process
is complete, QuickTime should know the actual duration of the streams.
Duration changes are also handled in the application's action filter procedure.
If the movie contains live content, it may not have a specific duration.
In this case, the duration remains indefinite: 0x7FFFFFF
. You might want to set a timeout in your code that detects the fact that
QuickTime has not adjusted the duration from 0x7FFFFFF
after a few seconds of movie play and use such a timeout to notify the
viewer that the movie is a live broadcast.
Sound
and Video Changes
Whether a streaming movie has sound or is sound only (no video) may not
be initially known or may change dynamically. If you have an action filter
procedure and set the movie hints, your applications filter procedure
will be called when the sound or video characteristics change.
Other
Playback Considerations
Streaming movies only play back at a rate of 1. Other playback rates,
such as playing backward, are not supported when streaming in real-time.
References
Streaming
Customizing
Movie Controllers
|