MacGui: store queue items statistics.
This commit is contained in:
parent
5396c8b3bd
commit
30b59112b7
16
macosx/HBFlippedClipView.h
Normal file
16
macosx/HBFlippedClipView.h
Normal file
@ -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
|
17
macosx/HBFlippedClipView.m
Normal file
17
macosx/HBFlippedClipView.m
Normal file
@ -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
|
@ -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;
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user