]> granicus.if.org Git - handbrake/commitdiff
MacGui: store queue items statistics.
authorDamiano Galassi <damiog@gmail.com>
Thu, 25 Jul 2019 06:12:35 +0000 (08:12 +0200)
committerDamiano Galassi <damiog@gmail.com>
Thu, 25 Jul 2019 06:12:35 +0000 (08:12 +0200)
macosx/HBFlippedClipView.h [new file with mode: 0644]
macosx/HBFlippedClipView.m [new file with mode: 0644]
macosx/HBQueue.h
macosx/HBQueue.m
macosx/HBQueueItem.h
macosx/HBQueueItem.m
macosx/HandBrake.xcodeproj/project.pbxproj

diff --git a/macosx/HBFlippedClipView.h b/macosx/HBFlippedClipView.h
new file mode 100644 (file)
index 0000000..63db278
--- /dev/null
@@ -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 (file)
index 0000000..cacd620
--- /dev/null
@@ -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
index a879b415c8baec09fd2473aca316d36db0577ac6..d62b2503364d61abdc2f68dbabd589d05e68da24 100644 (file)
@@ -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;
index 4a4b73b200b5e3f49600c0032be95416a0a942be..846f13c245624639edff62395f9fdf3360803218 100644 (file)
@@ -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];
index a4a96ab369be30ee2237e93e9a968f0374fac2c0..13ad6c094934a3462c49cc95131ab519785908c5 100644 (file)
@@ -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;
 
index 959167731fbaf54819a808450e1d7bd545cc0fef..f3279790e3f63e0f3176d2f1a6ea2a12b998e85f 100644 (file)
@@ -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
 
 #pragma mark - Properties
 
+- (void)setState:(HBQueueItemState)state
+{
+    _state = state;
+    if (state == HBQueueItemStateReady)
+    {
+        [self resetStatistics];
+    }
+}
+
 - (NSURL *)fileURL
 {
     return _job.fileURL;
     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:
index ecdb0c0e90066a027fb3f194c7ab9985b64ccd20..7df67155bf6fffc73e2eee87de461788cbacef5c 100644 (file)
                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 */; };
                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>"; };
                                A9D0FA761C1C284D0003F2A9 /* HBFocusRingView.m */,
                                A93B49201DA3AA6900DD70A3 /* HBToolbarBadgedItem.h */,
                                A93B49211DA3AA6900DD70A3 /* HBToolbarBadgedItem.m */,
+                               A9C61F9C22E31CDB00C28E7C /* HBFlippedClipView.h */,
+                               A9C61F9D22E31CDB00C28E7C /* HBFlippedClipView.m */,
                        );
                        name = "UI Views";
                        sourceTree = "<group>";
                                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 */,