diff options
author | Damiano Galassi <[email protected]> | 2016-09-03 18:11:11 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2016-09-03 18:11:11 +0200 |
commit | 85d5fb9e66e6568b055b8350dfed3e044206c4a8 (patch) | |
tree | 6f415c375eab50026432ba1948525eec7fe8d61d /macosx/HBAudioTransformers.m | |
parent | 29c7a63c2ae91fc557f5586587a3a3e949ca8843 (diff) |
MacGui: rework HBAudioTrack to use less NSDictionary.
Diffstat (limited to 'macosx/HBAudioTransformers.m')
-rw-r--r-- | macosx/HBAudioTransformers.m | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/macosx/HBAudioTransformers.m b/macosx/HBAudioTransformers.m new file mode 100644 index 000000000..4a4adec09 --- /dev/null +++ b/macosx/HBAudioTransformers.m @@ -0,0 +1,143 @@ +// +// HBAudioTransformers.m +// HandBrake +// +// Created by Damiano Galassi on 26/08/2016. +// +// + +#import "HBAudioTransformers.h" +#include "hb.h" + +#pragma mark - Value Trasformers + +@implementation HBEncoderTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + const char *name = hb_audio_encoder_get_name([value intValue]); + if (name) + { + return @(name); + } + else + { + return nil; + } +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + return @(hb_audio_encoder_get_from_name([value UTF8String])); +} + +@end + +@implementation HBMixdownTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + const char *name = hb_mixdown_get_name([value intValue]); + if (name) + { + return @(name); + } + else + { + return nil; + } +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + return @(hb_mixdown_get_from_name([value UTF8String])); +} + +@end + +@implementation HBSampleRateTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + const char *name = hb_audio_samplerate_get_name([value intValue]); + if (name) + { + return @(name); + } + else + { + return nil; + } +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + int sampleRate = hb_audio_samplerate_get_from_name([value UTF8String]); + if (sampleRate < 0) + { + sampleRate = 0; + } + return @(sampleRate); +} + +@end + +@implementation HBIntegerTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + // treat -1 as a special invalid value + // e.g. passthru has no bitrate since we have no source + if ([value intValue] == -1) + { + return @"N/A"; + } + return [value stringValue]; +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + return @([value intValue]); +} + +@end |