]> granicus.if.org Git - handbrake/commitdiff
MacGui: use HBJob when possible.
authorritsuka <damiog@gmail.com>
Sun, 21 Dec 2014 06:34:10 +0000 (06:34 +0000)
committerritsuka <damiog@gmail.com>
Sun, 21 Dec 2014 06:34:10 +0000 (06:34 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6633 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.m
macosx/HBAudioController.h
macosx/HBAudioController.m
macosx/HBChapterTitlesController.h
macosx/HBChapterTitlesController.m
macosx/HBSubtitlesController.h
macosx/HBSubtitlesController.m
macosx/HBTitle.m
macosx/HBVideoController.h
macosx/HBVideoController.m

index 77b66c0e3fbaab6a07401b91773a5fea47935058..41cd121c46ca710fb32d57cf1b51007b6b957001 100644 (file)
@@ -7,8 +7,6 @@
 #import <Cocoa/Cocoa.h>
 #import <Growl/Growl.h>
 
-#include "hb.h"
-
 #import "PictureController.h"
 #import "HBPreviewController.h"
 
@@ -24,8 +22,6 @@
 
 extern NSString *HBContainerChangedNotification;
 extern NSString *keyContainerTag;
-extern NSString *HBTitleChangedNotification;
-extern NSString *keyTitleTag;
 
 @class HBOutputPanelController;
 @class HBPresetsViewController;
@@ -148,7 +144,6 @@ extern NSString *keyTitleTag;
     
     /* Queue variables */
     int                          hbInstanceNum; //stores the number of HandBrake instances currently running
-       hb_title_t                   * fTitle;
     int                          fPendingCount;         // Number of various kinds of job groups in fJobGroups.
     int                          fWorkingCount;
     
@@ -159,10 +154,7 @@ extern NSString *keyTitleTag;
     /* integer to set to determine the previous state
                of encode 0==idle, 1==encoding, 2==cancelled*/
     int                            fEncodeState;
-    BOOL                           SuccessfulScan;
-    BOOL                           titleLoaded;
     BOOL                           applyQueueToScan;
-       NSString                      * currentSource;
     NSString                      * browsedSourceDisplayName;
     
     /* Dock progress variables */
index 39377cfd4f5ab6f2fd792959a5da8a5b6d7572cd..611eba03e62bbf87d9eea038e4fe4bfc0974b7e9 100644 (file)
@@ -4,7 +4,6 @@
    Homepage: <http://handbrake.fr/>.
    It may be used under the terms of the GNU General Public License. */
 
-#include <dlfcn.h>
 #import "Controller.h"
 #import "HBOutputPanelController.h"
 #import "HBPreferencesController.h"
 
 NSString *HBContainerChangedNotification       = @"HBContainerChangedNotification";
 NSString *keyContainerTag                      = @"keyContainerTag";
-NSString *HBTitleChangedNotification           = @"HBTitleChangedNotification";
-NSString *keyTitleTag                          = @"keyTitleTag";
 
 // DockTile update freqency in total percent increment
 #define dockTileUpdateFrequency                  0.1f
 
 @interface HBController () <HBPresetsViewControllerDelegate>
 
+// The current job.
 @property (nonatomic, retain) HBJob *job;
 
 // The current selected preset.
@@ -132,7 +130,6 @@ NSString *keyTitleTag                          = @"keyTitleTag";
         [fQueueController setHBController:self];
 
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(autoSetM4vExtension:) name:HBMixdownChangedNotification object:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateMp4Checkboxes:) name:HBVideoEncoderChangedNotification object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pictureSettingsDidChange) name:HBPictureChangedNotification object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pictureSettingsDidChange) name:HBFiltersChangedNotification object:nil];
 
@@ -253,7 +250,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
                  * the queue is empty of any finished items or cancelled items */
                 [self clearQueueAllItems];
 
-                if (self.core.state != HBStateScanning && !titleLoaded)
+                if (self.core.state != HBStateScanning && !self.job)
                 {
                     // We show whichever open source window specified in LaunchSourceBehavior preference key
                     if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
@@ -272,7 +269,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
     }
     else
     {
-        if (self.core.state != HBStateScanning && !titleLoaded)
+        if (self.core.state != HBStateScanning && !self.job)
         {
             // We show whichever open source window specified in LaunchSourceBehavior preference key
             if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
@@ -1024,7 +1021,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
                 [toolbarItem setToolTip: @"Pause Encoding"];
                 return YES;
             }
-            if (SuccessfulScan)
+            if (self.job)
             {
                 if (action == @selector(addToQueue:))
                     return YES;
@@ -1057,7 +1054,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
         {
             return NO;
         }
-        else if (queueState == HBStateWorkDone || queueState == HBStateScanDone || SuccessfulScan)
+        else if (queueState == HBStateWorkDone || queueState == HBStateScanDone || self.job)
         {
             if (action == @selector(Rip:))
             {
@@ -1103,7 +1100,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
         HBState queueState = self.queueCore.state;
 
         if (action == @selector(addToQueue:) || action == @selector(addAllTitlesToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
-            return SuccessfulScan && [fWindow attachedSheet] == nil;
+            return self.job && [fWindow attachedSheet] == nil;
         
         if (action == @selector(selectDefaultPreset:))
             return [fWindow attachedSheet] == nil;
@@ -1132,7 +1129,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
                     [menuItem setTitle:@"Stop Encoding"];
                 return YES;
             }
-            else if (SuccessfulScan)
+            else if (self.job)
             {
                 if(![[menuItem title] isEqualToString:@"Start Encoding"])
                     [menuItem setTitle:@"Start Encoding"];
@@ -1303,10 +1300,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
     /* User selected a file to open */
        if( returnCode == NSOKButton )
     {
-        // We started a new scan, so set SuccessfulScan to no for now.
-        SuccessfulScan = NO;
-
-            /* Free display name allocated previously by this code */
+        /* Free display name allocated previously by this code */
         [browsedSourceDisplayName release];
        
         NSURL *scanURL = [[sheet URLs] objectAtIndex: 0];
@@ -1461,22 +1455,20 @@ NSString *keyTitleTag                          = @"keyTitleTag";
 - (void)performScan:(NSString *)scanPath scanTitleNum:(NSInteger)scanTitleNum
 {
     // Save the current settings
-    if (titleLoaded) {
+    if (self.job) {
         self.selectedPreset = [self createPresetFromCurrentSettings];
-        titleLoaded = NO;
     }
 
+    self.job = nil;
     // Notify anyone interested (audio/subtitles/chapters controller) that there's no title
-    fTitle = NULL;
     fPictureController.picture = nil;
+    fPictureController.filters = nil;
     fPreviewController.job = nil;
 
-       [[NSNotificationCenter defaultCenter] postNotification:
-        [NSNotification notificationWithName: HBTitleChangedNotification
-                                                                  object: self
-                                                                userInfo: [NSDictionary dictionaryWithObjectsAndKeys:
-                                                                                       [NSData dataWithBytesNoCopy: &fTitle length: sizeof(fTitle) freeWhenDone: NO], keyTitleTag,
-                                                                                       nil]]];
+    fAudioController.job = nil;
+    fSubtitlesViewController.job = nil;
+    fVideoController.video = nil;
+    fChapterTitlesController.job = nil;
 
     [self enableUI: NO];
 
@@ -1548,20 +1540,6 @@ NSString *keyTitleTag                          = @"keyTitleTag";
         {
             /* We display a message if a valid dvd source was not chosen */
             [fSrcDVD2Field setStringValue: @"No Valid Source Found"];
-            SuccessfulScan = NO;
-
-            // Notify PictureController that there's no title
-            fPictureController.picture = nil;
-            fPictureController.filters = nil;
-            fPreviewController.job = nil;
-
-                       //      Notify anyone interested (video/audio/subtitles/chapters controller) that there's no title
-                       [[NSNotificationCenter defaultCenter] postNotification:
-                        [NSNotification notificationWithName: HBTitleChangedNotification
-                                                                                  object: self
-                                                                                userInfo: [NSDictionary dictionaryWithObjectsAndKeys:
-                                                                                                       [NSData dataWithBytesNoCopy: &fTitle length: sizeof(fTitle) freeWhenDone: NO], keyTitleTag,
-                                                                                                       nil]]];
         }
         else
         {
@@ -1587,7 +1565,7 @@ NSString *keyTitleTag                          = @"keyTitleTag";
             {
                 title = (hb_title_t *) hb_list_item( title_set->list_title, i );
                 
-                currentSource = [NSString stringWithUTF8String: title->name];
+                NSString *currentSource = [NSString stringWithUTF8String: title->name];
                 /*Set DVD Name at top of window with the browsedSourceDisplayName grokked right before -performScan */
                 if (!browsedSourceDisplayName)
                 {
@@ -1656,13 +1634,9 @@ NSString *keyTitleTag                          = @"keyTitleTag";
                 [fSrcTitlePopUp selectItemAtIndex: feature_title];
             }
 
-            SuccessfulScan = YES;
-
             [self enableUI:YES];
             [self titlePopUpChanged:nil];
 
-            titleLoaded = YES;
-
             [self encodeStartStopPopUpChanged:nil];
 
             // Open preview window now if it was visible when HB was closed
@@ -2087,21 +2061,21 @@ static void queueFSEventStreamCallback(
     
     /* Codecs */
        /* Video encoder */
-    [fVideoController.video prepareVideoForQueueFileJob:queueFileJob];
+    [self.job.video prepareVideoForQueueFileJob:queueFileJob];
 
        /* Picture Sizing */
-    [fPictureController.picture preparePictureForQueueFileJob:queueFileJob];
+    [self.job.picture preparePictureForQueueFileJob:queueFileJob];
 
     /* Text summaries of various settings */
     [queueFileJob setObject:[NSString stringWithString:[self pictureSettingsSummary]]
                      forKey:@"PictureSettingsSummary"];
-    [queueFileJob setObject:fPictureController.filters.summary
+    [queueFileJob setObject:self.job.filters.summary
                      forKey:@"PictureFiltersSummary"];
     [queueFileJob setObject:[NSString stringWithString:[self muxerOptionsSummary]]
                      forKey:@"MuxerOptionsSummary"];
 
     /* Picture Filters */
-    HBFilters *filters = fPictureController.filters;
+    HBFilters *filters = self.job.filters;
     queueFileJob[@"PictureDetelecine"] = @(filters.detelecine);
     queueFileJob[@"PictureDetelecineCustom"] = filters.detelecineCustomString;
 
@@ -2122,7 +2096,7 @@ static void queueFSEventStreamCallback(
 
     /* Audio Defaults */
     NSMutableDictionary *audioDefaults = [NSMutableDictionary dictionary];
-    [fAudioController.settings prepareAudioDefaultsForPreset:audioDefaults];
+    [self.job.audioDefaults prepareAudioDefaultsForPreset:audioDefaults];
     queueFileJob[@"AudioDefaults"] = audioDefaults;
 
     /* Audio */
@@ -2132,7 +2106,7 @@ static void queueFSEventStreamCallback(
 
        /* Subtitles Defaults */
     NSMutableDictionary *subtitlesDefaults = [NSMutableDictionary dictionary];
-    [fSubtitlesViewController.settings prepareSubtitlesDefaultsForPreset:subtitlesDefaults];
+    [self.job.subtitlesDefaults prepareSubtitlesDefaultsForPreset:subtitlesDefaults];
     queueFileJob[@"SubtitlesDefaults"] = subtitlesDefaults;
 
        /* Subtitles */
@@ -2390,26 +2364,26 @@ static void queueFSEventStreamCallback(
     [fDstMp4iPodFileCheck setState:[[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue]];
 
     /* video encoder */
-    [fVideoController.video applyVideoSettingsFromQueue:queueToApply];
+    [self.job.video applyVideoSettingsFromQueue:queueToApply];
 
     /* Audio Defaults */
-    [fAudioController.settings applySettingsFromPreset:queueToApply[@"AudioDefaults"]];
+    [self.job.audioDefaults applySettingsFromPreset:queueToApply[@"AudioDefaults"]];
 
     /* Audio */
     /* Now lets add our new tracks to the audio list here */
     [fAudioController addTracksFromQueue:[queueToApply objectForKey:@"AudioList"]];
 
     /* Subtitles Defaults */
-    [fSubtitlesViewController.settings applySettingsFromPreset:queueToApply[@"SubtitlesDefaults"]];
+    [self.job.subtitlesDefaults applySettingsFromPreset:queueToApply[@"SubtitlesDefaults"]];
 
     /* Subtitles */
     [fSubtitlesViewController addTracksFromQueue:[queueToApply objectForKey:@"SubtitleList"]];
 
     /* Picture Settings */
-    [fPictureController.picture applyPictureSettingsFromQueue:queueToApply];
+    [self.job.picture applyPictureSettingsFromQueue:queueToApply];
 
     /* Filters */
-    HBFilters *filters = [fPictureController filters];
+    HBFilters *filters = self.job.filters;
 
     /* We only allow *either* Decomb or Deinterlace. So check for the PictureDecombDeinterlace key. */
     filters.useDecomb = YES;
@@ -2481,7 +2455,7 @@ static void queueFSEventStreamCallback(
 
     filters.grayscale = [queueToApply[@"VideoGrayScale"] boolValue];
 
-    /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */
+    // Updates the previews window and summary strings
     [self pictureSettingsDidChange];
 
     [fPresetSelectedDisplay setStringValue:queueToApply[@"PresetName"]];
@@ -2516,7 +2490,7 @@ static void queueFSEventStreamCallback(
     job->mux = (int)[[fDstFormatPopUp selectedItem] tag];
 
     /* Video Encoder */
-    [fVideoController.video prepareVideoForJobPreview:job andTitle:title];
+    [self.job.video prepareVideoForJobPreview:job andTitle:title];
 
     /* Picture Size Settings */
     HBPicture *pict = self.job.picture;
@@ -2639,27 +2613,28 @@ static void queueFSEventStreamCallback(
 
     /* Auto Passthru */
     job->acodec_copy_mask = 0;
-    if (fAudioController.settings.allowAACPassthru)
+    HBAudioDefaults *audioDefaults = self.job.audioDefaults;
+    if (audioDefaults.allowAACPassthru)
     {
         job->acodec_copy_mask |= HB_ACODEC_FFAAC;
     }
-    if (fAudioController.settings.allowAC3Passthru)
+    if (audioDefaults.allowAC3Passthru)
     {
         job->acodec_copy_mask |= HB_ACODEC_AC3;
     }
-    if (fAudioController.settings.allowDTSHDPassthru)
+    if (audioDefaults.allowDTSHDPassthru)
     {
         job->acodec_copy_mask |= HB_ACODEC_DCA_HD;
     }
-    if (fAudioController.settings.allowDTSPassthru)
+    if (audioDefaults.allowDTSPassthru)
     {
         job->acodec_copy_mask |= HB_ACODEC_DCA;
     }
-    if (fAudioController.settings.allowMP3Passthru)
+    if (audioDefaults.allowMP3Passthru)
     {
         job->acodec_copy_mask |= HB_ACODEC_MP3;
     }
-    job->acodec_fallback = fAudioController.settings.encoderFallback;
+    job->acodec_fallback = audioDefaults.encoderFallback;
 
     // First clear out any audio tracks in the job currently
     int audiotrack_count = hb_list_count(job->list_audio);
@@ -2692,12 +2667,13 @@ static void queueFSEventStreamCallback(
     }
 
     /* Filters */
-    
+    HBFilters *filters = self.job.filters;
+
     /* Though Grayscale is not really a filter, per se
      * we put it here since its in the filters panel
      */
-     
-    if ([fPictureController.filters grayscale])
+
+    if (filters.grayscale)
     {
         job->grayscale = 1;
     }
@@ -2707,12 +2683,9 @@ static void queueFSEventStreamCallback(
     }
     
     /* Now lets call the filters if applicable.
-    * The order of the filters is critical
-    */
-    
+    * The order of the filters is critical */
 
        /* Detelecine */
-    HBFilters *filters = [fPictureController filters];
     if (filters.detelecine == 1)
     {
         hb_filter_object_t *filter = hb_filter_init(HB_FILTER_DETELECINE);
@@ -3731,7 +3704,7 @@ static void queueFSEventStreamCallback(
 
 - (void)updateFileName
 {
-    if (!SuccessfulScan)
+    if (!self.job)
     {
         return;
     }
@@ -3756,9 +3729,9 @@ static void queueFSEventStreamCallback(
     NSString *fileName = [HBUtilities automaticNameForSource:sourceName
                                                        title:title->index
                                                     chapters:NSMakeRange([fSrcChapterStartPopUp indexOfSelectedItem] + 1, [fSrcChapterEndPopUp indexOfSelectedItem] + 1)
-                                                     quality:fVideoController.video.qualityType ? fVideoController.video.quality : 0
-                                                     bitrate:!fVideoController.video.qualityType ? fVideoController.video.avgBitrate : 0
-                                                  videoCodec:fVideoController.video.encoder];
+                                                     quality:self.job.video.qualityType ? self.job.video.quality : 0
+                                                     bitrate:!self.job.video.qualityType ? self.job.video.avgBitrate : 0
+                                                  videoCodec:self.job.video.encoder];
 
     // Swap the old one with the new one
     [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@/%@.%@",
@@ -3770,7 +3743,7 @@ static void queueFSEventStreamCallback(
 - (IBAction) titlePopUpChanged: (id) sender
 {
     // If there is already a title load, save the current settings to a preset
-    if (titleLoaded)
+    if (self.job)
     {
         self.selectedPreset = [self createPresetFromCurrentSettings];
     }
@@ -3829,23 +3802,18 @@ static void queueFSEventStreamCallback(
     }
     [fSrcAnglePopUp selectItemAtIndex: 0];
 
-    /* Start Get and set the initial pic size for display */
-       fTitle = title;
-
+    // Set the jobs info to the view controllers
     fPictureController.picture = self.job.picture;
     fPictureController.filters = self.job.filters;
     fPreviewController.job = self.job;
 
-       /* Update the others views */
-       [[NSNotificationCenter defaultCenter] postNotification:
-        [NSNotification notificationWithName: HBTitleChangedNotification
-                                                                  object: self
-                                                                userInfo: [NSDictionary dictionaryWithObjectsAndKeys:
-                                                                                       [NSData dataWithBytesNoCopy: &fTitle length: sizeof(fTitle) freeWhenDone: NO], keyTitleTag,
-                                                                                       nil]]];
+    fVideoController.video = self.job.video;
+    fAudioController.job = self.job;
+    fSubtitlesViewController.job = self.job;
+    fChapterTitlesController.job = self.job;
 
-    /* Set Auto Crop to on upon selecting a new title  */
-    fPictureController.picture.autocrop = YES;
+    // Set Auto Crop to on upon selecting a new title
+    self.job.picture.autocrop = YES;
 
     /* If Auto Naming is on. We create an output filename of dvd name - title number */
     if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"])
@@ -4039,7 +4007,7 @@ static void queueFSEventStreamCallback(
 
 - (void)updateMp4Checkboxes:(NSNotification *)notification
 {
-    if (fVideoController.video.encoder != HB_VCODEC_X264)
+    if (self.job.video.encoder != HB_VCODEC_X264)
     {
         /* We set the iPod atom checkbox to disabled and uncheck it as its only for x264 in the mp4
          * container. Format is taken care of in formatPopUpChanged method by hiding and unchecking
@@ -4085,11 +4053,11 @@ the user is using "Custom" settings by determining the sender*/
 {
     // align picture settings and video filters in the UI using tabs
     fVideoController.pictureSettings = [self pictureSettingsSummary];
-    fVideoController.pictureFilters = fPictureController.filters.summary;
+    fVideoController.pictureFilters = self.job.filters.summary;
 
     /* Store storage resolution for unparse */
-    fVideoController.video.widthForUnparse  = fPictureController.picture.width;
-    fVideoController.video.heightForUnparse = fPictureController.picture.height;
+    fVideoController.video.widthForUnparse  = self.job.picture.width;
+    fVideoController.video.heightForUnparse = self.job.picture.height;
 
     [fPreviewController reloadPreviews];
 }
@@ -4100,10 +4068,10 @@ the user is using "Custom" settings by determining the sender*/
 - (NSString *)pictureSettingsSummary
 {
     NSMutableString *summary = [NSMutableString stringWithString:@""];
-    if (fPictureController.picture)
+    if (self.job.picture)
     {
-        HBPicture *pict = fPictureController.picture;
-        [summary appendString:fPictureController.picture.info];
+        HBPicture *pict = self.job.picture;
+        [summary appendString:pict.info];
         if (pict.anamorphicMode != HB_ANAMORPHIC_STRICT)
         {
             // anamorphic is not Strict, show the modulus
@@ -4225,7 +4193,7 @@ the user is using "Custom" settings by determining the sender*/
 
 - (void)applyPreset:(HBPreset *)preset
 {
-    if (preset != nil && SuccessfulScan)
+    if (preset != nil && self.job)
     {
         self.selectedPreset = preset;
         self.customPreset = NO;
@@ -4256,9 +4224,6 @@ the user is using "Custom" settings by determining the sender*/
         
         /* Mux mp4 with http optimization */
         [fDstMp4HttpOptFileCheck setState:[[chosenPreset objectForKey:@"Mp4HttpOptimize"] intValue]];
-        
-        /* Video encoder */
-        [fVideoController.video applySettingsFromPreset:chosenPreset];
 
         /* Lets run through the following functions to get variables set there */
         /* Set the state of ipod compatible with Mp4iPodCompatible. Only for x264*/
@@ -4270,10 +4235,9 @@ the user is using "Custom" settings by determining the sender*/
         /*Subtitles*/
         [fSubtitlesViewController applySettingsFromPreset:chosenPreset];
 
-        /* Picture Settings */
-        /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */
-        [fPictureController.picture applySettingsFromPreset:chosenPreset];
-        [fPictureController.filters applySettingsFromPreset:chosenPreset];
+        // Apply the preset to the current job
+        [self.job applyPreset:preset];
+
         [self pictureSettingsDidChange];
     }
 }
@@ -4313,7 +4277,7 @@ the user is using "Custom" settings by determining the sender*/
 {
        /* Show the add panel */
     HBAddPresetController *addPresetController = [[HBAddPresetController alloc] initWithPreset:[self createPresetFromCurrentSettings]
-                                                                                     videoSize:NSMakeSize(fPictureController.picture.width, fPictureController.picture.height)];
+                                                                                     videoSize:NSMakeSize(self.job.picture.width, self.job.picture.height)];
 
     [NSApp beginSheet:addPresetController.window modalForWindow:fWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:addPresetController];
 }
@@ -4358,22 +4322,22 @@ the user is using "Custom" settings by determining the sender*/
     preset[@"Mp4iPodCompatible"] = @(fDstMp4iPodFileCheck.state);
 
     // Video encoder
-    [fVideoController.video prepareVideoForPreset:preset];
+    [self.job.video prepareVideoForPreset:preset];
 
     preset[@"PictureWidth"]  = currentPreset[@"PictureWidth"];
     preset[@"PictureHeight"] = currentPreset[@"PictureHeight"];
 
     // Picture Filters
-    [fPictureController.filters prepareFiltersForPreset:preset];
+    [self.job.filters prepareFiltersForPreset:preset];
 
     // Picture Size
-    [fPictureController.picture preparePictureForPreset:preset];
+    [self.job.picture preparePictureForPreset:preset];
 
     // Audio
-    [fAudioController.settings prepareAudioDefaultsForPreset:preset];
+    [self.job.audioDefaults prepareAudioDefaultsForPreset:preset];
 
     // Subtitles
-    [fSubtitlesViewController.settings prepareSubtitlesDefaultsForPreset:preset];
+    [self.job.subtitlesDefaults prepareSubtitlesDefaultsForPreset:preset];
 
     return [[[HBPreset alloc] initWithName:preset[@"PresetName"] content:preset builtIn:NO] autorelease];
     
index b3cc702d88177bb2e8cb0ee09927b4860ba5292f..878f23a8814b30951819b0bd2a0378a61cf18341 100644 (file)
@@ -18,19 +18,20 @@ extern NSString *keyAudioInputChannelLayout;
 
 extern NSString *HBMixdownChangedNotification;
 
+@class HBJob;
 @class HBAudio;
-@class HBAudioDefaults;
+
 /**
  *  HBAudioController
  *
- *  Responds to HBContainerChangedNotification and HBTitleChangedNotification notifications.
+ *  Responds to HBContainerChangedNotification.
  */
 @interface HBAudioController : NSViewController <HBViewValidation>
 
 @property (nonatomic, readonly, retain) NSArray *masterTrackArray;
 @property (nonatomic, readonly) NSDictionary *noneTrack;
 
-@property(nonatomic, readonly) HBAudioDefaults *settings;
+@property (nonatomic, readwrite, assign) HBJob *job;
 
 // Get the list of audio tracks
 @property (readonly, nonatomic, copy) NSArray *audioTracks;
index 9d608a42126316961f5c6a09a360c734c036fbda..086495c0e8e42670b0f6a1ca481feccc9a1e7efe 100644 (file)
@@ -11,6 +11,9 @@
 #import "HBAudioDefaults.h"
 #import "HBAudioDefaultsController.h"
 #import "HBAudioTrackPreset.h"
+
+#import "HBJob.h"
+
 #import "hb.h"
 #include "lang.h"
 
@@ -68,7 +71,6 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
         /* register that we are interested in changes made to the video container */
         NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
         [center addObserver: self selector: @selector(containerChanged:) name: HBContainerChangedNotification object: nil];
-        [center addObserver: self selector: @selector(titleChanged:) name: HBTitleChangedNotification object: nil];
     }
     return self;
 }
@@ -199,7 +201,6 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
 
 - (void)applySettingsFromPreset:(NSDictionary *)preset
 {
-    self.settings = [[[HBAudioDefaults alloc] init] autorelease];
     [self.settings applySettingsFromPreset:preset];
     [self.settings validateEncoderFallbackForVideoContainer:[self.videoContainerTag intValue]];
 
@@ -485,22 +486,15 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
     [self.settings validateEncoderFallbackForVideoContainer:[self.videoContainerTag intValue]];
 }
 
-- (void) titleChanged: (NSNotification *) aNotification
+- (void)setJob:(HBJob *)job
 
 {
-    NSDictionary *notDict = [aNotification userInfo];
-    NSData *theData = notDict[keyTitleTag];
-    hb_title_t *title = NULL;
-
     // Reinitialize the configured list of audio tracks
     [self _clearAudioArray];
     
-    [theData getBytes: &title length: sizeof(title)];
-    if (title)
+    if (job)
     {
-        hb_audio_config_t *audio;
-        hb_list_t *list = title->list_audio;
-        int i, count = hb_list_count(list);
+        self.settings = job.audioDefaults;
 
         // Reinitialize the master list of available audio tracks from this title
         NSMutableArray *newTrackArray = [NSMutableArray array];
@@ -509,23 +503,13 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
                        keyAudioTrackName: NSLocalizedString(@"None", @"None"),
                        keyAudioInputCodec: @0} retain];
         [newTrackArray addObject: noneTrack];
-        for (i = 0; i < count; i++)
-        {
-            audio = (hb_audio_config_t *) hb_list_audio_config_item(list, i);
-            [newTrackArray addObject: @{keyAudioTrackIndex: @(i + 1),
-                                        keyAudioTrackName: [NSString stringWithFormat: @"%d: %s", i, audio->lang.description],
-                                        keyAudioInputBitrate: @(audio->in.bitrate / 1000),
-                                        keyAudioInputSampleRate: @(audio->in.samplerate),
-                                        keyAudioInputCodec: [NSNumber numberWithUnsignedInteger: audio->in.codec],
-                                        keyAudioInputCodecParam: [NSNumber numberWithUnsignedInteger: audio->in.codec_param],
-                                        keyAudioInputChannelLayout: @(audio->in.channel_layout),
-                                        keyAudioTrackLanguageIsoCode: @(audio->lang.iso639_2)}];
-        }
+        [newTrackArray addObjectsFromArray:job.title.audioTracks];
         self.masterTrackArray = newTrackArray;
         [self switchingTrackFromNone: nil]; // this ensures there is a None track at the end of the list
     }
     else
     {
+        self.settings = nil;
         self.masterTrackArray = nil;
     }
 
index 0e59ce9027ef07e1dff222674dc9cedcebe26dff..c0fdaec23535277f777733e8d6706ad08cd5e3d4 100644 (file)
@@ -7,14 +7,17 @@
 #import <Cocoa/Cocoa.h>
 #import "HBViewValidation.h"
 
+@class HBJob;
+
 /**
  *  HBChapterTitlesController
- *  Responds to HBTitleChangedNotification notifications.
  */
 @interface HBChapterTitlesController : NSViewController <HBViewValidation>
 
 - (void)addChaptersFromQueue:(NSMutableArray *)newChaptersArray;
 
+@property (nonatomic, readwrite, assign) HBJob *job;
+
 /**
  *  Enable/disable chapters markers
  */
index e029b7244632b6c37c743d1d77fc8dc6dbac6ece..debfcb63f88d14d31d4f592c6bc3cd462a490191 100644 (file)
@@ -6,7 +6,7 @@
    
 #import "HBChapterTitlesController.h"
 #import "Controller.h"
-#include "hb.h"
+#import "HBJob.h"
 
 @interface HBChapterTitlesController () <NSTableViewDataSource, NSTableViewDelegate>
 {
@@ -31,7 +31,6 @@
     if (self)
     {
         fChapterTitlesArray = [[[NSMutableArray alloc] init] retain];
-        [[NSNotificationCenter defaultCenter]  addObserver: self selector: @selector(titleChanged:) name: HBTitleChangedNotification object: nil];
     }
     return self;
 }
     [super               dealloc];
 }
 
-- (void)titleChanged:(NSNotification *)aNotification
+- (void)setJob:(HBJob *)job
 {
-    NSDictionary *notDict = [aNotification userInfo];
-    NSData *theData = [notDict objectForKey: keyTitleTag];
-    hb_title_t *title = NULL;
-
-    [theData getBytes: &title length: sizeof(title)];
-
     [fChapterTitlesArray removeAllObjects];
-
-    if (title)
-    {
-        for (int i = 0; i < hb_list_count(title->list_chapter); i++)
-        {
-            hb_chapter_t *chapter = hb_list_item(title->list_chapter, i);
-            if (chapter != NULL)
-            {
-                if (chapter->title != NULL)
-                {
-                    [fChapterTitlesArray addObject:[NSString
-                                                    stringWithFormat:@"%s",
-                                                    chapter->title]];
-                }
-                else
-                {
-                    [fChapterTitlesArray addObject:[NSString
-                                                    stringWithFormat:@"Chapter %d",
-                                                    i + 1]];
-                }
-            }
-        }
-    }
-
+    [fChapterTitlesArray addObjectsFromArray:job.title.chapters];
     [fChapterTable reloadData];
 }
 
index dd41d1d81ee011cb209c7d34c24df44f58003bb8..d44d514b1c9c1e629ddb5fb2061b5942e59d92a3 100644 (file)
@@ -21,21 +21,20 @@ extern NSString *keySubTrackSrtOffset;
 extern NSString *keySubTrackSrtFilePath;
 extern NSString *keySubTrackSrtCharCode;
 
-@class HBSubtitlesDefaults;
+@class HBJob;
 
 /**
  *  HBSubtitlesController
- *  Responds to HBContainerChangedNotification and HBTitleChangedNotification notifications.
+ *  Responds to HBContainerChangedNotification.
  */
 @interface HBSubtitlesController : NSViewController <HBViewValidation>
 
 - (void)addTracksFromQueue:(NSArray *)queueSubtitleArray;
-
 - (void)applySettingsFromPreset:(NSDictionary *)preset;
 
+@property (nonatomic, readwrite, assign) HBJob *job;
+
 // Get the list of subtitles tracks
 @property (readonly, nonatomic, copy) NSArray *subtitles;
 
-@property (nonatomic, readonly) HBSubtitlesDefaults *settings;
-
 @end
index df433fcc26198b1591f10bf2b89c793b33d46010..9b4337594fd28f9d8190bb3c4ad540640b1acfea 100644 (file)
@@ -8,6 +8,8 @@
 #import "HBSubtitlesDefaultsController.h"
 #import "HBSubtitlesDefaults.h"
 
+#import "HBJob.h"
+
 #import "Controller.h"
 #include "hb.h"
 #include "lang.h"
@@ -86,7 +88,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex";
 
         // Register as observer for the HBController notifications.
         [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(containerChanged:) name: HBContainerChangedNotification object: nil];
-        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(titleChanged:) name: HBTitleChangedNotification object: nil];
     }
 
     return self;
@@ -101,19 +102,18 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex";
     _enabled = enabled;
 }
 
-- (void)titleChanged:(NSNotification *)aNotification
+- (void)setJob:(HBJob *)job
 {
-    NSDictionary *notDict = [aNotification userInfo];
-    NSData *theData = notDict[keyTitleTag];
-    hb_title_t *title = NULL;
-    [theData getBytes: &title length: sizeof(title)];
-
     /* reset the subtitles arrays */
     [self.subtitleArray removeAllObjects];
     [self.subtitleSourceArray removeAllObjects];
+    self.settings = nil;
 
-    if (title)
+    if (job)
     {
+        self.settings = job.subtitlesDefaults;
+        hb_title_t *title = job.title.hb_title;
+
         /* now populate the array with the source subtitle track info */
         NSMutableArray *forcedSourceNamesArray = [[NSMutableArray alloc] init];
         for (int i = 0; i < hb_list_count(title->list_subtitle); i++)
@@ -220,7 +220,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex";
 
 - (void)applySettingsFromPreset:(NSDictionary *)preset
 {
-    self.settings = [[[HBSubtitlesDefaults alloc] init] autorelease];
     [self.settings applySettingsFromPreset:preset];
 
     [self addTracksFromDefaults:self];
index 6955935efc467c9c3518a98c2dd85a236c891956..989d963057ea268c5b38341defd18561e611b36a 100644 (file)
@@ -187,7 +187,7 @@ extern NSString *keySubTrackSrtCharCode;
 
 - (NSArray *)chapters
 {
-    if (_chapters)
+    if (!_chapters)
     {
         NSMutableArray *chapters = [NSMutableArray array];
 
index f878879c03d29d70c4bdb4888a9723b9d2186a39..9ebc2cb54356f34d5fa09cfa1091c66547669b5b 100644 (file)
@@ -7,15 +7,11 @@
 #import <Cocoa/Cocoa.h>
 #import "HBViewValidation.h"
 
-#include "hb.h"
-
 @class HBController;
 @class HBAdvancedController;
 
 @class HBVideo;
 
-extern NSString *HBVideoEncoderChangedNotification;
-
 /**
  *  HBVideoController
  *
@@ -31,6 +27,6 @@ extern NSString *HBVideoEncoderChangedNotification;
 @property (nonatomic, copy, readwrite) NSString *pictureSettings;
 @property (nonatomic, copy, readwrite) NSString *pictureFilters;
 
-@property (nonatomic, readonly) HBVideo *video;
+@property (nonatomic, readwrite, retain) HBVideo *video;
 
 @end
index 2b28f24b5fee2fc978d57f5f2f85fdc24f1fd268..42ee4d542534c39a3eec998024dd29758c99354a 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "hb.h"
 
-NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotification";
 static void *HBVideoControllerContext = &HBVideoControllerContext;
 
 @interface HBVideoController () {
@@ -39,7 +38,6 @@ static void *HBVideoControllerContext = &HBVideoControllerContext;
 
 @property (nonatomic, retain, readwrite) HBAdvancedController *advancedController;
 
-@property (nonatomic, readwrite) HBVideo *video;
 @property (nonatomic, readwrite) BOOL presetViewEnabled;
 
 @property (nonatomic, readwrite) NSColor *labelColor;