Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
TLevelReader3gp::TLevelReader3gp(const TFilePath &path)
	: TLevelReader(path), m_IOError(QTNoError), m_track(0), m_movie(0), m_depth(0)
//                ,m_timeScale(0)
{

	FSSpec fspec;
	QDErr err;
	Boolean dataRefWasChanged;
	if (QuickTimeStuff::instance()->getStatus() != noErr) {
		m_IOError = QTNotInstalled;
		return;
	}

	const char *pStr = toString(m_path.getWideString()).c_str();
	FSMakeFSSpec(0, 0, (const unsigned char *)pStr, &fspec);
	getFSSpecFromPosixPath(pStr, &fspec, false);
	pStr = 0;

	if ((err = OpenMovieFile(&fspec, &m_refNum, fsRdPerm))) {
		m_IOError = QTUnableToOpenFile;
		return;
	}

	m_resId = 0;
	Str255 name;
	err = NewMovieFromFile(&m_movie, m_refNum, &m_resId,
						   name, fsRdPerm, &dataRefWasChanged);

	int numTracks = GetMovieTrackCount(m_movie);
	assert(numTracks == 1 || numTracks == 2);

	m_track = GetMovieIndTrackType(m_movie, 1, VideoMediaType, movieTrackMediaType);

	//m_track=GetMovieTrack(m_movie,numTracks);

	ImageDescriptionHandle imageH;
	imageH = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));
	TINT32 index = 1;
	Media theMedia = GetTrackMedia(m_track);

	GetMediaSampleDescription(theMedia, index, (SampleDescriptionHandle)imageH);
	ImageDescriptionPtr imagePtr = *imageH;
	m_lx = imagePtr->width;
	m_ly = imagePtr->height;
	m_depth = imagePtr->depth;
	m_info = new TImageInfo();
	m_info->m_lx = m_lx;
	m_info->m_ly = m_ly;
	Tiio::MovWriterProperties *prop = new Tiio::MovWriterProperties();
	m_info->m_properties = prop;

	DisposeHandle((Handle)imageH);

	m_info->m_frameRate = GetMediaTimeScale(theMedia);
}
Exemplo n.º 5
0
	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 );
	}
Exemplo n.º 6
0
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;
    }