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