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/types_convert.h"
26 #include "ardour/session_directory.h"
28 #include "ardour_ui.h"
29 #include "ardour_http.h"
30 #include "public_editor.h"
31 #include "gui_thread.h"
32 #include "utils_videotl.h"
33 #include "rgb_macros.h"
34 #include "video_timeline.h"
35 #include "video_tool_paths.h"
37 #include <gtkmm2ext/utils.h>
39 #include <curl/curl.h>
44 using namespace ARDOUR;
46 using namespace Timecode;
47 using namespace VideoUtils;
49 VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Container *vbg, int initial_height)
52 , bar_height(initial_height)
54 video_start_offset = 0L;
58 auto_set_session_fps = false;
59 video_offset_lock = false;
60 video_aspect_ratio = 4.0/3.0;
61 Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
64 video_file_fps = 25.0;
67 reopen_vmonitor=false;
70 video_server_url = video_get_server_url(Config);
71 server_docroot = video_get_docroot(Config);
73 VtlUpdate.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
74 GuiUpdate.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
77 VideoTimeLine::~VideoTimeLine ()
82 /* close and save settings */
84 VideoTimeLine::save_session ()
92 XMLNode* node = new XMLNode(X_("Videomonitor"));
94 node->set_property (X_("active"), (vmonitor && vmonitor->is_started()));
95 _session->add_extra_xml (*node);
98 if (vmonitor->is_started()) {
99 vmonitor->query_full_state(true);
101 vmonitor->save_session();
105 node = _session->extra_xml (X_("Videotimeline"));
107 node->set_property (X_("id"), id());
108 node->set_property (X_("Height"), editor->get_videotl_bar_height());
109 node->set_property (X_("VideoOffsetLock"), video_offset_lock);
110 node->set_property (X_("VideoOffset"), video_offset);
111 node->set_property (X_("AutoFPS"), auto_set_session_fps);
114 /* close and save settings */
116 VideoTimeLine::close_session ()
118 if (video_duration == 0) {
121 sessionsave.disconnect();
122 close_video_monitor();
127 GuiUpdate("set-xjadeo-sensitive-off");
128 GuiUpdate("video-unavailable");
132 VideoTimeLine::sync_session_state ()
134 if (!_session || !vmonitor || !vmonitor->is_started()) {
140 /** load settings from session */
142 VideoTimeLine::set_session (ARDOUR::Session *s)
144 SessionHandlePtr::set_session (s);
145 if (!_session) { return ; }
147 _session->SessionSaveUnderway.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
150 XMLNode* node = _session->extra_xml (X_("Videotimeline"));
152 if (!node || !node->property (X_("Filename"))) {
156 ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false);
161 if (node->get_property (X_("Height"), height)) {
162 editor->set_video_timeline_height(height);
164 #if 0 /* TODO THINK: set FPS first time only ?! */
165 XMLProperty const * propasfps = node->property (X_("AutoFPS"));
167 auto_set_session_fps = atoi(propasfps->value())?true:false;
171 if (node->get_property (X_("VideoOffset"), video_offset)) {
172 video_offset_p = video_offset;
175 node->get_property (X_("VideoOffsetLock"), video_offset_lock);
176 node->get_property (X_("LocalFile"), local_file);
178 std::string filename;
179 if (node->get_property (X_("Filename"), filename)) {
180 video_file_info (filename, local_file);
183 if ((node = _session->extra_xml (X_("Videomonitor")))) {
185 if (node->get_property (X_("active"), active) && active && found_xjadeo () &&
186 !video_filename.empty () && local_file) {
187 open_video_monitor();
191 _session->register_with_memento_command_factory(id(), this);
192 _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
196 VideoTimeLine::set_offset_locked (bool v) {
197 if (_session && v != video_offset_lock) {
198 _session->set_dirty ();
200 video_offset_lock = v;
204 VideoTimeLine::toggle_offset_locked () {
205 video_offset_lock = !video_offset_lock;
207 _session->set_dirty ();
212 VideoTimeLine::save_undo ()
214 if (_session && video_offset_p != video_offset) {
215 _session->set_dirty ();
217 video_offset_p = video_offset;
221 VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
224 node.get_property (X_("VideoOffset"), video_offset);
225 ARDOUR_UI::instance()->flush_videotimeline_cache(true);
230 VideoTimeLine::get_state ()
232 XMLNode* node = new XMLNode (X_("Videotimeline"));
234 node->set_property (X_("VideoOffset"), video_offset_p);
239 VideoTimeLine::remove_frames ()
241 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) {
242 VideoImageFrame *frame = (*i);
246 video_frames.clear();
250 VideoTimeLine::get_video_frame (framepos_t vfn, int cut, int rightend)
253 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) {
254 VideoImageFrame *frame = (*i);
255 if (abs(frame->get_video_frame_number()-vfn)<=cut
256 && frame->get_rightend() == rightend) { return frame; }
262 VideoTimeLine::get_apv()
264 // XXX: dup code - TODO use this fn in update_video_timeline()
265 float apv = -1; /* audio samples per video frame; */
266 if (!_session) return apv;
268 if (_session->config.get_use_video_file_fps()) {
269 if (video_file_fps == 0 ) return apv;
271 if (_session->timecode_frames_per_second() == 0 ) return apv;
274 if (_session->config.get_videotimeline_pullup()) {
275 apv = _session->frame_rate();
277 apv = _session->nominal_frame_rate();
279 if (_session->config.get_use_video_file_fps()) {
280 apv /= video_file_fps;
282 apv /= _session->timecode_frames_per_second();
288 VideoTimeLine::update_video_timeline()
290 if (!_session) return;
292 if (_session->config.get_use_video_file_fps()) {
293 if (video_file_fps == 0 ) return;
295 if (_session->timecode_frames_per_second() == 0 ) return;
298 const double samples_per_pixel = editor->get_current_zoom();
299 const framepos_t leftmost_sample = editor->leftmost_sample();
302 * 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
303 * 2) calculate first frame and distance between video-frames (according to zoom)
304 * 3) destroy/add frames
305 * 4) reposition existing frames
306 * 5) assign framenumber to frames -> request/decode video.
309 /* video-file and session properties */
310 double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
311 float apv; /* audio samples per video frame; */
312 framepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
314 /* variables needed to render videotimeline -- what needs to computed first */
315 framepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */
316 framepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */
317 unsigned int visible_video_frames; /* number of frames that fit on current canvas */
319 if (_session->config.get_videotimeline_pullup()) {
320 apv = _session->frame_rate();
322 apv = _session->nominal_frame_rate();
324 if (_session->config.get_use_video_file_fps()) {
325 apv /= video_file_fps;
327 apv /= _session->timecode_frames_per_second();
330 display_vframe_width = bar_height * video_aspect_ratio;
332 if (apv > samples_per_pixel * display_vframe_width) {
333 /* high-zoom: need space between successive video-frames */
334 vtl_dist = rint(apv);
336 /* continous timeline: skip video-frames */
337 vtl_dist = ceil(display_vframe_width * samples_per_pixel / apv) * apv;
340 assert (vtl_dist > 0);
343 leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv);
345 vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv);
346 visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */
348 /* expand timeline (cache next/prev page images) */
349 vtl_start -= visible_video_frames * vtl_dist;
350 visible_video_frames *=3;
352 /* don't request frames that are too far to the right */
353 if (vtl_start < video_offset) {
354 visible_video_frames = std::max((double)0.0, (double)visible_video_frames + ceil((double)(vtl_start - video_offset)/vtl_dist));
355 vtl_start = video_offset;
358 /* apply video-file constraints
359 * (first frame in video is at video_start_offset) */
360 if (vtl_start > video_start_offset + video_duration + video_offset ) {
361 visible_video_frames = 0;
364 * end = position on timeline (video-offset) minus video-file's first frame position
365 * TODO optimize: compute rather than iterate */
366 while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + video_offset) {
367 --visible_video_frames;
375 while (video_frames.size() < visible_video_frames) {
376 VideoImageFrame *frame;
377 frame = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename());
378 frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
379 video_frames.push_back(frame);
382 VideoFrames outdated_video_frames;
383 std::list<int> remaining;
385 outdated_video_frames = video_frames;
388 /* when zoomed out, ignore shifts by +-1 frame
389 * which can occur due to rounding errors when
390 * scrolling to a new leftmost-audio frame.
393 if (vtl_dist/apv < 3.0) cut =0;
398 for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
399 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
400 framepos_t vframeno = rint ( (vfpos - video_offset) / apv); /* unit: video-frames */
401 vfpos = (vframeno * apv ) + video_offset; /* audio-frame corresponding to /rounded/ video-frame */
403 int rightend = -1; /* unit: pixels */
404 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
405 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
406 //printf("lf(e): %lu\n", vframeno); // XXX
408 VideoImageFrame * frame = get_video_frame(vframeno, cut, rightend);
410 frame->set_position(vfpos);
411 outdated_video_frames.remove(frame);
413 remaining.push_back(vfcount);
417 for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
418 VideoImageFrame *frame = (*i);
419 if (remaining.empty()) {
420 frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */
422 int vfcount=remaining.front();
423 remaining.pop_front();
424 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
425 framepos_t vframeno = rint ((vfpos - video_offset) / apv); /* unit: video-frames */
426 int rightend = -1; /* unit: pixels */
427 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
428 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
429 //printf("lf(n): %lu\n", vframeno); // XXX
431 frame->set_position(vfpos);
432 frame->set_videoframe(vframeno, rightend);
438 VideoTimeLine::translated_filename ()
441 return video_filename;
443 return video_map_path(server_docroot, video_filename);
448 VideoTimeLine::video_file_info (std::string filename, bool local)
452 if (Glib::path_is_absolute(filename) || !local_file)
454 video_filename = filename;
456 video_filename = Glib::build_filename (_session->session_directory().video_path(), filename);
459 long long int _duration;
460 double _start_offset;
462 if (!video_query_info(
463 video_server_url, translated_filename(),
464 video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
465 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;
467 GuiUpdate("set-xjadeo-sensitive-off");
468 GuiUpdate("video-unavailable");
471 video_duration = _duration * _session->nominal_frame_rate() / video_file_fps;
472 video_start_offset = _start_offset * _session->nominal_frame_rate();
474 if (auto_set_session_fps && video_file_fps != _session->timecode_frames_per_second()) {
475 switch ((int)floorf(video_file_fps*1000.0)) {
477 _session->config.set_timecode_format(timecode_23976);
480 _session->config.set_timecode_format(timecode_24);
484 _session->config.set_timecode_format(timecode_24976);
487 _session->config.set_timecode_format(timecode_25);
490 _session->config.set_timecode_format(timecode_2997drop);
493 _session->config.set_timecode_format(timecode_30);
496 _session->config.set_timecode_format(timecode_5994);
499 _session->config.set_timecode_format(timecode_60);
502 warning << string_compose (
503 _("Failed to set session-framerate: '%1' does not have a corresponding option setting in %2."),
504 video_file_fps, PROGRAM_NAME ) << endmsg;
507 _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
509 if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) {
510 warning << string_compose(
511 _("Video file's framerate is not equal to %1 session timecode's framerate: '%2' vs '%3'"),
512 PROGRAM_NAME, video_file_fps, _session->timecode_frames_per_second())
515 flush_local_cache ();
517 if (found_xjadeo() && local_file) {
518 GuiUpdate("set-xjadeo-sensitive-on");
519 if (vmonitor && vmonitor->is_started()) {
521 /* xjadeo <= 0.6.4 has a bug where changing the video-file may segfauls
522 * if the geometry changes to a different line-size alignment
524 reopen_vmonitor = true;
527 vmonitor->set_fps(video_file_fps);
528 vmonitor->open(video_filename);
531 } else if (!local_file) {
532 #if 1 /* temp debug/devel message */
533 // TODO - call xjremote remotely.
534 printf("the given video file can not be accessed on localhost, video monitoring is not currently supported for this case\n");
535 GuiUpdate("set-xjadeo-sensitive-off");
539 GuiUpdate("video-available");
544 VideoTimeLine::check_server ()
548 snprintf(url, sizeof(url), "%s%sstatus"
549 , video_server_url.c_str()
550 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
552 char* res = ArdourCurl::http_get (url, NULL);
554 if (strstr(res, "status: ok, online.")) { ok = true; }
561 VideoTimeLine::check_server_docroot ()
565 std::vector<std::vector<std::string> > lines;
567 if (video_server_url.find("/localhost:") == string::npos) {
570 snprintf(url, sizeof(url), "%s%src?format=csv"
571 , video_server_url.c_str()
572 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
574 char* res = ArdourCurl::http_get (url, NULL);
579 ParseCSV(std::string(res), lines);
581 || lines.at(0).empty()
582 || lines.at(0).at(0) != video_get_docroot(Config)) {
583 warning << string_compose(
584 _("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."),
585 PROGRAM_NAME, video_get_docroot(Config), lines.at(0).at(0))
587 ok = false; // TODO allow to override
594 VideoTimeLine::gui_update(std::string const & t) {
595 /* this is to be called via GuiUpdate() only. */
596 ENSURE_GUI_THREAD (*this, &VideoTimeLine::queue_visual_videotimeline_update)
597 if (t == "videotimeline-update") {
598 editor->queue_visual_videotimeline_update();
599 } else if (t == "set-xjadeo-active-off") {
600 editor->toggle_xjadeo_proc(0);
601 } else if (t == "set-xjadeo-active-on") {
602 editor->toggle_xjadeo_proc(1);
603 } else if (t == "set-xjadeo-sensitive-on") {
604 editor->set_xjadeo_sensitive(true);
605 } else if (t == "set-xjadeo-sensitive-off") {
606 editor->toggle_xjadeo_proc(0);
607 //close_video_monitor();
608 editor->set_xjadeo_sensitive(false);
609 } else if (t == "xjadeo-window-ontop-on") {
610 editor->toggle_xjadeo_viewoption(1, 1);
611 } else if (t == "xjadeo-window-ontop-off") {
612 editor->toggle_xjadeo_viewoption(1, 0);
613 } else if (t == "xjadeo-window-osd-timecode-on") {
614 editor->toggle_xjadeo_viewoption(2, 1);
615 } else if (t == "xjadeo-window-osd-timecode-off") {
616 editor->toggle_xjadeo_viewoption(2, 0);
617 } else if (t == "xjadeo-window-osd-frame-on") {
618 editor->toggle_xjadeo_viewoption(3, 1);
619 } else if (t == "xjadeo-window-osd-frame-off") {
620 editor->toggle_xjadeo_viewoption(3, 0);
621 } else if (t == "xjadeo-window-osd-box-on") {
622 editor->toggle_xjadeo_viewoption(4, 1);
623 } else if (t == "xjadeo-window-osd-box-off") {
624 editor->toggle_xjadeo_viewoption(4, 0);
625 } else if (t == "xjadeo-window-fullscreen-on") {
626 editor->toggle_xjadeo_viewoption(5, 1);
627 } else if (t == "xjadeo-window-fullscreen-off") {
628 editor->toggle_xjadeo_viewoption(5, 0);
629 } else if (t == "xjadeo-window-letterbox-on") {
630 editor->toggle_xjadeo_viewoption(6, 1);
631 } else if (t == "xjadeo-window-letterbox-off") {
632 editor->toggle_xjadeo_viewoption(6, 0);
633 } else if (t == "video-available") {
634 editor->set_close_video_sensitive(true);
635 } else if (t == "video-unavailable") {
636 editor->set_close_video_sensitive(false);
641 VideoTimeLine::set_height (int height) {
642 if (_session && bar_height != height) {
643 _session->set_dirty ();
650 VideoTimeLine::vmon_update () {
651 if (vmonitor && vmonitor->is_started()) {
652 vmonitor->set_offset(video_offset); // TODO proper re-init xjadeo w/o restart not just offset.
657 VideoTimeLine::flush_local_cache () {
663 VideoTimeLine::flush_cache () {
666 snprintf(url, sizeof(url), "%s%sadmin/flush_cache"
667 , video_server_url.c_str()
668 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
670 char* res = ArdourCurl::http_get (url, NULL);
674 if (vmonitor && vmonitor->is_started()) {
675 reopen_vmonitor=true;
678 video_file_info(video_filename, local_file);
683 VideoTimeLine::parameter_changed (std::string const & p)
685 if (p == "video-server-url") {
686 set_video_server_url (video_get_server_url(Config));
687 } else if (p == "video-server-docroot") {
688 set_video_server_docroot (video_get_docroot(Config));
689 } else if (p == "video-advanced-setup") {
690 set_video_server_url (video_get_server_url(Config));
691 set_video_server_docroot (video_get_docroot(Config));
693 if (p == "use-video-file-fps" || p == "videotimeline-pullup" ) { /* session->config parameter */
699 VideoTimeLine::set_video_server_url(std::string vsu) {
700 flush_local_cache ();
701 video_server_url = vsu;
706 VideoTimeLine::set_video_server_docroot(std::string vsr) {
707 flush_local_cache ();
708 server_docroot = vsr;
712 /* video-monitor for this timeline */
714 VideoTimeLine::xjadeo_readversion (std::string d, size_t /* s */) {
719 VideoTimeLine::find_xjadeo () {
720 if (!ArdourVideoToolPaths::xjadeo_exe(_xjadeo_bin)) {
721 warning << _("Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ "
722 "(a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. "
723 "It should point to an application compatible with xjadeo's remote-control interface 'xjremote').\n"
725 "see also http://manual.ardour.org/video-timeline/setup/")
729 if (found_xjadeo ()) {
730 ARDOUR::SystemExec version_check(_xjadeo_bin, X_("--version"));
732 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, _1 ,_2));
733 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, "\n" ,1));
734 if (version_check.start(2)) {
736 "Video-monitor 'xjadeo' cannot be launched."
738 _xjadeo_bin = X_("");
742 #ifdef PLATFORM_WINDOWS
743 version_check.wait (); // 40ms timeout
745 version_check.wait (WNOHANG);
749 while (xjadeo_version.empty() && --timeout) {
754 size_t vo = xjadeo_version.find(" version ");
755 if (vo != string::npos) {
756 int v_major, v_minor, v_micro;
757 if(sscanf(xjadeo_version.substr(vo + 9, string::npos).c_str(),"%d.%d.%d",
758 &v_major, &v_minor, &v_micro) == 3)
760 if (v_major >= 1) v_ok = true;
761 else if (v_major == 0 && v_minor >= 8) v_ok = true;
762 else if (v_major == 0 && v_minor >= 7 && v_micro >= 7) v_ok = true;
766 _xjadeo_bin = X_("");
768 "Video-monitor 'xjadeo' is too old. "
769 "Please install xjadeo version 0.7.7 or later. http://xjadeo.sf.net/"
776 VideoTimeLine::harvid_readversion (std::string d, size_t /* s */) {
781 VideoTimeLine::find_harvid () {
782 /* This is mainly for the benefit of the windows version:
783 * harvid >= 0.8.2 allows an empty docroot and ardour can
784 * pass the drive-letter along.
786 * It is a chicken/egg w.r.t. the video-server dialog
787 * but needed for default preferences and initial settings.
789 std::string harvid_bin;
790 if (VideoUtils::harvid_version != 0x0) {
793 if (!ArdourVideoToolPaths::harvid_exe(harvid_bin)) {
796 if (harvid_bin.empty ()) {
799 ARDOUR::SystemExec version_check(harvid_bin, X_("--version"));
801 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, _1 ,_2));
802 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, "\n" ,1));
803 if (version_check.start(2)) {
807 #ifdef PLATFORM_WINDOWS
808 version_check.wait (); // 40ms timeout
810 version_check.wait (WNOHANG);
814 while (harvid_version.empty() && --timeout) {
818 size_t vo = harvid_version.find("harvid v");
819 if (vo != string::npos) {
820 int v_major, v_minor, v_micro;
821 if(sscanf(harvid_version.substr(vo + 8, string::npos).c_str(),"%d.%d.%d",
822 &v_major, &v_minor, &v_micro) == 3)
824 VideoUtils::harvid_version = (v_major << 16) | (v_minor << 8) | v_micro;
825 info << "harvid version: "<< hex << VideoUtils::harvid_version << endmsg;
831 VideoTimeLine::open_video_monitor() {
832 if (!found_xjadeo()) return;
834 vmonitor = new VideoMonitor(editor, _xjadeo_bin);
835 vmonitor->set_session(_session);
836 vmonitor->set_offset(video_offset);
837 vmonitor->Terminated.connect (sigc::mem_fun (*this, &VideoTimeLine::terminated_video_monitor));
838 vmonitor->UiState.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
839 } else if (vmonitor->is_started()) {
845 * the idea is to selective ignore certain monitor window
846 * states if xjadeo is not running on the same host as ardour.
847 * However with the removal of the video-monitor-startup-dialogue
848 * (git rev 5a4d0fff0) these settings are currently not accessible.
850 int xj_settings_mask = vmonitor->restore_settings_mask();
852 /* load mask from Session */
853 XMLNode* node = _session->extra_xml (X_("XJRestoreSettings"));
855 XMLProperty const * prop = node->property (X_("mask"));
857 xj_settings_mask = atoi(prop->value());
862 vmonitor->restore_settings_mask(xj_settings_mask);
865 if (!vmonitor->start()) {
866 warning << "launching xjadeo failed.." << endmsg;
867 close_video_monitor();
869 GuiUpdate("set-xjadeo-active-on");
870 vmonitor->set_fps(video_file_fps);
871 vmonitor->open(video_filename);
874 XMLNode* node = _session->extra_xml (X_("Videomonitor"));
877 if (node->get_property (X_("active"), active) && !active) {
878 _session->set_dirty ();
881 _session->set_dirty ();
889 VideoTimeLine::close_video_monitor() {
890 if (vmonitor && vmonitor->is_started()) {
896 VideoTimeLine::control_video_monitor(int what, int param) {
897 if (!vmonitor || !vmonitor->is_started()) {
900 vmonitor->send_cmd(what, param);
905 VideoTimeLine::terminated_video_monitor () {
907 vmonitor->save_session();
911 GuiUpdate("set-xjadeo-active-off");
912 if (reopen_vmonitor) {
913 reopen_vmonitor=false;
914 open_video_monitor();
917 _session->set_dirty ();
923 VideoTimeLine::manual_seek_video_monitor (framepos_t pos)
925 if (!vmonitor) { return; }
926 if (!vmonitor->is_started()) { return; }
927 if (!vmonitor->synced_by_manual_seeks()) { return; }
928 vmonitor->manual_seek(pos, false, video_offset); // XXX -> set offset in xjadeo