+FFOptionsViewFormat::FFOptionsViewFormat(FFMPEGConfigWindow *cfg_window,
+ EDL *edl, Asset *asset, int x, int y, const char *text)
+ : BC_GenericButton(x, y, text)
+{
+ this->cfg_window = cfg_window;
+ this->edl = edl;
+ this->asset = asset;
+ format_dialog = 0;
+}
+
+FFOptionsViewFormat::~FFOptionsViewFormat()
+{
+ delete format_dialog;
+}
+
+int FFOptionsViewFormat::handle_event()
+{
+ delete format_dialog;
+ int wx, wy;
+ get_pop_cursor(wx, wy);
+ format_dialog = new FFOptionsFormatViewDialog(this, wx, wy);
+ format_dialog->start();
+ return 1;
+}
+
+
+FFOptionsFormatView::FFOptionsFormatView(FFMPEGConfigFormat *fmt_config,
+ int x, int y, const char *text)
+ : BC_GenericButton(x, y, text)
+{
+ this->fmt_config = fmt_config;
+ fmt_ctx = 0;
+}
+
+FFOptionsFormatView::~FFOptionsFormatView()
+{
+ avformat_free_context(fmt_ctx);
+}
+
+int FFOptionsFormatView::handle_event()
+{
+ Asset *asset = fmt_config->asset;
+ char *format_name = asset->fformat;
+ char replace_name0[] = "mov";
+ char replace_name1[] = "mpegts";
+ char replace_name2[] = "matroska";
+ if (!strcmp(format_name, "qt"))
+ format_name = replace_name0; // fixup
+ if (!strcmp(format_name, "m2ts"))
+ format_name = replace_name1; // fixup
+ if (!strcmp(format_name, "mkv"))
+ format_name = replace_name2; // fixup
+ avformat_free_context(fmt_ctx); fmt_ctx = 0;
+ int ret = avformat_alloc_output_context2(&fmt_ctx, 0, format_name, 0);
+ if( ret || !fmt_ctx ) {
+ eprintf(_("no format named: %s"), format_name);
+ ret = 1;
+ }
+ if( !ret )
+ fmt_config->start(fmt_ctx);
+ return 1;
+}
+
+FFOptionsFormatViewDialog::FFOptionsFormatViewDialog(FFOptionsViewFormat *view_format,
+ int wx, int wy)
+{
+ this->view_format = view_format;
+ this->wx = wx;
+ this->wy = wy;
+ cfg_window = 0;
+}
+
+FFOptionsFormatViewDialog::~FFOptionsFormatViewDialog()
+{
+ close_window();
+}
+
+BC_Window *FFOptionsFormatViewDialog::new_gui()
+{
+ cfg_window = new FFMPEGConfigFormat(this, wx, wy,
+ view_format->asset, view_format->edl);
+ cfg_window->create_objects();
+ cfg_window->read_options();
+ return cfg_window;
+}
+
+void FFOptionsFormatViewDialog::handle_done_event(int result)
+{
+ if( !result )
+ cfg_window->save_changes();
+ cfg_window = 0;
+}
+