WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / macosx / HBCore.h
blob1d7a4e279018ab466c077e885d832de5a5a98a44
1 /* HBCore.h $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
5 It may be used under the terms of the GNU General Public License. */
7 #import <Foundation/Foundation.h>
8 #include "hb.h"
10 @class HBJob;
11 @class HBPicture;
12 @class HBTitle;
14 NS_ASSUME_NONNULL_BEGIN
16 // These constants specify the current state of HBCore.
17 typedef NS_ENUM(NSUInteger, HBState) {
18 HBStateIdle = HB_STATE_IDLE, ///< HB is doing nothing
19 HBStateScanning = HB_STATE_SCANNING, ///< HB is scanning
20 HBStateScanDone = HB_STATE_SCANDONE, ///< Scanning has been completed
21 HBStateWorking = HB_STATE_WORKING, ///< HB is encoding
22 HBStatePaused = HB_STATE_PAUSED, ///< Encoding is paused
23 HBStateWorkDone = HB_STATE_WORKDONE, ///< Encoding has been completed
24 HBStateMuxing = HB_STATE_MUXING, ///< HB is muxing
25 HBStateSearching = HB_STATE_SEARCHING ///< HB is searching
28 typedef void (^HBCoreProgressHandler)(HBState state, hb_state_t hb_state);
29 typedef void (^HBCoreCompletionHandler)(BOOL success);
31 /**
32 * HBCore is an Objective-C interface to the low-level HandBrake library.
33 * HBCore monitors state changes of libhb. It can also be used
34 * to implement properties that can be directly bound to elements of the gui.
36 @interface HBCore : NSObject
38 /**
39 * Set the status of libdvdnav in low level HandBrake library.
40 * This should be called once before other functions HBCore are used.
42 * @param enabled whether libdvdnav is enabled or not.
44 + (void)setDVDNav:(BOOL)enabled;
46 /**
47 * Inits libhb globals.
49 + (void)initGlobal;
51 /**
52 * Performs the final cleanup for the process.
54 + (void)closeGlobal;
56 /**
57 * Registers a global error handler block.
59 * @param handler a block called with the error message.
61 + (void)registerErrorHandler:(void (^)(NSString *error))handler;
63 /**
64 * Opens low level HandBrake library. This should be called once before other
65 * functions HBCore are used.
67 * @param level the desired libhb logging level.
69 - (instancetype)initWithLogLevel:(int)level NS_DESIGNATED_INITIALIZER;
71 /**
72 * Opens low level HandBrake library. This should be called once before other
73 * functions HBCore are used.
75 * @param level the desired libhb logging level
76 * @param name the instance debug name
78 - (instancetype)initWithLogLevel:(int)level name:(NSString *)name;
80 /**
81 * Current state of HBCore.
83 @property (nonatomic, readonly) HBState state;
85 /**
86 * The name of the core, used for debugging purpose.
88 @property (nonatomic, copy) NSString *name;
90 /**
91 * Determines whether the scan operation can scan a particural URL or whether an additional decryption lib is needed.
93 * @param url the URL of the input file.
94 * @param error an error containing additional info.
96 * @return YES is the file at URL is scannable.
98 - (BOOL)canScan:(NSURL *)url error:(NSError * __autoreleasing *)error;
101 * Initiates an asynchronous scan operation and returns immediately.
103 * @param url the URL of the input file.
104 * @param index the index of the desired title. Use 0 to scan every title.
105 * @param previewsNum the number of previews image to generate.
106 * @param seconds the minimum duration of the wanted titles in seconds.
107 * @param progressHandler a block called periodically with the progress information.
108 * @param completionHandler a block called with the scan result.
110 - (void)scanURL:(NSURL *)url titleIndex:(NSUInteger)index previews:(NSUInteger)previewsNum minDuration:(NSUInteger)seconds progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler;
113 * Cancels the scan execution.
114 * Cancel can be invoked when the scan is running.
116 - (void)cancelScan;
119 * An array of HBTitles found by the latest scan.
121 @property (nonatomic, readonly, nullable) NSArray *titles;
124 * This function converts an image created by libhb (specified via index)
125 * into an CGImage.
127 * @param index the index of the desired image.
128 * @param title Handle to hb_title_t of desired title
129 * @param frame a HBPicture instance that describe the image's frame.
130 * @param deinterlace whether the preview image must be deinterlaced or not.
132 * @return a CGImageRef of the wanted image, NULL if the index is out of bounds.
134 - (nullable CGImageRef)copyImageAtIndex:(NSUInteger)index
135 forTitle:(HBTitle *)title
136 pictureFrame:(HBPicture *)frame
137 deinterlace:(BOOL)deinterlace CF_RETURNS_RETAINED;
140 * Initiates an asynchronous encode operation and returns immediately.
142 * @param job the job to encode
143 * @param progressHandler a block called periodically with the progress information.
144 * @param completionHandler a block called with the scan result
146 - (void)encodeJob:(HBJob *)job progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler;
149 * Stops encode operation and releases resources.
150 * Cancel can be invoked when the encode is running.
152 - (void)cancelEncode;
155 * Pauses the encode operation.
156 * Pause can be invoked when the encode is running.
158 - (void)pause;
161 * Resumes a paused encoding session.
162 * Resume can be invoked when the encode is running.
164 - (void)resume;
166 @end
168 NS_ASSUME_NONNULL_END