convert automation line from Canvas::Curve to Canvas::PolyLine (note: this means...
[ardour.git] / gtk2_ardour / export_video_dialog.cc
index dd08b586611aa2854b5419f11bf306255581aad5..2f9df2fb1c6033fe74a04b7b997a2b1db3ea81c8 100644 (file)
@@ -61,7 +61,7 @@ using namespace PBD;
 using namespace ARDOUR;
 using namespace VideoUtils;
 
-ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme)
+ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme, bool range)
        : ArdourDialog (_("Export Video File "))
        , export_range (tme)
        , outfn_path_label (_("File:"), Gtk::ALIGN_LEFT)
@@ -152,7 +152,11 @@ ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme)
        if (!export_range.empty()) {
                insnd_combo.append_text (_("Selected range"));  // TODO show export_range.start() -> export_range.end_frame()
        }
-       insnd_combo.set_active(0);
+       if (range) {
+               insnd_combo.set_active(2);
+       } else {
+               insnd_combo.set_active(0);
+       }
 
        outfn_path_entry.set_width_chars(38);
        outfn_path_entry.set_text (_session->session_directory().export_path() + G_DIR_SEPARATOR +"export.avi");
@@ -510,9 +514,8 @@ ExportVideoDialog::launch_export ()
                end += av_offset;
        }
        else if (insnd_combo.get_active_row_number() == 2) {
-               // TODO quantize to video-frame ?!
-               start = export_range.start();
-               end   = export_range.end_frame();
+               start = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(export_range.start());
+               end   = ARDOUR_UI::instance()->video_timeline->quantify_frames_to_apv(export_range.end_frame());
        }
        if (end <= 0) {
                start = _session->current_start_frame();
@@ -522,6 +525,15 @@ ExportVideoDialog::launch_export ()
        printf("audio export-range %lld -> %lld\n", start, end);
 #endif
 
+       const frameoffset_t vstart = ARDOUR_UI::instance()->video_timeline->get_offset();
+       const frameoffset_t vend   = vstart + ARDOUR_UI::instance()->video_timeline->get_duration();
+
+       if ( (start >= end) || (end < vstart) || (start > vend)) {
+               warning << _("Export Video: export-range does not include video.") << endmsg;
+               Gtk::Dialog::response(RESPONSE_CANCEL);
+               return;
+       }
+
        tsp->set_range (start, end);
        tsp->set_name ("mysession");
        tsp->set_range_id ("session");