bunch of small fixes, add msg.txt to about prefs
[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                 audio_switch->update(asset->audio_data);
368                 if( !asset->audio_data )
369                         audio_switch->disable();
370                 else
371                         audio_switch->enable();
372         }
373         if( do_video && prompt_video && video_switch ) {
374                 video_switch->update(asset->video_data);
375                 if( !asset->video_data )
376                         video_switch->disable();
377                 else
378                         video_switch->enable();
379         }
380         if( asset->format == FILE_FFMPEG ) {
381                 ffmpeg_type->show();
382                 format_ffmpeg->show();
383         }
384         else {
385                 ffmpeg_type->hide();
386                 format_ffmpeg->hide();
387         }
388 }
389
390 int FormatTools::handle_event()
391 {
392         return 0;
393 }
394
395 Asset* FormatTools::get_asset()
396 {
397         return asset;
398 }
399
400 void FormatTools::update_extension()
401 {
402         const char *extension = File::get_tag(asset->format);
403 // split multiple extensions
404         ArrayList<const char*> extensions;
405         int len = strlen(extension);
406         const char *extension_ptr = extension;
407         for(int i = 0; i <= len; i++)
408         {
409                 if(extension[i] == '/' || extension[i] == 0)
410                 {
411                         extensions.append(extension_ptr);
412                         extension_ptr = extension + i + 1;
413                 }
414         }
415         
416         if(extensions.size())
417         {
418                 char *ptr = strrchr(asset->path, '.');
419                 if(!ptr)
420                 {
421                         ptr = asset->path + strlen(asset->path);
422                         *ptr = '.';
423                 }
424                 ptr++;
425                 
426                 
427 // test for equivalent extension
428                 int need_extension = 1;
429                 //int extension_len = 0;
430                 for(int i = 0; i < extensions.size() && need_extension; i++)
431                 {
432                         char *ptr1 = ptr;
433                         extension_ptr = extensions.get(i);
434 // test an extension
435                         need_extension = 0;
436                         while(*ptr1 != 0 && *extension_ptr != 0 && *extension_ptr != '/')
437                         {
438                                 if(tolower(*ptr1) != tolower(*extension_ptr))
439                                 {
440                                         need_extension = 1;
441                                         break;
442                                 }
443                                 ptr1++;
444                                 extension_ptr++;
445                         }
446
447                         if(*ptr1 == 0 && 
448                                 *extension_ptr != 0 &&
449                                 *extension_ptr != '/')
450                                 need_extension = 1;
451                 }
452
453 //printf("FormatTools::update_extension %d %d\n", __LINE__, need_extension);
454 // copy extension
455                 if(need_extension) 
456                 {
457                         char *ptr1 = ptr;
458                         extension_ptr = asset->format != FILE_FFMPEG ?
459                                 extensions.get(0) : asset->fformat;
460                         while(*extension_ptr != 0 && *extension_ptr != '/')
461                                 *ptr1++ = *extension_ptr++;
462                         *ptr1 = 0;
463                 }
464
465                 int character1 = ptr - asset->path;
466                 int character2 = strlen(asset->path);
467 //              *(asset->path + character2) = 0;
468                 if(path_textbox) 
469                 {
470                         path_textbox->update(asset->path);
471                         path_textbox->set_selection(character1, character2, character2);
472                 }
473         }
474 }
475
476 void FormatTools::update(Asset *asset, int *strategy)
477 {
478         this->asset = asset;
479         this->strategy = strategy;
480
481         if(path_textbox) 
482                 path_textbox->update(asset->path);
483         format_text->update(File::formattostr(plugindb, asset->format));
484         if(do_audio && prompt_audio && audio_switch)
485                 audio_switch->update(asset->audio_data);
486         if(do_video && prompt_video && video_switch)
487                 video_switch->update(asset->video_data);
488         if(strategy)
489         {
490                 multiple_files->update(strategy);
491         }
492         close_format_windows();
493 }
494
495 void FormatTools::close_format_windows()
496 {
497 // This is done in ~file
498         if(aparams_thread && aparams_thread->running())
499         {
500                 aparams_thread->file->close_window();
501                 aparams_thread->join();
502         }
503         if(vparams_thread && vparams_thread->running())
504         {
505                 vparams_thread->file->close_window();
506                 vparams_thread->join();
507         }
508 }
509
510 int FormatTools::get_w()
511 {
512         return w;
513 }
514
515 void FormatTools::set_w(int w)
516 {
517         this->w = w;
518 }
519
520 void FormatTools::reposition_window(int &init_x, int &init_y)
521 {
522         int x = init_x;
523         int y = init_y;
524
525         if(path_textbox) 
526         {
527                 path_textbox->reposition_window(x, y);
528                 x += path_textbox->get_w() + 5;
529                 path_button->reposition_window(x, y);
530                 x -= path_textbox->get_w() + 5;
531                 y += 35;
532         }
533
534         format_title->reposition_window(x, y);
535         x += 90;
536         format_text->reposition_window(x, y);
537         x += format_text->get_w();
538         format_button->reposition_window(x, y);
539
540         x = init_x;
541         y += format_button->get_h() + 10;
542
543         if(do_audio)
544         {
545                 audio_title->reposition_window(x, y);
546                 x += 80;
547                 aparams_button->reposition_window(x, y);
548                 x += aparams_button->get_w() + 10;
549                 if(prompt_audio) audio_switch->reposition_window(x, y);
550
551                 x = init_x;
552                 y += aparams_button->get_h() + 20;
553                 if(prompt_audio_channels)
554                 {
555                         channels_title->reposition_window(x, y);
556                         x += 260;
557                         channels_button->reposition_window(x, y);
558                         x += channels_button->get_w() + 5;
559                         channels_tumbler->reposition_window(x, y);
560                         y += channels_button->get_h() + 20;
561                         x = init_x;
562                 }
563         }
564
565
566         if(do_video)
567         {
568                 video_title->reposition_window(x, y);
569                 x += 80;
570                 if(prompt_video_compression)
571                 {
572                         vparams_button->reposition_window(x, y);
573                         x += vparams_button->get_w() + 10;
574                 }
575
576                 if(prompt_video)
577                 {
578                         video_switch->reposition_window(x, y);
579                         y += video_switch->get_h();
580                 }
581                 else
582                 {
583                         y += vparams_button->get_h();
584                 }
585
586                 y += 10;
587                 x = init_x;
588         }
589
590         if(strategy)
591         {
592                 multiple_files->reposition_window(x, y);
593                 y += multiple_files->get_h() + 10;
594         }
595
596         init_y = y;
597 }
598
599
600 int FormatTools::set_audio_options()
601 {
602 //      if(video_driver == CAPTURE_DVB)
603 //      {
604 //              return 0;
605 //      }
606
607         if(!aparams_thread->running())
608         {
609                 aparams_thread->start();
610         }
611         else
612         {
613                 aparams_thread->file->raise_window();
614         }
615         return 0;
616 }
617
618 int FormatTools::set_video_options()
619 {
620 //      if(video_driver == CAPTURE_DVB)
621 //      {
622 //              return 0;
623 //      }
624
625         if(!vparams_thread->running())
626         {
627                 vparams_thread->start();
628         }
629         else
630         {
631                 vparams_thread->file->raise_window();
632         }
633
634         return 0;
635 }
636
637
638
639
640
641 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
642  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
643 {
644         this->format = format;
645         set_tooltip(_("Configure audio compression"));
646 }
647
648 FormatAParams::~FormatAParams() 
649 {
650 }
651
652 int FormatAParams::handle_event() 
653 {
654         format->set_audio_options(); 
655         return 1;
656 }
657
658
659
660
661
662 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
663  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
664
665         this->format = format; 
666         set_tooltip(_("Configure video compression"));
667 }
668
669 FormatVParams::~FormatVParams() 
670 {
671 }
672
673 int FormatVParams::handle_event() 
674
675         format->set_video_options(); 
676         return 1;
677 }
678
679
680
681
682
683 FormatAThread::FormatAThread(FormatTools *format)
684  : Thread(1, 0, 0)
685
686         this->format = format; 
687         file = new File;
688         joined = 1;
689 }
690
691 FormatAThread::~FormatAThread() 
692 {
693         join();
694         delete file;
695         file = 0;
696 }
697
698 void FormatAThread::start()
699 {
700         join();
701         joined = 0;
702         Thread::start();
703 }
704
705
706 void FormatAThread::run()
707 {
708         file->get_options(format, 1, 0);
709 }
710
711
712
713
714 FormatVThread::FormatVThread(FormatTools *format)
715  : Thread(1, 0, 0)
716 {
717         this->format = format;
718         file = new File;
719         joined = 1;
720 }
721
722 FormatVThread::~FormatVThread() 
723 {
724         join();
725         delete file;
726         file = 0;
727 }
728
729 void FormatVThread::start()
730 {
731         join();
732         joined = 0;
733         Thread::start();
734 }
735
736 void FormatVThread::run()
737 {
738         file->get_options(format, 0, 1);
739 }
740
741
742
743
744
745 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
746  : BC_TextBox(x, 
747         y, 
748         format->w - 
749                 format->mwindow->theme->get_image_set("wrench")[0]->get_w() - 
750                 x - 10, 
751         1, 
752         format->asset->path) 
753 {
754         this->format = format; 
755 }
756
757 FormatPathText::~FormatPathText() 
758 {
759 }
760 int FormatPathText::handle_event() 
761 {
762 // Suggestions
763         calculate_suggestions(format->file_entries);
764
765
766
767         strcpy(format->asset->path, get_text());
768         format->handle_event();
769
770         return 1;
771 }
772
773
774
775
776 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
777  : BC_CheckBox(x, 
778         y, 
779         default_, 
780         (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
781
782         this->format = format; 
783 }
784
785 FormatAudio::~FormatAudio() {}
786 int FormatAudio::handle_event()
787 {
788         format->asset->audio_data = get_value();
789         return 1;
790 }
791
792
793 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
794  : BC_CheckBox(x, 
795         y, 
796         default_, 
797         (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
798 {
799 this->format = format; 
800 }
801
802 FormatVideo::~FormatVideo() {}
803 int FormatVideo::handle_event()
804 {
805         format->asset->video_data = get_value();
806         return 1;
807 }
808
809
810
811
812 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
813  : FormatPopup(format->plugindb, x, y, format->use_brender)
814
815         this->format = format; 
816 }
817
818 FormatFormat::~FormatFormat() 
819 {
820 }
821
822 int FormatFormat::handle_event()
823 {
824         BC_ListBoxItem *selection = get_selection(0, 0);
825         if( selection ) {
826                 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
827 //              if(new_format != format->asset->format)
828                 {
829                         Asset *asset = format->asset;
830                         asset->format = new_format;
831                         asset->audio_data = File::supports_audio(asset->format);
832                         asset->video_data = File::supports_video(asset->format);
833                         format->format_text->update(selection->get_text());
834                         format->update_extension();
835                         format->close_format_windows();
836                         format->update_format();
837                 }
838         }
839         return 1;
840 }
841
842
843 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
844  : FFMPEGPopup(format->plugindb, x, y)
845
846         this->format = format; 
847 }
848
849 FormatFFMPEG::~FormatFFMPEG() 
850 {
851 }
852
853 int FormatFFMPEG::load_defaults(const char *path, const char *type,
854                  char *codec, char *codec_options, int len)
855 {
856         char default_file[BCTEXTLEN];
857         FFMPEG::set_option_path(default_file, "%s/%s.dfl", path, type);
858         FILE *fp = fopen(default_file,"r");
859         if( !fp ) return 1;
860         fgets(codec, BCSTRLEN, fp);
861         char *cp = codec;
862         while( *cp && *cp!='\n' ) ++cp;
863         *cp = 0;
864         while( len > 0 && fgets(codec_options, len, fp) ) {
865                 int n = strlen(codec_options);
866                 codec_options += n;  len -= n;
867         }
868         fclose(fp);
869         FFMPEG::set_option_path(default_file, "%s/%s", path, codec);
870         return FFMPEG::load_options(default_file, codec_options, len);
871 }
872
873 int FormatFFMPEG::handle_event()
874 {
875         BC_ListBoxItem *selection = get_selection(0, 0);
876         if( selection ) {
877                 char *text = get_selection(0, 0)->get_text();
878                 format->ffmpeg_type->update(text);
879                 Asset *asset = format->asset;
880                 strcpy(asset->fformat, text);
881                 strcpy(asset->ff_audio_options, "");
882                 strcpy(asset->ff_video_options, "");
883                 asset->audio_data = !load_defaults("audio", text, asset->acodec,
884                         asset->ff_audio_options, sizeof(asset->ff_audio_options));
885                 asset->video_data = !load_defaults("video", text, asset->vcodec,
886                         asset->ff_video_options, sizeof(asset->ff_video_options));
887                 format->update_extension();
888                 format->close_format_windows();
889                 format->update_format();
890         }
891         return 1;
892 }
893
894
895
896
897 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
898  : BC_TextBox(x, y, 100, 1, format->asset->channels) 
899
900         this->format = format; 
901 }
902
903 FormatChannels::~FormatChannels() 
904 {
905 }
906
907 int FormatChannels::handle_event() 
908 {
909         format->asset->channels = atol(get_text());
910         return 1;
911 }
912
913
914 FormatToTracks::FormatToTracks(int x, int y, int *output)
915  : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
916
917         this->output = output; 
918 }
919
920 FormatToTracks::~FormatToTracks() 
921 {
922 }
923
924 int FormatToTracks::handle_event()
925 {
926         *output = get_value();
927         return 1;
928 }
929
930
931 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
932  : BC_CheckBox(x, 
933         y, 
934         (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM), 
935         _("Create new file at each label"))
936
937         this->output = output;
938         this->mwindow = mwindow;
939 }
940
941 FormatMultiple::~FormatMultiple() 
942 {
943 }
944
945 int FormatMultiple::handle_event()
946 {
947         if(get_value())
948         {
949                 if(mwindow->preferences->use_renderfarm)
950                         *output = FILE_PER_LABEL_FARM;
951                 else
952                         *output = FILE_PER_LABEL;
953         }
954         else
955         {
956                 if(mwindow->preferences->use_renderfarm)
957                         *output = SINGLE_PASS_FARM;
958                 else
959                         *output = SINGLE_PASS;
960         }
961         return 1;
962 }
963
964 void FormatMultiple::update(int *output)
965 {
966         this->output = output;
967         if(*output == FILE_PER_LABEL_FARM ||
968                 *output ==FILE_PER_LABEL)
969                 set_value(1);
970         else
971                 set_value(0);
972 }
973
974