diff options
author | Damiano Galassi <[email protected]> | 2019-07-25 08:12:35 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-07-25 08:12:35 +0200 |
commit | 30b59112b75ef6572615db032fb461d9e9c51fa2 (patch) | |
tree | 92c8598edf6d3dcf6f02565695c36b13db55e005 | |
parent | 5396c8b3bd401d4f574dc57de68cd4b3cc560d9f (diff) |
MacGui: store queue items statistics.
-rw-r--r-- | macosx/HBFlippedClipView.h | 16 | ||||
-rw-r--r-- | macosx/HBFlippedClipView.m | 17 | ||||
-rw-r--r-- | macosx/HBQueue.h | 1 | ||||
-rw-r--r-- | macosx/HBQueue.m | 5 | ||||
-rw-r--r-- | macosx/HBQueueItem.h | 11 | ||||
-rw-r--r-- | macosx/HBQueueItem.m | 60 | ||||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 6 |
7 files changed, 114 insertions, 2 deletions
diff --git a/macosx/HBFlippedClipView.h b/macosx/HBFlippedClipView.h new file mode 100644 index 000000000..63db278af --- /dev/null +++ b/macosx/HBFlippedClipView.h @@ -0,0 +1,16 @@ +/* HBFlippedClipView.m + + 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. + */ + +#import <Cocoa/Cocoa.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface HBFlippedClipView : NSClipView + +@end + +NS_ASSUME_NONNULL_END diff --git a/macosx/HBFlippedClipView.m b/macosx/HBFlippedClipView.m new file mode 100644 index 000000000..cacd620c9 --- /dev/null +++ b/macosx/HBFlippedClipView.m @@ -0,0 +1,17 @@ +/* HBFlippedClipView.m + + 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. + */ + +#import "HBFlippedClipView.h" + +@implementation HBFlippedClipView + +- (BOOL)isFlipped +{ + return YES; +} + +@end diff --git a/macosx/HBQueue.h b/macosx/HBQueue.h index a879b415c..d62b25033 100644 --- a/macosx/HBQueue.h +++ b/macosx/HBQueue.h @@ -42,6 +42,7 @@ extern NSString * const HBQueueItemNotificationItemKey; // HBQueueI @interface HBQueue : NSObject +- (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithURL:(NSURL *)queueURL; @property (nonatomic, readonly) HBCore *core; diff --git a/macosx/HBQueue.m b/macosx/HBQueue.m index 4a4b73b20..846f13c24 100644 --- a/macosx/HBQueue.m +++ b/macosx/HBQueue.m @@ -410,6 +410,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK - (void)pause { + [self.currentItem pausedAtDate:[NSDate date]]; [self.core pause]; [self.core allowSleep]; } @@ -421,6 +422,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK - (void)resume { + [self.currentItem resumedAtDate:[NSDate date]]; [self.core resume]; [self.core preventSleep]; } @@ -551,6 +553,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK { // now we mark the queue item as working so another instance can not come along and try to scan it while we are scanning nextItem.state = HBQueueItemStateWorking; + nextItem.startedDate = [NSDate date]; // Tell HB to output a new activity log file for this encode self.currentLog = [[HBJobOutputFileWriter alloc] initWithJob:nextItem.job]; @@ -590,6 +593,8 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK NSParameterAssert(item); [self.items beginTransaction]; + item.endedDate = [NSDate date]; + // Since we are done with this encode, tell output to stop writing to the // individual encode log. [[HBOutputRedirect stderrRedirect] removeListener:self.currentLog]; diff --git a/macosx/HBQueueItem.h b/macosx/HBQueueItem.h index a4a96ab36..13ad6c094 100644 --- a/macosx/HBQueueItem.h +++ b/macosx/HBQueueItem.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A flag to indicate the item's state */ -typedef NS_ENUM(NSUInteger, HBQueueItemState){ +typedef NS_ENUM(NSUInteger, HBQueueItemState) { HBQueueItemStateReady, HBQueueItemStateWorking, HBQueueItemStateCompleted, @@ -45,7 +45,14 @@ typedef NS_ENUM(NSUInteger, HBQueueItemState){ @property (nonatomic, readonly) NSAttributedString *attributedTitleDescription; @property (nonatomic, readonly) NSAttributedString *attributedDescription; -@property (nonatomic, readwrite) BOOL expanded; +@property (nonatomic) NSTimeInterval encodeDuration; +@property (nonatomic) NSTimeInterval pauseDuration; + +@property (nonatomic, nullable) NSDate *startedDate; +@property (nonatomic, nullable) NSDate *endedDate; + +- (void)pausedAtDate:(NSDate *)date; +- (void)resumedAtDate:(NSDate *)date; @property (nonatomic, readonly) HBJob *job; diff --git a/macosx/HBQueueItem.m b/macosx/HBQueueItem.m index 959167731..f3279790e 100644 --- a/macosx/HBQueueItem.m +++ b/macosx/HBQueueItem.m @@ -8,12 +8,20 @@ #import "HBCodingUtilities.h" +@interface HBQueueItem () + +@property (nonatomic, nullable) NSDate *pausedDate; +@property (nonatomic, nullable) NSDate *resumedDate; + +@end + @implementation HBQueueItem @synthesize job = _job; @synthesize attributedTitleDescription = _attributedTitleDescription; @synthesize attributedDescription = _attributedDescription; + @synthesize uuid = _uuid; - (instancetype)initWithJob:(HBJob *)job @@ -29,6 +37,15 @@ #pragma mark - Properties +- (void)setState:(HBQueueItemState)state +{ + _state = state; + if (state == HBQueueItemStateReady) + { + [self resetStatistics]; + } +} + - (NSURL *)fileURL { return _job.fileURL; @@ -65,6 +82,36 @@ return _attributedDescription; } +#pragma mark - Statistics + +- (void)resetStatistics +{ + self.pausedDate = nil; + self.resumedDate = nil; + self.startedDate = nil; + self.endedDate = nil; + self.encodeDuration = 0; + self.pauseDuration = 0; +} + +- (void)pausedAtDate:(NSDate *)date +{ + self.pausedDate = date; +} + +- (void)resumedAtDate:(NSDate *)date +{ + self.resumedDate = date; + self.pauseDuration += [self.resumedDate timeIntervalSinceDate:self.pausedDate]; +} + +- (void)setEndedDate:(NSDate *)endedDate +{ + _endedDate = endedDate; + self.encodeDuration = [self.startedDate timeIntervalSinceDate:self.endedDate]; + self.encodeDuration -= self.pauseDuration; +} + #pragma mark - NSSecureCoding + (BOOL)supportsSecureCoding @@ -80,6 +127,12 @@ static NSString *versionKey = @"HBQueueItemVersion"; encodeInt(_state); encodeObject(_job); encodeObject(_uuid); + + encodeDouble(_encodeDuration); + encodeDouble(_pauseDuration); + + encodeObject(_startedDate); + encodeObject(_endedDate); } - (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder @@ -91,6 +144,13 @@ static NSString *versionKey = @"HBQueueItemVersion"; decodeInt(_state); if (_state < HBQueueItemStateReady || _state > HBQueueItemStateFailed) { goto fail; } decodeObjectOrFail(_job, HBJob); decodeObjectOrFail(_uuid, NSString); + + decodeDouble(_encodeDuration); + decodeDouble(_pauseDuration); + + decodeObject(_startedDate, NSDate); + decodeObject(_endedDate, NSDate); + return self; } fail: diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index ecdb0c0e9..7df67155b 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -264,6 +264,7 @@ A9B6B9F1217B408E00B957AE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B6B9EF217B408E00B957AE /* InfoPlist.strings */; }; A9B6B9F4217B408E00B957AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B6B9F2217B408E00B957AE /* Localizable.strings */; }; A9BC24C91A69293E007DC41A /* HBAttributedStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A9BC24C81A69293E007DC41A /* HBAttributedStringAdditions.m */; }; + A9C61F9E22E31CDB00C28E7C /* HBFlippedClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C61F9D22E31CDB00C28E7C /* HBFlippedClipView.m */; }; A9CE0A921F57EC3400724577 /* HBImageUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = A9CE0A911F57EC3400724577 /* HBImageUtilities.m */; }; A9CF25F71990D6820023F727 /* HBPresetsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9CF25F61990D6820023F727 /* HBPresetsViewController.m */; }; A9D0FA771C1C284D0003F2A9 /* HBFocusRingView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9D0FA761C1C284D0003F2A9 /* HBFocusRingView.m */; }; @@ -677,6 +678,8 @@ A9BC24C81A69293E007DC41A /* HBAttributedStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBAttributedStringAdditions.m; sourceTree = "<group>"; }; A9C183931A716B8F00C897C2 /* HBTitleSelectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBTitleSelectionController.h; sourceTree = "<group>"; }; A9C183941A716B8F00C897C2 /* HBTitleSelectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBTitleSelectionController.m; sourceTree = "<group>"; }; + A9C61F9C22E31CDB00C28E7C /* HBFlippedClipView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBFlippedClipView.h; sourceTree = "<group>"; }; + A9C61F9D22E31CDB00C28E7C /* HBFlippedClipView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBFlippedClipView.m; sourceTree = "<group>"; }; A9CAC26E1CCB6B0F00A39E72 /* HBPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPlayer.h; sourceTree = "<group>"; }; A9CE0A911F57EC3400724577 /* HBImageUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBImageUtilities.m; sourceTree = "<group>"; }; A9CE0A931F57EC4600724577 /* HBImageUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBImageUtilities.h; sourceTree = "<group>"; }; @@ -1425,6 +1428,8 @@ A9D0FA761C1C284D0003F2A9 /* HBFocusRingView.m */, A93B49201DA3AA6900DD70A3 /* HBToolbarBadgedItem.h */, A93B49211DA3AA6900DD70A3 /* HBToolbarBadgedItem.m */, + A9C61F9C22E31CDB00C28E7C /* HBFlippedClipView.h */, + A9C61F9D22E31CDB00C28E7C /* HBFlippedClipView.m */, ); name = "UI Views"; sourceTree = "<group>"; @@ -1806,6 +1811,7 @@ A98036CD1CCA91DD007661AA /* HBAVPlayer.m in Sources */, A9BC24C91A69293E007DC41A /* HBAttributedStringAdditions.m in Sources */, 273F20B314ADBE670021BE6D /* HBOutputPanelController.m in Sources */, + A9C61F9E22E31CDB00C28E7C /* HBFlippedClipView.m in Sources */, 273F20B414ADBE670021BE6D /* HBOutputRedirect.m in Sources */, A95BA15D220C968500A2F9F9 /* HBQueueItem.m in Sources */, A9D0FA771C1C284D0003F2A9 /* HBFocusRingView.m in Sources */, |