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;
37 FormatTools::~FormatTools()
45 if(aparams_button) delete aparams_button;
46 if(vparams_button) delete vparams_button;
47 if(aparams_thread) delete aparams_thread;
48 if(vparams_thread) delete vparams_thread;
49 if(channels_tumbler) delete channels_tumbler;
52 int FormatTools::create_objects(int &init_x,
54 int do_audio, // Include support for audio
55 int do_video, // Include support for video
56 int prompt_audio, // Include checkbox for audio
58 int prompt_audio_channels,
59 int prompt_video_compression,
60 char *locked_compressor,
68 this->locked_compressor = locked_compressor;
69 this->recording = recording;
70 this->use_brender = brender;
71 this->do_audio = do_audio;
72 this->do_video = do_video;
73 this->prompt_audio = prompt_audio;
74 this->prompt_audio_channels = prompt_audio_channels;
75 this->prompt_video = prompt_video;
76 this->prompt_video_compression = prompt_video_compression;
77 this->strategy = strategy;
79 //printf("FormatTools::create_objects 1\n");
81 // Modify strategy depending on render farm
84 if(mwindow->preferences->use_renderfarm)
86 if(*strategy == FILE_PER_LABEL)
87 *strategy = FILE_PER_LABEL_FARM;
89 if(*strategy == SINGLE_PASS)
90 *strategy = SINGLE_PASS_FARM;
94 if(*strategy == FILE_PER_LABEL_FARM)
95 *strategy = FILE_PER_LABEL;
97 if(*strategy == SINGLE_PASS_FARM)
98 *strategy = SINGLE_PASS;
102 //printf("FormatTools::create_objects 1\n");
105 window->add_subwindow(path_textbox = new FormatPathText(x, y, this));
107 path_recent = new BC_RecentList("PATH", mwindow->defaults,
108 path_textbox, 10, x, y, 300, 100);
109 window->add_subwindow(path_recent);
110 path_recent->load_items(FILE_FORMAT_PREFIX(asset->format));
113 window->add_subwindow(path_button = new BrowseButton(
121 _("Select a file to write to:"),
125 w = x + path_button->get_w() + 5;
130 pipe_status = new PipeStatus(x, y, "");
131 window->add_subwindow(pipe_status);
132 pipe_status->set_status(asset);
139 window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
141 window->add_subwindow(format_text = new BC_TextBox(x,
145 File::formattostr(asset->format)));
146 x += format_text->get_w();
147 window->add_subwindow(format_button = new FormatFormat(x,
150 format_button->create_objects();
153 y += format_button->get_h() + 10;
156 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
158 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
159 x += aparams_button->get_w() + 10;
162 window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
165 y += aparams_button->get_h() + 20;
167 // Audio channels only used for recording.
168 // if(prompt_audio_channels)
170 // window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
172 // window->add_subwindow(channels_button = new FormatChannels(x, y, this));
173 // x += channels_button->get_w() + 5;
174 // window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
175 // y += channels_button->get_h() + 20;
179 //printf("FormatTools::create_objects 6\n");
180 aparams_thread = new FormatAThread(this);
183 //printf("FormatTools::create_objects 7\n");
187 //printf("FormatTools::create_objects 8\n");
188 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
190 if(prompt_video_compression)
192 window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
193 x += vparams_button->get_w() + 10;
196 //printf("FormatTools::create_objects 9\n");
199 window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
200 y += video_switch->get_h();
204 y += vparams_button->get_h();
207 //printf("FormatTools::create_objects 10\n");
209 vparams_thread = new FormatVThread(this);
212 //printf("FormatTools::create_objects 11\n");
217 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
218 y += multiple_files->get_h() + 10;
221 //printf("FormatTools::create_objects 12\n");
227 void FormatTools::update_driver(int driver)
229 this->video_driver = driver;
234 // Just give the user information about how the stream is going to be
235 // stored but don't change the asset.
236 // Want to be able to revert to user settings.
237 if(asset->format != FILE_MPEG)
239 format_text->update(_("MPEG transport stream"));
240 asset->format = FILE_MPEG;
242 locked_compressor = 0;
243 audio_switch->update(1);
244 video_switch->update(1);
247 case CAPTURE_IEC61883:
248 case CAPTURE_FIREWIRE:
249 if(asset->format != FILE_AVI &&
250 asset->format != FILE_MOV)
252 format_text->update(MOV_NAME);
253 asset->format = FILE_MOV;
256 format_text->update(File::formattostr(asset->format));
257 locked_compressor = QUICKTIME_DVSD;
258 strcpy(asset->vcodec, QUICKTIME_DVSD);
259 audio_switch->update(asset->audio_data);
260 video_switch->update(asset->video_data);
264 case VIDEO4LINUX2JPEG:
265 if(asset->format != FILE_AVI &&
266 asset->format != FILE_MOV)
268 format_text->update(MOV_NAME);
269 asset->format = FILE_MOV;
272 format_text->update(File::formattostr(asset->format));
273 locked_compressor = QUICKTIME_MJPA;
274 audio_switch->update(asset->audio_data);
275 video_switch->update(asset->video_data);
279 format_text->update(File::formattostr(asset->format));
280 locked_compressor = 0;
281 audio_switch->update(asset->audio_data);
282 video_switch->update(asset->video_data);
285 close_format_windows();
290 int FormatTools::handle_event()
295 Asset* FormatTools::get_asset()
300 void FormatTools::update_extension()
302 char *extension = File::get_tag(asset->format);
305 char *ptr = strrchr(asset->path, '.');
308 ptr = asset->path + strlen(asset->path);
312 sprintf(ptr, extension);
314 int character1 = ptr - asset->path;
315 int character2 = ptr - asset->path + strlen(extension);
316 *(asset->path + character2) = 0;
319 path_textbox->update(asset->path);
320 path_textbox->set_selection(character1, character2, character2);
325 void FormatTools::update(Asset *asset, int *strategy)
328 this->strategy = strategy;
331 path_textbox->update(asset->path);
332 format_text->update(File::formattostr(plugindb, asset->format));
333 if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
334 if(do_video && video_switch) video_switch->update(asset->video_data);
337 multiple_files->update(strategy);
339 close_format_windows();
342 void FormatTools::close_format_windows()
344 if(aparams_thread) aparams_thread->file->close_window();
345 if(vparams_thread) vparams_thread->file->close_window();
348 int FormatTools::get_w()
353 void FormatTools::reposition_window(int &init_x, int &init_y)
360 path_textbox->reposition_window(x, y);
362 path_button->reposition_window(x, y);
367 format_title->reposition_window(x, y);
369 format_text->reposition_window(x, y);
370 x += format_text->get_w();
371 format_button->reposition_window(x, y);
374 y += format_button->get_h() + 10;
378 audio_title->reposition_window(x, y);
380 aparams_button->reposition_window(x, y);
381 x += aparams_button->get_w() + 10;
382 if(prompt_audio) audio_switch->reposition_window(x, y);
385 y += aparams_button->get_h() + 20;
386 if(prompt_audio_channels)
388 channels_title->reposition_window(x, y);
390 channels_button->reposition_window(x, y);
391 x += channels_button->get_w() + 5;
392 channels_tumbler->reposition_window(x, y);
393 y += channels_button->get_h() + 20;
401 video_title->reposition_window(x, y);
403 if(prompt_video_compression)
405 vparams_button->reposition_window(x, y);
406 x += vparams_button->get_w() + 10;
411 video_switch->reposition_window(x, y);
412 y += video_switch->get_h();
416 y += vparams_button->get_h();
425 multiple_files->reposition_window(x, y);
426 y += multiple_files->get_h() + 10;
433 int FormatTools::set_audio_options()
435 // if(video_driver == CAPTURE_DVB)
440 if(!aparams_thread->running())
442 aparams_thread->start();
446 aparams_thread->file->raise_window();
451 int FormatTools::set_video_options()
453 // if(video_driver == CAPTURE_DVB)
458 if(!vparams_thread->running())
460 vparams_thread->start();
464 vparams_thread->file->raise_window();
474 FormatAParams::FormatAParams(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 audio compression"));
480 FormatAParams::~FormatAParams()
483 int FormatAParams::handle_event()
485 format->set_audio_options();
488 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
489 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
491 this->format = format;
492 set_tooltip(_("Configure video compression"));
494 FormatVParams::~FormatVParams()
497 int FormatVParams::handle_event()
499 format->set_video_options();
503 FormatAThread::FormatAThread(FormatTools *format)
506 this->format = format;
510 FormatAThread::~FormatAThread()
515 void FormatAThread::run()
517 file->get_options(format, 1, 0);
523 FormatVThread::FormatVThread(FormatTools *format)
526 this->format = format;
530 FormatVThread::~FormatVThread()
535 void FormatVThread::run()
537 file->get_options(format, 0, 1);
540 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
541 : BC_TextBox(x, y, 300, 1, format->asset->path)
543 this->format = format;
545 FormatPathText::~FormatPathText()
548 int FormatPathText::handle_event()
550 strcpy(format->asset->path, get_text());
551 format->handle_event();
557 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
561 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
563 this->format = format;
565 FormatAudio::~FormatAudio() {}
566 int FormatAudio::handle_event()
568 format->asset->audio_data = get_value();
572 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
576 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
578 this->format = format;
580 FormatVideo::~FormatVideo() {}
581 int FormatVideo::handle_event()
583 format->asset->video_data = get_value();
589 FormatFormat::FormatFormat(int x,
592 : FormatPopup(format->plugindb,
597 this->format = format;
599 FormatFormat::~FormatFormat()
602 int FormatFormat::handle_event()
604 if(get_selection(0, 0) >= 0)
606 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
607 if(new_format != format->asset->format)
609 // save the state of the old format
610 format->asset->save_format_defaults
611 (format->mwindow->defaults);
613 // close the configure window if open
614 format->close_format_windows();
616 // change to the new format
617 format->asset->format = new_format;
619 // load the state for the new format
620 format->asset->load_format_defaults
621 (format->mwindow->defaults);
623 // update the render window to match
624 format->format_text->update(get_selection(0, 0)->get_text());
625 format->update_extension();
626 if (format->path_textbox)
627 format->path_textbox->update(format->asset->path);
628 if (format->pipe_status)
629 format->pipe_status->set_status(format->asset);
630 if (format->path_recent)
631 format->path_recent->load_items
632 (FILE_FORMAT_PREFIX(format->asset->format));
640 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
641 : BC_TextBox(x, y, 100, 1, format->asset->channels)
643 this->format = format;
645 FormatChannels::~FormatChannels()
648 int FormatChannels::handle_event()
650 format->asset->channels = atol(get_text());
654 FormatToTracks::FormatToTracks(int x, int y, int *output)
655 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
657 this->output = output;
659 FormatToTracks::~FormatToTracks()
662 int FormatToTracks::handle_event()
664 *output = get_value();
669 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
672 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
673 _("Create new file at each label"))
675 this->output = output;
676 this->mwindow = mwindow;
678 FormatMultiple::~FormatMultiple()
681 int FormatMultiple::handle_event()
685 if(mwindow->preferences->use_renderfarm)
686 *output = FILE_PER_LABEL_FARM;
688 *output = FILE_PER_LABEL;
692 if(mwindow->preferences->use_renderfarm)
693 *output = SINGLE_PASS_FARM;
695 *output = SINGLE_PASS;
700 void FormatMultiple::update(int *output)
702 this->output = output;
703 if(*output == FILE_PER_LABEL_FARM ||
704 *output ==FILE_PER_LABEL)