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;
36 FormatTools::~FormatTools()
43 if(aparams_button) delete aparams_button;
44 if(vparams_button) delete vparams_button;
45 if(aparams_thread) delete aparams_thread;
46 if(vparams_thread) delete vparams_thread;
47 if(channels_tumbler) delete channels_tumbler;
50 int FormatTools::create_objects(int &init_x,
52 int do_audio, // Include support for audio
53 int do_video, // Include support for video
54 int prompt_audio, // Include checkbox for audio
56 int prompt_audio_channels,
57 int prompt_video_compression,
58 char *locked_compressor,
66 this->locked_compressor = locked_compressor;
67 this->recording = recording;
68 this->use_brender = brender;
69 this->do_audio = do_audio;
70 this->do_video = do_video;
71 this->prompt_audio = prompt_audio;
72 this->prompt_audio_channels = prompt_audio_channels;
73 this->prompt_video = prompt_video;
74 this->prompt_video_compression = prompt_video_compression;
75 this->strategy = strategy;
77 //printf("FormatTools::create_objects 1\n");
79 // Modify strategy depending on render farm
82 if(mwindow->preferences->use_renderfarm)
84 if(*strategy == FILE_PER_LABEL)
85 *strategy = FILE_PER_LABEL_FARM;
87 if(*strategy == SINGLE_PASS)
88 *strategy = SINGLE_PASS_FARM;
92 if(*strategy == FILE_PER_LABEL_FARM)
93 *strategy = FILE_PER_LABEL;
95 if(*strategy == SINGLE_PASS_FARM)
96 *strategy = SINGLE_PASS;
100 //printf("FormatTools::create_objects 1\n");
103 window->add_subwindow(path_textbox = new FormatPathText(x, y, this));
105 path_recent = new BC_RecentList("PATH", mwindow->defaults,
106 path_textbox, 10, x, y, 300, 100);
107 window->add_subwindow(path_recent);
108 path_recent->load_items(FILE_FORMAT_PREFIX(asset->format));
111 window->add_subwindow(path_button = new BrowseButton(
119 _("Select a file to write to:"),
123 w = x + path_button->get_w() + 5;
131 window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
133 window->add_subwindow(format_text = new BC_TextBox(x,
137 File::formattostr(asset->format)));
138 x += format_text->get_w();
139 window->add_subwindow(format_button = new FormatFormat(x,
142 format_button->create_objects();
145 y += format_button->get_h() + 10;
148 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
150 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
151 x += aparams_button->get_w() + 10;
154 window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
157 y += aparams_button->get_h() + 20;
159 // Audio channels only used for recording.
160 // if(prompt_audio_channels)
162 // window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
164 // window->add_subwindow(channels_button = new FormatChannels(x, y, this));
165 // x += channels_button->get_w() + 5;
166 // window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
167 // y += channels_button->get_h() + 20;
171 //printf("FormatTools::create_objects 6\n");
172 aparams_thread = new FormatAThread(this);
175 //printf("FormatTools::create_objects 7\n");
179 //printf("FormatTools::create_objects 8\n");
180 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT, BC_WindowBase::get_resources()->audiovideo_color));
182 if(prompt_video_compression)
184 window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
185 x += vparams_button->get_w() + 10;
188 //printf("FormatTools::create_objects 9\n");
191 window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
192 y += video_switch->get_h();
196 y += vparams_button->get_h();
199 //printf("FormatTools::create_objects 10\n");
201 vparams_thread = new FormatVThread(this);
204 //printf("FormatTools::create_objects 11\n");
209 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
210 y += multiple_files->get_h() + 10;
213 //printf("FormatTools::create_objects 12\n");
219 void FormatTools::update_driver(int driver)
221 this->video_driver = driver;
226 // Just give the user information about how the stream is going to be
227 // stored but don't change the asset.
228 // Want to be able to revert to user settings.
229 if(asset->format != FILE_MPEG)
231 format_text->update(_("MPEG transport stream"));
232 asset->format = FILE_MPEG;
234 locked_compressor = 0;
235 audio_switch->update(1);
236 video_switch->update(1);
239 case CAPTURE_IEC61883:
240 case CAPTURE_FIREWIRE:
241 if(asset->format != FILE_AVI &&
242 asset->format != FILE_MOV)
244 format_text->update(MOV_NAME);
245 asset->format = FILE_MOV;
248 format_text->update(File::formattostr(asset->format));
249 locked_compressor = QUICKTIME_DVSD;
250 strcpy(asset->vcodec, QUICKTIME_DVSD);
251 audio_switch->update(asset->audio_data);
252 video_switch->update(asset->video_data);
256 case VIDEO4LINUX2JPEG:
257 if(asset->format != FILE_AVI &&
258 asset->format != FILE_MOV)
260 format_text->update(MOV_NAME);
261 asset->format = FILE_MOV;
264 format_text->update(File::formattostr(asset->format));
265 locked_compressor = QUICKTIME_MJPA;
266 audio_switch->update(asset->audio_data);
267 video_switch->update(asset->video_data);
271 format_text->update(File::formattostr(asset->format));
272 locked_compressor = 0;
273 audio_switch->update(asset->audio_data);
274 video_switch->update(asset->video_data);
277 close_format_windows();
282 int FormatTools::handle_event()
287 Asset_GC FormatTools::get_asset()
292 void FormatTools::update_extension()
294 char *extension = File::get_tag(asset->format);
297 char *ptr = strrchr(asset->path, '.');
300 ptr = asset->path + strlen(asset->path);
304 sprintf(ptr, extension);
306 int character1 = ptr - asset->path;
307 int character2 = ptr - asset->path + strlen(extension);
308 *(asset->path + character2) = 0;
311 path_textbox->update(asset->path);
312 path_textbox->set_selection(character1, character2, character2);
317 void FormatTools::update(Asset_GC asset, int *strategy)
320 this->strategy = strategy;
323 path_textbox->update(asset->path);
324 format_text->update(File::formattostr(plugindb, asset->format));
325 if(do_audio && audio_switch) audio_switch->update(asset->audio_data);
326 if(do_video && video_switch) video_switch->update(asset->video_data);
329 multiple_files->update(strategy);
331 close_format_windows();
334 void FormatTools::close_format_windows()
336 if(aparams_thread) aparams_thread->file->close_window();
337 if(vparams_thread) vparams_thread->file->close_window();
340 int FormatTools::get_w()
345 void FormatTools::reposition_window(int &init_x, int &init_y)
352 path_textbox->reposition_window(x, y);
354 path_button->reposition_window(x, y);
359 format_title->reposition_window(x, y);
361 format_text->reposition_window(x, y);
362 x += format_text->get_w();
363 format_button->reposition_window(x, y);
366 y += format_button->get_h() + 10;
370 audio_title->reposition_window(x, y);
372 aparams_button->reposition_window(x, y);
373 x += aparams_button->get_w() + 10;
374 if(prompt_audio) audio_switch->reposition_window(x, y);
377 y += aparams_button->get_h() + 20;
378 if(prompt_audio_channels)
380 channels_title->reposition_window(x, y);
382 channels_button->reposition_window(x, y);
383 x += channels_button->get_w() + 5;
384 channels_tumbler->reposition_window(x, y);
385 y += channels_button->get_h() + 20;
393 video_title->reposition_window(x, y);
395 if(prompt_video_compression)
397 vparams_button->reposition_window(x, y);
398 x += vparams_button->get_w() + 10;
403 video_switch->reposition_window(x, y);
404 y += video_switch->get_h();
408 y += vparams_button->get_h();
417 multiple_files->reposition_window(x, y);
418 y += multiple_files->get_h() + 10;
425 int FormatTools::set_audio_options()
427 // if(video_driver == CAPTURE_DVB)
432 if(!aparams_thread->running())
434 aparams_thread->start();
438 aparams_thread->file->raise_window();
443 int FormatTools::set_video_options()
445 // if(video_driver == CAPTURE_DVB)
450 if(!vparams_thread->running())
452 vparams_thread->start();
456 vparams_thread->file->raise_window();
466 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
467 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
469 this->format = format;
470 set_tooltip(_("Configure audio compression"));
472 FormatAParams::~FormatAParams()
475 int FormatAParams::handle_event()
477 format->set_audio_options();
480 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
481 : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
483 this->format = format;
484 set_tooltip(_("Configure video compression"));
486 FormatVParams::~FormatVParams()
489 int FormatVParams::handle_event()
491 format->set_video_options();
495 FormatAThread::FormatAThread(FormatTools *format)
498 this->format = format;
502 FormatAThread::~FormatAThread()
507 void FormatAThread::run()
509 file->get_options(format, 1, 0);
515 FormatVThread::FormatVThread(FormatTools *format)
518 this->format = format;
522 FormatVThread::~FormatVThread()
527 void FormatVThread::run()
529 file->get_options(format, 0, 1);
532 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
533 : BC_TextBox(x, y, 300, 1, format->asset->path)
535 this->format = format;
537 FormatPathText::~FormatPathText()
540 int FormatPathText::handle_event()
542 strcpy(format->asset->path, get_text());
543 format->handle_event();
549 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
553 (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
555 this->format = format;
557 FormatAudio::~FormatAudio() {}
558 int FormatAudio::handle_event()
560 format->asset->audio_data = get_value();
564 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
568 (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
570 this->format = format;
572 FormatVideo::~FormatVideo() {}
573 int FormatVideo::handle_event()
575 format->asset->video_data = get_value();
581 FormatFormat::FormatFormat(int x,
584 : FormatPopup(format->plugindb,
589 this->format = format;
591 FormatFormat::~FormatFormat()
594 int FormatFormat::handle_event()
596 if(get_selection(0, 0) >= 0)
598 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
599 if(new_format != format->asset->format)
601 format->asset->format = new_format;
602 format->format_text->update(get_selection(0, 0)->get_text());
603 format->update_extension();
604 format->close_format_windows();
605 if (format->path_recent)
606 format->path_recent->load_items
607 (FILE_FORMAT_PREFIX(format->asset->format));
615 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
616 : BC_TextBox(x, y, 100, 1, format->asset->channels)
618 this->format = format;
620 FormatChannels::~FormatChannels()
623 int FormatChannels::handle_event()
625 format->asset->channels = atol(get_text());
629 FormatToTracks::FormatToTracks(int x, int y, int *output)
630 : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
632 this->output = output;
634 FormatToTracks::~FormatToTracks()
637 int FormatToTracks::handle_event()
639 *output = get_value();
644 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
647 (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
648 _("Create new file at each label"))
650 this->output = output;
651 this->mwindow = mwindow;
653 FormatMultiple::~FormatMultiple()
656 int FormatMultiple::handle_event()
660 if(mwindow->preferences->use_renderfarm)
661 *output = FILE_PER_LABEL_FARM;
663 *output = FILE_PER_LABEL;
667 if(mwindow->preferences->use_renderfarm)
668 *output = SINGLE_PASS_FARM;
670 *output = SINGLE_PASS;
675 void FormatMultiple::update(int *output)
677 this->output = output;
678 if(*output == FILE_PER_LABEL_FARM ||
679 *output ==FILE_PER_LABEL)
689 // c-file-style: "linux"