diff options
author | ritsuka <[email protected]> | 2015-04-30 16:04:37 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-04-30 16:04:37 +0000 |
commit | 96bf5cafd9e7891d2ad5741543e6e1e76ae52f77 (patch) | |
tree | 36e14374381e55963fd603bc32c2079fea9d6170 /macosx/HBPreviewGenerator.m | |
parent | 1c59ab0f6e1a92c0f79629658302936796c6f7ed (diff) |
MacGui: add a new formatter to convert a hb_state_t to a textual representation.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7134 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPreviewGenerator.m')
-rw-r--r-- | macosx/HBPreviewGenerator.m | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 75d2b0ab8..6719b54d2 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -10,6 +10,7 @@ #import "HBCore.h" #import "HBJob.h" +#import "HBStateFormatter.h" #import "HBPicture+UIAdditions.h" @interface HBPreviewGenerator () @@ -180,46 +181,28 @@ int level = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; self.core = [[HBCore alloc] initWithLogLevel:level name:@"PreviewCore"]; + HBStateFormatter *formatter = [[HBStateFormatter alloc] init]; + formatter.twoLines = NO; + formatter.showPassNumber = NO; + // start the actual encode [self.core encodeJob:job progressHandler:^(HBState state, hb_state_t hb_state) { - switch (state) { - case HBStateWorking: - { - NSMutableString *info = [NSMutableString stringWithFormat: @"Encoding preview: %.2f %%", 100.0 * hb_state.param.working.progress]; - - if (hb_state.param.working.seconds > -1) - { - [info appendFormat:@" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)", - hb_state.param.working.rate_cur, hb_state.param.working.rate_avg, hb_state.param.working.hours, - hb_state.param.working.minutes, hb_state.param.working.seconds]; - } - - double progress = 100.0 * hb_state.param.working.progress; - - [self.delegate updateProgress:progress info:info]; - break; - } - case HBStateMuxing: - [self.delegate updateProgress:100.0 info:@"Muxing Preview…"]; - break; - - default: - break; - } - } - completionHandler:^(BOOL success) { - // Encode done, call the delegate and close libhb handle - if (success) - { - [self.delegate didCreateMovieAtURL:destURL]; - } - else - { - [self.delegate didCancelMovieCreation]; - } - self.core = nil; - }]; + [self.delegate updateProgress:[formatter stateToPercentComplete:hb_state] * 100 + info:[formatter stateToString:hb_state title:@"preview"]]; + } + completionHandler:^(BOOL success) { + // Encode done, call the delegate and close libhb handle + if (success) + { + [self.delegate didCreateMovieAtURL:destURL]; + } + else + { + [self.delegate didCancelMovieCreation]; + } + self.core = nil; + }]; return YES; } |