Boolean QTInfo_MovieHasPoster (Movie theMovie) { long myCount = 0L; long myIndex = 0L; Track myTrack = NULL; long myUsage = 0L; Boolean myHasPoster = true; // make sure that some track is used in the movie poster myCount = GetMovieTrackCount(theMovie); for (myIndex = 1; myIndex <= myCount; myIndex++) { myTrack = GetMovieIndTrack(theMovie, myIndex); if (myTrack == NULL) continue; myUsage = GetTrackUsage(myTrack); if (myUsage & trackUsageInPoster) break; // we found a track with the trackUsageInPoster flag set; break out of the loop } if (myIndex > myCount) myHasPoster = false; // we went thru all tracks without finding one with a poster usage return(myHasPoster); }
Boolean QTInfo_MovieHasPreview (Movie theMovie) { TimeValue myStart; TimeValue myDuration; long myCount = 0L; long myIndex = 0L; Track myTrack = NULL; long myUsage = 0L; Boolean myHasPreview = false; // see if the movie has a positive preview duration GetMoviePreviewTime(theMovie, &myStart, &myDuration); if (myDuration > 0) myHasPreview = true; // make sure that some track is used in the movie preview myCount = GetMovieTrackCount(theMovie); for (myIndex = 1; myIndex <= myCount; myIndex++) { myTrack = GetMovieIndTrack(theMovie, myIndex); if (myTrack == NULL) continue; myUsage = GetTrackUsage(myTrack); if (myUsage & trackUsageInPreview) break; // we found a track with the trackUsageInPreview flag set; break out of the loop } if (myIndex > myCount) myHasPreview = false; // we went thru all tracks without finding one with a preview usage return(myHasPreview); }
Boolean QTDR_IsMovieSelfContained (Movie theMovie) { long myTrackCount = 0L; long myTrackIndex = 0L; short myMediaRefCount = 0L; short myMediaRefIndex = 0L; Media myMedia = NULL; long myAttrs = 0L; OSErr myErr = noErr; myTrackCount = GetMovieTrackCount(theMovie); for (myTrackIndex = 1; myTrackIndex <= myTrackCount; myTrackIndex++) { myMedia = GetTrackMedia(GetMovieIndTrack(theMovie, myTrackIndex)); if (myMedia != NULL) { myErr = GetMediaDataRefCount(myMedia, &myMediaRefCount); if (myErr == noErr) { for (myMediaRefIndex = 1; myMediaRefIndex <= myMediaRefCount; myMediaRefIndex++) { myErr = GetMediaDataRef(myMedia, myMediaRefIndex, NULL, NULL, &myAttrs); if (myErr == noErr) { if (!(myAttrs & dataRefSelfReference)) return(false); } } } } } return(true); }
/* call-seq: load(movie, index) Loads a QuickTime track from a given movie. This is done automatically when calling movie.tracks. */ static VALUE track_load(VALUE obj, VALUE movie_obj, VALUE index_obj) { RTRACK(obj)->track = GetMovieIndTrack(MOVIE(movie_obj), NUM2INT(index_obj)); if (!RTRACK(obj)->track) rb_raise(eQuickTime, "Unable to fetch track for movie at index %d", NUM2INT(index_obj)); return obj; }
void MovieGlHap::allocateVisualContext() { // Load HAP Movie if( HapQTQuickTimeMovieHasHapTrackPlayable( getObj()->mMovie ) ) { // QT Visual Context attributes OSStatus err = noErr; QTVisualContextRef * visualContext = (QTVisualContextRef*)&getObj()->mVisualContext; CFDictionaryRef pixelBufferOptions = HapQTCreateCVPixelBufferOptionsDictionary(); const CFStringRef keys[] = { kQTVisualContextPixelBufferAttributesKey }; CFDictionaryRef visualContextOptions = ::CFDictionaryCreate(kCFAllocatorDefault, (const void**)&keys, (const void**)&pixelBufferOptions, sizeof(keys)/sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); err = QTPixelBufferContextCreate( kCFAllocatorDefault, visualContextOptions, visualContext ); ::CFRelease( pixelBufferOptions ); ::CFRelease( visualContextOptions ); if( err != noErr ) { CI_LOG_E( "HAP ERROR :: " << err << " couldnt create visual context." ); return; } // Set the movie's visual context err = SetMovieVisualContext( getObj()->mMovie, *visualContext ); if( err != noErr ) { CI_LOG_E( "HAP ERROR :: " << err << " SetMovieVisualContext." ); return; } } // Get codec name for (long i = 1; i <= GetMovieTrackCount(getObj()->mMovie); i++) { Track track = GetMovieIndTrack(getObj()->mMovie, i); Media media = GetTrackMedia(track); OSType mediaType; GetMediaHandlerDescription(media, &mediaType, NULL, NULL); if (mediaType == VideoMediaType) { // Get the codec-type of this track ImageDescriptionHandle imageDescription = (ImageDescriptionHandle)NewHandle(0); // GetMediaSampleDescription will resize it GetMediaSampleDescription(media, 1, (SampleDescriptionHandle)imageDescription); OSType codecType = (*imageDescription)->cType; DisposeHandle((Handle)imageDescription); switch (codecType) { case 'Hap1': mCodec = Codec::HAP; break; case 'Hap5': mCodec = Codec::HAP_A; break; case 'HapY': mCodec = Codec::HAP_Q; break; default: mCodec = Codec::UNSUPPORTED; break; } } } // Set framerate callback this->setNewFrameCallback( updateMovieFPS, (void*)this ); }
OSErr QTInfo_ClearPreview (Movie theMovie, MovieController theMC) { long myCount = 0L; long myIndex = 0L; Track myTrack = NULL; long myUsage = 0L; ComponentResult myErr = noErr; // set the movie preview start time and duration to 0 SetMoviePreviewTime(theMovie, 0, 0); // remove all tracks that are used *only* in the movie preview myCount = GetMovieTrackCount(theMovie); for (myIndex = myCount; myIndex >= 1; myIndex--) { myTrack = GetMovieIndTrack(theMovie, myIndex); if (myTrack == NULL) continue; myUsage = GetTrackUsage(myTrack); myUsage &= trackUsageInMovie | trackUsageInPreview | trackUsageInPoster; if (myUsage == trackUsageInPreview) DisposeMovieTrack(myTrack); } // add trackUsageInPreview to any remaining tracks that are in the movie // (so that subsequently setting the preview to a selection will include // these tracks) myCount = GetMovieTrackCount(theMovie); for (myIndex = 1; myIndex <= myCount; myIndex++) { myTrack = GetMovieIndTrack(theMovie, myIndex); if (myTrack == NULL) continue; myUsage = GetTrackUsage(myTrack); if (myUsage & trackUsageInMovie) SetTrackUsage(myTrack, myUsage | trackUsageInPreview); } myErr = MCMovieChanged(theMC, theMovie); return((OSErr)myErr); }
short QTTarg_GetLowestLayerInMovie (Movie theMovie) { long myCount = 0; long myIndex; short myLayer = 0; short myMinLayer = kMaxLayerNumber; myCount = GetMovieTrackCount(theMovie); for (myIndex = 1; myIndex <= myCount; myIndex++) { myLayer = GetTrackLayer(GetMovieIndTrack(theMovie, myIndex)); if (myLayer < myMinLayer) myMinLayer = myLayer; } return(myMinLayer); }
QTAudioReader (InputStream* const input_, const int trackNum_) : AudioFormatReader (input_, TRANS (quickTimeFormatName)), ok (false), movie (0), trackNum (trackNum_), lastSampleRead (0), lastThreadId (0), extractor (0), dataHandle (0) { JUCE_AUTORELEASEPOOL bufferList.calloc (256, 1); #if JUCE_WINDOWS if (InitializeQTML (0) != noErr) return; #endif if (EnterMovies() != noErr) return; bool opened = juce_OpenQuickTimeMovieFromStream (input_, movie, dataHandle); if (! opened) return; { const int numTracks = GetMovieTrackCount (movie); int trackCount = 0; for (int i = 1; i <= numTracks; ++i) { track = GetMovieIndTrack (movie, i); media = GetTrackMedia (track); OSType mediaType; GetMediaHandlerDescription (media, &mediaType, 0, 0); if (mediaType == SoundMediaType && trackCount++ == trackNum_) { ok = true; break; } } } if (! ok) return; ok = false; lengthInSamples = GetMediaDecodeDuration (media); usesFloatingPointData = false; samplesPerFrame = (int) (GetMediaDecodeDuration (media) / GetMediaSampleCount (media)); trackUnitsPerFrame = GetMovieTimeScale (movie) * samplesPerFrame / GetMediaTimeScale (media); OSStatus err = MovieAudioExtractionBegin (movie, 0, &extractor); unsigned long output_layout_size; err = MovieAudioExtractionGetPropertyInfo (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, 0, &output_layout_size, 0); if (err != noErr) return; HeapBlock <AudioChannelLayout> qt_audio_channel_layout; qt_audio_channel_layout.calloc (output_layout_size, 1); err = MovieAudioExtractionGetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, output_layout_size, qt_audio_channel_layout, 0); qt_audio_channel_layout[0].mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, output_layout_size, qt_audio_channel_layout); err = MovieAudioExtractionGetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof (inputStreamDesc), &inputStreamDesc, 0); if (err != noErr) return; inputStreamDesc.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian; inputStreamDesc.mBitsPerChannel = sizeof (SInt16) * 8; inputStreamDesc.mChannelsPerFrame = jmin ((UInt32) 2, inputStreamDesc.mChannelsPerFrame); inputStreamDesc.mBytesPerFrame = sizeof (SInt16) * inputStreamDesc.mChannelsPerFrame; inputStreamDesc.mBytesPerPacket = inputStreamDesc.mBytesPerFrame; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof (inputStreamDesc), &inputStreamDesc); if (err != noErr) return; Boolean allChannelsDiscrete = false; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Movie, kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete, sizeof (allChannelsDiscrete), &allChannelsDiscrete); if (err != noErr) return; bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); bufferList->mBuffers[0].mData = dataBuffer; sampleRate = inputStreamDesc.mSampleRate; bitsPerSample = 16; numChannels = inputStreamDesc.mChannelsPerFrame; detachThread(); ok = true; }