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