//
//  BXUQuickTimeMovie.h
//  BXQuickTime
//
//  Created by Michael Ehrmann on 24.04.06.
//  Copyright 2006 Boinx Software. All rights reserved.
//

#if !__LP64__
#import <QuickTime/QuickTime.h>

@class QTMovie;

@interface BXUQuickTimeMovie : NSObject {

}

+ (BOOL)isMovieFile:(NSString*)filePath;

#pragma mark Wrappers for UQuickTimeMovie

+ (int) getTrackCount:(Movie)inMovie;
+ (Track) getFirstTrackOfMovie:(Movie)inMovie forMediaType:(OSType)inMediaType;
+ (OSErr) createNewTrackInMovie:(Movie)inMovie mediaType:(OSType)inMediaType width:(int)inWidth height:(int)inHeight layer:(int)inLayer timeScale:(TimeScale)inTimeScale track:(Track*)outTrack media:(Media*)outMedia;
+ (OSErr) createNewAudioTrackInMovie:(Movie)inMovie timeScale:(TimeScale)inTimeScale track:(Track*)outTrack media:(Media*)outMedia;

#pragma mark Timecode Utilitys

+ (NSString*) timeCodeStringForTimeCode:(TimeCodeTime)timeCode withFrameRate:(int)frameRate addFrame:(BOOL)addFrame addHour:(BOOL)addHour;
+ (NSString*) timeCodeStringForFrame:(int)frame withFrameRate:(int)frameRate addFrame:(BOOL)addFrame addHour:(BOOL)addHour;
+ (long) timeCodeToFrame:(TimeCodeTime)theTimeCode withFrameRate:(int)theFrameRate;
+ (TimeCodeTime) frameToTimeCode:(long)frame withFrameRate:(int)theFrameRate;
+ (OSErr) timeCodeStringToTCT:(NSString*)theTimeCodeString withFrameRate:(int)theFrameRate resultTimeCode:(TimeCodeTime*)resultTimeCodePtr resultFrameNumber:(long*)resultFrameNumber;
+ (OSErr) addTimeCode:(TimeCodeTime)theTimeCode toMovie:(Movie)movieIn withFrameRate:(int)frameRateIn;
+ (TimeCodeTime) getStartTimeCodeOfMovie: (Movie) movieIn;
+ (MediaHandler) getTimeCodeMediaHandlerOfMovie: (Movie) movieIn;
+ (BOOL) hasMovieTimeCodeTrack:(Movie) movieIn;
+ (BOOL) removeTimeCodeTrackOfMovie:(Movie) movieIn;


#pragma mark Movie User Data

+ (BOOL) existsUserDataForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;

#pragma mark   - C Standard Data Types

+ (BOOL) getUserDataBOOLForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (OSErr) setUserDataBOOL:(BOOL)theInput forKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (int) getUserDataIntForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (OSErr) setUserDataInt:(int)theInput forKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (float) getUserDataFloatForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (OSErr) setUserDataFloat:(float)theInput forKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;

#pragma mark   - Data Blobs

+ (OSErr) setMovieUserDictionary:(NSDictionary*)theDictionary forKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (NSDictionary*) getMovieUserDictionaryForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (OSErr) setMovieUserData:(NSData*)theData forKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;
+ (NSData*) getMovieUserDataForKey:(OSType)theUserDataKey inMovie:(Movie)theMovie;

#pragma mark  - other User Data

+ (short) getLoopModeOfMovie:(Movie)theMovie;

#pragma mark Movie Controll

+ (void)gotoNextFrame:(Movie)movie;
+ (void)gotoPreviousFrame:(Movie)movie;

#pragma mark Movies

+ (Movie) createMovieFromPath:(NSString*)movieFilePath WithPermissions:(SInt8)filePermissions outFSSPec:(FSSpec*)resultFSSpec outResRefNum:(short*)resultResRefNum outOSError:(OSErr*)resultErr;
+ (Movie) createMovieFromFSSpec:(FSSpec)movieFileSpec WithPermissions:(SInt8)filePermissions outResRefNum:(short*)resultResRefNum outOSError:(OSErr*)resultErr;
+ (Movie) createCloneOfMovie:(Movie)theMasterMovie;

+ (QTMovie *) movieWithPath:(NSString *)inPath apertureMode:(NSString *)inMode;

#pragma mark Tracks

+ (BOOL) disposeTracksOfMovie:(Movie)aMovie ofMediaType:(OSType)mediaType;
+ (BOOL) disposeDisabledTracksOfMovie:(Movie)aMovie;

#pragma mark Thread Safty

+ (BOOL) isMovieThreadSafe:(Movie)aMovie;
+ (BOOL) isTrackThreadSafe:(Track)aTrack;

#pragma mark Images

+ (NSImage*) frameImageAtTime:(double)second ofMovieAtPath:(NSString*)movieFilePath;
+ (NSImage*) frameImageAtTime:(double)second ofMovie:(Movie)theMovie;
+ (NSImage*) frameImageAtTime:(double)second ofTrack:(Track)theTrack ofMovie:(Movie)theMovie;
+ (NSImage*) frameImageAtTime:(double)second ofTrack:(Track)theTrack ofMovie:(Movie)theMovie withAlpha:(BOOL)withAlphaChannel withSize:(NSSize)resultImageSize;

+ (NSImage*) imageFromPicHandle:(PicHandle)picHandle;
+ (double) getMoviePosterTimeInSeconds:(Movie)theMovie;
+ (NSImage*) posterImageOfMovieAtPath:(NSString*)movieFilePath;
+ (void) addPixelAspectRatio:(double)pixelAspectRatio toImageDescription:(ImageDescriptionHandle)imageDescription;
+ (double) getPixelAspectRatioOfImageDescription:(ImageDescriptionHandle)imageDescription;

@end

OSErr FilePathToFSSpec( NSString* asFilePath, FSSpec* apSpec );
OSErr FileURLToFSSpec(NSURL *inFileURL, FSSpec *outFSSpec);
pascal OSErr bxMovieUncoverProc (Movie theMovie, RgnHandle theRegion, long theRefCon);


#endif // !_LP64
