4 #include "formattools.h"
6 #include "maxchannels.h"
8 #include "preferences.h"
11 #include "videodevice.inc"
16 FormatTools::FormatTools(MWindow *mwindow,
17 BC_WindowBase *window,
20 this->mwindow = mwindow;
21 this->window = window;
23 this->plugindb = mwindow->plugindb;
32 FormatTools::~FormatTools()
34 delete aparams_thread;
35 delete vparams_thread;
38 int FormatTools::create_objects(int &init_x,
40 int do_audio, // Include support for audio
41 int do_video, // Include support for video
42 int prompt_audio, // Include checkbox for audio
44 int prompt_audio_channels,
45 int prompt_video_compression,
54 this->lock_compressor = lock_compressor;
55 this->recording = recording;
56 this->use_brender = brender;
57 this->do_audio = do_audio;
58 this->do_video = do_video;
59 this->prompt_audio = prompt_audio;
60 this->prompt_audio_channels = prompt_audio_channels;
61 this->prompt_video = prompt_video;
62 this->prompt_video_compression = prompt_video_compression;
63 this->strategy = strategy;
65 //printf("FormatTools::create_objects 1\n");
67 // Modify strategy depending on render farm
70 if(mwindow->preferences->use_renderfarm)
72 if(*strategy == FILE_PER_LABEL)
73 *strategy = FILE_PER_LABEL_FARM;
75 if(*strategy == SINGLE_PASS)
76 *strategy = SINGLE_PASS_FARM;
80 if(*strategy == FILE_PER_LABEL_FARM)
81 *strategy = FILE_PER_LABEL;
83 if(*strategy == SINGLE_PASS_FARM)
84 *strategy = SINGLE_PASS;
88 //printf("FormatTools::create_objects 1\n");
91 window->add_subwindow(path_textbox = new FormatPathText(x, y, this));
93 path_recent = new BC_RecentList("PATH", mwindow->defaults,
94 path_textbox, 10, x, y, 300, 100);
95 window->add_subwindow(path_recent);
96 path_recent->load_items(FILE_FORMAT_PREFIX(asset->format));
99 window->add_subwindow(path_button = new BrowseButton(
107 _("Select a file to write to:"),
111 w = x + path_button->get_w() + 5;
116 pipe_status = new PipeStatus(x, y, "");
117 window->add_subwindow(pipe_status);
118 pipe_status->set_status(asset);
125 window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
127 window->add_subwindow(format_text = new BC_TextBox(x,
131 File::formattostr(plugindb, asset->format)));
132 x += format_text->get_w();
133 window->add_subwindow(format_button = new FormatFormat(x,
136 format_button->create_objects();
139 y += format_button->get_h() + 10;
142 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
144 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
145 x += aparams_button->get_w() + 10;
148 window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
151 y += aparams_button->get_h() + 20;
153 // Audio channels only used for recording.
154 // if(prompt_audio_channels)
156 // window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
158 // window->add_subwindow(channels_button = new FormatChannels(x, y, this));
159 // x += channels_button->get_w() + 5;
160 // window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
161 // y += channels_button->get_h() + 20;
165 //printf("FormatTools::create_objects 6\n");
166 aparams_thread = new FormatAThread(this);
169 //printf("FormatTools::create_objects 7\n");
173 //printf("FormatTools::create_objects 8\n");
174 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
176 if(prompt_video_compression)
178 window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
179 x += vparams_button->get_w() + 10;
182 //printf("FormatTools::create_objects 9\n");
185 window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
186 y += video_switch->get_h();
190 y += vparams_button->get_h();
193 //printf("FormatTools::create_objects 10\n");
195 vparams_thread = new FormatVThread(this, lock_compressor);
198 //printf("FormatTools::create_objects 11\n");
203 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
204 y += multiple_files->get_h() + 10;
207 //printf("FormatTools::create_objects 12\n");
213 void FormatTools::update_driver(int driver)
215 this->video_driver = driver;
219 case CAPTURE_IEC61883:
220 case CAPTURE_FIREWIRE:
221 if(asset->format != FILE_AVI &&
222 asset->format != FILE_MOV)
224 format_text->update(MOV_NAME);
225 asset->format = FILE_MOV;
228 format_text->update(File::formattostr(asset->format));
229 strcpy(asset->vcodec, QUICKTIME_DVSD);
230 audio_switch->update(asset->audio_data);
231 video_switch->update(asset->video_data);
235 case VIDEO4LINUX2JPEG:
236 if(asset->format != FILE_AVI &&
237 asset->format != FILE_MOV)
239 format_text->update(MOV_NAME);
240 asset->format = FILE_MOV;
243 format_text->update(File::formattostr(asset->format));
244 audio_switch->update(asset->audio_data);
245 video_switch->update(asset->video_data);
249 format_text->update(File::formattostr(asset->format));
250 audio_switch->update(asset->audio_data);
251 video_switch->update(asset->video_data);
254 close_format_windows();
259 int FormatTools::handle_event()
264 Asset* FormatTools::get_asset()
269 void FormatTools::update_extension()
271 char *extension = File::get_tag(asset->format);
274 char *ptr = strrchr(asset->path, '.');
277 ptr = asset->path + strlen(asset->path);
281 sprintf(ptr, extension);
283 int character1 = ptr - asset->path;
284 int character2 = ptr - asset->path + strlen(extension);
285 *(asset->path + character2) = 0;
288 path_textbox->update(asset->path);
289 path_textbox->set_selection(character1, character2, character2);
294 void FormatTools::update(Asset *asset, int *strategy)
297 this->strategy = strategy;
300 path_textbox->update(asset->path);
301 format_text->update(File::formattostr(plugindb, asset->format));
302 if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
303 if(do_video && video_switch) video_switch->update(asset->video_data);
306 multiple_files->update(strategy);
308 close_format_windows();
311 void FormatTools::close_format_windows()
313 if(aparams_thread) aparams_thread->file->close_window();
314 if(vparams_thread) vparams_thread->file->close_window();
317 int FormatTools::get_w()
322 void FormatTools::reposition_window(int &init_x, int &init_y)
329 path_textbox->reposition_window(x, y);
331 path_button->reposition_window(x, y);
336 format_title->reposition_window(x, y);
338 format_text->reposition_window(x, y);
339 x += format_text->get_w();
340 format_button->reposition_window(x, y);
343 y += format_button->get_h() + 10;
347 audio_title->reposition_window(x, y);
349 aparams_button->reposition_window(x, y);
350 x += aparams_button->get_w() + 10;
351 if(prompt_audio) audio_switch->reposition_window(x, y);
354 y += aparams_button->get_h() + 20;
355 if(prompt_audio_channels)
357 channels_title->reposition_window(x, y);
359 channels_button->reposition_window(x, y);
360 x += channels_button->get_w() + 5;
361 channels_tumbler->reposition_window(x, y);
362 y += channels_button->get_h() + 20;
370 video_title->reposition_window(x, y);
372 if(prompt_video_compression)
374 vparams_button->reposition_window(x, y);
375 x += vparams_button->get_w() + 10;
380 video_switch->reposition_window(x, y);
381 y += video_switch->get_h();
385 y += vparams_button->get_h();
394 multiple_files->reposition_window(x, y);
395 y += multiple_files->get_h() + 10;
402 int FormatTools::set_audio_options()
404 if(!aparams_thread->running())
406 aparams_thread->start();
410 aparams_thread->file->raise_window();
415 int FormatTools::set_video_options()
417 if(!vparams_thread->running())
419 vparams_thread->start();
423 vparams_thread->file->raise_window();
433 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
434 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
436 this->format = format;
437 set_tooltip(_("Configure audio compression"));
439 FormatAParams::~FormatAParams()
442 int FormatAParams::handle_event()
444 format->set_audio_options();
447 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
448 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
450 this->format = format;
451 set_tooltip(_("Configure video compression"));
453 FormatVParams::~FormatVParams()
456 int FormatVParams::handle_event()
458 format->set_video_options();
462 FormatAThread::FormatAThread(FormatTools *format)
465 this->format = format;
469 FormatAThread::~FormatAThread()
474 void FormatAThread::run()
476 file->get_options(format, 1, 0, 0);
482 FormatVThread::FormatVThread(FormatTools *format,
486 this->lock_compressor = lock_compressor;
487 this->format = format;
491 FormatVThread::~FormatVThread()
496 void FormatVThread::run()
498 file->get_options(format, 0, 1, lock_compressor);
501 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
502 : BC_TextBox(x, y, 300, 1, format->asset->path)
504 this->format = format;
506 FormatPathText::~FormatPathText()
509 int FormatPathText::handle_event()
511 strcpy(format->asset->path, get_text());
512 format->handle_event();
518 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
522 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
524 this->format = format;
526 FormatAudio::~FormatAudio() {}
527 int FormatAudio::handle_event()
529 format->asset->audio_data = get_value();
533 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
537 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
539 this->format = format;
541 FormatVideo::~FormatVideo() {}
542 int FormatVideo::handle_event()
544 format->asset->video_data = get_value();
550 FormatFormat::FormatFormat(int x,
553 : FormatPopup(format->plugindb,
558 this->format = format;
560 FormatFormat::~FormatFormat()
563 int FormatFormat::handle_event()
565 if(get_selection(0, 0) >= 0)
567 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
568 if(new_format != format->asset->format)
570 // save the state of the old format
571 format->asset->save_format_defaults
572 (format->mwindow->defaults);
574 // close the configure window if open
575 format->close_format_windows();
577 // change to the new format
578 format->asset->format = new_format;
580 // load the state for the new format
581 format->asset->load_format_defaults
582 (format->mwindow->defaults);
584 // update the render window to match
585 format->format_text->
586 update(get_selection(0, 0)->get_text());
587 format->update_extension();
588 format->path_textbox->update(format->asset->path);
589 format->pipe_status->set_status(format->asset);
590 format->path_recent->load_items
591 (FILE_FORMAT_PREFIX(format->asset->format));
599 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
600 : BC_TextBox(x, y, 100, 1, format->asset->channels)
602 this->format = format;
604 FormatChannels::~FormatChannels()
607 int FormatChannels::handle_event()
609 format->asset->channels = atol(get_text());
613 FormatToTracks::FormatToTracks(int x, int y, int *output)
614 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
616 this->output = output;
618 FormatToTracks::~FormatToTracks()
621 int FormatToTracks::handle_event()
623 *output = get_value();
628 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
631 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
632 _("Create new file at each label"))
634 this->output = output;
635 this->mwindow = mwindow;
637 FormatMultiple::~FormatMultiple()
640 int FormatMultiple::handle_event()
644 if(mwindow->preferences->use_renderfarm)
645 *output = FILE_PER_LABEL_FARM;
647 *output = FILE_PER_LABEL;
651 if(mwindow->preferences->use_renderfarm)
652 *output = SINGLE_PASS_FARM;
654 *output = SINGLE_PASS;
659 void FormatMultiple::update(int *output)
661 this->output = output;
662 if(*output == FILE_PER_LABEL_FARM ||
663 *output ==FILE_PER_LABEL)