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*/
100 [self AddTextField: [NSString stringWithFormat:
101 @"Task: %d Source: %s Title: %d Chapters: %d to %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];
102 /* Muxer settings (File Format in the gui) */
103 if (j->mux == 65536 || j->mux == 131072 || j->mux == 1048576)
105 jobFormat = @"MP4"; // HB_MUX_MP4,HB_MUX_PSP,HB_MUX_IPOD
107 if (j->mux == 262144)
109 jobFormat = @"AVI"; // HB_MUX_AVI
111 if (j->mux == 524288)
113 jobFormat = @"OGM"; // HB_MUX_OGM
115 if (j->mux == 2097152)
117 jobFormat = @"MKV"; // HB_MUX_MKV
120 /* Video Codec settings (Encoder in the gui) */
123 jobVideoCodec = @"FFmpeg"; // HB_VCODEC_FFMPEG
127 jobVideoCodec = @"XviD"; // HB_VCODEC_XVID
131 /* Deterimine for sure how we are now setting iPod uuid atom */
132 if (j->h264_level) // We are encoding for iPod
134 jobVideoCodec = @"x264 (H.264 iPod)"; // HB_VCODEC_X264
138 jobVideoCodec = @"x264 (H.264 Main)"; // HB_VCODEC_X264
141 /* Audio Codecs (Second half of Codecs in the gui) */
142 if (j->acodec == 256)
144 jobAudioCodec = @"AAC"; // HB_ACODEC_FAAC
146 if (j->acodec == 512)
148 jobAudioCodec = @"MP3"; // HB_ACODEC_LAME
150 if (j->acodec == 1024)
152 jobAudioCodec = @"Vorbis"; // HB_ACODEC_VORBIS
154 if (j->acodec == 2048)
156 jobAudioCodec = @"AC3"; // HB_ACODEC_AC3
158 /* Show Basic File info */
159 if (j->chapter_markers == 1)
161 [self AddTextField: [NSString stringWithFormat: @"Format: %@ Codecs: %@ Video / %@ Audio Chapter Markers", jobFormat, jobVideoCodec, jobAudioCodec]
166 [self AddTextField: [NSString stringWithFormat: @"Format: %@ Codecs: %@ Video / %@ Audio", jobFormat, jobVideoCodec, jobAudioCodec]
171 /*integers for picture values deinterlace, crop[4], keep_ratio, grayscale, pixel_ratio, pixel_aspect_width, pixel_aspect_height,
172 maxWidth, maxHeight */
173 if (j->pixel_ratio == 1)
175 int titlewidth = title->width - j->crop[2] - j->crop[3];
176 int displayparwidth = titlewidth * j->pixel_aspect_width / j->pixel_aspect_height;
177 int displayparheight = title->height - j->crop[0] - j->crop[1];
178 jobPictureDetail = [NSString stringWithFormat: @"Picture: %d x %d Anamorphic", displayparwidth, displayparheight];
179 //jobPictureDetail = [NSString stringWithFormat: @"Picture: Anamorphic"];
183 jobPictureDetail = [NSString stringWithFormat: @"Picture: %d x %d", j->width, j->height];
185 if (j->keep_ratio == 1)
187 jobPictureDetail = [jobPictureDetail stringByAppendingString: @" Keep Aspect Ratio"];
190 if (j->grayscale == 1)
192 jobPictureDetail = [jobPictureDetail stringByAppendingString: @" ,Grayscale"];
195 if (j->deinterlace == 1)
197 jobPictureDetail = [jobPictureDetail stringByAppendingString: @" ,Deinterlace"];
199 /* Show Picture info */
200 [self AddTextField: [NSString stringWithFormat: @"%@", jobPictureDetail]rect: &rect];
202 /* Detailed Video info */
203 if (j->vquality <= 0 || j->vquality >= 1)
205 jobVideoQuality =[NSString stringWithFormat: @"%d (kbps)", j->vbitrate];
209 NSNumber * vidQuality;
210 vidQuality = [NSNumber numberWithInt: j->vquality * 100];
211 /* this is screwed up kind of. Needs to be formatted properly */
214 jobVideoQuality =[NSString stringWithFormat: @"%@ %% (crf)", vidQuality];
218 jobVideoQuality =[NSString stringWithFormat: @"%@ %% (cqp)", vidQuality];
223 jobVideoDetail = [NSString stringWithFormat:@"Video: %@ %@ FPS: %d", jobVideoCodec, jobVideoQuality, j->vrate / j->vrate_base];
226 /* Add the video detail string to the job filed in the window */
227 [self AddTextField: [NSString stringWithFormat:@"%@", jobVideoDetail] rect: &rect];
229 /* if there is an x264 option string, lets add it here*/
230 /*NOTE: Due to size, lets get this in a tool tip*/
234 [self AddTextField: [NSString stringWithFormat:@"x264 Options: %@", [NSString stringWithUTF8String:j->x264opts]] rect: &rect];
237 /* Audio Detail abitrate arate*/
238 if ([jobAudioCodec isEqualToString: @"AC3"])
240 jobAudioDetail = [NSString stringWithFormat:@"Audio: %@ Pass-Through", jobAudioCodec];
244 jobAudioDetail = [NSString stringWithFormat:@"Audio: %@ Bitrate:%d (kbps) Sample Rate:%d (khz)", jobAudioCodec, j->abitrate, j->arate];
247 /* we now get the audio mixdown info for each of the two gui audio tracks */
248 /* lets do it the long way here to get a handle on things.
249 Hardcoded for two tracks for gui: audio_mixdowns[i] audio_mixdowns[i] */
250 int ai; // counter for each audios [] , macgui only allows for two audio tracks currently
251 for( ai = 0; ai < 2; ai++ )
253 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_MONO)
255 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,Track %d: Mono",ai + 1]];
257 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_STEREO)
259 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,Track %d: Stero",ai + 1]];
261 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_DOLBY)
263 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,Track %d: Dolby Surround",ai + 1]];
265 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_DOLBYPLII)
267 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,Track %d: DPL2",ai + 1]];
269 if (j->audio_mixdowns[ai] == HB_AMIXDOWN_6CH)
271 jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,Track %d: 6 Channel Discreet",ai + 1]];
274 //jobAudioDetail = [jobAudioDetail stringByAppendingString: [NSString stringWithFormat:@" ,MixDown: %d",j->audio_mixdowns]];
275 /* Add the Audio detail string to the job filed in the window */
276 [self AddTextField: [NSString stringWithFormat:@"%@", jobAudioDetail] rect: &rect];
278 /*Destination Field */
279 [self AddTextField: [NSString stringWithFormat: @"Destination: %s", j->file] rect: &rect];
280 /* Show remove button */
281 [self AddButton: &rect tag: i];
284 [fTaskView scrollPoint: NSMakePoint(0,height)];
285 [fTaskView setNeedsDisplay: YES];
289 - (IBAction) ClosePanel: (id) sender