Soundcloud upload example export format presets.
[ardour.git] / gtk2_ardour / video_timeline.cc
index 72b0900e1646e1f404c5c14ffb537fbeaca5b91b..75f6150691cd9dc36c2c1b7938a2be6a6a90144b 100644 (file)
@@ -45,6 +45,7 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 using namespace Timecode;
+using namespace VideoUtils;
 
 VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Group *vbg, int initial_height)
        : editor (ed)
@@ -124,6 +125,7 @@ VideoTimeLine::close_session ()
        video_filename = "";
        video_duration = 0;
        GuiUpdate("set-xjadeo-sensitive-off");
+       GuiUpdate("video-unavailable");
 }
 
 void
@@ -465,6 +467,8 @@ VideoTimeLine::video_file_info (std::string filename, bool local)
                        video_server_url, translated_filename(),
                        video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
                warning << _("Parsing video file info failed. Is the Video Server running? Is the file readable by the Video Server? Does the docroot match? Is it a video file?") << endmsg;
+               video_duration = 0;
+               GuiUpdate("set-xjadeo-sensitive-off");
                GuiUpdate("video-unavailable");
                return false;
        }
@@ -499,14 +503,18 @@ VideoTimeLine::video_file_info (std::string filename, bool local)
                                _session->config.set_timecode_format(timecode_60);
                                break;
                        default:
-                               warning << _("Failed to set session-framerate: ") << video_file_fps << _(" does not have a corresponding option setting in Ardour.") << endmsg; /* TODO: gettext arg */
+                               warning << string_compose (
+                                               _("Failed to set session-framerate: '%1' does not have a corresponding option setting in %2."),
+                                               video_file_fps, PROGRAM_NAME ) << endmsg;
                                break;
                }
                _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
        }
        if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) {
-               warning << _("Video file's framerate is not equal to Ardour session timecode's framerate: ")
-                       << video_file_fps << _(" vs ") << _session->timecode_frames_per_second() << endmsg;
+               warning << string_compose(
+                               _("Video file's framerate is not equal to %1 session timecode's framerate: '%2' vs '%3'"),
+                                       PROGRAM_NAME, video_file_fps, _session->timecode_frames_per_second())
+                               << endmsg;
        }
        flush_local_cache ();
 
@@ -545,7 +553,7 @@ VideoTimeLine::check_server ()
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        );
-       char *res=curl_http_get(url, NULL);
+       char *res=a3_curl_http_get(url, NULL);
        if (res) {
                if (strstr(res, "status: ok, online.")) { ok = true; }
                free(res);
@@ -553,6 +561,39 @@ VideoTimeLine::check_server ()
        return ok;
 }
 
+bool
+VideoTimeLine::check_server_docroot ()
+{
+       bool ok = true;
+       char url[1024];
+       std::vector<std::vector<std::string> > lines;
+
+       if (video_server_url.find("/localhost:") == string::npos) {
+               return true;
+       }
+       snprintf(url, sizeof(url), "%s%src?format=csv"
+                       , video_server_url.c_str()
+                       , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
+                       );
+       char *res=a3_curl_http_get(url, NULL);
+       if (!res) {
+               return false;
+       }
+
+       ParseCSV(std::string(res), lines);
+       if (   lines.empty()
+                       || lines.at(0).empty()
+                       || lines.at(0).at(0) != video_get_docroot(Config)) {
+               warning << string_compose(
+                               _("Video-server docroot mismatch. %1: '%2', video-server: '%3'. This usually means that the video server was not started by ardour and uses a different document-root."),
+                               PROGRAM_NAME, video_get_docroot(Config), lines.at(0).at(0))
+               << endmsg;
+               ok = false; // TODO allow to override
+       }
+       free(res);
+       return ok;
+}
+
 void
 VideoTimeLine::gui_update(std::string const & t) {
        /* this is to be called via GuiUpdate() only. */
@@ -630,7 +671,7 @@ VideoTimeLine::flush_cache () {
                        , video_server_url.c_str()
                        , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
                        );
-       char *res=curl_http_get(url, NULL);
+       char *res=a3_curl_http_get(url, NULL);
        if (res) {
                free (res);
        }
@@ -778,8 +819,8 @@ VideoTimeLine::terminated_video_monitor () {
                vmonitor->save_session();
                delete vmonitor;
        }
-       GuiUpdate("set-xjadeo-active-off");
        vmonitor=0;
+       GuiUpdate("set-xjadeo-active-off");
        if (reopen_vmonitor) {
                reopen_vmonitor=false;
                open_video_monitor();