DTSQTUtilities.h

/*
    File:       DTSQTUtilities.h
 
    Contains:   QuickTime functions, header file definitions.
 
    Written by:     
 
    Copyright:  Copyright © 1994-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                7/28/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
// Define that this file should only be parsed once, most dev environments know of pragma once.
#pragma once
 
 
// INCLUDES
#include <Gestalt.h>
#include <GestaltEqu.h>
#include <TextUtils.h>
#include <Errors.h>
#include <SegLoad.h>
#include <Printing.h>
#include <Sound.h>
 
#include <Movies.h>
#include "MoviesFormat.h"
#include <Components.h>
#include <QuickTimeComponents.h>
#include <FixMath.h>
 
#include <stdio.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
// Window size constants.
enum eQTUWindowSize {
    kNormalMovieSize = 1L,
    kHalfMovieSize,
    kDoubleMovieSize
};
 
 
// Rate constant values, Fwd = forward, Bwd = backwards.
enum eQTUMovieRates {   kNoSpeed = 0x00000000,  kFwdSpeed = 0x00010000,
                                        kFwdDoubleSpeed = 0x00020000, kFwdTripleSpeed = 0x00030000, 
                                        kFwdQuadSpeed = 0x00040000, kFwdHalfSpeed = 0x00008000, 
                                        kFwdQuarterSpeed = 0x00004000, kFwdEightspeed = 0x00002000, 
                                        kBwdSpeed = 0xFFFF0000, kBwdDoubleSpeed = 0xFFFE0000, 
                                        kBwdHalfSpeed = 0xFFFF8000 };
 
 
// Constants used for QTUPrintMoviePICT.
enum eQTUPICTPrinting { kPrintFrame = 1, kPrintPoster };
 
 
// MACROS
#if DEBUG
static char gDebugString[256];
 
#define DebugAssert(condition)                                                                      \
        if (condition)      NULL;                                                                           \
    else                                                                                                            \
    {                                                                                                               \
        sprintf(gDebugString,"File: %s, Line: %d", __FILE__, __LINE__);         \
        DebugStr(c2pstr(gDebugString));                                                         \
    }
#else
#define DebugAssert(condition)      NULL
#endif
 
#define MBSTARTTIMER() DebugStr("\pStart! `;mc starttime @ticks;g")
#define MBSTOPTIMER()   DebugStr("\pElapsed time in ticks: '; @ticks - starttime")
 
 
// ReturnIfError is a simple macro around the frequently written code line doing the same (see below)
#define ReturnIfError(theError)  DebugAssert(theError == noErr);  \
                                                    if(theError != noErr) return theError
 
 
// FUNCTION PROTOTYPES
 
 
 
// MOVIE TOOLBOX FUNCTIONS
pascal Boolean          QTUIsQuickTimeInstalled(void);                                                                                      // Check if QT is present.
 
#ifdef powerc
pascal Boolean          QTUIsQuickTimeCFMInstalled(void);                                                                               // Check if QT CFM library is present.
#endif // powerc
 
pascal long                 QTUGetQTVersion();                                                                                                      // Get QT version number.
pascal Boolean          QTUAreQuickTimeMusicInstrumentsPresent(void);                                                           // Test if Musical Instrumentscomponent is present.
 
pascal OSErr                QTUPrerollMovie(Movie theMovie);                                                                                // Preroll Movies before Playback.
 
pascal Boolean          QTUFileFilter(ParmBlkPtr theParamBlock);
pascal Movie            QTUGetMovie(FSSpec *theFSSpec, short *theRefNum, short *theResID);                      // Return a Movie from a file with the movie.
pascal OSErr            QTUSimpleGetMovie(Movie *theMovie);                                                                     // Simpler version of querying for a movie and return it.
pascal OSErr            QTUSaveMovie(Movie theMovie);                                                                                   // Save the movie (standard dialog box).
pascal OSErr                QTUFlattenMovieFile(Movie theMovie, FSSpec *theFile);                                               // Takes a movie and a file and flattens the movie into the file.
pascal OSErr                QTUPrintMoviePICT(Movie theMovie, short x, short y, long PICTUsed);                         // Print the movie poster.
pascal OSErr                QTUCalculateMovieMemorySize(Movie theMovie, long *theSize);                                 // Return the size of the movie in memory.
pascal OSErr                QTULoadWholeMovieToRAM(Movie theMovie);                                                             // Load the whole movie to RAM.
pascal OSErr                QTUPlayMovieSound(Movie theMovie);                                                                          // Play the movie sound track using the snd resource.
pascal OSErr                QTUDrawVideoFrameAtTime(Movie theMovie, TimeValue atTime);                                  // Draw a movie frame at specified time.
pascal OSErr            QTUScrollToNextVideoSample(Movie theMovie, TimeValue fromTimePoint, 
                                                                                TimeValue toTimePoint);                                             // Do a visible scroll from one video frame to another.
 
pascal OSErr            QTUGetStartPointOfFirstVideoSample(Movie theMovie,TimeValue *startPoint);               // Get time value of first sample in the movie.
 
// TRACK & MEDIA
pascal Boolean          QTUMediaTypeInTrack(Movie theMovie, OSType theMediaType);                                   // Check if a Media type is present in a track of a movie.
pascal OSErr                QTUGetTrackRect(Track theTrack, Rect *theRect);                                                     // Get the track rect of a possible video track
pascal short                QTUGetVideoMediaPixelDepth(Media theMedia, short index);                                            // Get the pixel depth of a video media.
pascal long             QTUCountMediaSamples(Movie theMovie, OSType theMediaType);                                  // Count frames in a movie based on defined media.
pascal TimeValue        QTUGetDurationOfFirstMovieSample(Movie theMovie, OSType theMediaType)   ;               // Get duration of first sample in the track
pascal OSErr            QTUCountMaxSoundRate(Movie theMovie,long *theMaxSoundRate);                             // Return max sound rate from a sound track in a movie.
pascal long                 QTUGetMovieFrameCount(Movie theMovie, long theFrameRate);                                       // Return frames based on frame rate and movie.
pascal OSErr            QTUCopySoundTracks(Movie theSrcMovie, Movie theDestMovie);                                  // Copy sound tracks from source movie to destination movie
 
 
// IMAGE COMPRESSION MANAGER
Boolean                     QTUHasCodecLossLessQuality(CodecType theCodec, short thePixelDepth);                        // Test if a codec has lossless spatial compression.
 
 
// MOVIE CONTROLLER FUNCTIONS
pascal OSErr            QTUPlayMovieWithMC(MovieController mc);                                                                 // Play the movie using the movie controllers.
pascal OSErr            QTUDoIgnoreMCDrags(MovieController  mc);                                                                    // ignore Drag-and-Drop functionality.
pascal Boolean          QTUPointInMC(MovieController mc, WindowRef theWindow, Point where);                 // Check if a point is inside the movie controller rect.
pascal OSErr            QTUSelectAllMovie(MovieController mc);                                                                      // Select the whole time frame from a movie with the mc.
pascal Boolean          QTUResizeMCActionFilter(MovieController mc, short action, void *params, long refCon);
pascal OSErr            QTUResizeMCWindow(MovieController mc, WindowPtr theWindow, long theMovieSize,  Rect originalSize);
 
pascal OSErr                QTUMCSetMovieRate(MovieController mc, long theRate);                                                // Set movie rate using movie controller.
 
 
// SEQUENCE GRABBER FUNCTIONS
pascal SeqGrabComponent QTUCreateSequenceGrabber(WindowPtr theWindow);                                              // Create a sequence grabber instance.
pascal OSErr                    QTUCreateSGGrabChannels(SeqGrabComponent s, const Rect *theBounds, 
                                            long theUsage, SGChannel *theVideoChannel, SGChannel *theSoundChannel);         // Create sequence grabber channels.
pascal Boolean                  QTUDoesVDIGReceiveVideo(SeqGrabComponent s);                                                    // Do we have live incoming video?
pascal OSErr                    QTUChangeSGWindowSize(SeqGrabComponent s,SGChannel videoChannel,                // Change the window size of Sequence Grabber window
                                            WindowPtr theWindow, long width, long height);
 
// COMPONENT FUNCTIONS
pascal Component        QTUDoGetComponent(OSType theComponentType, OSType theSpecificComponent);
pascal Boolean          QTUHasComponentType(OSType theComponentType, OSType theSpecificComponent);
 
 
#ifdef __cplusplus
}
#endif