
The following sample code does the trick:
Media GetFirstVideoMedia(Movie coolMovie, long *trackIndex)
{
Track coolTrack = nil;
Media coolMedia = nil;
long numTracks;
OSType mediaType;
numTracks = GetMovieTrackCount(coolMovie);
for (*trackIndex=1; *trackIndex<=numTracks; (*trackIndex)++) {
coolTrack = GetMovieIndTrack(coolMovie, *trackIndex);
if (coolTrack) coolMedia = GetTrackMedia(coolTrack);
if (coolMedia) GetMediaHandlerDescription(coolMedia,
&mediaType, nil, nil);
if (mediaType = VideoMediaType) return coolMedia;
}
*trackIndex = 0; // trackIndex can't be 0
return nil; // went through all tracks and no video
}
short GetFirstVideoTrackPixelDepth(Movie coolMovie)
{
SampleDescriptionHandle imageDescH =
(SampleDescriptionHandle)NewHandle(sizeof(Handle));
long trackIndex = 0;
Media coolMedia = nil;
coolMedia = GetFirstVideoMedia(coolMovie, &trackIndex);
if (!trackIndex || !coolMedia) return -1; // we need both
GetMediaSampleDescription(coolMedia, trackIndex, imageDescH);
return (*(ImageDescriptionHandle)imageDescH)->depth;
}
Note that QuickTime 2.0 has a new function called GetMovieIndTrackType that
does most of the work described in the sample. GetMovieIndTrackType lets you
search for all of a movie's tracks that share a given media type or media
characteristic. See the QuickTime 2.0 SDK documentation for more details.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help