OSDN Git Service

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