////////////////////////////////////////////////////////////////////////////////
// private
bool LLMediaImplQuickTime::unload()
{
	if ( mMovieHandle )
	{
		StopMovie( mMovieHandle );
		if ( mMovieController )
		{
			MCMovieChanged( mMovieController, mMovieHandle );
		};
	};

	if ( mMovieController )
	{
		MCSetActionFilterWithRefCon( mMovieController, NULL, (long)this );
		DisposeMovieController( mMovieController );
		mMovieController = NULL;
	};

	if ( mMovieHandle )
	{
		SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, nil, ( long )this );
		DisposeMovie ( mMovieHandle );
		mMovieHandle = NULL;
	};

	if ( mGWorldHandle )
	{
		DisposeGWorld( mGWorldHandle );
		mGWorldHandle = NULL;
	};

	return true;
}
Пример #2
0
OSErr QTInfo_SetSelectionToPreview (Movie theMovie, MovieController theMC)
{
    TimeValue			myStart;
    TimeValue			myDuration;
    ComponentResult		myErr = noErr;

    GetMoviePreviewTime(theMovie, &myStart, &myDuration);
    SetMovieSelection(theMovie, myStart, myDuration);

    myErr = MCMovieChanged(theMC, theMovie);

    return((OSErr)myErr);
}
Пример #3
0
OSErr QTInfo_SetPosterToFrame (Movie theMovie, MovieController theMC)
{
    TimeValue			myTime;
    ComponentResult		myErr = noErr;

    // stop the movie from playing
    myErr = MCDoAction(theMC, mcActionPlay, (void *)0L);
    if (myErr != noErr)
        goto bail;

    myTime = GetMovieTime(theMovie, NULL);
    SetMoviePosterTime(theMovie, myTime);

    myErr = MCMovieChanged(theMC, theMovie);

bail:
    return((OSErr)myErr);
}
Пример #4
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);
}
Пример #5
0
Boolean QTApp_HandleMenu (UInt16 theMenuItem)
{
	WindowObject		myWindowObject = NULL;
	ApplicationDataHdl	myAppData = NULL;
	MovieController 	myMC = NULL;
	Movie			 	myMovie = NULL;
	Boolean				myIsHandled = false;			// false => allow caller to process the menu item
	OSErr				myErr = noErr;
	
	myWindowObject = QTFrame_GetWindowObjectFromFrontWindow();
	if (myWindowObject != NULL) {
		myMC = (**myWindowObject).fController;
		myMovie = (**myWindowObject).fMovie;
		myAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(myWindowObject);
	}
	
	switch (theMenuItem) {
	
		case IDM_SET_TEXT:
			// put up a dialog box to get a text string
			QTText_SetSearchText();
			myIsHandled = true;
			break;
				
		case IDM_FIND_TEXT:
			QTText_FindText(myWindowObject, gSearchText);
			myIsHandled = true;
			break;
				
		case IDM_EDIT_TEXT:
			QTText_EditText(myWindowObject);
			myIsHandled = true;
			break;
				
		case IDM_SEARCH_FORWARD:
			gSearchForward = true;	
			myIsHandled = true;
			break;
				
		case IDM_SEARCH_BACKWARD:
			gSearchForward = false;	
			myIsHandled = true;
			break;
				
		case IDM_WRAP_SEARCH:
			gSearchWrap = !gSearchWrap;	
			myIsHandled = true;
			break;
				
		case IDM_USE_CASE:
			gSearchWithCase = !gSearchWithCase;	
			myIsHandled = true;
			break;
				
		case IDM_ADD_TEXT_TRACK:
			{
				// add a text track to the specified movie;
				// for purposes of illustration, we'll add 11 (count 'em!) text strings to the movie,
				// with each string occupying about one-tenth of the movie duration
				
				Track		myTypeTrack = NULL;
				Track		myTextTrack = NULL;
				TimeValue	myMovieDuration = 0;
				TimeValue	mySampleDuration = 0;
				char		*myStrings[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"};
				short		myFrames[11];
				Boolean		isChapter = true;
				
				myTypeTrack = GetMovieIndTrackType(myMovie, 1, VideoMediaType, movieTrackMediaType);
				if (myTypeTrack == NULL)
					break;
					
				// get the duration of the movie and the duration of a single frame;
				// this tells us how many frames fit into one-tenth of the movie
				myMovieDuration = GetMovieDuration(myMovie);
				mySampleDuration = QTUtils_GetFrameDuration(myTypeTrack);
				
				myFrames[0] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[1] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[2] = (myMovieDuration / mySampleDuration) / 10;				
				myFrames[3] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[4] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[5] = (myMovieDuration / mySampleDuration) / 10;				
				myFrames[6] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[7] = (myMovieDuration / mySampleDuration) / 10;
				myFrames[8] = (myMovieDuration / mySampleDuration) / 10;				
				myFrames[9] = ((myMovieDuration / mySampleDuration) / 10) - 1;
				myFrames[10] = 1;
								
				myTextTrack = QTText_AddTextTrack(myMovie, myStrings, myFrames, 11, VideoMediaType, isChapter);
				if (myTextTrack != NULL) {

					MCMovieChanged(myMC, myMovie);

					// stamp the movie as dirty and update our saved data
					(**myWindowObject).fIsDirty = true;
					(**myAppData).fMovieHasText = true;
					(**myAppData).fTextIsChapter = isChapter;
					(**myAppData).fTextTrack = myTextTrack;
					(**myAppData).fTextHandler = GetMediaHandler(GetTrackMedia(myTextTrack));
				}
			}
			myIsHandled = true;
			break;
				
		case IDM_CUT_TEXT_TRACK:
			// remove all existing text tracks from the specified movie
			myErr = QTText_RemoveIndTextTrack(myWindowObject, kAllTextTracks);
			if (myErr == noErr) {
			
				MCMovieChanged(myMC, myMovie);

				// stamp the movie as dirty and update our saved data
				(**myWindowObject).fIsDirty = true;
				(**myAppData).fMovieHasText = false;
				(**myAppData).fTextIsChapter = false;
				(**myAppData).fTextIsHREF = false;
				(**myAppData).fTextTrack = NULL;
				(**myAppData).fTextHandler = NULL;
			}
			myIsHandled = true;
			break;
				
		case IDM_CHAPTER_TRACK:
			(**myAppData).fTextIsChapter = !(**myAppData).fTextIsChapter;
			QTText_SetTextTrackAsChapterTrack(myWindowObject, VideoMediaType, (**myAppData).fTextIsChapter);
			(**myWindowObject).fIsDirty = true;
			myIsHandled = true;
			break;
			
		case IDM_HREF_TRACK:
			(**myAppData).fTextIsHREF = !(**myAppData).fTextIsHREF;
			QTText_SetTextTrackAsHREFTrack((**myAppData).fTextTrack, (**myAppData).fTextIsHREF);
			(**myWindowObject).fIsDirty = true;
			myIsHandled = true;
			break;
			
		default:
			break;
	} // switch (theMenuItem)
	
	return(myIsHandled);
}
///////////////////////////////////////////////////////////////////////////////
// used for stop / loop
void LLMediaImplQuickTime::rewind()
{
	GoToBeginningOfMovie ( mMovieHandle );

	MCMovieChanged( mMovieController, mMovieHandle );
}
////////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplQuickTime::sizeChanged()
{
	if ( ! mMovieHandle )
		return false;

	// sanitize size of movie
	Rect movie_rect;
	setMovieBoxEnhanced( &movie_rect );

	// we need this later
	int width = ( movie_rect.right - movie_rect.left );
	int height = ( movie_rect.bottom - movie_rect.top );

	std::cout << "LLMEDIA> size changed to " << width << " x " << height << std::endl;

	setMediaSize( width, height );

	// media depth won't change
	int depth_bits = getMediaDepth() * 8;

	GWorldPtr old_gworld_handle = mGWorldHandle;

	if (old_gworld_handle)
	{
		GWorldFlags result = UpdateGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, 0 );
		if ( gwFlagErr == result )
		{
			// TODO: unrecoverable?? throw exception?  return something?
			return false;
		}
	}
	else
	{
		OSErr result = NewGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, keepLocal | pixelsLocked );
		if ( noErr != result )
		{
			// ATODO: unrecoverable??  throw exception?  return something?
			return false;
		}

		// clear memory in GWorld to avoid random screen visual fuzz from uninitialized texture data
		if ( mGWorldHandle )
		{
			PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
			unsigned char* ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
			memset( ptr, 0x00, height * QTGetPixMapHandleRowBytes( pix_map_handle ) );
		}
	}

	// point movie at GWorld if it's new
	if ( mMovieHandle && ! old_gworld_handle )
	{
		SetMovieGWorld( mMovieHandle, mGWorldHandle, GetGWorldDevice ( mGWorldHandle ) );
	}

	// update movie controller
	if ( mMovieController )
	{
		MCSetControllerPort( mMovieController, mGWorldHandle );
		MCPositionController( mMovieController, &movie_rect, &movie_rect,
							  mcTopLeftMovie | mcPositionDontInvalidate );
		MCMovieChanged( mMovieController, mMovieHandle );
	}

	// Emit event with size change so the calling app knows about it too
	LLMediaEvent event( this );
	mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );

	return true;
}