/* Copyright (c) 2004, Noah Sorscher
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 	¥ 	Redistributions of source code must retain the above copyright
 * 	notice, this list of conditions and the following disclaimer.
 * 	¥ 	Redistributions in binary form must reproduce the above copyright
 * 	notice, this list of conditions and the following disclaimer in the
 * 	documentation and/or other materials provided with the distribution.
 * 	¥ 	Neither the name of the Noah Sorscher nor the names of its
 * 	contributors may be used to endorse or promote products derived from
 * 	this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
//
//  MHMovie.h
//  Hootenanny
//
//  Created by Noah Sorscher on Tue Mar 25 2003.
//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <QuickTime/Movies.h>
#import "MHUtil.h"
#import "MHChapters.h"
#import "IconFamily.h"
#import "tLanguages.h"
#import "MHString.h"
/*
@interface MHQTMovie : QTMovie {
	NSMovie *myMHMovie;
}
-(NSMovie *)mhMovie;
@end
*/
@interface MHTrack : NSObject {
    Track myTrack;
}
- (id) initWithTrack:(Track)aTrack;
- (MHTrack *)alternate;
- (BOOL)containsString:(NSString *)searchString;
- (NSRect)displayFrame;
- (TimeValue)duration;
- (BOOL)enabled;
- (NSString *)format;
- (NSString *)fourCC;
- (BOOL)highQuality;
- (NSString *)language;
- (short)layer;
- (double)mbSize;
- (NSString *)name;
- (TimeValue)offset;
- (BOOL)preloads;
- (Track)QTTrack;
- (void)setAlternate:(MHTrack *)track;
- (void)setDisplayFrame:(NSRect)frame;
- (void)setDuration:(TimeValue)duration;
- (void)setEnabled:(BOOL)flag;
- (void)setFourCC:(NSString *)fourcc;
- (void)setFormat:(NSString *)format;
- (void)setHighQuality:(BOOL)flag;
- (BOOL)setLanguage:(NSString *)lang;
- (void)setLayer:(short)layer;
- (void)setName:(NSString *)name;
- (void)setOffset:(TimeValue)offset;
- (void)setPreloads:(BOOL)p;
- (void)setTimeScale:(TimeScale)ts;
- (void)setVendor:(NSString *)ven;
- (NSString *)type;
- (BOOL)isSoundType;
- (MHTrack *)chapterTrack;
- (void)remove;
- (TimeScale)timeScale;
- (NSString *)vendor;
@end

@interface MHMovie : NSMovie {
    NSMovie *mainMovie;
    NSMutableDictionary *data, *metadata, *info;
    BOOL isChanged, isOffline, wasOffline, chaptersNeedUpdating, saveInPlaceUnSafe;
    id Chapters;
    NSString *stringPath, *statusString, *myRefMovie;
    NSMutableDictionary *Menus;
    NSMutableArray *tempFiles, *listNumbers, *_sortedKeys;
    //NSImage *previewPic;
	//id myQTKitMovie;
}

//NSArray *theUserDataTypes = [NSArray arrayWithObjects: @"Album", @"Artist", @"Author", @"Chapter", @"Comment", @"Composer", @"Copyright", @"Creation Date", @"Description", @"Director", @"Disclaimer", @"Encoded By", @"Full Name", @"Genre", @"Host Computer", @"Information", @"Keywords", @"Make", @"Model", @"Original Artist", @"Original Format", @"Original Source", @"Performers", @"Producer", @"Product", @"Software", @"Special Playback Requirements", @"Track", @"Warning", @"Writer", @"URL Link", @"Edit Date", nil];
// ^---This is what they are, they just can't be initialized in the .h

// returns the above array
+ (NSArray *)supportedMetadata;
+ (void)setAsksForMissingFiles:(BOOL)flag;
+ (void)setIgnoresMissingFiles:(BOOL)flag;
+ (void)setLanguages:(NSArray *)langs;  // langs is an array of integer NSNumbers

// inits
//- (MHMovie *)init;
- (MHMovie *)initWithURL:(NSURL *)aURL byReference:(BOOL)ref;
- (MHMovie *)initWithURL:(NSURL *)aURL;
- (MHMovie *)initWithPath:(NSString *)path;
- (MHMovie *)initWithDefaultsEntry:(NSDictionary *)entry;
- (void) dealloc;

- (id)qtKitMovie;
- (Movie)quickTimeMovie;

// queries/filesystem
- (BOOL) isFileWritable;
- (BOOL) addSeparateAudio;
- (BOOL) containsString:(NSString *)searchString;
- (BOOL) saveToPath:(NSString *)path flatten:(BOOL)f;
- (BOOL) saveInPlace;
- (void) setMovie:(NSMovie *)movie;
- (void)cancelSave;
- (MHTrack *)trackAtIndex:(int)index; // zero based, unlike the actual QTMovie
- (int)trackCount;
- (NSArray *)tracksOfType:(NSString *)type;
- (NSArray *)languages;
- (NSString *)currentLanguage;
- (NSRect)displayFrame;
- (NSString *)summary;
- (NSString *)data;
- (NSString *)stringValue;
- (NSString *)description;
- (TimeValue)duration;
- (double)durationSeconds;
- (NSImage *)image;
- (NSImage *)imageForLanguage:(NSString *)language;
- (void)setImageFile:(NSString *)path;
- (void)setImageFile:(NSString *)path language:(NSString *)language;
- (id)objectForKey:(id)anObject language:(NSString *)lang;
- (id)objectForKey:(id)anObject;
- (BOOL)setObject:(id)anObject forKey:(id)key;
- (BOOL)setObject:(id)anObject forKey:(id)key language:(NSString *)language;
- (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary;
- (BOOL)setDataCode:(NSString *)newC forKey:(NSString *)key;
- (NSArray *)allKeys;
- (NSArray *)allMetadataKeys;
- (void)setListNumber:(int)number;
- (NSDictionary *)defsEntry;
- (void)setChapters:(id)chapters;
- (id)chapters;
- (void)setChaptersNeedUpdating;
- (void)setMenu:(id)menu;
- (id)menu;
- (void)saveCurrentHeight;
- (void)addTempFilePath:(NSString *)aPath;

// state
- (void)setStatus:(NSString *)status;
- (BOOL)saveInPlaceUnSafe;
- (void)setSaveInPlaceUnSafe;
- (BOOL)isEdited;
- (void)setEdited:(BOOL)e;
- (BOOL)isOffline;
- (double)currentTimeIndexSeconds;
- (TimeValue)currentTimeIndex;
- (TimeValue)timeIndex;
- (void)setCurrentTimeIndexSeconds:(double)seconds;
- (void)setCurrentTimeIndex:(TimeValue)samples;
- (void)setTimeIndex:(TimeValue)tv;
/* normal size: 0, double size: 1, last used size: 2 */
- (void)setSize:(int)size;
- (void)updateQTMovie;
- (void)setQTData:(NSString *)value forKey:(NSString *)key forLanguage:(NSString *)language;
- (void) removeQTDataForKey:(NSString *)key;

// table view
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- (BOOL) tableView: (NSTableView *) tableView shouldEditTableColumn: (NSTableColumn *) tableColumn row: (int) rowIndex;

// internal
//- (NSMovie *)makeMovieFromPath:(NSString *)path;
- (void)readMetadata;
- (NSString *)osTypeToString:(OSType)type;
- (OSType)stringToOSType:(NSString *)string;
- (void)gatherData;
- (NSNumber *)fpsForMovie:(Movie)theMovie;
- (IconFamily *)iconFromFile:(NSString *)path;
- (BOOL)askForMovie;

@end
