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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/* HBQueueController
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. */
#include <Cocoa/Cocoa.h>
#include "hb.h"
@class HBController;
@class HBJob;
@class HBJobGroup;
#define HB_QUEUE_DRAGGING 0 // <--- NOT COMPLETELY FUNCTIONAL YET
#define HB_OUTLINE_METRIC_CONTROLS 0 // for tweaking the outline cell spacings
// hb_job_t contains a sequence_id field. The high word is a unique job group id.
// The low word contains the "sequence id" which is a value starting at 0 and
// incremented for each pass in the job group. Use the function below to create and
// interpret a sequence_id field.
int MakeJobID(int jobGroupID, int sequenceNum);
bool IsFirstPass(int jobID);
typedef enum _HBQueueJobGroupStatus
{
HBStatusNone = 0,
HBStatusPending = 1,
HBStatusWorking = 2,
HBStatusCompleted = 3,
HBStatusCanceled = 4
} HBQueueJobGroupStatus;
// Notification sent whenever the status of a HBJobGroup changes (via setStatus). The
// user info contains one object, @"HBOldJobGroupStatus", which is an NSNumber
// containing the previous status of the job group.
extern NSString * HBJobGroupStatusNotification;
//------------------------------------------------------------------------------------
// As usual, we need to subclass NSOutlineView to handle a few special cases:
//
// (1) variable row heights during live resizes
// HBQueueOutlineView exists solely to get around a bug in variable row height outline
// views in which row heights get messed up during live resizes. See this discussion:
// http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00871.html
// However, the recommeneded fix (override drawRect:) does not work. Instead, this
// subclass implements viewDidEndLiveResize in order to recalculate all row heights.
//
// (2) prevent expanding of items during drags
// During dragging operations, we don't want outline items to expand, since a queue
// doesn't really have children items.
//
// (3) generate a drag image that incorporates more than just the first column
// By default, NSTableView only drags an image of the first column. Change this to
// drag an image of the queue's icon and desc columns.
@interface HBQueueOutlineView : NSOutlineView
{
#if HB_QUEUE_DRAGGING
BOOL fIsDragging;
#endif
}
#if HB_QUEUE_DRAGGING
- (BOOL) isDragging;
#endif
@end
//------------------------------------------------------------------------------------
// HBJob is the UI's equivalent to libhb's hb_job_t struct. It is used mainly for
// drawing the job's description. HBJob are referred to in the UI as 'passes'.
//------------------------------------------------------------------------------------
@interface HBJob : NSObject
{
HBJobGroup *jobGroup; // The group this job belongs to
// The following fields match up with similar fields found in hb_job_t and it's
// various substructures.
@public
// from hb_job_s
int sequence_id; // This is how we xref to the jobs inside libhb
int chapter_start;
int chapter_end;
int chapter_markers;
int crop[4];
int deinterlace;
int width; // source dimensions
int height;
int output_width; // output dimensions
int output_height;
int anamorphic_width; // anamorphic dimensions
int anamorphic_height;
int keep_ratio;
int grayscale;
int pixel_ratio;
int pixel_aspect_width;
int pixel_aspect_height;
int vcodec;
float vquality;
int vbitrate;
int vrate;
int vrate_base;
int pass;
int h264_level;
int crf;
NSString *x264opts;
/* Used to concatenate audio list values into a string for display */
NSString *audioinfo_codecs;
NSString *audioinfo_summary;
int audio_mixdowns[8];
int acodec;
int abitrate;
int arate;
int subtitle;
int mux;
NSString *file;
// from hb_title_s
NSString *titleName;
int titleIndex;
int titleWidth;
int titleHeight;
// from hb_subtitle_s
NSString *subtitleLang;
}
+ (HBJob*) jobWithLibhbJob: (hb_job_t *) job;
- (id) initWithLibhbJob: (hb_job_t *) job;
- (HBJobGroup *) jobGroup;
- (void) setJobGroup: (HBJobGroup *)aJobGroup;
- (NSMutableAttributedString *) attributedDescriptionWithIcon: (BOOL)withIcon
withTitle: (BOOL)withTitle
withPassName: (BOOL)withPassName
withFormatInfo: (BOOL)withFormatInfo
withDestination: (BOOL)withDestination
withPictureInfo: (BOOL)withPictureInfo
withVideoInfo: (BOOL)withVideoInfo
withx264Info: (BOOL)withx264Info
withAudioInfo: (BOOL)withAudioInfo
withSubtitleInfo: (BOOL)withSubtitleInfo;
// Attributes used by attributedDescriptionWithIcon:::::::::
+ (NSMutableParagraphStyle *) descriptionParagraphStyle;
+ (NSDictionary *) descriptionDetailAttribute;
+ (NSDictionary *) descriptionDetailBoldAttribute;
+ (NSDictionary *) descriptionTitleAttribute;
+ (NSDictionary *) descriptionShortHeightAttribute;
@end
//------------------------------------------------------------------------------------
// HBJobGroup is what's referred to in the UI as an 'encode'. A job group contains
// multiple HBJobs, one for each 'pass' of the encode. Whereas libhb keeps a simple
// list of jobs in it's queue, the queue controller presents them to the user as a
// series of encodes and passes (HBJObGroups and HBJobs).
//------------------------------------------------------------------------------------
@interface HBJobGroup : NSObject
{
NSMutableArray *fJobs; // array of HBJob
NSMutableAttributedString *fDescription;
BOOL fNeedsDescription;
CGFloat fLastDescriptionHeight;
CGFloat fLastDescriptionWidth;
HBQueueJobGroupStatus fStatus;
NSString *fPresetName;
}
// Creating a job group
+ (HBJobGroup *) jobGroup;
// Adding jobs
- (void) addJob: (HBJob *)aJob;
// Querying a job group
- (unsigned int) count;
- (HBJob *) jobAtIndex: (unsigned)index;
- (unsigned int) indexOfJob: (HBJob *)aJob;
- (NSEnumerator *) jobEnumerator;
- (void) setStatus: (HBQueueJobGroupStatus)status;
- (HBQueueJobGroupStatus) status;
- (void) setPresetName: (NSString *)name;
- (NSString *) presetName;
- (NSString *) destinationPath;
- (NSString *) name;
// Creating a description
- (void) setNeedsDescription: (BOOL)flag;
- (NSMutableAttributedString *) attributedDescription;
- (CGFloat) heightOfDescriptionForWidth:(CGFloat)width;
- (CGFloat) lastDescriptionHeight;
@end
//------------------------------------------------------------------------------------
@interface HBQueueController : NSWindowController
{
hb_handle_t *fHandle; // reference to libhb
HBController *fHBController; // reference to HBController
NSMutableArray *fJobGroups; // libhb's job list organized in a hierarchy of HBJobGroup and HBJob
HBJobGroup *fCurrentJobGroup; // the HJobGroup currently being processed by libhb
HBJob *fCurrentJob; // the HJob (pass) currently being processed by libhb
int fCurrentJobID; // this is how we track when hbib has started processing a different job. This is the job's sequence_id.
unsigned int fPendingCount; // Number of various kinds of job groups in fJobGroups.
unsigned int fCompletedCount; // Don't access these directly as they may not always be up-to-date.
unsigned int fCanceledCount; // Use the accessor functions instead.
unsigned int fWorkingCount;
BOOL fJobGroupCountsNeedUpdating;
BOOL fCurrentJobPaneShown; // NO when fCurrentJobPane has been shifted out of view (see showCurrentJobPane)
NSMutableIndexSet *fSavedExpandedItems; // used by save/restoreOutlineViewState to preserve which items are expanded
NSMutableIndexSet *fSavedSelectedItems; // used by save/restoreOutlineViewState to preserve which items are selected
#if HB_QUEUE_DRAGGING
NSArray *fDraggedNodes;
#endif
NSTimer *fAnimationTimer; // animates the icon of the current job in the queue outline view
int fAnimationIndex; // used to generate name of image used to animate the current job in the queue outline view
// +------------------window-------------------+
// |+-------------fCurrentJobPane-------------+|
// || ||
// || ||
// || ||
// |+-----------------------------------------+|
// |+---------------fQueuePane----------------+|
// || ||
// || ||
// || ||
// || ||
// || ||
// || ||
// || ||
// |+-----------------------------------------+|
// +-------------------------------------------+
// fCurrentJobPane - visible only when processing a job
IBOutlet NSView *fCurrentJobPane;
IBOutlet NSImageView *fJobIconView;
IBOutlet NSTextField *fJobDescTextField;
IBOutlet NSProgressIndicator *fProgressBar;
IBOutlet NSTextField *fProgressTextField;
// fQueuePane - always visible; fills entire window when fCurrentJobPane is hidden
IBOutlet NSView *fQueuePane;
IBOutlet HBQueueOutlineView *fOutlineView;
IBOutlet NSTextField *fQueueCountField;
#if HB_OUTLINE_METRIC_CONTROLS
IBOutlet NSSlider *fIndentation; // debug
IBOutlet NSSlider *fSpacing; // debug
#endif
}
- (void)setHandle: (hb_handle_t *)handle;
- (void)setHBController: (HBController *)controller;
- (void)libhbStateChanged: (hb_state_t &)state;
- (void)libhbWillStop;
// Adding items to the queue
- (void) addJobGroup: (HBJobGroup *) aJobGroup;
// Getting the currently processing job group
- (HBJobGroup *) currentJobGroup;
- (HBJob *) currentJob;
// Getting job groups
- (HBJobGroup *) pendingJobGroupWithDestinationPath: (NSString *)path;
// Getting queue statistics
- (unsigned int) pendingCount;
- (unsigned int) completedCount;
- (unsigned int) canceledCount;
- (unsigned int) workingCount;
- (IBAction)showQueueWindow: (id)sender;
- (IBAction)removeSelectedJobGroups: (id)sender;
- (IBAction)revealSelectedJobGroups: (id)sender;
- (IBAction)cancelCurrentJob: (id)sender;
- (IBAction)toggleStartCancel: (id)sender;
- (IBAction)togglePauseResume: (id)sender;
#if HB_OUTLINE_METRIC_CONTROLS
- (IBAction)imageSpacingChanged: (id)sender;
- (IBAction)indentChanged: (id)sender;
#endif
@end
|