@import HandBrakeKit;
-static void *HBSummaryViewControllerContext = &HBSummaryViewControllerContext;
+static void *HBSummaryViewControllerContainerContext = &HBSummaryViewControllerContainerContext;
+static void *HBSummaryViewControllerVideoContext = &HBSummaryViewControllerVideoContext;
+static void *HBSummaryViewControllerPictureContext = &HBSummaryViewControllerPictureContext;
+static void *HBSummaryViewControllerFiltersContext = &HBSummaryViewControllerFiltersContext;
+static void *HBSummaryViewControllerAudioContext = &HBSummaryViewControllerAudioContext;
+static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsContext;
@interface HBSummaryViewController ()
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- if (context == HBSummaryViewControllerContext)
+ if (context == HBSummaryViewControllerAudioContext)
{
- if ([keyPath isEqualToString:@"audio.tracks"])
+ if ([change[NSKeyValueChangeKindKey] integerValue] == NSKeyValueChangeInsertion)
{
- if ([change[NSKeyValueChangeKindKey] integerValue] == NSKeyValueChangeInsertion)
- {
- [self addAudioTracksObservers:change[NSKeyValueChangeNewKey]];
- }
- else if ([change[NSKeyValueChangeKindKey] integerValue]== NSKeyValueChangeRemoval)
- {
- [self removeAudioTracksObservers:change[NSKeyValueChangeOldKey]];
- }
+ [self addAudioTracksObservers:change[NSKeyValueChangeNewKey]];
}
- else if ([keyPath isEqualToString:@"subtitles.tracks"])
+ else if ([change[NSKeyValueChangeKindKey] integerValue]== NSKeyValueChangeRemoval)
{
- if ([change[NSKeyValueChangeKindKey] integerValue] == NSKeyValueChangeInsertion)
- {
- [self addSubtitlesTracksObservers:change[NSKeyValueChangeNewKey]];
- }
- else if ([change[NSKeyValueChangeKindKey] integerValue]== NSKeyValueChangeRemoval)
- {
- [self removeSubtitlesTracksObservers:change[NSKeyValueChangeOldKey]];
- }
+ [self removeAudioTracksObservers:change[NSKeyValueChangeOldKey]];
}
- else if ([keyPath isEqualToString:@"container"] && change[NSKeyValueChangeNewKey] && NSAppKitVersionNumber >= NSAppKitVersionNumber10_10)
+ [self updateTracks:nil];
+ }
+ else if (context == HBSummaryViewControllerSubsContext)
+ {
+ if ([change[NSKeyValueChangeKindKey] integerValue] == NSKeyValueChangeInsertion)
{
-
- if ([change[NSKeyValueChangeNewKey] integerValue] & 0x030000)
- {
- self.bottomOptionsConstrain.active = YES;
- }
- else
- {
- self.bottomOptionsConstrain.active = NO;
- }
+ [self addSubtitlesTracksObservers:change[NSKeyValueChangeNewKey]];
+ }
+ else if ([change[NSKeyValueChangeKindKey] integerValue]== NSKeyValueChangeRemoval)
+ {
+ [self removeSubtitlesTracksObservers:change[NSKeyValueChangeOldKey]];
}
[self updateTracks:nil];
}
+ else if (context == HBSummaryViewControllerContainerContext && NSAppKitVersionNumber >= NSAppKitVersionNumber10_10 && change[NSKeyValueChangeNewKey])
+ {
+ if ([change[NSKeyValueChangeNewKey] integerValue] & 0x030000)
+ {
+ self.bottomOptionsConstrain.active = YES;
+ }
+ else
+ {
+ self.bottomOptionsConstrain.active = NO;
+ }
+ [self updateTracks:nil];
+ }
+ else if (context == HBSummaryViewControllerVideoContext)
+ {
+ [self updateTracks:nil];
+ }
+ else if (context == HBSummaryViewControllerFiltersContext)
+ {
+ [self updatePicture:nil];
+ }
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
{
for (HBAudioTrack *track in tracks)
{
- [track addObserver:self forKeyPath:@"encoder" options:0 context:HBSummaryViewControllerContext];
- [track addObserver:self forKeyPath:@"mixdown" options:0 context:HBSummaryViewControllerContext];
+ [track addObserver:self forKeyPath:@"encoder" options:0 context:HBSummaryViewControllerAudioContext];
+ [track addObserver:self forKeyPath:@"mixdown" options:0 context:HBSummaryViewControllerAudioContext];
}
}
{
for (HBSubtitlesTrack *track in tracks)
{
- [track addObserver:self forKeyPath:@"burnedIn" options:0 context:HBSummaryViewControllerContext];
+ [track addObserver:self forKeyPath:@"burnedIn" options:0 context:HBSummaryViewControllerSubsContext];
}
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePicture:) name:HBPictureChangedNotification object:_job.picture];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFilters:) name:HBFiltersChangedNotification object:_job.filters];
- [_job addObserver:self forKeyPath:@"container" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"video.encoder" options:0 context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"video.frameRate" options:0 context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"video.frameRateMode" options:0 context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"container" options:0 context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"chaptersEnabled" options:0 context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"audio.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerContext];
- [_job addObserver:self forKeyPath:@"subtitles.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerContext];
+ [_job addObserver:self forKeyPath:@"container" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:HBSummaryViewControllerContainerContext];
+ [_job addObserver:self forKeyPath:@"chaptersEnabled" options:0 context:HBSummaryViewControllerVideoContext];
+ [_job addObserver:self forKeyPath:@"video.encoder" options:0 context:HBSummaryViewControllerVideoContext];
+ [_job addObserver:self forKeyPath:@"video.frameRate" options:0 context:HBSummaryViewControllerVideoContext];
+ [_job addObserver:self forKeyPath:@"video.frameRateMode" options:0 context:HBSummaryViewControllerVideoContext];
+ [_job addObserver:self forKeyPath:@"filters.deinterlace" options:0 context:HBSummaryViewControllerFiltersContext];
+ [_job addObserver:self forKeyPath:@"filters.rotate" options:0 context:HBSummaryViewControllerFiltersContext];
+ [_job addObserver:self forKeyPath:@"filters.flip" options:0 context:HBSummaryViewControllerFiltersContext];
+ [_job addObserver:self forKeyPath:@"audio.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerAudioContext];
+ [_job addObserver:self forKeyPath:@"subtitles.tracks" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:HBSummaryViewControllerSubsContext];
[self addAudioTracksObservers:_job.audio.tracks];
[self addSubtitlesTracksObservers:_job.subtitles.tracks];
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBFiltersChangedNotification object:_job.filters];
[_job removeObserver:self forKeyPath:@"container"];
+ [_job removeObserver:self forKeyPath:@"chaptersEnabled"];
[_job removeObserver:self forKeyPath:@"video.encoder"];
[_job removeObserver:self forKeyPath:@"video.frameRate"];
[_job removeObserver:self forKeyPath:@"video.frameRateMode"];
- [_job removeObserver:self forKeyPath:@"container"];
- [_job removeObserver:self forKeyPath:@"chaptersEnabled"];
+ [_job removeObserver:self forKeyPath:@"filters.deinterlace"];
+ [_job removeObserver:self forKeyPath:@"filters.rotate"];
+ [_job removeObserver:self forKeyPath:@"filters.flip"];
[_job removeObserver:self forKeyPath:@"audio.tracks"];
[_job removeObserver:self forKeyPath:@"subtitles.tracks"];