Streaming movies come in two forms: server movies and client movies.
You create a server movie that can be streamed over RTP by adding hint tracks. Hint tracks tell the server how to packetize the movie. You add hint tracks by exporting a movie as a hinted movie using QuickTime’s standard movie export mechanism.
You create a client movie that includes streaming content by adding one or more streaming tracks. A streaming track tells the client where to get the streaming media. In its simplest form, a client movie consists of just a streaming track containing the URL of a movie on a server. A client movie can contain multiple streaming tracks.
A client movie can contain non-streaming tracks with local media content as well as streaming tracks. Streaming tracks can be composited with local tracks. For example, a streaming track could be used as the source for an effect track that is local to the client movie.
You create a streaming movie for an RTP server by adding hint tracks to an existing movie. You do this by calling ConvertMovieToFile, which invokes a movie exporter component. This displays a standard dialog box that lets the user specify “Export Movie to Hinted Movie,” set the parameters for hinting the movie, select compressors, and specify a file name and directory for the hinted movie (see Figure 2-5).
The hinting is performed by media packetizer components. QuickTime selects an appropriate media packetizer for each track and routes each packetizer’s output through an Apple-provided packet builder to create a hint track. One hint track is created for each streamable track in the movie.
Hint tracks are quite small compared with audio or video tracks. A movie that contains hint tracks can be played from a local disk or streamed over HTTP, like any other QuickTime movie. The hint tracks are only used when streaming the movie over RTP.
As long as your application supports movie exporter components, it should be able to create hinted movies. If you want to bypass the standard dialog for user input, selecting “Export Movie to Hinted Movie” programmatically, you will need to modify your code by adding the appropriate selectors.
A hinted movie does not need to be self-contained (flattened). It can reference sample media contained in other files. But observe these cautions:
Use file names that are transportable between the system that the movies are created on and the RTP server.
The relative path from the movie file to the data files must not change after the movie is saved.
The simplest way to ensure both of these is to use only lowercase letters in file names, without spaces, and to keep the media data files and the movie file in the same folder or directory.
Hint tracks should be created as the last step in making a streaming movie. Any editing of the movie that adds or deletes sample data, including the flattening of a movie with edit lists, invalidates the hint track. If your application edits a hinted movie in a way that invalidates the hint tracks, delete the hint tracks and re-export the movie.
Hint tracks are marked as inactive so they do not interfere with local playback. If you call FlattenMovie with the flattenActiveTracksOnly flag, the hint tracks are deleted from the flattened movie.
This release of QuickTime supports RTP streaming of video, audio, text (including HREF Tracks), and MIDI. If your movie contains other media types, or features that rely on track references, you cannot currently export the entire movie to a hinted movie. You can either stream such movies over HTTP, or you can put some of the tracks into a client movie and stream the rest, as described in the section “Compositing Streaming and Non-Streaming Tracks.”
You incorporate streaming content in a client movie by adding at least one streaming track. The simplest form of client movie has only one track: a streaming track with the URL of a movie on a server.
A streaming track has a media type of kQTSStreamMediaType ('strm') and contains a single media sample: typically either an RTSP URL of a streaming movie or the SDP text describing a multicast.
The code example in Listing 2-1 shows how to create a streaming track, insert a sample description, and add a URL media sample.
Listing 2-1 Creating a streaming track with an RTSP URL
Handle dataRef; |
long dataLength; |
char url[] = "rtsp://myserver.bigcompany.com/mystreaming.mov"; |
dataRef = NewHandle(strlen(url) + 1); |
BlockMoveData(url, *urlDataRef, strlen(url) + 1); |
dataLength = GetHandleSize(dataRef); |
newMedia = NewTrackMedia(newTrack, kQTSStreamMediaType, |
kQTSMediaTimeScale, handleDataRef, HandleDataHandlerSubType); |
err = BeginMediaEdits(newMedia); |
qtsDesc = |
(QTSSampleDescriptionHandle)NewHandleClear(sizeof(QTSSampleDescription)); |
(**qtsDesc).descSize = sizeof(QTSSampleDescription); |
(**qtsDesc).dataFormat = 'rtsp'; |
(**qtsDesc).dataRefIndex = 1; |
(**qtsDesc).version = kQTSSampleDescriptionVersion; |
duration = kQTSInfiniteDuration; |
err = AddMediaSample(newMedia, dataRef, 0, dataLength, duration, |
(SampleDescriptionHandle)qtsDesc, 1, 0, nil); |
err = EndMediaEdits(newMedia); |
err = InsertMediaIntoTrack(newTrack, 0, 0, GetMediaDuration(newMedia), |
kQTSNormalForwardRate); |
A streaming track in a client movie can point to a server movie containing audio, video, text, and MIDI tracks. Any or all of the tracks in the server movie can appear as a single streaming track in the client movie.
To sum up:
A client-side streaming movie contains at least one streaming 'strm' track.
A streaming track contains a single media sample, typically an RTSP URL that points to streaming content. It can also contain SDP information for a multicast.
The streaming content can be a live stream or a stored movie on a streaming server.
The movie on the server can contain any number of tracks; multiple tracks in the server movie may be represented in the client movie as a single streaming track.
Last updated: 2006-01-10