2 Copyright (C) 2010 Paul Davis
3 Author: Robin Gareus <robin@gareus.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <sigc++/bind.h>
22 #include "ardour/tempo.h"
24 #include "pbd/file_utils.h"
25 #include "pbd/convert.h"
26 #include "ardour/session_directory.h"
28 #ifdef PLATFORM_WINDOWS
30 #include <shlobj.h> // CSIDL_*
31 #include "pbd/windows_special_dirs.h"
34 #include "ardour_ui.h"
35 #include "public_editor.h"
36 #include "gui_thread.h"
38 #include "utils_videotl.h"
39 #include "rgb_macros.h"
40 #include "video_timeline.h"
42 #include <gtkmm2ext/utils.h>
44 #include <curl/curl.h>
49 using namespace ARDOUR;
51 using namespace Timecode;
52 using namespace VideoUtils;
54 VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Container *vbg, int initial_height)
57 , bar_height(initial_height)
59 video_start_offset = 0L;
63 auto_set_session_fps = false;
64 video_offset_lock = false;
65 video_aspect_ratio = 4.0/3.0;
66 Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
67 video_server_url = video_get_server_url(Config);
68 server_docroot = video_get_docroot(Config);
71 video_file_fps = 25.0;
74 reopen_vmonitor=false;
77 VtlUpdate.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
78 GuiUpdate.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
81 VideoTimeLine::~VideoTimeLine ()
86 /* close and save settings */
88 VideoTimeLine::save_session ()
94 LocaleGuard lg (X_("POSIX"));
96 XMLNode* node = new XMLNode(X_("Videomonitor"));
98 node->add_property (X_("active"), (vmonitor && vmonitor->is_started())?"yes":"no");
99 _session->add_extra_xml (*node);
102 if (vmonitor->is_started()) {
103 vmonitor->query_full_state(true);
105 vmonitor->save_session();
109 node = _session->extra_xml (X_("Videotimeline"));
111 node->add_property (X_("id"), id().to_s());
112 node->add_property (X_("Height"), editor->get_videotl_bar_height());
113 node->add_property (X_("VideoOffsetLock"), video_offset_lock?X_("1"):X_("0"));
114 node->add_property (X_("VideoOffset"), video_offset);
115 node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0"));
118 /* close and save settings */
120 VideoTimeLine::close_session ()
122 if (video_duration == 0) {
125 sessionsave.disconnect();
126 close_video_monitor();
131 GuiUpdate("set-xjadeo-sensitive-off");
132 GuiUpdate("video-unavailable");
136 VideoTimeLine::sync_session_state ()
138 if (!_session || !vmonitor || !vmonitor->is_started()) {
144 /** load settings from session */
146 VideoTimeLine::set_session (ARDOUR::Session *s)
148 SessionHandlePtr::set_session (s);
149 if (!_session) { return ; }
151 _session->SaveSession.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
152 LocaleGuard lg (X_("POSIX"));
154 XMLNode* node = _session->extra_xml (X_("Videotimeline"));
156 if (!node || !node->property (X_("Filename"))) {
160 ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false);
164 const XMLProperty* proph = node->property (X_("Height"));
166 editor->set_video_timeline_height(atoi(proph->value()));
168 #if 0 /* TODO THINK: set FPS first time only ?! */
169 const XMLProperty* propasfps = node->property (X_("AutoFPS"));
171 auto_set_session_fps = atoi(propasfps->value())?true:false;
175 const XMLProperty* propoffset = node->property (X_("VideoOffset"));
177 video_offset = atoll(propoffset->value());
178 video_offset_p = video_offset;
181 const XMLProperty* proplock = node->property (X_("VideoOffsetLock"));
183 video_offset_lock = atoi(proplock->value())?true:false;
186 const XMLProperty* localfile = node->property (X_("LocalFile"));
188 local_file = atoi(localfile->value())?true:false;
191 const XMLProperty* propf = node->property (X_("Filename"));
192 video_file_info(propf->value(), local_file);
194 if ((node = _session->extra_xml (X_("Videomonitor")))) {
195 const XMLProperty* prop = node->property (X_("active"));
196 if (prop && prop->value() == "yes" && found_xjadeo() && !video_filename.empty() && local_file) {
197 open_video_monitor();
201 _session->register_with_memento_command_factory(id(), this);
202 _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
206 VideoTimeLine::set_offset_locked (bool v) {
207 if (_session && v != video_offset_lock) {
208 _session->set_dirty ();
210 video_offset_lock = v;
214 VideoTimeLine::toggle_offset_locked () {
215 video_offset_lock = !video_offset_lock;
217 _session->set_dirty ();
222 VideoTimeLine::save_undo ()
224 if (_session && video_offset_p != video_offset) {
225 _session->set_dirty ();
227 video_offset_p = video_offset;
231 VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
233 LocaleGuard lg (X_("POSIX"));
234 const XMLProperty* propoffset = node.property (X_("VideoOffset"));
236 video_offset = atoll(propoffset->value());
238 ARDOUR_UI::instance()->flush_videotimeline_cache(true);
243 VideoTimeLine::get_state ()
245 XMLNode* node = new XMLNode (X_("Videotimeline"));
246 LocaleGuard lg (X_("POSIX"));
247 node->add_property (X_("VideoOffset"), video_offset_p);
252 VideoTimeLine::remove_frames ()
254 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) {
255 VideoImageFrame *frame = (*i);
259 video_frames.clear();
263 VideoTimeLine::get_video_frame (framepos_t vfn, int cut, int rightend)
266 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) {
267 VideoImageFrame *frame = (*i);
268 if (abs(frame->get_video_frame_number()-vfn)<=cut
269 && frame->get_rightend() == rightend) { return frame; }
275 VideoTimeLine::get_apv()
277 // XXX: dup code - TODO use this fn in update_video_timeline()
278 float apv = -1; /* audio samples per video frame; */
279 if (!_session) return apv;
281 if (_session->config.get_use_video_file_fps()) {
282 if (video_file_fps == 0 ) return apv;
284 if (_session->timecode_frames_per_second() == 0 ) return apv;
287 if (_session->config.get_videotimeline_pullup()) {
288 apv = _session->frame_rate();
290 apv = _session->nominal_frame_rate();
292 if (_session->config.get_use_video_file_fps()) {
293 apv /= video_file_fps;
295 apv /= _session->timecode_frames_per_second();
301 VideoTimeLine::update_video_timeline()
303 if (!_session) return;
305 if (_session->config.get_use_video_file_fps()) {
306 if (video_file_fps == 0 ) return;
308 if (_session->timecode_frames_per_second() == 0 ) return;
311 const double samples_per_pixel = editor->get_current_zoom();
312 const framepos_t leftmost_sample = editor->leftmost_sample();
315 * 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
316 * 2) calculate first frame and distance between video-frames (according to zoom)
317 * 3) destroy/add frames
318 * 4) reposition existing frames
319 * 5) assign framenumber to frames -> request/decode video.
322 /* video-file and session properties */
323 double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
324 float apv; /* audio samples per video frame; */
325 framepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
327 /* variables needed to render videotimeline -- what needs to computed first */
328 framepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */
329 framepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */
330 unsigned int visible_video_frames; /* number of frames that fit on current canvas */
332 if (_session->config.get_videotimeline_pullup()) {
333 apv = _session->frame_rate();
335 apv = _session->nominal_frame_rate();
337 if (_session->config.get_use_video_file_fps()) {
338 apv /= video_file_fps;
340 apv /= _session->timecode_frames_per_second();
343 display_vframe_width = bar_height * video_aspect_ratio;
345 if (apv > samples_per_pixel * display_vframe_width) {
346 /* high-zoom: need space between successive video-frames */
347 vtl_dist = rint(apv);
349 /* continous timeline: skip video-frames */
350 vtl_dist = ceil(display_vframe_width * samples_per_pixel / apv) * apv;
353 assert (vtl_dist > 0);
356 leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv);
358 vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv);
359 visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */
361 /* expand timeline (cache next/prev page images) */
362 vtl_start -= visible_video_frames * vtl_dist;
363 visible_video_frames *=3;
365 if (vtl_start < video_offset ) {
366 visible_video_frames += ceil((double)vtl_start/vtl_dist);
367 vtl_start = video_offset;
370 /* apply video-file constraints */
371 if (vtl_start > video_start_offset + video_duration + video_offset ) {
372 visible_video_frames = 0;
374 /* TODO optimize: compute rather than iterate */
375 while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + video_offset) {
376 --visible_video_frames;
384 while (video_frames.size() < visible_video_frames) {
385 VideoImageFrame *frame;
386 frame = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename());
387 frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
388 video_frames.push_back(frame);
391 VideoFrames outdated_video_frames;
392 std::list<int> remaining;
394 outdated_video_frames = video_frames;
397 /* when zoomed out, ignore shifts by +-1 frame
398 * which can occur due to rounding errors when
399 * scrolling to a new leftmost-audio frame.
402 if (vtl_dist/apv < 3.0) cut =0;
407 for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
408 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
409 framepos_t vframeno = rint ( (vfpos - video_offset) / apv); /* unit: video-frames */
410 vfpos = (vframeno * apv ) + video_offset; /* audio-frame corresponding to /rounded/ video-frame */
412 int rightend = -1; /* unit: pixels */
413 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
414 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
415 //printf("lf(e): %lu\n", vframeno); // XXX
417 VideoImageFrame * frame = get_video_frame(vframeno, cut, rightend);
419 frame->set_position(vfpos);
420 outdated_video_frames.remove(frame);
422 remaining.push_back(vfcount);
426 for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
427 VideoImageFrame *frame = (*i);
428 if (remaining.empty()) {
429 frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */
431 int vfcount=remaining.front();
432 remaining.pop_front();
433 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
434 framepos_t vframeno = rint ((vfpos - video_offset) / apv); /* unit: video-frames */
435 int rightend = -1; /* unit: pixels */
436 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
437 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
438 //printf("lf(n): %lu\n", vframeno); // XXX
440 frame->set_position(vfpos);
441 frame->set_videoframe(vframeno, rightend);
447 VideoTimeLine::translated_filename ()
450 return video_filename;
452 return video_map_path(server_docroot, video_filename);
457 VideoTimeLine::video_file_info (std::string filename, bool local)
461 if (Glib::path_is_absolute(filename) || !local_file)
463 video_filename = filename;
465 video_filename = Glib::build_filename (_session->session_directory().video_path(), filename);
468 long long int _duration;
469 double _start_offset;
471 if (!video_query_info(
472 video_server_url, translated_filename(),
473 video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
474 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;
476 GuiUpdate("set-xjadeo-sensitive-off");
477 GuiUpdate("video-unavailable");
480 video_duration = _duration * _session->nominal_frame_rate() / video_file_fps;
481 video_start_offset = _start_offset * _session->nominal_frame_rate();
483 if (auto_set_session_fps && video_file_fps != _session->timecode_frames_per_second()) {
484 switch ((int)floorf(video_file_fps*1000.0)) {
486 _session->config.set_timecode_format(timecode_23976);
489 _session->config.set_timecode_format(timecode_24);
493 _session->config.set_timecode_format(timecode_24976);
496 _session->config.set_timecode_format(timecode_25);
499 _session->config.set_timecode_format(timecode_2997drop);
502 _session->config.set_timecode_format(timecode_30);
505 _session->config.set_timecode_format(timecode_5994);
508 _session->config.set_timecode_format(timecode_60);
511 warning << string_compose (
512 _("Failed to set session-framerate: '%1' does not have a corresponding option setting in %2."),
513 video_file_fps, PROGRAM_NAME ) << endmsg;
516 _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
518 if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) {
519 warning << string_compose(
520 _("Video file's framerate is not equal to %1 session timecode's framerate: '%2' vs '%3'"),
521 PROGRAM_NAME, video_file_fps, _session->timecode_frames_per_second())
524 flush_local_cache ();
526 if (found_xjadeo() && local_file) {
527 GuiUpdate("set-xjadeo-sensitive-on");
528 if (vmonitor && vmonitor->is_started()) {
530 /* xjadeo <= 0.6.4 has a bug where changing the video-file may segfauls
531 * if the geometry changes to a different line-size alignment
533 reopen_vmonitor = true;
536 vmonitor->set_fps(video_file_fps);
537 vmonitor->open(video_filename);
540 } else if (!local_file) {
541 #if 1 /* temp debug/devel message */
542 // TODO - call xjremote remotely.
543 printf("the given video file can not be accessed on localhost, video monitoring is not currently supported for this case\n");
544 GuiUpdate("set-xjadeo-sensitive-off");
548 GuiUpdate("video-available");
553 VideoTimeLine::check_server ()
557 snprintf(url, sizeof(url), "%s%sstatus"
558 , video_server_url.c_str()
559 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
561 char *res=a3_curl_http_get(url, NULL);
563 if (strstr(res, "status: ok, online.")) { ok = true; }
570 VideoTimeLine::check_server_docroot ()
574 std::vector<std::vector<std::string> > lines;
576 if (video_server_url.find("/localhost:") == string::npos) {
579 snprintf(url, sizeof(url), "%s%src?format=csv"
580 , video_server_url.c_str()
581 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
583 char *res=a3_curl_http_get(url, NULL);
588 ParseCSV(std::string(res), lines);
590 || lines.at(0).empty()
591 || lines.at(0).at(0) != video_get_docroot(Config)) {
592 warning << string_compose(
593 _("Video-server docroot mismatch. %1: '%2', video-server: '%3'. This usually means that the video server was not started by %1 and uses a different document-root."),
594 PROGRAM_NAME, video_get_docroot(Config), lines.at(0).at(0))
596 ok = false; // TODO allow to override
603 VideoTimeLine::gui_update(std::string const & t) {
604 /* this is to be called via GuiUpdate() only. */
605 ENSURE_GUI_THREAD (*this, &VideoTimeLine::queue_visual_videotimeline_update)
606 if (t == "videotimeline-update") {
607 editor->queue_visual_videotimeline_update();
608 } else if (t == "set-xjadeo-active-off") {
609 editor->toggle_xjadeo_proc(0);
610 } else if (t == "set-xjadeo-active-on") {
611 editor->toggle_xjadeo_proc(1);
612 } else if (t == "set-xjadeo-sensitive-on") {
613 editor->set_xjadeo_sensitive(true);
614 } else if (t == "set-xjadeo-sensitive-off") {
615 editor->toggle_xjadeo_proc(0);
616 //close_video_monitor();
617 editor->set_xjadeo_sensitive(false);
618 } else if (t == "xjadeo-window-ontop-on") {
619 editor->toggle_xjadeo_viewoption(1, 1);
620 } else if (t == "xjadeo-window-ontop-off") {
621 editor->toggle_xjadeo_viewoption(1, 0);
622 } else if (t == "xjadeo-window-osd-timecode-on") {
623 editor->toggle_xjadeo_viewoption(2, 1);
624 } else if (t == "xjadeo-window-osd-timecode-off") {
625 editor->toggle_xjadeo_viewoption(2, 0);
626 } else if (t == "xjadeo-window-osd-frame-on") {
627 editor->toggle_xjadeo_viewoption(3, 1);
628 } else if (t == "xjadeo-window-osd-frame-off") {
629 editor->toggle_xjadeo_viewoption(3, 0);
630 } else if (t == "xjadeo-window-osd-box-on") {
631 editor->toggle_xjadeo_viewoption(4, 1);
632 } else if (t == "xjadeo-window-osd-box-off") {
633 editor->toggle_xjadeo_viewoption(4, 0);
634 } else if (t == "xjadeo-window-fullscreen-on") {
635 editor->toggle_xjadeo_viewoption(5, 1);
636 } else if (t == "xjadeo-window-fullscreen-off") {
637 editor->toggle_xjadeo_viewoption(5, 0);
638 } else if (t == "xjadeo-window-letterbox-on") {
639 editor->toggle_xjadeo_viewoption(6, 1);
640 } else if (t == "xjadeo-window-letterbox-off") {
641 editor->toggle_xjadeo_viewoption(6, 0);
642 } else if (t == "video-available") {
643 editor->set_close_video_sensitive(true);
644 } else if (t == "video-unavailable") {
645 editor->set_close_video_sensitive(false);
650 VideoTimeLine::set_height (int height) {
651 if (_session && bar_height != height) {
652 _session->set_dirty ();
659 VideoTimeLine::vmon_update () {
660 if (vmonitor && vmonitor->is_started()) {
661 vmonitor->set_offset(video_offset); // TODO proper re-init xjadeo w/o restart not just offset.
666 VideoTimeLine::flush_local_cache () {
672 VideoTimeLine::flush_cache () {
675 snprintf(url, sizeof(url), "%s%sadmin/flush_cache"
676 , video_server_url.c_str()
677 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
679 char *res=a3_curl_http_get(url, NULL);
683 if (vmonitor && vmonitor->is_started()) {
684 reopen_vmonitor=true;
687 video_file_info(video_filename, local_file);
692 VideoTimeLine::parameter_changed (std::string const & p)
694 if (p == "video-server-url") {
695 set_video_server_url (video_get_server_url(Config));
696 } else if (p == "video-server-docroot") {
697 set_video_server_docroot (video_get_docroot(Config));
698 } else if (p == "video-advanced-setup") {
699 set_video_server_url (video_get_server_url(Config));
700 set_video_server_docroot (video_get_docroot(Config));
702 if (p == "use-video-file-fps" || p == "videotimeline-pullup" ) { /* session->config parameter */
708 VideoTimeLine::set_video_server_url(std::string vsu) {
709 flush_local_cache ();
710 video_server_url = vsu;
715 VideoTimeLine::set_video_server_docroot(std::string vsr) {
716 flush_local_cache ();
717 server_docroot = vsr;
721 /* video-monitor for this timeline */
723 VideoTimeLine::xjadeo_readversion (std::string d, size_t /* s */) {
728 VideoTimeLine::find_xjadeo () {
729 std::string xjadeo_file_path;
730 #ifdef PLATFORM_WINDOWS
732 DWORD size = PATH_MAX;
733 char tmp[PATH_MAX+1];
734 const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
736 if (getenv("XJREMOTE")) {
737 _xjadeo_bin = getenv("XJREMOTE");
738 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
739 _xjadeo_bin = xjadeo_file_path;
741 #ifdef PLATFORM_WINDOWS
742 /* old xjadeo, typo in key <= 0.7.6 */
743 else if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\RSSxjadeo", 0, KEY_READ, &key))
744 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
747 _xjadeo_bin = std::string(g_build_filename(Glib::locale_to_utf8(tmp).c_str(), "xjadeo.exe", 0));
749 else if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\RSS\\xjadeo", 0, KEY_READ, &key))
750 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
753 _xjadeo_bin = std::string(g_build_filename(Glib::locale_to_utf8(tmp).c_str(), "xjadeo.exe", 0));
755 else if (program_files && Glib::file_test(g_build_filename(program_files, "xjadeo", "xjadeo.exe", 0), Glib::FILE_TEST_EXISTS))
757 _xjadeo_bin = std::string(g_build_filename(program_files, "harvid", "xjadeo.exe", 0));
760 /* generic fallbacks to try */
762 else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/xjremote"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
763 _xjadeo_bin = X_("/Applications/Jadeo.app/Contents/MacOS/xjremote");
766 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjadeo.exe"), Glib::FILE_TEST_EXISTS)) {
767 _xjadeo_bin = X_("C:\\Program Files\\xjadeo\\xjadeo.exe");
770 _xjadeo_bin = X_("");
771 warning << _("Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ "
772 "(a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. "
773 "It should point to an application compatible with xjadeo's remote-control interface 'xjremote').\n"
775 "see also http://manual.ardour.org/video-timeline/setup/")
778 if (found_xjadeo ()) {
779 ARDOUR::SystemExec version_check(_xjadeo_bin, X_("--version"));
781 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, _1 ,_2));
782 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, "\n" ,1));
783 if (version_check.start(2)) {
785 "Video-monitor 'xjadeo' cannot be launched."
787 _xjadeo_bin = X_("");
791 version_check.wait ();
793 while (xjadeo_version.empty() && --timeout) {
798 size_t vo = xjadeo_version.find(" version ");
799 if (vo != string::npos) {
800 int v_major, v_minor, v_micro;
801 if(sscanf(xjadeo_version.substr(vo + 9, string::npos).c_str(),"%d.%d.%d",
802 &v_major, &v_minor, &v_micro) == 3)
804 if (v_major >= 1) v_ok = true;
805 else if (v_major == 0 && v_minor >= 8) v_ok = true;
806 else if (v_major == 0 && v_minor >= 7 && v_micro >= 7) v_ok = true;
810 _xjadeo_bin = X_("");
812 "Video-monitor 'xjadeo' is too old. "
813 "Please install xjadeo version 0.7.7 or later. http://xjadeo.sf.net/"
820 VideoTimeLine::open_video_monitor() {
821 if (!found_xjadeo()) return;
823 vmonitor = new VideoMonitor(editor, _xjadeo_bin);
824 vmonitor->set_session(_session);
825 vmonitor->set_offset(video_offset);
826 vmonitor->Terminated.connect (sigc::mem_fun (*this, &VideoTimeLine::terminated_video_monitor));
827 vmonitor->UiState.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
828 } else if (vmonitor->is_started()) {
834 * the idea is to selective ignore certain monitor window
835 * states if xjadeo is not running on the same host as ardour.
836 * However with the removal of the video-monitor-startup-dialogue
837 * (git rev 5a4d0fff0) these settings are currently not accessible.
839 int xj_settings_mask = vmonitor->restore_settings_mask();
841 /* load mask from Session */
842 XMLNode* node = _session->extra_xml (X_("XJRestoreSettings"));
844 const XMLProperty* prop = node->property (X_("mask"));
846 xj_settings_mask = atoi(prop->value());
851 vmonitor->restore_settings_mask(xj_settings_mask);
854 if (!vmonitor->start()) {
855 warning << "launching xjadeo failed.." << endmsg;
856 close_video_monitor();
858 GuiUpdate("set-xjadeo-active-on");
859 vmonitor->set_fps(video_file_fps);
860 vmonitor->open(video_filename);
863 XMLNode* node = _session->extra_xml (X_("Videomonitor"));
865 const XMLProperty* prop = node->property (X_("active"));
866 if (prop && prop->value() != "yes") _session->set_dirty ();
868 _session->set_dirty ();
876 VideoTimeLine::close_video_monitor() {
877 if (vmonitor && vmonitor->is_started()) {
883 VideoTimeLine::control_video_monitor(int what, int param) {
884 if (!vmonitor || !vmonitor->is_started()) {
887 vmonitor->send_cmd(what, param);
892 VideoTimeLine::terminated_video_monitor () {
894 vmonitor->save_session();
898 GuiUpdate("set-xjadeo-active-off");
899 if (reopen_vmonitor) {
900 reopen_vmonitor=false;
901 open_video_monitor();
904 _session->set_dirty ();
910 VideoTimeLine::manual_seek_video_monitor (framepos_t pos)
912 if (!vmonitor) { return; }
913 if (!vmonitor->is_started()) { return; }
914 if (!vmonitor->synced_by_manual_seeks()) { return; }
915 vmonitor->manual_seek(pos, false, video_offset); // XXX -> set offset in xjadeo