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,
46 char *locked_compressor,
54 this->locked_compressor = locked_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(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);
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;
220 // Just give the user information about how the stream is going to be
221 // stored but don't change the asset.
222 // Want to be able to revert to user settings.
223 if(asset->format != FILE_MPEG)
225 format_text->update(_("MPEG transport stream"));
226 asset->format = FILE_MPEG;
228 locked_compressor = 0;
229 audio_switch->update(1);
230 video_switch->update(1);
233 case CAPTURE_IEC61883:
234 case CAPTURE_FIREWIRE:
235 if(asset->format != FILE_AVI &&
236 asset->format != FILE_MOV)
238 format_text->update(MOV_NAME);
239 asset->format = FILE_MOV;
242 format_text->update(File::formattostr(asset->format));
243 locked_compressor = QUICKTIME_DVSD;
244 strcpy(asset->vcodec, QUICKTIME_DVSD);
245 audio_switch->update(asset->audio_data);
246 video_switch->update(asset->video_data);
250 case VIDEO4LINUX2JPEG:
251 if(asset->format != FILE_AVI &&
252 asset->format != FILE_MOV)
254 format_text->update(MOV_NAME);
255 asset->format = FILE_MOV;
258 format_text->update(File::formattostr(asset->format));
259 locked_compressor = QUICKTIME_MJPA;
260 audio_switch->update(asset->audio_data);
261 video_switch->update(asset->video_data);
265 format_text->update(File::formattostr(asset->format));
266 locked_compressor = 0;
267 audio_switch->update(asset->audio_data);
268 video_switch->update(asset->video_data);
271 close_format_windows();
276 int FormatTools::handle_event()
281 Asset* FormatTools::get_asset()
286 void FormatTools::update_extension()
288 char *extension = File::get_tag(asset->format);
291 char *ptr = strrchr(asset->path, '.');
294 ptr = asset->path + strlen(asset->path);
298 sprintf(ptr, extension);
300 int character1 = ptr - asset->path;
301 int character2 = ptr - asset->path + strlen(extension);
302 *(asset->path + character2) = 0;
305 path_textbox->update(asset->path);
306 path_textbox->set_selection(character1, character2, character2);
311 void FormatTools::update(Asset *asset, int *strategy)
314 this->strategy = strategy;
317 path_textbox->update(asset->path);
318 format_text->update(File::formattostr(plugindb, asset->format));
319 if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
320 if(do_video && video_switch) video_switch->update(asset->video_data);
323 multiple_files->update(strategy);
325 close_format_windows();
328 void FormatTools::close_format_windows()
330 if(aparams_thread) aparams_thread->file->close_window();
331 if(vparams_thread) vparams_thread->file->close_window();
334 int FormatTools::get_w()
339 void FormatTools::reposition_window(int &init_x, int &init_y)
346 path_textbox->reposition_window(x, y);
348 path_button->reposition_window(x, y);
353 format_title->reposition_window(x, y);
355 format_text->reposition_window(x, y);
356 x += format_text->get_w();
357 format_button->reposition_window(x, y);
360 y += format_button->get_h() + 10;
364 audio_title->reposition_window(x, y);
366 aparams_button->reposition_window(x, y);
367 x += aparams_button->get_w() + 10;
368 if(prompt_audio) audio_switch->reposition_window(x, y);
371 y += aparams_button->get_h() + 20;
372 if(prompt_audio_channels)
374 channels_title->reposition_window(x, y);
376 channels_button->reposition_window(x, y);
377 x += channels_button->get_w() + 5;
378 channels_tumbler->reposition_window(x, y);
379 y += channels_button->get_h() + 20;
387 video_title->reposition_window(x, y);
389 if(prompt_video_compression)
391 vparams_button->reposition_window(x, y);
392 x += vparams_button->get_w() + 10;
397 video_switch->reposition_window(x, y);
398 y += video_switch->get_h();
402 y += vparams_button->get_h();
411 multiple_files->reposition_window(x, y);
412 y += multiple_files->get_h() + 10;
419 int FormatTools::set_audio_options()
421 // if(video_driver == CAPTURE_DVB)
426 if(!aparams_thread->running())
428 aparams_thread->start();
432 aparams_thread->file->raise_window();
437 int FormatTools::set_video_options()
439 // if(video_driver == CAPTURE_DVB)
444 if(!vparams_thread->running())
446 vparams_thread->start();
450 vparams_thread->file->raise_window();
460 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
461 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
463 this->format = format;
464 set_tooltip(_("Configure audio compression"));
466 FormatAParams::~FormatAParams()
469 int FormatAParams::handle_event()
471 format->set_audio_options();
474 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
475 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
477 this->format = format;
478 set_tooltip(_("Configure video compression"));
480 FormatVParams::~FormatVParams()
483 int FormatVParams::handle_event()
485 format->set_video_options();
489 FormatAThread::FormatAThread(FormatTools *format)
492 this->format = format;
496 FormatAThread::~FormatAThread()
501 void FormatAThread::run()
503 file->get_options(format, 1, 0);
509 FormatVThread::FormatVThread(FormatTools *format)
512 this->format = format;
516 FormatVThread::~FormatVThread()
521 void FormatVThread::run()
523 file->get_options(format, 0, 1);
526 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
527 : BC_TextBox(x, y, 300, 1, format->asset->path)
529 this->format = format;
531 FormatPathText::~FormatPathText()
534 int FormatPathText::handle_event()
536 strcpy(format->asset->path, get_text());
537 format->handle_event();
543 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
547 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
549 this->format = format;
551 FormatAudio::~FormatAudio() {}
552 int FormatAudio::handle_event()
554 format->asset->audio_data = get_value();
558 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
562 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
564 this->format = format;
566 FormatVideo::~FormatVideo() {}
567 int FormatVideo::handle_event()
569 format->asset->video_data = get_value();
575 FormatFormat::FormatFormat(int x,
578 : FormatPopup(format->plugindb,
583 this->format = format;
585 FormatFormat::~FormatFormat()
588 int FormatFormat::handle_event()
590 if(get_selection(0, 0) >= 0)
592 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
593 if(new_format != format->asset->format)
595 // save the state of the old format
596 format->asset->save_format_defaults
597 (format->mwindow->defaults);
599 // close the configure window if open
600 format->close_format_windows();
602 // change to the new format
603 format->asset->format = new_format;
605 // load the state for the new format
606 format->asset->load_format_defaults
607 (format->mwindow->defaults);
609 // update the render window to match
610 format->format_text->update(get_selection(0, 0)->get_text());
611 format->update_extension();
612 format->path_textbox->update(format->asset->path);
613 format->pipe_status->set_status(format->asset);
614 format->path_recent->load_items
615 (FILE_FORMAT_PREFIX(format->asset->format));
623 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
624 : BC_TextBox(x, y, 100, 1, format->asset->channels)
626 this->format = format;
628 FormatChannels::~FormatChannels()
631 int FormatChannels::handle_event()
633 format->asset->channels = atol(get_text());
637 FormatToTracks::FormatToTracks(int x, int y, int *output)
638 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
640 this->output = output;
642 FormatToTracks::~FormatToTracks()
645 int FormatToTracks::handle_event()
647 *output = get_value();
652 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
655 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
656 _("Create new file at each label"))
658 this->output = output;
659 this->mwindow = mwindow;
661 FormatMultiple::~FormatMultiple()
664 int FormatMultiple::handle_event()
668 if(mwindow->preferences->use_renderfarm)
669 *output = FILE_PER_LABEL_FARM;
671 *output = FILE_PER_LABEL;
675 if(mwindow->preferences->use_renderfarm)
676 *output = SINGLE_PASS_FARM;
678 *output = SINGLE_PASS;
683 void FormatMultiple::update(int *output)
685 this->output = output;
686 if(*output == FILE_PER_LABEL_FARM ||
687 *output ==FILE_PER_LABEL)