diff options
author | ritsuka <[email protected]> | 2015-01-19 09:03:29 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-01-19 09:03:29 +0000 |
commit | ea82134f6199f79cb939781cb38dceaa1534dbc1 (patch) | |
tree | 7e1ae99de08481a8e47eb4ca75f003235c6af49d | |
parent | f69f4e15cf1a4e010aef3f1a77c768425562cc67 (diff) |
MacGui: remove startProgressHandler:completationHandler: method in HBCore. Switched HBPreviewGenerator to encodeJob: .
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6771 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/HBCore.h | 8 | ||||
-rw-r--r-- | macosx/HBCore.m | 21 | ||||
-rw-r--r-- | macosx/HBJob+HBJobConversion.m | 6 | ||||
-rw-r--r-- | macosx/HBPreviewGenerator.m | 39 | ||||
-rw-r--r-- | macosx/HBRange.h | 9 |
5 files changed, 40 insertions, 43 deletions
diff --git a/macosx/HBCore.h b/macosx/HBCore.h index 66fd40d72..94bdfe05a 100644 --- a/macosx/HBCore.h +++ b/macosx/HBCore.h @@ -123,14 +123,6 @@ completationHandler:(HBCoreCompletationHandler)completationHandler; - (void)cancelEncode; /** - * Starts the libhb encoding session. - * - * This method must be called after all jobs have been added. - * deprecated, will be removed soon. - */ -- (void)startProgressHandler:(HBCoreProgressHandler)progressHandler completationHandler:(HBCoreCompletationHandler)completationHandler; - -/** * Pauses the encoding session. */ - (void)pause; diff --git a/macosx/HBCore.m b/macosx/HBCore.m index 05871bbbc..f516e9916 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -226,6 +226,13 @@ - (void)encodeJob:(HBJob *)job progressHandler:(HBCoreProgressHandler)progressHandler completationHandler:(HBCoreCompletationHandler)completationHandler; { + // Copy the progress/completation blocks + self.progressHandler = progressHandler; + self.completationHandler = completationHandler; + + // Start the timer to handle libhb state changes + [self startUpdateTimerWithInterval:0.5]; + // Add the job to libhb hb_job_t *hb_job = job.hb_job; hb_job_set_file(hb_job, job.destURL.path.fileSystemRepresentation); @@ -234,18 +241,6 @@ // Free the job hb_job_close(&hb_job); - [self startProgressHandler:progressHandler completationHandler:completationHandler]; -} - -- (void)startProgressHandler:(HBCoreProgressHandler)progressHandler completationHandler:(HBCoreCompletationHandler)completationHandler; -{ - // Copy the progress/completation blocks - self.progressHandler = progressHandler; - self.completationHandler = completationHandler; - - // Start the timer to handle libhb state changes - [self startUpdateTimerWithInterval:0.5]; - hb_system_sleep_prevent(_hb_handle); hb_start(_hb_handle); @@ -254,7 +249,7 @@ // waiting for libhb to set it in a background thread. self.state = HBStateWorking; - [HBUtilities writeToActivityLog:"%s work started", self.name.UTF8String]; + [HBUtilities writeToActivityLog:"%s started encoding %s", self.name.UTF8String, job.destURL.lastPathComponent.UTF8String]; } - (BOOL)workDone diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m index e886cb0ef..dd14573d6 100644 --- a/macosx/HBJob+HBJobConversion.m +++ b/macosx/HBJob+HBJobConversion.m @@ -54,6 +54,12 @@ int stop_frame = self.range.frameStop; job->frame_to_stop = stop_frame; } + else if (self.range.type == HBRangePreviewIndex) + { + job->start_at_preview = self.range.previewIndex; + job->seek_points = self.range.previewsCount; + job->pts_to_stop = self.range.ptsToStop; + } // Format (Muxer) and Video Encoder job->mux = self.container; diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 88ad2c320..754ddaa1d 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -28,8 +28,6 @@ typedef enum EncodeState : NSUInteger { @property (nonatomic) HBCore *core; -@property (nonatomic, retain) NSURL *fileURL; - @end @implementation HBPreviewGenerator @@ -202,52 +200,51 @@ typedef enum EncodeState : NSUInteger { return NO; } + NSURL *destURL = nil; // Generate the file url and directories. if (self.job.container & HB_MUX_MASK_MP4) { // we use .m4v for our mp4 files so that ac3 and chapters in mp4 will play properly. - self.fileURL = [HBPreviewGenerator generateFileURLForType:@"m4v"]; + destURL = [HBPreviewGenerator generateFileURLForType:@"m4v"]; } else if (self.job.container & HB_MUX_MASK_MKV) { - self.fileURL = [HBPreviewGenerator generateFileURLForType:@"mkv"]; + destURL = [HBPreviewGenerator generateFileURLForType:@"mkv"]; } // return if we couldn't get the fileURL. - if (!self.fileURL) + if (!destURL) { return NO; } // See if there is an existing preview file, if so, delete it. - if (![[NSFileManager defaultManager] fileExistsAtPath:[self.fileURL path]]) + if (![[NSFileManager defaultManager] fileExistsAtPath:destURL.path]) { - [[NSFileManager defaultManager] removeItemAtPath:[self.fileURL path] error:NULL]; + [[NSFileManager defaultManager] removeItemAtPath:destURL.path error:NULL]; } - hb_job_t *job = self.job.hb_job; + HBJob *job = [[self.job copy] autorelease]; + job.title = self.job.title; + job.destURL = destURL; - // We now direct our preview encode to fileURL path. - hb_job_set_file(job, [[self.fileURL path] UTF8String]); + job.range.type = HBRangePreviewIndex; + job.range.previewIndex = (int)index + 1;; + job.range.previewsCount = (int)self.imagesCount; + job.range.ptsToStop = seconds * 90000LL; - job->start_at_preview = (int)index + 1; - job->seek_points = (int)self.imagesCount; - job->pts_to_stop = seconds * 90000LL; // Note: unlike a full encode, we only send 1 pass regardless if the final encode calls for 2 passes. // this should suffice for a fairly accurate short preview and cuts our preview generation time in half. - job->twopass = 0; + job.video.twoPass = NO; // Init the libhb core int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; self.core = [[[HBCore alloc] initWithLoggingLevel:loggingLevel] autorelease]; self.core.name = @"PreviewCore"; - // lets go ahead and send it off to libhb - hb_add(self.core.hb_handle, job); - hb_job_close(&job); - // start the actual encode - [self.core startProgressHandler:^(HBState state, hb_state_t hb_state) { + [self.core encodeJob:job + progressHandler:^(HBState state, hb_state_t hb_state) { switch (state) { case HBStateWorking: { @@ -279,7 +276,7 @@ typedef enum EncodeState : NSUInteger { // Encode done, call the delegate and close libhb handle if (success) { - [self.delegate didCreateMovieAtURL:self.fileURL]; + [self.delegate didCreateMovieAtURL:destURL]; } else { @@ -309,8 +306,6 @@ typedef enum EncodeState : NSUInteger { [_core release]; _core = nil; - [_fileURL release]; - _fileURL = nil; [_picturePreviews release]; _picturePreviews = nil; diff --git a/macosx/HBRange.h b/macosx/HBRange.h index bbffb2ede..166f33822 100644 --- a/macosx/HBRange.h +++ b/macosx/HBRange.h @@ -12,6 +12,7 @@ typedef NS_ENUM(NSUInteger, HBRangeType) { HBRangeTypeChapters, HBRangeTypeFrames, HBRangeTypeSeconds, + HBRangePreviewIndex, }; @interface HBRange : NSObject <NSCoding, NSCopying> @@ -20,15 +21,23 @@ typedef NS_ENUM(NSUInteger, HBRangeType) { @property (nonatomic, readwrite) HBRangeType type; +/// HBRangeTypeChapters @property (nonatomic, readwrite) int chapterStart; @property (nonatomic, readwrite) int chapterStop; +/// HBRangeTypeFrames @property (nonatomic, readwrite) int frameStart; @property (nonatomic, readwrite) int frameStop; +/// HBRangeTypeSeconds @property (nonatomic, readwrite) int secondsStart; @property (nonatomic, readwrite) int secondsStop; +/// HBRangePreviewIndex +@property (nonatomic, readwrite) int previewIndex; +@property (nonatomic, readwrite) int previewsCount; +@property (nonatomic, readwrite) int64_t ptsToStop; + @property (nonatomic, readonly) NSString *duration; @property (nonatomic, readwrite, assign) HBTitle *title; |