1 #include "QueueController.h"
3 @implementation QueueController
5 - (void) SetHandle: (hb_handle_t *) handle
10 - (void) AddTextField: (NSString *) string rect: (NSRect *) rect
12 NSTextField * textField;
16 rect->size.width = 700;
17 rect->size.height = 15;
18 textField = [[NSTextField alloc] initWithFrame: *rect];
19 [textField setEditable: NO];
20 [textField setSelectable: NO];
21 [textField setDrawsBackground: NO];
22 [textField setBordered: NO];
23 [textField setFont: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
24 [textField setStringValue: string];
26 [fTaskView addSubview: textField];
30 - (void) removeTask: (id) sender
32 hb_rem( fHandle, hb_job( fHandle, [sender tag] ) );
33 [self performSelectorOnMainThread: @selector( Update: )
34 withObject: sender waitUntilDone: NO];
37 - (void) AddButton: (NSRect *) rect tag: (int) tag
41 rect->origin.x = rect->size.width - 60;
43 rect->size.width = 60;
44 rect->size.height = 20;
46 button = [[NSButton alloc] initWithFrame: *rect];
47 rect->size.width = rect->origin.x + 90;
49 [button setTitle: @"Remove"];
50 [button setBezelStyle: NSRoundedBezelStyle];
51 [button setFont: [NSFont systemFontOfSize:
52 [NSFont systemFontSizeForControlSize: NSMiniControlSize]]];
53 [[button cell] setControlSize: NSMiniControlSize];
56 [button setTarget: self];
57 [button setAction: @selector( removeTask: )];
59 [fTaskView addSubview: button];
65 rect->size.width -= 10;
66 rect->size.height = 1;
67 box = [[NSBox alloc] initWithFrame: *rect];
68 [box setBoxType: NSBoxSeparator];
70 rect->size.width -= 30;
72 [fTaskView addSubview: box];
75 - (IBAction) Update: (id) sender
81 NSSize size = [fScrollView contentSize];
82 int height = MAX( 20 + 145 * hb_count( fHandle ), size.height );
83 [fTaskView setFrame: NSMakeRect(0,0,size.width,height)];
85 NSRect rect = NSMakeRect(10,height-10,size.width-20,10);
87 NSArray * subviews = [fTaskView subviews];
88 while( [subviews count] > 0 )
90 [[subviews objectAtIndex: 0]
91 removeFromSuperviewWithoutNeedingDisplay];
94 for( i = 0; i < hb_count( fHandle ); i++ )
96 j = hb_job( fHandle, i );
98 /* show the name of the source Note: use title->name instead of
99 title->dvd since name is just the chosen folder, instead of dvd which is the full path*/
105 [self AddTextField: [NSString stringWithFormat:
106 @"Task: %d Source: %s, Title %d, Chapters %d-%d Pass: Scan",i+1, title->name, title->index , j->chapter_start, j->chapter_end] rect: &rect];
111 [self AddTextField: [NSString stringWithFormat:
112 @"Task: %d Source: %s, Title %d, Chapters %d-%d Pass: %d of %d",i+1, title->name, title->index , j->chapter_start, j->chapter_end,MAX( 1, j->pass ), MIN( 2, j->pass + 1 )] rect: &rect]; /* Muxer settings (File Format in the gui) */
113 if (j->mux == 65536 || j->mux == 131072 || j->mux == 1048576)
115 jobFormat = @"MP4"; // HB_MUX_MP4,HB_MUX_PSP,HB_MUX_IPOD
117 if (j->mux == 262144)
119 jobFormat = @"AVI"; // HB_MUX_AVI
121 if (j->mux == 524288)
123 jobFormat = @"OGM"; // HB_MUX_OGM
125 if (j->mux == 2097152)
127 jobFormat = @"MKV"; // HB_MUX_MKV
130 /* Video Codec settings (Encoder in the gui) */
133 jobVideoCodec = @"FFmpeg"; // HB_VCODEC_FFMPEG
137 jobVideoCodec = @"XviD"; // HB_VCODEC_XVID
141 /* Deterimine for sure how we are now setting iPod uuid atom */
142 if (j->h264_level) // We are encoding for iPod
144 jobVideoCodec = @"x264 (H.264 iPod)"; // HB_VCODEC_X264
148 jobVideoCodec = @"x264 (H.264 Main)"; // HB_VCODEC_X264
151 /* Audio Codecs (Second half of Codecs in the gui) */
152 if (j->acodec == 256)
154 jobAudioCodec = @"AAC"; // HB_ACODEC_FAAC
156 if (j->acodec == 512)
158 jobAudioCodec = @"MP3"; // HB_ACODEC_LAME
160 if (j->acodec == 1024)
162 jobAudioCodec = @"Vorbis"; // HB_ACODEC_VORBIS
164 if (j->acodec == 2048)
166 jobAudioCodec = @"AC3"; // HB_ACODEC_AC3
168 /* Show Basic File info */
169 if (j->chapter_markers == 1)
171 [self AddTextField: [NSString stringWithFormat: @"Format: %@ Container, %@ Video + %@ Audio, Chapter Markers", jobFormat, jobVideoCodec, jobAudioCodec]
176 [self AddTextField: [NSString stringWithFormat: @"Format: %@ Container, %@ Video + %@ Audio", jobFormat, jobVideoCodec, jobAudioCodec]
181 /*integers for picture values deinterlace, crop[4], keep_ratio, grayscale, pixel_ratio, pixel_aspect_width, pixel_aspect_height,
182 maxWidth, maxHeight */
183 if (j->pixel_ratio == 1)
185 int titlewidth = title->width - j->crop[2] - j->crop[3];
186 int displayparwidth = titlewidth * j->pixel_aspect_width / j->pixel_aspect_height;
187 int displayparheight = title->height - j->crop[0] - j->crop[1];
188 jobPictureDetail = [NSString stringWithFormat: @"Picture: %dx%d (%dx%d Anamorphic)", displayparwidth, displayparheight, j->width, displayparheight];
192 jobPictureDetail = [NSString stringWithFormat: @"Picture: %dx%d", j->width, j->height];
194 if (j->keep_ratio == 1)
196 jobPictureDetail = [jobPictureDetail stringByAppendingString: @" Keep Aspect Ratio"];
199 if (j->grayscale == 1)
201 jobPictureDetail = [jobPictureDetail stringByAppendingString: @", Grayscale"];
204 if (j->deinterlace == 1)
206 jobPictureDetail = [jobPictureDetail stringByAppendingString: @", Deinterlace"];
208 /* Show Picture info */
209 [self AddTextField: [NSString stringWithFormat: @"%@", jobPictureDetail]rect: &rect];
211 /* Detailed Video info */
212 if (j->vquality <= 0 || j->vquality >= 1)
214 jobVideoQuality =[NSString stringWithFormat: @"%d kbps", j->vbitrate];
218 NSNumber * vidQuality;
219 vidQuality = [NSNumber numberWithInt: j->vquality * 100];
220 /* this is screwed up kind of. Needs to be formatted properly */
223 jobVideoQuality =[NSString stringWithFormat: @"%@%% CRF", vidQuality];
227 jobVideoQuality =[NSString stringWithFormat: @"%@%% CQP", vidQuality];
232 if (j->vrate_base == 1126125)
234 /* NTSC FILM 23.976 */
235 jobVideoDetail = [NSString stringWithFormat:@"Video: %@, %@, 23.976 fps", jobVideoCodec, jobVideoQuality];
237 else if (j->vrate_base == 900900)
240 jobVideoDetail = [NSString stringWithFormat:@"Video: %@, %@, 29.97 fps", jobVideoCodec, jobVideoQuality];
244 /* Everything else */
245 jobVideoDetail = [NSString stringWithFormat:@"Video: %@, %@, %d fps", jobVideoCodec, jobVideoQuality, j->vrate / j->vrate_base];
248 /* Add the video detail string to the job filed in the window */
249 [self AddTextField: [NSString stringWithFormat:@"%@", jobVideoDetail] rect: &rect];
251 /* if there is an x264 option string, lets add it here*/
252 /*NOTE: Due to size, lets get this in a tool tip*/
256 [self AddTextField: [NSString stringWithFormat:@"x264 Options: %@", [NSString stringWithUTF8String:j->x264opts]] rect: &rect];
260 if ([jobAudioCodec isEqualToString: @"AC3"])
262 jobAudioDetail = [NSString stringWithFormat:@"Audio: %@, Pass-Through", jobAudioCodec];
266 jobAudioDetail = [NSString stringWithFormat:@"Audio: %@, %d kbps, %d Hz", jobAudioCodec, j->abitrate, j->arate];
269 /* we now get the audio mixdown info for each of the two gui audio tracks */
270 /* lets do it the long way here to get a handle on things.
271 Hardcoded for two tracks for gui: audio_mixdowns[i] audio_mixdowns[i] */
272 int ai; // counter for each audios [] , macgui only allows for two audio tracks currently
273 for( ai = 0; ai < 2; ai++ )
275 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_MONO)
277 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@", Track %d: Mono",ai + 1]];
279 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_STEREO)
281 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@", Track %d: Stereo",ai + 1]];
283 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_DOLBY)
285 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@", Track %d: Dolby Surround",ai + 1]];
287 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_DOLBYPLII)
289 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@", Track %d: Dolby Pro Logic II",ai + 1]];
291 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_6CH)
293 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@", Track %d: 6-channel discreet",ai + 1]];
297 /* Add the Audio detail string to the job filed in the window */
298 [self AddTextField: [NSString stringWithFormat:@"%@", jobAudioDetail] rect: &rect];
300 /*Destination Field */
301 [self AddTextField: [NSString stringWithFormat: @"Destination: %s", j->file] rect: &rect];
303 /* Show remove button */
304 [self AddButton: &rect tag: i];
307 [fTaskView scrollPoint: NSMakePoint(0,height)];
308 [fTaskView setNeedsDisplay: YES];
312 - (IBAction) ClosePanel: (id) sender