* HBAudioSettings
* Stores the audio defaults settings.
*/
-@interface HBAudioDefaults : NSObject
+@interface HBAudioDefaults : NSObject <NSCoding>
@property (nonatomic, readwrite) HBAudioTrackSelectionBehavior trackSelectionBehavior;
@property (nonatomic, readwrite, retain) NSMutableArray *trackSelectionLanguages;
#import "HBAudioDefaults.h"
#import "HBAudioTrackPreset.h"
+#import "NSCodingMacro.h"
#import "hb.h"
#import "lang.h"
self.container = container;
}
+#pragma mark - NSCoding
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:1 forKey:@"HBAudioDefaultsVersion"];
+
+ encodeInteger(_trackSelectionBehavior);
+ encodeObject(_trackSelectionLanguages);
+
+ encodeObject(_tracksArray);
+
+ encodeBool(_allowAACPassthru);
+ encodeBool(_allowAC3Passthru);
+ encodeBool(_allowDTSHDPassthru);
+ encodeBool(_allowDTSPassthru);
+ encodeBool(_allowMP3Passthru);
+
+ encodeInt(_encoderFallback);
+ encodeBool(_secondaryEncoderMode);
+}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self = [super init];
+
+ decodeInteger(_trackSelectionBehavior);
+ decodeObject(_trackSelectionLanguages);
+
+ decodeObject(_tracksArray);
+
+ decodeBool(_allowAACPassthru);
+ decodeBool(_allowAC3Passthru);
+ decodeBool(_allowDTSHDPassthru);
+ decodeBool(_allowDTSPassthru);
+ decodeBool(_allowMP3Passthru);
+
+ decodeInt(_encoderFallback);
+ decodeBool(_secondaryEncoderMode);
+
+ return self;
+}
+
@end
/**
* Filters settings.
*/
-@interface HBFilters : NSObject
+@interface HBFilters : NSObject <NSCoding>
- (void)prepareFiltersForPreset:(NSMutableDictionary *)preset;
- (void)applySettingsFromPreset:(NSDictionary *)preset;
It may be used under the terms of the GNU General Public License. */
#import "HBFilters.h"
+#import "NSCodingMacro.h"
NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification";
[self postChangedNotification];
}
+#pragma mark - NSCoding
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:1 forKey:@"HBFiltersVersion"];
+
+ encodeInteger(_detelecine);
+ encodeObject(_detelecineCustomString);
+
+ encodeInteger(_deinterlace);
+ encodeObject(_deinterlaceCustomString);
+
+ encodeInteger(_decomb);
+ encodeObject(_decombCustomString);
+
+ encodeInteger(_detelecine);
+ encodeObject(_detelecineCustomString);
+
+ encodeObject(_denoise);
+ encodeObject(_denoisePreset);
+ encodeObject(_denoiseTune);
+ encodeObject(_denoiseCustomString);
+
+ encodeInteger(_deblock);
+ encodeBool(_grayscale);
+
+ encodeBool(_useDecomb);
+}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self = [super init];
+
+ decodeInteger(_detelecine);
+ decodeObject(_detelecineCustomString);
+
+ decodeInteger(_deinterlace);
+ decodeObject(_deinterlaceCustomString);
+
+ decodeInteger(_decomb);
+ decodeObject(_decombCustomString);
+
+ decodeInteger(_detelecine);
+ decodeObject(_detelecineCustomString);
+
+ decodeObject(_denoise);
+ decodeObject(_denoisePreset);
+ decodeObject(_denoiseTune);
+ decodeObject(_denoiseCustomString);
+
+ decodeInteger(_deblock);
+ decodeBool(_grayscale);
+
+ decodeBool(_useDecomb);
+
+ _notificationsEnabled = YES;
+
+ return self;
+}
+
#pragma mark - Presets and queue
- (void)prepareFiltersForPreset:(NSMutableDictionary *)preset
#import "HBAudioController.h"
#import "HBSubtitlesController.h"
-#include "lang.h"
+#import "NSCodingMacro.h"
@implementation HBJob
*/
- (hb_job_t *)hb_job
{
+ NSAssert(self.title, @"HBJob: calling hb_job without a valid title loaded");
+
hb_title_t *title = self.title.hb_title;
hb_job_t *job = hb_job_init(title);
- (void)encodeWithCoder:(NSCoder *)coder
{
+ [coder encodeInt:1 forKey:@"HBVideoVersion"];
+
+ encodeInt(_state);
+
+ encodeObject(_fileURL);
+ encodeObject(_destURL);
+
+ encodeInt(_fileFormat);
+ encodeBool(_mp4HttpOptimize);
+ encodeBool(_mp4iPodCompatible);
+
+ encodeObject(_video);
+ encodeObject(_picture);
+ encodeObject(_filters);
+
+ encodeObject(_audioTracks);
+ encodeObject(_subtitlesTracks);
+
+ encodeBool(_chaptersEnabled);
+ encodeObject(_chapterNames);
+
+ encodeObject(_audioDefaults);
+ encodeObject(_subtitlesDefaults);
}
- (id)initWithCoder:(NSCoder *)decoder
{
- return nil;
+ self = [super init];
+
+ decodeInt(_state);
+
+ decodeObject(_fileURL);
+ decodeObject(_destURL);
+
+ decodeInt(_fileFormat);
+ decodeBool(_mp4HttpOptimize);
+ decodeBool(_mp4iPodCompatible);
+
+ decodeObject(_video);
+ decodeObject(_picture);
+ decodeObject(_filters);
+
+ decodeObject(_audioTracks);
+ decodeObject(_subtitlesTracks);
+
+ decodeBool(_chaptersEnabled);
+ decodeObject(_chapterNames);
+
+ decodeObject(_audioDefaults);
+ decodeObject(_subtitlesDefaults);
+
+ return self;
}
#pragma mark - NSCopying
/**
* HBPicture
*/
-@interface HBPicture : NSObject
+@interface HBPicture : NSObject <NSCoding>
- (instancetype)initWithTitle:(HBTitle *)title;
@property (nonatomic, readonly, getter=isKeepDisplayAspect) BOOL keepDisplayAspectEditable;
@property (nonatomic, readonly, getter=isCustomAnamorphicEnabled) BOOL customAnamorphicEnabled;
-@property (nonatomic, readonly) HBTitle *title;
+@property (nonatomic, readwrite, assign) HBTitle *title;
@end
#import "HBPicture.h"
#import "HBTitle.h"
+#import "NSCodingMacro.h"
+
#include "hb.h"
NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification";
self = [self init];
if (self)
{
- _title = [title retain];
+ _title = title;
_width = title.hb_title->geometry.width;
_height = title.hb_title->geometry.height;
[self postChangedNotification];
}
+#pragma mark - NSCoding
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:1 forKey:@"HBPictureVersion"];
+
+ encodeInt(_width);
+ encodeInt(_height);
+
+ encodeInt(_keepDisplayAspect);
+ encodeInt(_anamorphicMode);
+ encodeInt(_modulus);
+
+ encodeInt(_displayWidth);
+ encodeInt(_parWidth);
+ encodeInt(_parHeight);
+
+ encodeBool(_autocrop);
+ encodeInt(_cropTop);
+ encodeInt(_cropBottom);
+ encodeInt(_cropLeft);
+ encodeInt(_cropRight);
+}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self = [super init];
+
+ decodeInt(_width);
+ decodeInt(_height);
+
+ decodeInt(_keepDisplayAspect);
+ decodeInt(_anamorphicMode);
+ decodeInt(_modulus);
+
+ decodeInt(_displayWidth);
+ decodeInt(_parWidth);
+ decodeInt(_parHeight);
+
+ decodeBool(_autocrop);
+ decodeInt(_cropTop);
+ decodeInt(_cropBottom);
+ decodeInt(_cropLeft);
+ decodeInt(_cropRight);
+
+ return self;
+}
+
+#pragma mark - Presets/Queue
+
- (void)preparePictureForPreset:(NSMutableDictionary *)preset
{
preset[@"PictureKeepRatio"] = @(self.keepDisplayAspect);
HBSubtitleTrackSelectionBehaviorAll,
};
-@interface HBSubtitlesDefaults : NSObject
+@interface HBSubtitlesDefaults : NSObject <NSCoding>
@property (nonatomic, readwrite) HBSubtitleTrackSelectionBehavior trackSelectionBehavior;
@property (nonatomic, readwrite, retain) NSMutableArray *trackSelectionLanguages;
It may be used under the terms of the GNU General Public License. */
#import "HBSubtitlesDefaults.h"
+#import "NSCodingMacro.h"
@implementation HBSubtitlesDefaults
preset[@"SubtitleAddForeignAudioSubtitle"] = @(self.addForeignAudioSubtitle);
}
+#pragma mark - NSCoding
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:1 forKey:@"HBAudioDefaultsVersion"];
+
+ encodeInteger(_trackSelectionBehavior);
+ encodeObject(_trackSelectionLanguages);
+
+ encodeBool(_addForeignAudioSearch);
+ encodeBool(_addForeignAudioSubtitle);
+ encodeBool(_addCC);
+}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self = [super init];
+
+ decodeInteger(_trackSelectionBehavior);
+ decodeObject(_trackSelectionLanguages);
+
+ decodeBool(_addForeignAudioSearch);
+ decodeBool(_addForeignAudioSubtitle);
+ decodeBool(_addCC);
+
+ return self;
+}
+
- (void)dealloc
{
[_trackSelectionLanguages release];
It may be used under the terms of the GNU General Public License. */
#import <Foundation/Foundation.h>
-#include "hb.h"
/**
* HBVideo
*/
-@interface HBVideo : NSObject
+@interface HBVideo : NSObject <NSCoding>
- (void)applySettingsFromPreset:(NSDictionary *)preset;
- (void)prepareVideoForPreset:(NSMutableDictionary *)preset;
@property (nonatomic, readwrite) int frameRate;
@property (nonatomic, readwrite) int frameRateMode;
-@property (nonatomic, readwrite) BOOL fastFirstPass;
@property (nonatomic, readwrite) BOOL twoPass;
@property (nonatomic, readwrite) BOOL turboTwoPass;
It may be used under the terms of the GNU General Public License. */
#import "HBVideo.h"
+#import "NSCodingMacro.h"
+#include "hb.h"
@interface HBVideo ()
return retval;
}
+#pragma mark - NSCoding
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [coder encodeInt:1 forKey:@"HBVideoVersion"];
+
+ encodeInt(_encoder);
+
+ encodeInt(_qualityType);
+ encodeInt(_avgBitrate);
+ encodeDouble(_quality);
+
+ encodeInt(_frameRate);
+ encodeInt(_frameRateMode);
+
+ encodeBool(_twoPass);
+ encodeBool(_turboTwoPass);
+
+ encodeBool(_turboTwoPass);
+
+ encodeInt(_advancedOptions);
+ encodeObject(_preset);
+ encodeObject(_tune);
+ encodeObject(_profile);
+ encodeObject(_level);
+
+ encodeObject(_videoOptionExtra);
+
+ encodeBool(_fastDecode);
+}
+
+- (id)initWithCoder:(NSCoder *)decoder
+{
+ self = [super init];
+
+ decodeInt(_encoder);
+
+ decodeInt(_qualityType);
+ decodeInt(_avgBitrate);
+ decodeDouble(_quality);
+
+ decodeInt(_frameRate);
+ decodeInt(_frameRateMode);
+
+ decodeBool(_twoPass);
+ decodeBool(_turboTwoPass);
+
+ decodeBool(_turboTwoPass);
+
+ decodeInt(_advancedOptions);
+ decodeObject(_preset);
+ decodeObject(_tune);
+ decodeObject(_profile);
+ decodeObject(_level);
+
+ decodeObject(_videoOptionExtra);
+
+ decodeBool(_fastDecode);
+
+ return self;
+}
+
#pragma mark - Various conversion methods from dict/preset/queue/etc
- (void)applySettingsFromPreset:(NSDictionary *)preset
A98C29C21977B10600AF5DED /* HBLanguagesSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBLanguagesSelection.h; sourceTree = "<group>"; };
A98C29C31977B10600AF5DED /* HBLanguagesSelection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBLanguagesSelection.m; sourceTree = "<group>"; };
A9935212196F38A70069C6B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = ChaptersTitles.xib; sourceTree = "<group>"; };
+ A9A2A77F1A4737DD006C219C /* NSCodingMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSCodingMacro.h; sourceTree = "<group>"; };
A9AA44781970664A00D7DEFC /* HBUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBUtilities.h; sourceTree = "<group>"; };
A9AA44791970664A00D7DEFC /* HBUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBUtilities.m; sourceTree = "<group>"; };
A9AA447B1970724D00D7DEFC /* HBAdvancedController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBAdvancedController.h; sourceTree = "<group>"; };
A9D1E41618262364002F6424 /* HBPreviewGenerator.m */,
273F209714ADBE670021BE6D /* HBDVDDetector.h */,
273F209814ADBE670021BE6D /* HBDVDDetector.m */,
+ A9A2A77F1A4737DD006C219C /* NSCodingMacro.h */,
);
name = Core;
sourceTree = "<group>";
--- /dev/null
+/* NSCodingMacro.h $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#ifndef HandBrake_NSCodingMacro_h
+#define HandBrake_NSCodingMacro_h
+
+#define OBJC_STRINGIFY(x) @#x
+#define encodeInt(x) [coder encodeInt:x forKey:OBJC_STRINGIFY(x)]
+#define encodeInteger(x) [coder encodeInteger:x forKey:OBJC_STRINGIFY(x)]
+#define encodeBool(x) [coder encodeBool:x forKey:OBJC_STRINGIFY(x)]
+#define encodeDouble(x) [coder encodeDouble:x forKey:OBJC_STRINGIFY(x)]
+#define encodeObject(x) [coder encodeObject:x forKey:OBJC_STRINGIFY(x)]
+
+#define decodeInt(x) x = [decoder decodeIntForKey:OBJC_STRINGIFY(x)]
+#define decodeInteger(x) x = [decoder decodeIntegerForKey:OBJC_STRINGIFY(x)]
+#define decodeBool(x) x = [decoder decodeBoolForKey:OBJC_STRINGIFY(x)]
+#define decodeDouble(x) x = [decoder decodeDoubleForKey:OBJC_STRINGIFY(x)]
+#define decodeObject(x) x = [decoder decodeObjectForKey:OBJC_STRINGIFY(x)]
+
+#endif