summaryrefslogtreecommitdiffstats
path: root/macosx/HBCore.h
blob: ba10addbec33f6e05e539ddb4820643d2183a58e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*  HBCore.h $

 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>
#include "hb.h"

// These constants specify the current state of HBCore.
typedef NS_ENUM(NSUInteger, HBState) {
    HBStateIdle      = HB_STATE_IDLE,        ///< HB is doing nothing
    HBStateScanning  = HB_STATE_SCANNING,    ///< HB is scanning
    HBStateScanDone  = HB_STATE_SCANDONE,    ///< Scanning has been completed
    HBStateWorking   = HB_STATE_WORKING,     ///< HB is encoding
    HBStatePaused    = HB_STATE_PAUSED,      ///< Encoding is paused
    HBStateWorkDone  = HB_STATE_WORKDONE,    ///< Encoding has been completed
    HBStateMuxing    = HB_STATE_MUXING,      ///< HB is muxing
    HBStateSearching = HB_STATE_SEARCHING    ///< HB is searching
};

extern NSString *HBCoreScanningNotification;
extern NSString *HBCoreScanDoneNotification;
extern NSString *HBCoreWorkingNotification;
extern NSString *HBCorePausedNotification;
extern NSString *HBCoreWorkDoneNotification;
extern NSString *HBCoreMuxingNotification;

/**
 * HBCore is an Objective-C interface to the low-level HandBrake library.
 * HBCore monitors state changes of libhb and provides notifications via
 * NSNotificationCenter to any object who needs them. It can also be used
 * to implement properties that can be directly bound to elements of the gui.
 */
@interface HBCore : NSObject

/**
 * Set the status of libdvdnav in low level HandBrake library.
 * This should be called once before other functions HBCore are used.
 *
 * @param enabled         whether libdvdnav is enabled or not.
 */
+ (void)setDVDNav:(BOOL)enabled;

/**
 * Opens low level HandBrake library. This should be called once before other
 * functions HBCore are used.
 *
 * @param loggingLevel         the desired libhb logging level.
 *
 * @return YES if libhb was opened, NO if there was an error.
 */
- (instancetype)initWithLoggingLevel:(int)loggingLevel;

/**
 * Current state of HBCore.
 */
@property (nonatomic, readonly) HBState state;

/**
 * Pointer to a hb_state_s struct containing state information of libhb.
 */
@property (nonatomic, readonly) hb_state_t *hb_state;

/**
 * Pointer to a libhb handle used by this HBCore instance.
 */
@property (nonatomic, readonly) hb_handle_t *hb_handle;


/**
 *  Determines whether the scan operation can scan a particural URL or whether an additional decription lib is needed..
 *
 *  @param url   the URL of the input file.
 *  @param error an error containing additional info.
 *
 *  @return YES is the file at URL is scannable.
 */
- (BOOL)canScan:(NSURL *)url error:(NSError **)error;

/**
 *  Starts the asynchronous execution of a scan.
 *
 *  @param url              the URL of the input file.
 *  @param titleNum         the number of the desired title. Use 0 to scan every title.
 *  @param previewsNum      the number of previews image to generate.
 *  @param minTitleDuration the minimum duration of the wanted titles in seconds.
 */
- (void)scan:(NSURL *)url titleNum:(NSUInteger)titleNum previewsNum:(NSUInteger)previewsNum minTitleDuration:(NSUInteger)minTitleDuration;

/**
 * Starts the libhb encoding session.
 *
 *	This method must be called after all jobs have been added.
 */
- (void)start;

/**
 * Stops encoding session and releases resources.
 */
- (void)stop;

@end