add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formattools.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010-2013 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "asset.h"
23 #include "bcsignals.h"
24 #include "clip.h"
25 #include "guicast.h"
26 #include "file.h"
27 #include "filesystem.h"
28 #include "formattools.h"
29 #include "language.h"
30 #include "libdv.h"
31 #include "libmjpeg.h"
32 #include "maxchannels.h"
33 #include "mwindow.h"
34 #include "preferences.h"
35 #include "theme.h"
36 #include "videodevice.inc"
37 #include <string.h>
38 #include <unistd.h>
39 #include <ctype.h>
40
41
42 FormatTools::FormatTools(MWindow *mwindow,
43                                 BC_WindowBase *window,
44                                 Asset *asset)
45 {
46         this->mwindow = mwindow;
47         this->window = window;
48         this->asset = asset;
49         this->plugindb = mwindow->plugindb;
50
51         aparams_button = 0;
52         vparams_button = 0;
53         aparams_thread = 0;
54         vparams_thread = 0;
55         channels_tumbler = 0;
56         audio_switch = 0;
57         video_switch = 0;
58         path_textbox = 0;
59         path_button = 0;
60         path_recent = 0;
61         format_title = 0;
62         format_button = 0;
63         format_text = 0;
64         audio_title = 0;
65         audio_switch = 0;
66         video_title = 0;
67         video_switch = 0;
68         channels_title = 0;
69         channels_button = 0;
70         multiple_files = 0;
71         w = window->get_w();
72
73         recording = 0;
74         use_brender = 0;
75         do_audio = 0;
76         do_video = 0;
77         prompt_audio = 0;
78         prompt_audio_channels = 0;
79         prompt_video = 0;
80         prompt_video_compression = 0;
81         strategy = 0;
82         locked_compressor = 0;
83         video_driver = 0;
84 }
85
86 FormatTools::~FormatTools()
87 {
88         delete path_recent;
89 SET_TRACE
90         delete path_button;
91 SET_TRACE
92         delete path_textbox;
93 SET_TRACE
94         delete format_button;
95 SET_TRACE
96
97         if(aparams_button) delete aparams_button;
98 SET_TRACE
99         if(vparams_button) delete vparams_button;
100 SET_TRACE
101         if(aparams_thread) delete aparams_thread;
102 SET_TRACE
103         if(vparams_thread) delete vparams_thread;
104 SET_TRACE
105         if(channels_tumbler) delete channels_tumbler;
106 }
107
108 void FormatTools::create_objects(int &init_x,
109                                                 int &init_y,
110                                                 int do_audio,    // Include support for audio
111                                                 int do_video,   // Include support for video
112                                                 int prompt_audio,  // Include checkbox for audio
113                                                 int prompt_video,
114                                                 int prompt_audio_channels,
115                                                 int prompt_video_compression,
116                                                 const char *locked_compressor,
117                                                 int recording,
118                                                 int *strategy,
119                                                 int brender,
120                                                 int horizontal_layout)
121 {
122         int x = init_x;
123         int y = init_y;
124         int ylev = init_y;
125
126         this->locked_compressor = locked_compressor;
127         this->recording = recording;
128         this->use_brender = brender;
129         this->do_audio = do_audio;
130         this->do_video = do_video;
131         this->prompt_audio = prompt_audio;
132         this->prompt_audio_channels = prompt_audio_channels;
133         this->prompt_video = prompt_video;
134         this->prompt_video_compression = prompt_video_compression;
135         this->strategy = strategy;
136
137 //printf("FormatTools::create_objects 1\n");
138
139 // Modify strategy depending on render farm
140         if(strategy)
141         {
142                 if(mwindow->preferences->use_renderfarm)
143                 {
144                         if(*strategy == FILE_PER_LABEL)
145                                 *strategy = FILE_PER_LABEL_FARM;
146                         else
147                         if(*strategy == SINGLE_PASS)
148                                 *strategy = SINGLE_PASS_FARM;
149                 }
150                 else
151                 {
152                         if(*strategy == FILE_PER_LABEL_FARM)
153                                 *strategy = FILE_PER_LABEL;
154                         else
155                         if(*strategy == SINGLE_PASS_FARM)
156                                 *strategy = SINGLE_PASS;
157                 }
158         }
159
160         if(!recording)
161         {
162                 int px = x;
163                 window->add_subwindow(path_textbox = new FormatPathText(px, y, this));
164                 px += path_textbox->get_w() + 5;
165                 path_recent = new BC_RecentList("PATH", mwindow->defaults,
166                                         path_textbox, 10, px, y, 300, 100);
167                 window->add_subwindow(path_recent);
168                 path_recent->load_items(File::formattostr(asset->format));
169                 px += path_recent->get_w();
170                 window->add_subwindow(path_button = new BrowseButton(
171                         mwindow->theme, window, path_textbox, px, y, asset->path,
172                         _("Output to file"), _("Select a file to write to:"), 0));
173
174 // Set w for user.
175                 w = MAX(w, 305);
176                 y += path_textbox->get_h() + 10;
177         }
178         else
179         {
180 //              w = x + 305;
181                 w = 305;
182         }
183
184         x = init_x;
185         window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
186         x += 90;
187         window->add_subwindow(format_text = new BC_TextBox(x, y, 160, 1,
188                 File::formattostr(asset->format)));
189         x += format_text->get_w();
190 //printf("FormatTools::create_objects %d %p\n", __LINE__, window);
191         window->add_subwindow(format_button = new FormatFormat(x, y, this));
192         format_button->create_objects();
193         x += format_button->get_w() + 5;
194         window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 64, 1, asset->fformat));
195         FFMPEG::set_asset_format(asset, asset->fformat);
196         x += ffmpeg_type->get_w();
197         window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this));
198         format_ffmpeg->create_objects();
199         x = init_x;
200         y += format_button->get_h() + 10;
201         if(do_audio)
202         {
203                 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
204                 x += 80;
205                 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
206                 x += aparams_button->get_w() + 10;
207                 if(prompt_audio)
208                 {
209                         window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
210                 }
211                 x = init_x;
212                 ylev = y;
213                 y += aparams_button->get_h() + 10;
214
215 // Audio channels only used for recording.
216 //              if(prompt_audio_channels)
217 //              {
218 //                      window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
219 //                      x += 260;
220 //                      window->add_subwindow(channels_button = new FormatChannels(x, y, this));
221 //                      x += channels_button->get_w() + 5;
222 //                      window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
223 //                      y += channels_button->get_h() + 20;
224 //                      x = init_x;
225 //              }
226
227 //printf("FormatTools::create_objects 6\n");
228                 aparams_thread = new FormatAThread(this);
229         }
230
231 //printf("FormatTools::create_objects 7\n");
232         if(do_video)
233         {
234                 if(horizontal_layout && do_audio){
235                         x += 370;
236                         y = ylev;
237                 }
238
239 //printf("FormatTools::create_objects 8\n");
240                 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
241                 x += 80;
242                 if(prompt_video_compression)
243                 {
244                         window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
245                         x += vparams_button->get_w() + 10;
246                 }
247
248 //printf("FormatTools::create_objects 9\n");
249                 if(prompt_video)
250                 {
251                         window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
252                         y += video_switch->get_h();
253                 }
254                 else
255                 {
256                         y += vparams_button->get_h();
257                 }
258
259 //printf("FormatTools::create_objects 10\n");
260                 y += 10;
261                 vparams_thread = new FormatVThread(this);
262         }
263
264 //printf("FormatTools::create_objects 11\n");
265
266         x = init_x;
267         if(strategy)
268         {
269                 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
270                 y += multiple_files->get_h() + 10;
271         }
272
273 //printf("FormatTools::create_objects 12\n");
274
275         init_y = y;
276         update_format();
277 }
278
279 void FormatTools::update_driver(int driver)
280 {
281         this->video_driver = driver;
282
283         locked_compressor = 0;
284         switch(driver)
285         {
286                 case CAPTURE_DVB:
287                 case VIDEO4LINUX2MPEG:
288 // Just give the user information about how the stream is going to be
289 // stored but don't change the asset.
290 // Want to be able to revert to user settings.
291                         if(asset->format == FILE_MPEG) break;
292                         asset->format = FILE_MPEG;
293                         format_text->update(File::formattostr(asset->format));
294                         asset->audio_data = 1;
295                         asset->video_data = 1;
296                         audio_switch->update(1);
297                         video_switch->update(1);
298                         break;
299
300                 case CAPTURE_IEC61883:
301                 case CAPTURE_FIREWIRE:
302                 case VIDEO4LINUX2JPEG:
303                 case CAPTURE_JPEG_WEBCAM:
304                         asset->format = FILE_FFMPEG;
305                         format_text->update(File::formattostr(asset->format));
306
307                         switch(driver) {
308                         case CAPTURE_IEC61883:
309                         case CAPTURE_FIREWIRE:
310                                 locked_compressor = (char*)CODEC_TAG_DVSD;
311                                 break;
312
313                         case VIDEO4LINUX2JPEG:
314                                 locked_compressor = (char*)CODEC_TAG_MJPEG;
315                                 break;
316
317                         case CAPTURE_JPEG_WEBCAM:
318                                 locked_compressor = (char*)CODEC_TAG_JPEG;
319                                 break;
320                         }
321                         if( locked_compressor )
322                                 strcpy(asset->vcodec, locked_compressor);
323
324                         audio_switch->update(asset->audio_data);
325                         video_switch->update(asset->video_data);
326                         break;
327
328                 default:
329                         format_text->update(File::formattostr(asset->format));
330                         audio_switch->update(asset->audio_data);
331                         video_switch->update(asset->video_data);
332                         break;
333         }
334         close_format_windows();
335         update_format();
336 }
337
338 void FormatTools::update_format()
339 {
340         if( do_audio && prompt_audio && audio_switch ) {
341                 audio_switch->update(asset->audio_data);
342                 if( !asset->audio_data )
343                         audio_switch->disable();
344                 else
345                         audio_switch->enable();
346         }
347         if( do_video && prompt_video && video_switch ) {
348                 video_switch->update(asset->video_data);
349                 if( !asset->video_data )
350                         video_switch->disable();
351                 else
352                         video_switch->enable();
353         }
354         if( asset->format == FILE_FFMPEG ) {
355                 ffmpeg_type->show();
356                 format_ffmpeg->show();
357         }
358         else {
359                 ffmpeg_type->hide();
360                 format_ffmpeg->hide();
361         }
362 }
363
364 int FormatTools::handle_event()
365 {
366         return 0;
367 }
368
369 Asset* FormatTools::get_asset()
370 {
371         return asset;
372 }
373
374 void FormatTools::update_extension()
375 {
376         const char *extension = File::get_tag(asset->format);
377 // split multiple extensions
378         ArrayList<const char*> extensions;
379         int len = !extension ? -1 : strlen(extension);
380         const char *extension_ptr = extension;
381         for(int i = 0; i <= len; i++)
382         {
383                 if(extension[i] == '/' || extension[i] == 0)
384                 {
385                         extensions.append(extension_ptr);
386                         extension_ptr = extension + i + 1;
387                 }
388         }
389
390         if(extensions.size())
391         {
392                 char *ptr = strrchr(asset->path, '.');
393                 if(!ptr)
394                 {
395                         ptr = asset->path + strlen(asset->path);
396                         *ptr = '.';
397                 }
398                 ptr++;
399
400 // test for equivalent extension
401                 int need_extension = 1;
402                 //int extension_len = 0;
403                 for(int i = 0; i < extensions.size() && need_extension; i++)
404                 {
405                         char *ptr1 = ptr;
406                         extension_ptr = extensions.get(i);
407 // test an extension
408                         need_extension = 0;
409                         while(*ptr1 != 0 && *extension_ptr != 0 && *extension_ptr != '/')
410                         {
411                                 if(tolower(*ptr1) != tolower(*extension_ptr))
412                                 {
413                                         need_extension = 1;
414                                         break;
415                                 }
416                                 ptr1++;
417                                 extension_ptr++;
418                         }
419
420                         if(*ptr1 == 0 &&
421                                 *extension_ptr != 0 &&
422                                 *extension_ptr != '/')
423                                 need_extension = 1;
424                 }
425
426 //printf("FormatTools::update_extension %d %d\n", __LINE__, need_extension);
427 // copy extension
428                 if(need_extension)
429                 {
430                         char *ptr1 = ptr;
431                         extension_ptr = asset->format != FILE_FFMPEG ?
432                                 extensions.get(0) : asset->fformat;
433                         while(*extension_ptr != 0 && *extension_ptr != '/')
434                                 *ptr1++ = *extension_ptr++;
435                         *ptr1 = 0;
436                 }
437
438                 int character1 = ptr - asset->path;
439                 int character2 = strlen(asset->path);
440 //              *(asset->path + character2) = 0;
441                 if(path_textbox)
442                 {
443                         path_textbox->update(asset->path);
444                         path_textbox->set_selection(character1, character2, character2);
445                 }
446         }
447 }
448
449 void FormatTools::update(Asset *asset, int *strategy)
450 {
451         this->asset = asset;
452         this->strategy = strategy;
453
454         if(path_textbox)
455                 path_textbox->update(asset->path);
456         format_text->update(File::formattostr(plugindb, asset->format));
457         if(do_audio && prompt_audio && audio_switch)
458                 audio_switch->update(asset->audio_data);
459         if(do_video && prompt_video && video_switch)
460                 video_switch->update(asset->video_data);
461         if(strategy)
462         {
463                 multiple_files->update(strategy);
464         }
465         close_format_windows();
466 }
467
468 void FormatTools::close_format_windows()
469 {
470 // This is done in ~file
471         if( aparams_thread ) {
472                 if( aparams_thread->running() )
473                         aparams_thread->file->close_window();
474                 aparams_thread->join();
475         }
476         if( vparams_thread ) {
477                 if( vparams_thread->running() )
478                         vparams_thread->file->close_window();
479                 vparams_thread->join();
480         }
481 }
482
483 int FormatTools::get_w()
484 {
485         return asset->format != FILE_FFMPEG ? w :
486                 format_ffmpeg->get_x() + format_ffmpeg->get_w();
487 }
488
489 void FormatTools::set_w(int w)
490 {
491         this->w = w;
492 }
493
494 void FormatTools::reposition_window(int &init_x, int &init_y)
495 {
496         int x = init_x;
497         int y = init_y;
498
499         if(path_textbox)
500         {
501                 int px = x;
502                 path_textbox->reposition_window(px, y);
503                 px += path_textbox->get_w() + 5;
504                 path_recent->reposition_window(px, y);
505                 px += path_recent->get_w() + 8;
506                 path_button->reposition_window(px, y);
507                 y += path_textbox->get_h() + 10;
508         }
509
510         format_title->reposition_window(x, y);
511         x += 90;
512         format_text->reposition_window(x, y);
513         x += format_text->get_w();
514         format_button->reposition_window(x, y);
515
516         x = init_x;
517         y += format_button->get_h() + 10;
518
519         if(do_audio)
520         {
521                 audio_title->reposition_window(x, y);
522                 x += 80;
523                 aparams_button->reposition_window(x, y);
524                 x += aparams_button->get_w() + 10;
525                 if(prompt_audio) audio_switch->reposition_window(x, y);
526
527                 x = init_x;
528                 y += aparams_button->get_h() + 10;
529                 if(prompt_audio_channels)
530                 {
531                         channels_title->reposition_window(x, y);
532                         x += 260;
533                         channels_button->reposition_window(x, y);
534                         x += channels_button->get_w() + 5;
535                         channels_tumbler->reposition_window(x, y);
536                         y += channels_button->get_h() + 20;
537                         x = init_x;
538                 }
539         }
540
541
542         if(do_video)
543         {
544                 video_title->reposition_window(x, y);
545                 x += 80;
546                 if(prompt_video_compression)
547                 {
548                         vparams_button->reposition_window(x, y);
549                         x += vparams_button->get_w() + 10;
550                 }
551
552                 if(prompt_video)
553                 {
554                         video_switch->reposition_window(x, y);
555                         y += video_switch->get_h();
556                 }
557                 else
558                 {
559                         y += vparams_button->get_h();
560                 }
561
562                 y += 10;
563                 x = init_x;
564         }
565
566         if(strategy)
567         {
568                 multiple_files->reposition_window(x, y);
569                 y += multiple_files->get_h() + 10;
570         }
571
572         init_y = y;
573 }
574
575
576 int FormatTools::set_audio_options()
577 {
578 //      if(video_driver == CAPTURE_DVB)
579 //      {
580 //              return 0;
581 //      }
582
583         if(!aparams_thread->running())
584         {
585                 aparams_thread->start();
586         }
587         else
588         {
589                 aparams_thread->file->raise_window();
590         }
591         return 0;
592 }
593
594 int FormatTools::set_video_options()
595 {
596 //      if(video_driver == CAPTURE_DVB)
597 //      {
598 //              return 0;
599 //      }
600
601         if(!vparams_thread->running())
602         {
603                 vparams_thread->start();
604         }
605         else
606         {
607                 vparams_thread->file->raise_window();
608         }
609
610         return 0;
611 }
612
613
614
615
616
617 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
618  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
619 {
620         this->format = format;
621         set_tooltip(_("Configure audio compression"));
622 }
623
624 FormatAParams::~FormatAParams()
625 {
626 }
627
628 int FormatAParams::handle_event()
629 {
630         format->set_audio_options();
631         return 1;
632 }
633
634
635
636
637
638 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
639  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
640 {
641         this->format = format;
642         set_tooltip(_("Configure video compression"));
643 }
644
645 FormatVParams::~FormatVParams()
646 {
647 }
648
649 int FormatVParams::handle_event()
650 {
651         format->set_video_options();
652         return 1;
653 }
654
655
656
657
658
659 FormatAThread::FormatAThread(FormatTools *format)
660  : Thread(1, 0, 0)
661 {
662         this->format = format;
663         file = new File;
664         joined = 1;
665 }
666
667 FormatAThread::~FormatAThread()
668 {
669         delete file;  file = 0;
670         join();
671 }
672
673 void FormatAThread::start()
674 {
675         join();
676         joined = 0;
677         Thread::start();
678 }
679
680
681 void FormatAThread::run()
682 {
683         file->get_options(format, 1, 0);
684 }
685
686
687
688
689 FormatVThread::FormatVThread(FormatTools *format)
690  : Thread(1, 0, 0)
691 {
692         this->format = format;
693         file = new File;
694         joined = 1;
695 }
696
697 FormatVThread::~FormatVThread()
698 {
699         delete file;  file = 0;
700         join();
701 }
702
703 void FormatVThread::start()
704 {
705         join();
706         joined = 0;
707         Thread::start();
708 }
709
710 void FormatVThread::run()
711 {
712         file->get_options(format, 0, 1);
713 }
714
715
716
717
718
719 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
720  : BC_TextBox(x, y, format->w - x -
721                 2*format->mwindow->theme->get_image_set("wrench")[0]->get_w() - 20, 1,
722         format->asset->path)
723 {
724         this->format = format;
725 }
726
727 FormatPathText::~FormatPathText()
728 {
729 }
730 int FormatPathText::handle_event()
731 {
732         calculate_suggestions();
733         strcpy(format->asset->path, get_text());
734         format->handle_event();
735         return 1;
736 }
737
738
739
740
741 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
742  : BC_CheckBox(x,
743         y,
744         default_,
745         (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
746 {
747         this->format = format;
748 }
749
750 FormatAudio::~FormatAudio() {}
751 int FormatAudio::handle_event()
752 {
753         format->asset->audio_data = get_value();
754         return 1;
755 }
756
757
758 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
759  : BC_CheckBox(x,
760         y,
761         default_,
762         (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
763 {
764 this->format = format;
765 }
766
767 FormatVideo::~FormatVideo() {}
768 int FormatVideo::handle_event()
769 {
770         format->asset->video_data = get_value();
771         return 1;
772 }
773
774
775
776
777 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
778  : FormatPopup(format->plugindb, x, y, format->use_brender)
779 {
780         this->format = format;
781 }
782
783 FormatFormat::~FormatFormat()
784 {
785 }
786
787 int FormatFormat::handle_event()
788 {
789         BC_ListBoxItem *selection = get_selection(0, 0);
790         if( selection ) {
791                 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
792 //              if(new_format != format->asset->format)
793                 {
794                         Asset *asset = format->asset;
795                         asset->format = new_format;
796                         asset->audio_data = File::supports_audio(asset->format);
797                         asset->video_data = File::supports_video(asset->format);
798                         asset->ff_audio_options[0] = 0;
799                         asset->ff_video_options[0] = 0;
800                         format->format_text->update(selection->get_text());
801                         format->update_extension();
802                         format->close_format_windows();
803                         if (format->path_recent) format->path_recent->
804                                 load_items(File::formattostr(format->asset->format));
805                         format->update_format();
806                 }
807         }
808         return 1;
809 }
810
811
812 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
813  : FFMPEGPopup(format->plugindb, x, y)
814 {
815         this->format = format;
816 }
817
818 FormatFFMPEG::~FormatFFMPEG()
819 {
820 }
821
822 int FormatFFMPEG::handle_event()
823 {
824         BC_ListBoxItem *selection = get_selection(0, 0);
825         if( selection ) {
826                 char *text = get_selection(0, 0)->get_text();
827                 format->ffmpeg_type->update(text);
828                 format->asset->ff_audio_options[0] = 0;
829                 format->asset->ff_video_options[0] = 0;
830                 FFMPEG::set_asset_format(format->asset, text);
831                 format->update_extension();
832                 format->close_format_windows();
833                 format->update_format();
834         }
835         return 1;
836 }
837
838
839
840
841 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
842  : BC_TextBox(x, y, 100, 1, format->asset->channels)
843 {
844         this->format = format;
845 }
846
847 FormatChannels::~FormatChannels()
848 {
849 }
850
851 int FormatChannels::handle_event()
852 {
853         format->asset->channels = atol(get_text());
854         return 1;
855 }
856
857
858 FormatToTracks::FormatToTracks(int x, int y, int *output)
859  : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
860 {
861         this->output = output;
862 }
863
864 FormatToTracks::~FormatToTracks()
865 {
866 }
867
868 int FormatToTracks::handle_event()
869 {
870         *output = get_value();
871         return 1;
872 }
873
874
875 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
876  : BC_CheckBox(x,
877         y,
878         (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
879         _("Create new file at each label"))
880 {
881         this->output = output;
882         this->mwindow = mwindow;
883 }
884
885 FormatMultiple::~FormatMultiple()
886 {
887 }
888
889 int FormatMultiple::handle_event()
890 {
891         if(get_value())
892         {
893                 if(mwindow->preferences->use_renderfarm)
894                         *output = FILE_PER_LABEL_FARM;
895                 else
896                         *output = FILE_PER_LABEL;
897         }
898         else
899         {
900                 if(mwindow->preferences->use_renderfarm)
901                         *output = SINGLE_PASS_FARM;
902                 else
903                         *output = SINGLE_PASS;
904         }
905         return 1;
906 }
907
908 void FormatMultiple::update(int *output)
909 {
910         this->output = output;
911         if(*output == FILE_PER_LABEL_FARM ||
912                 *output ==FILE_PER_LABEL)
913                 set_value(1);
914         else
915                 set_value(0);
916 }
917
918