1 /* $Id: Controller.h,v 1.35 2005/08/01 14:29:50 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
5 It may be used under the terms of the GNU General Public License. */
7 #import <Cocoa/Cocoa.h>
8 #import <Growl/Growl.h>
12 #import "ChapterTitles.h"
13 #import "HBSubtitles.h"
14 #import "PictureController.h"
15 #import "HBPreviewController.h"
16 #import "HBQueueController.h"
17 #import "HBAdvancedController.h"
18 #import "HBPreferencesController.h"
21 @class HBOutputPanelController;
23 /* We subclass NSView so that our drags show both the icon as well as PresetName columns */
24 @interface HBPresetsOutlineView : NSOutlineView
32 @interface HBController : NSObject <GrowlApplicationBridgeDelegate>
34 NSImage * fApplicationIcon;
35 IBOutlet NSWindow * fWindow;
37 /* Main Menu Outlets */
38 NSMenuItem * fOpenSourceTitleMMenu;
40 /* Source Title Scan Outlets */
41 IBOutlet NSPanel * fScanSrcTitlePanel;
42 IBOutlet NSTextField * fScanSrcTitlePathField;
43 IBOutlet NSTextField * fSrcDsplyNameTitleScan;
44 IBOutlet NSTextField * fScanSrcTitleNumField;
45 IBOutlet NSButton * fScanSrcTitleCancelButton;
46 IBOutlet NSButton * fScanSrcTitleOpenButton;
49 /* Picture Settings */
50 PictureController * fPictureController;
53 PreviewController * fPreviewController;
55 /* Advanced options tab */
56 HBAdvancedController * fAdvancedOptions;
57 IBOutlet NSBox * fAdvancedView;
59 HBPreferencesController * fPreferencesController;
62 HBQueueController * fQueueController;
63 IBOutlet NSTextField * fQueueStatus;
66 HBOutputPanelController *outputPanel;
69 IBOutlet NSProgressIndicator * fScanIndicator;
70 NSString * sourceDisplayName;
71 IBOutlet NSTextField * fSrcDVD2Field;
72 IBOutlet NSTextField * fSrcTitleField;
73 IBOutlet NSPopUpButton * fSrcTitlePopUp;
76 /* lib dvd nav specific */
77 IBOutlet NSTextField * fSrcAngleLabel;
78 IBOutlet NSPopUpButton * fSrcAnglePopUp;
80 /* Source start and end points */
81 IBOutlet NSPopUpButton * fEncodeStartStopPopUp;
82 /* pts based start / stop */
83 IBOutlet NSTextField * fSrcTimeStartEncodingField;
84 IBOutlet NSTextField * fSrcTimeEndEncodingField;
85 /* frame based based start / stop */
86 IBOutlet NSTextField * fSrcFrameStartEncodingField;
87 IBOutlet NSTextField * fSrcFrameEndEncodingField;
89 IBOutlet NSTextField * fSrcChapterField;
90 IBOutlet NSPopUpButton * fSrcChapterStartPopUp;
91 IBOutlet NSTextField * fSrcChapterToField;
92 IBOutlet NSPopUpButton * fSrcChapterEndPopUp;
94 /* Source duration information */
95 IBOutlet NSTextField * fSrcDuration1Field;
96 IBOutlet NSTextField * fSrcDuration2Field;
99 IBOutlet NSTextField * fDstFormatField;
100 IBOutlet NSPopUpButton * fDstFormatPopUp;
102 IBOutlet NSTextField * fDstFile1Field;
103 IBOutlet NSTextField * fDstFile2Field;
104 IBOutlet NSButton * fDstBrowseButton;
106 // Creates 64 bit mp4's that allow file sizes over 4gb
107 IBOutlet NSButton * fDstMp4LargeFileCheck;
108 // Optimizes mp4's for http
109 IBOutlet NSButton * fDstMp4HttpOptFileCheck;
110 // Creates iPod compatible mp4's (add ipod uuid atom)
111 IBOutlet NSButton * fDstMp4iPodFileCheck;
114 IBOutlet NSButton * fFrameratePfrCheck;
116 IBOutlet NSTextField * fVidRateField;
117 IBOutlet NSPopUpButton * fVidRatePopUp;
118 IBOutlet NSTextField * fVidEncoderField;
119 IBOutlet NSPopUpButton * fVidEncoderPopUp;
120 IBOutlet NSTextField * fVidQualityField;
121 IBOutlet NSTextField * fVidQualityRFLabel;
122 IBOutlet NSTextField * fVidQualityRFField;
123 IBOutlet NSMatrix * fVidQualityMatrix;
124 IBOutlet NSButtonCell * fVidTargetCell;
125 IBOutlet NSTextField * fVidTargetSizeField;
126 IBOutlet NSButtonCell * fVidBitrateCell;
127 IBOutlet NSTextField * fVidBitrateField;
128 IBOutlet NSButtonCell * fVidConstantCell;
129 IBOutlet NSSlider * fVidQualitySlider;
130 IBOutlet NSButton * fVidTwoPassCheck;
131 IBOutlet NSButton * fVidTurboPassCheck;
133 /* Status read out fileds for picture sizing */
134 IBOutlet NSTextField * fPictureSizeField;
135 IBOutlet NSTextField * fPictureCroppingField;
137 /* Status read out fileds for video filters */
138 IBOutlet NSTextField * fVideoFiltersField;
140 /* Picture variables */
141 int PicOrigOutputWidth;
142 int PicOrigOutputHeight;
148 IBOutlet NSTextField * fSubField;
149 IBOutlet NSPopUpButton * fSubPopUp;
150 IBOutlet NSButton * fSubForcedCheck;
153 IBOutlet NSTableView * fSubtitlesTable;
154 HBSubtitles * fSubtitlesDelegate;
155 IBOutlet NSButton * fBrowseSrtFileButton;
160 IBOutlet NSTextField * fAudSourceLabel;
161 IBOutlet NSTextField * fAudCodecLabel;
162 IBOutlet NSTextField * fAudMixdownLabel;
163 IBOutlet NSTextField * fAudSamplerateLabel;
164 IBOutlet NSTextField * fAudBitrateLabel;
165 IBOutlet NSTextField * fAudDrcLabel;
167 IBOutlet NSTextField * fAudTrack1Label;
168 IBOutlet NSTextField * fAudTrack2Label;
169 IBOutlet NSTextField * fAudTrack3Label;
170 IBOutlet NSTextField * fAudTrack4Label;
172 /* Source Audio PopUps */
173 IBOutlet NSPopUpButton * fAudLang1PopUp;
174 IBOutlet NSPopUpButton * fAudLang2PopUp;
175 IBOutlet NSPopUpButton * fAudLang3PopUp;
176 IBOutlet NSPopUpButton * fAudLang4PopUp;
179 IBOutlet NSPopUpButton * fAudTrack1CodecPopUp;
180 IBOutlet NSPopUpButton * fAudTrack2CodecPopUp;
181 IBOutlet NSPopUpButton * fAudTrack3CodecPopUp;
182 IBOutlet NSPopUpButton * fAudTrack4CodecPopUp;
185 IBOutlet NSPopUpButton * fAudTrack1MixPopUp;
186 IBOutlet NSPopUpButton * fAudTrack2MixPopUp;
187 IBOutlet NSPopUpButton * fAudTrack3MixPopUp;
188 IBOutlet NSPopUpButton * fAudTrack4MixPopUp;
190 /* Samplerate PopUps */
191 IBOutlet NSPopUpButton * fAudTrack1RatePopUp;
192 IBOutlet NSPopUpButton * fAudTrack2RatePopUp;
193 IBOutlet NSPopUpButton * fAudTrack3RatePopUp;
194 IBOutlet NSPopUpButton * fAudTrack4RatePopUp;
197 IBOutlet NSPopUpButton * fAudTrack1BitratePopUp;
198 IBOutlet NSPopUpButton * fAudTrack2BitratePopUp;
199 IBOutlet NSPopUpButton * fAudTrack3BitratePopUp;
200 IBOutlet NSPopUpButton * fAudTrack4BitratePopUp;
202 /* Dynamic Range Compression */
203 IBOutlet NSSlider * fAudTrack1DrcSlider;
204 IBOutlet NSTextField * fAudTrack1DrcField;
205 IBOutlet NSSlider * fAudTrack2DrcSlider;
206 IBOutlet NSTextField * fAudTrack2DrcField;
207 IBOutlet NSSlider * fAudTrack3DrcSlider;
208 IBOutlet NSTextField * fAudTrack3DrcField;
209 IBOutlet NSSlider * fAudTrack4DrcSlider;
210 IBOutlet NSTextField * fAudTrack4DrcField;
213 IBOutlet NSButton * fCreateChapterMarkers;
214 IBOutlet NSTableView * fChapterTable;
215 IBOutlet NSButton * fLoadChaptersButton;
216 IBOutlet NSButton * fSaveChaptersButton;
217 IBOutlet NSTableColumn * fChapterTableNameColumn;
218 ChapterTitles * fChapterTitlesDelegate;
221 IBOutlet NSTextField * fStatusField;
222 IBOutlet NSProgressIndicator * fRipIndicator;
223 BOOL fRipIndicatorShown;
225 /* Queue File variables */
226 NSString * QueueFile;
227 NSMutableArray * QueueFileArray;
228 int currentQueueEncodeIndex; // Used to track the currently encoding queueu item
230 /* User Preset variables here */
231 HBPresets * fPresetsBuiltin;
232 IBOutlet NSDrawer * fPresetDrawer;
233 IBOutlet NSTextField * fPresetNewName;
234 IBOutlet NSTextField * fPresetNewDesc;
235 IBOutlet NSPopUpButton * fPresetNewPicSettingsPopUp;
236 IBOutlet NSTextField * fPresetNewPicWidth;
237 IBOutlet NSTextField * fPresetNewPicHeight;
238 IBOutlet NSBox * fPresetNewPicWidthHeightBox;
240 IBOutlet NSButton * fPresetNewPicFiltersCheck;
241 IBOutlet NSButton * fPresetNewFolderCheck;
242 IBOutlet NSTextField * fPresetSelectedDisplay;
244 NSString * AppSupportDirectory;
245 NSString * UserPresetsFile;
246 NSMutableArray * UserPresets;
247 NSMutableArray * UserPresetssortedArray;
248 NSMutableDictionary * chosenPreset;
249 int curUserPresetChosenNum;
251 NSMutableDictionary *presetHbDefault; // this is 1 in "Default" preset key
252 NSMutableDictionary *presetUserDefault;// this is 2 in "Default" preset key
253 NSMutableDictionary *presetUserDefaultParent;
254 NSMutableDictionary *presetUserDefaultParentParent;
255 int presetCurrentBuiltInCount; // keeps track of the current number of built in presets
256 IBOutlet NSPanel * fAddPresetPanel;
258 /* NSOutline View for the presets */
259 NSArray *fDraggedNodes;
260 IBOutlet HBPresetsOutlineView * fPresetsOutlineView;
261 IBOutlet NSButton * fPresetsAdd;
262 IBOutlet NSButton * fPresetsDelete;
263 IBOutlet NSPopUpButton * fPresetsActionButton;
265 hb_handle_t * fHandle;
267 /* Queue variables */
268 int hbInstanceNum; //stores the number of HandBrake instances currently running
269 hb_handle_t * fQueueEncodeLibhb; // libhb for HB Encoding
271 hb_title_t * fQueueEncodeTitle;
272 int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item
273 int fPendingCount; // Number of various kinds of job groups in fJobGroups.
278 int fqueueEditRescanItemNum; // queue array item to be reloaded into the main window
279 int pidNum; // The pid number for this instance
280 NSString * currentQueueEncodeNameString;
282 /* integer to set to determine the previous state
283 of encode 0==idle, 1==encoding, 2==cancelled*/
285 int currentScanCount;
286 int currentSuccessfulScanCount;
288 BOOL applyQueueToScan;
289 NSString * currentSource;
290 NSString * browsedSourceDisplayName;
292 double dockIconProgress;
295 - (IBAction) showAboutPanel:(id)sender;
297 - (void) writeToActivityLog:(const char *) format, ...;
298 - (IBAction) browseSources: (id) sender;
299 - (void) browseSourcesDone: (NSOpenPanel *) sheet
300 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
301 - (IBAction) showSourceTitleScanPanel: (id) sender;
302 - (IBAction) closeSourceTitleScanPanel: (id) sender;
303 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
304 - (IBAction) showNewScan: (id) sender;
307 - (IBAction) cancelScanning:(id)sender;
309 - (void) updateUI: (NSTimer *) timer;
310 - (void) enableUI: (bool) enable;
311 - (IBAction) encodeStartStopPopUpChanged: (id) sender;
312 - (IBAction) titlePopUpChanged: (id) sender;
313 - (IBAction) chapterPopUpChanged: (id) sender;
314 - (IBAction) startEndSecValueChanged: (id) sender;
315 - (IBAction) startEndFrameValueChanged: (id) sender;
318 - (IBAction) formatPopUpChanged: (id) sender;
319 - (IBAction) videoEncoderPopUpChanged: (id) sender;
320 - (IBAction) autoSetM4vExtension: (id) sender;
321 - (IBAction) twoPassCheckboxChanged: (id) sender;
322 - (IBAction) videoFrameRateChanged: (id) sender;
323 - (IBAction) audioAddAudioTrackCodecs: (id)sender;
324 - (IBAction) audioCodecsPopUpChanged: (id) sender;
325 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender;
326 - (IBAction) addAllAudioTracksToPopUp: (id) sender;
327 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound;
328 - (IBAction) audioTrackPopUpChanged: (id) sender;
329 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
330 - (IBAction) audioTrackMixdownChanged: (id) sender;
332 - (IBAction) browseFile: (id) sender;
333 - (void) browseFileDone: (NSSavePanel *) sheet
334 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
336 - (IBAction) videoMatrixChanged: (id) sender;
338 - (IBAction) qualitySliderChanged: (id) sender;
339 - (void) setupQualitySlider;
341 - (IBAction) audioDRCSliderChanged: (id) sender;
342 - (IBAction) browseImportSrtFile: (id) sender;
343 - (void) browseImportSrtFileDone: (NSSavePanel *) sheet
344 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
346 - (IBAction) showPicturePanel: (id) sender;
347 - (void) picturePanelFullScreen;
348 - (void) picturePanelWindowed;
349 - (IBAction) showPreviewWindow: (id) sender;
350 - (void)pictureSettingsDidChange;
351 - (IBAction) calculatePictureSizing: (id) sender;
352 - (IBAction) openMainWindow: (id) sender;
354 /* Queue File Stuff */
355 - (void) loadQueueFile;
356 - (NSDictionary *)createQueueFileItem;
357 - (void)saveQueueFileItem;
358 - (void) incrementQueueItemDone:(int) queueItemDoneIndexNum;
359 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum;
360 - (void) processNewQueueEncode;
361 - (void) clearQueueEncodedItems;
363 - (IBAction)applyQueueSettingsToMainWindow:(id)sender;
364 - (IBAction)rescanQueueItemToMainWindow:(NSString *) scanPath scanTitleNum: (int) scanTitleNum selectedQueueItem: (int) selectedQueueItem;
367 - (void) removeQueueFileItem:(int) queueItemToRemove;
368 - (void) clearQueueAllItems;
369 - (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
370 - (void)getQueueStats;
371 - (void)setQueueEncodingItemsAsPending;
372 - (IBAction) addToQueue: (id) sender;
373 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
374 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
375 - (void) doAddToQueue;
377 - (IBAction) showQueueWindow:(id)sender;
379 - (IBAction)showPreferencesWindow:(id)sender;
381 - (IBAction) Rip: (id) sender;
382 - (void) overWriteAlertDone: (NSWindow *) sheet
383 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
386 - (IBAction) Cancel: (id) sender;
387 - (void) doCancelCurrentJob;
388 - (void) doCancelCurrentJobAndStop;
389 - (IBAction) Pause: (id) sender;
391 - (IBAction) calculateBitrate: (id) sender;
392 - (void) controlTextDidChange: (NSNotification *) notification;
394 - (IBAction) openHomepage: (id) sender;
395 - (IBAction) openForums: (id) sender;
396 - (IBAction) openUserGuide: (id) sender;
398 // Preset Methods Here
400 /* These are required by the NSOutlineView Datasource Delegate */
401 /* We use this to deterimine children of an item */
402 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item;
403 /* We use this to determine if an item should be expandable */
404 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item;
405 /* used to specify the number of levels to show for each item */
406 - (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item;
407 /* Used to tell the outline view which information is to be displayed per item */
408 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
409 /* Use to customize the font and display characteristics of the title cell */
410 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
411 /* We use this to edit the name field in the outline view */
412 - (void)outlineView:(NSOutlineView *)fPresetsOutlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
413 /* We use this to provide tooltips for the items in the presets outline view */
414 - (NSString *)outlineView:(NSOutlineView *)fPresetsOutlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation;
415 - (void) checkBuiltInsForUpdates;
416 /* We use this to actually select the preset and act accordingly */
417 - (IBAction)selectPreset:(id)sender;
419 /* Export / Import Presets */
420 - (IBAction) browseExportPresetFile: (id) sender;
421 - (void) browseExportPresetFileDone: (NSSavePanel *) sheet
422 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
424 - (IBAction) browseImportPresetFile: (id) sender;
425 - (void) browseImportPresetDone: (NSSavePanel *) sheet
426 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
428 /* Manage User presets */
429 - (void) loadPresets;
430 - (IBAction) customSettingUsed: (id) sender;
431 - (IBAction) showAddPresetPanel: (id) sender;
432 - (IBAction) addPresetPicDropdownChanged: (id) sender;
433 - (IBAction) closeAddPresetPanel: (id) sender;
434 - (NSDictionary *)createPreset;
436 - (IBAction) revertPictureSizeToMax:(id)sender;
438 - (IBAction)setDefaultPreset:(id)sender;
439 - (IBAction)selectDefaultPreset:(id)sender;
442 - (IBAction)addFactoryPresets:(id)sender;
443 - (IBAction)deleteFactoryPresets:(id)sender;
444 - (IBAction)addUserPreset:(id)sender;
446 - (IBAction)insertPreset:(id)sender;
447 - (IBAction)deletePreset:(id)sender;
448 - (IBAction)getDefaultPresets:(id)sender;
450 -(void)sendToMetaX:(NSString *) filePath;
452 - (NSDictionary *) registrationDictionaryForGrowl;
453 -(void)showGrowlDoneNotification:(NSString *) filePath;
454 - (IBAction)showDebugOutputPanel:(id)sender;
455 - (void)setupToolbar;
457 - (void) prepareJobForPreview;
458 - (void) remindUserOfSleepOrShutdown;
460 - (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex;
463 - (int) getThisHBInstancePID;
465 // Chapter files methods
466 - (IBAction) browseForChapterFile: (id) sender;
467 - (void) browseForChapterFileDone: (NSOpenPanel *) sheet
468 returnCode: (int) returnCode contextInfo: (void *) contextInfo;
470 - (IBAction) browseForChapterFileSave: (id) sender;
471 - (void) browseForChapterFileSaveDone: (NSSavePanel *) sheet
472 returnCode: (int) returnCode contextInfo: (void *) contextInfo;