]> granicus.if.org Git - handbrake/commitdiff
MacGui: small improvements to HBTitle and HBJob.
authorritsuka <damiog@gmail.com>
Sat, 20 Dec 2014 17:37:18 +0000 (17:37 +0000)
committerritsuka <damiog@gmail.com>
Sat, 20 Dec 2014 17:37:18 +0000 (17:37 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6625 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBJob.h
macosx/HBJob.m
macosx/HBTitle.h
macosx/HBTitle.m

index 5fec2e0790fb0015f4b126f62eddfd946f256a7b..bb69ed773163f8a32ae311a7165a5bfb0459ec64 100644 (file)
@@ -6,9 +6,7 @@
 
 #import <Foundation/Foundation.h>
 
-@class HBPreset;
-
-@class HBTitle;
+#import "HBTitle.h"
 
 #import "HBVideo.h"
 #import "HBPicture.h"
@@ -17,6 +15,8 @@
 @class HBAudioDefaults;
 @class HBSubtitlesDefaults;
 
+@class HBPreset;
+
 typedef NS_ENUM(NSUInteger, HBJobStatus) {
     HBJobStatusNone,
     HBJobStatusWorking,
@@ -30,6 +30,7 @@ typedef NS_ENUM(NSUInteger, HBJobStatus) {
 @interface HBJob : NSObject <NSCoding, NSCopying>
 
 - (instancetype)initWithTitle:(HBTitle *)title url:(NSURL *)fileURL andPreset:(HBPreset *)preset;
+- (void)applyPreset:(HBPreset *)preset;
 
 @property (nonatomic, readonly) HBJobStatus status;
 
index 395e5fa9f18eda8b0aba5a893678768bda9fe5cf..03aafa2f8319f932237a2c40fd69ea24cd3f83c6 100644 (file)
 {
     self = [super init];
     if (self) {
+        NSParameterAssert(title);
+        NSParameterAssert(fileURL);
+        NSParameterAssert(preset);
+
         _title = title;
         _fileURL = [fileURL copy];
 
@@ -27,7 +31,7 @@
         _subtitlesDefaults = [[HBSubtitlesDefaults alloc] init];
 
         _video = [[HBVideo alloc] init];
-        _picture = [[HBPicture alloc] init];
+        _picture = [[HBPicture alloc] initWithTitle:title];
         _filters = [[HBFilters alloc] init];
 
         [self applyPreset:preset];
index e0d5ebdf6a830d4272cb35d856e18e87d6f718f5..64f2fd9ab4f0cb8d76ae453728fddbc8d4b09944 100644 (file)
@@ -9,7 +9,7 @@
 
 /**
  * HBTitles is an interface to the low-level hb_title_t.
- * the properties ara lazy-loaded.
+ * the properties are lazy-loaded.
  */
 @interface HBTitle : NSObject
 
@@ -25,7 +25,7 @@
 @property (nonatomic, readonly) NSString *name;
 @property (nonatomic, readonly, getter=isFeatured) BOOL featured;
 
-@property (nonatomic, readonly) hb_title_t *title;
+@property (nonatomic, readonly) hb_title_t *hb_title;
 
 @property (nonatomic, readonly) NSArray *audioTracks;
 @property (nonatomic, readonly) NSArray *subtitlesTracks;
index cde1c61004e70fa5d7224fba1ec71fe57bd5896c..6955935efc467c9c3518a98c2dd85a236c891956 100644 (file)
@@ -54,6 +54,7 @@ extern NSString *keySubTrackSrtCharCode;
             return nil;
         }
 
+        _hb_title = title;
         _featured = featured;
     }
 
@@ -64,32 +65,35 @@ extern NSString *keySubTrackSrtCharCode;
 {
     if (!_name)
     {
-        if (self.title->type == HB_BD_TYPE)
-        {
-            _name = [NSString stringWithFormat:@"%s %d (%05d.MPLS) - %02dh%02dm%02ds",
-                     self.title->name, self.title->index, self.title->playlist,
-                     self.title->hours, self.title->minutes, self.title->seconds];
-        }
-        else
-        {
-            _name = [NSString stringWithFormat:@"%s %d - %02dh%02dm%02ds",
-                     self.title->name, self.title->index,
-                     self.title->hours, self.title->minutes, self.title->seconds];
-        }
-
-        [_name retain];
+        _name = [@(self.hb_title->name) retain];
     }
 
     return _name;
 }
 
+- (NSString *)description
+{
+    if (self.hb_title->type == HB_BD_TYPE)
+    {
+        return [NSString stringWithFormat:@"%@ %d (%05d.MPLS) - %02dh%02dm%02ds",
+                 @(self.hb_title->name), self.hb_title->index, self.hb_title->playlist,
+                 self.hb_title->hours, self.hb_title->minutes, self.hb_title->seconds];
+    }
+    else
+    {
+        return [NSString stringWithFormat:@"%@ %d - %02dh%02dm%02ds",
+                 @(self.hb_title->name), self.hb_title->index,
+                 self.hb_title->hours, self.hb_title->minutes, self.hb_title->seconds];
+    }
+}
+
 - (NSArray *)audioTracks
 {
     if (!_audioTracks)
     {
         NSMutableArray *tracks = [NSMutableArray array];
         hb_audio_config_t *audio;
-        hb_list_t *list = self.title->list_audio;
+        hb_list_t *list = self.hb_title->list_audio;
         int count = hb_list_count(list);
 
         // Initialize the audio list of available audio tracks from this title
@@ -118,7 +122,7 @@ extern NSString *keySubTrackSrtCharCode;
     {
         NSMutableArray *tracks = [NSMutableArray array];
         hb_subtitle_t *subtitle;
-        hb_list_t *list = self.title->list_audio;
+        hb_list_t *list = self.hb_title->list_audio;
         int count = hb_list_count(list);
 
         NSMutableArray *forcedSourceNamesArray = [[NSMutableArray alloc] init];
@@ -126,7 +130,7 @@ extern NSString *keySubTrackSrtCharCode;
 
         for (int i = 0; i < count; i++)
         {
-            subtitle = (hb_subtitle_t *)hb_list_item(self.title->list_subtitle, i);
+            subtitle = (hb_subtitle_t *)hb_list_item(self.hb_title->list_subtitle, i);
 
             /* Human-readable representation of subtitle->source */
             NSString *bitmapOrText  = subtitle->format == PICTURESUB ? @"Bitmap" : @"Text";
@@ -187,9 +191,9 @@ extern NSString *keySubTrackSrtCharCode;
     {
         NSMutableArray *chapters = [NSMutableArray array];
 
-        for (int i = 0; i < hb_list_count(self.title->job->list_chapter); i++)
+        for (int i = 0; i < hb_list_count(self.hb_title->list_chapter); i++)
         {
-            hb_chapter_t *chapter = hb_list_item(self.title->job->list_chapter, i);
+            hb_chapter_t *chapter = hb_list_item(self.hb_title->list_chapter, i);
 
             if (chapter != NULL)
             {