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 ()
90 XMLNode* node = new XMLNode(X_("Videomonitor"));
92 node->set_property (X_("active"), (vmonitor && vmonitor->is_started()));
93 _session->add_extra_xml (*node);
96 if (vmonitor->is_started()) {
97 vmonitor->query_full_state(true);
99 vmonitor->save_session();
103 node = _session->extra_xml (X_("Videotimeline"));
105 node->set_property (X_("id"), id());
106 node->set_property (X_("Height"), editor->get_videotl_bar_height());
107 node->set_property (X_("VideoOffsetLock"), video_offset_lock);
108 node->set_property (X_("VideoOffset"), video_offset);
109 node->set_property (X_("AutoFPS"), auto_set_session_fps);
112 /* close and save settings */
114 VideoTimeLine::close_session ()
116 if (video_duration == 0) {
119 sessionsave.disconnect();
120 close_video_monitor();
125 GuiUpdate("set-xjadeo-sensitive-off");
126 GuiUpdate("video-unavailable");
130 VideoTimeLine::sync_session_state ()
132 if (!_session || !vmonitor || !vmonitor->is_started()) {
138 /** load settings from session */
140 VideoTimeLine::set_session (ARDOUR::Session *s)
142 SessionHandlePtr::set_session (s);
143 if (!_session) { return ; }
145 _session->SessionSaveUnderway.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
147 XMLNode* node = _session->extra_xml (X_("Videotimeline"));
149 if (!node || !node->property (X_("Filename"))) {
153 ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false);
158 if (node->get_property (X_("Height"), height)) {
159 editor->set_video_timeline_height(height);
161 #if 0 /* TODO THINK: set FPS first time only ?! */
162 XMLProperty const * propasfps = node->property (X_("AutoFPS"));
164 auto_set_session_fps = atoi(propasfps->value())?true:false;
168 if (node->get_property (X_("VideoOffset"), video_offset)) {
169 video_offset_p = video_offset;
172 node->get_property (X_("VideoOffsetLock"), video_offset_lock);
173 node->get_property (X_("LocalFile"), local_file);
175 std::string filename;
176 if (node->get_property (X_("Filename"), filename)) {
177 video_file_info (filename, local_file);
180 if ((node = _session->extra_xml (X_("Videomonitor")))) {
182 if (node->get_property (X_("active"), active) && active && found_xjadeo () &&
183 !video_filename.empty () && local_file) {
184 open_video_monitor();
188 _session->register_with_memento_command_factory(id(), this);
189 _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
193 VideoTimeLine::set_offset_locked (bool v) {
194 if (_session && v != video_offset_lock) {
195 _session->set_dirty ();
197 video_offset_lock = v;
201 VideoTimeLine::toggle_offset_locked () {
202 video_offset_lock = !video_offset_lock;
204 _session->set_dirty ();
209 VideoTimeLine::save_undo ()
211 if (_session && video_offset_p != video_offset) {
212 _session->set_dirty ();
214 video_offset_p = video_offset;
218 VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
220 node.get_property (X_("VideoOffset"), video_offset);
221 ARDOUR_UI::instance()->flush_videotimeline_cache(true);
226 VideoTimeLine::get_state ()
228 XMLNode* node = new XMLNode (X_("Videotimeline"));
229 node->set_property (X_("VideoOffset"), video_offset_p);
234 VideoTimeLine::remove_frames ()
236 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) {
237 VideoImageFrame *frame = (*i);
241 video_frames.clear();
245 VideoTimeLine::get_video_frame (framepos_t vfn, int cut, int rightend)
248 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) {
249 VideoImageFrame *frame = (*i);
250 if (abs(frame->get_video_frame_number()-vfn)<=cut
251 && frame->get_rightend() == rightend) { return frame; }
257 VideoTimeLine::get_apv()
259 // XXX: dup code - TODO use this fn in update_video_timeline()
260 float apv = -1; /* audio samples per video frame; */
261 if (!_session) return apv;
263 if (_session->config.get_use_video_file_fps()) {
264 if (video_file_fps == 0 ) return apv;
266 if (_session->timecode_frames_per_second() == 0 ) return apv;
269 if (_session->config.get_videotimeline_pullup()) {
270 apv = _session->frame_rate();
272 apv = _session->nominal_frame_rate();
274 if (_session->config.get_use_video_file_fps()) {
275 apv /= video_file_fps;
277 apv /= _session->timecode_frames_per_second();
283 VideoTimeLine::update_video_timeline()
285 if (!_session) return;
287 if (_session->config.get_use_video_file_fps()) {
288 if (video_file_fps == 0 ) return;
290 if (_session->timecode_frames_per_second() == 0 ) return;
293 const double samples_per_pixel = editor->get_current_zoom();
294 const framepos_t leftmost_sample = editor->leftmost_sample();
297 * 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
298 * 2) calculate first frame and distance between video-frames (according to zoom)
299 * 3) destroy/add frames
300 * 4) reposition existing frames
301 * 5) assign framenumber to frames -> request/decode video.
304 /* video-file and session properties */
305 double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
306 float apv; /* audio samples per video frame; */
307 framepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
309 /* variables needed to render videotimeline -- what needs to computed first */
310 framepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */
311 framepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */
312 unsigned int visible_video_frames; /* number of frames that fit on current canvas */
314 if (_session->config.get_videotimeline_pullup()) {
315 apv = _session->frame_rate();
317 apv = _session->nominal_frame_rate();
319 if (_session->config.get_use_video_file_fps()) {
320 apv /= video_file_fps;
322 apv /= _session->timecode_frames_per_second();
325 display_vframe_width = bar_height * video_aspect_ratio;
327 if (apv > samples_per_pixel * display_vframe_width) {
328 /* high-zoom: need space between successive video-frames */
329 vtl_dist = rint(apv);
331 /* continous timeline: skip video-frames */
332 vtl_dist = ceil(display_vframe_width * samples_per_pixel / apv) * apv;
335 assert (vtl_dist > 0);
338 leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv);
340 vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv);
341 visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */
343 /* expand timeline (cache next/prev page images) */
344 vtl_start -= visible_video_frames * vtl_dist;
345 visible_video_frames *=3;
347 /* don't request frames that are too far to the right */
348 if (vtl_start < video_offset) {
349 visible_video_frames = std::max((double)0.0, (double)visible_video_frames + ceil((double)(vtl_start - video_offset)/vtl_dist));
350 vtl_start = video_offset;
353 /* apply video-file constraints
354 * (first frame in video is at video_start_offset) */
355 if (vtl_start > video_start_offset + video_duration + video_offset ) {
356 visible_video_frames = 0;
359 * end = position on timeline (video-offset) minus video-file's first frame position
360 * TODO optimize: compute rather than iterate */
361 while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + video_offset) {
362 --visible_video_frames;
370 while (video_frames.size() < visible_video_frames) {
371 VideoImageFrame *frame;
372 frame = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename());
373 frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
374 video_frames.push_back(frame);
377 VideoFrames outdated_video_frames;
378 std::list<int> remaining;
380 outdated_video_frames = video_frames;
383 /* when zoomed out, ignore shifts by +-1 frame
384 * which can occur due to rounding errors when
385 * scrolling to a new leftmost-audio frame.
388 if (vtl_dist/apv < 3.0) cut =0;
393 for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
394 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
395 framepos_t vframeno = rint ( (vfpos - video_offset) / apv); /* unit: video-frames */
396 vfpos = (vframeno * apv ) + video_offset; /* audio-frame corresponding to /rounded/ video-frame */
398 int rightend = -1; /* unit: pixels */
399 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
400 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
401 //printf("lf(e): %lu\n", vframeno); // XXX
403 VideoImageFrame * frame = get_video_frame(vframeno, cut, rightend);
405 frame->set_position(vfpos);
406 outdated_video_frames.remove(frame);
408 remaining.push_back(vfcount);
412 for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
413 VideoImageFrame *frame = (*i);
414 if (remaining.empty()) {
415 frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */
417 int vfcount=remaining.front();
418 remaining.pop_front();
419 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
420 framepos_t vframeno = rint ((vfpos - video_offset) / apv); /* unit: video-frames */
421 int rightend = -1; /* unit: pixels */
422 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
423 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
424 //printf("lf(n): %lu\n", vframeno); // XXX
426 frame->set_position(vfpos);
427 frame->set_videoframe(vframeno, rightend);
433 VideoTimeLine::translated_filename ()
436 return video_filename;
438 return video_map_path(server_docroot, video_filename);
443 VideoTimeLine::video_file_info (std::string filename, bool local)
447 if (Glib::path_is_absolute(filename) || !local_file)
449 video_filename = filename;
451 video_filename = Glib::build_filename (_session->session_directory().video_path(), filename);
454 long long int _duration;
455 double _start_offset;
457 if (!video_query_info(
458 video_server_url, translated_filename(),
459 video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
460 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;
462 GuiUpdate("set-xjadeo-sensitive-off");
463 GuiUpdate("video-unavailable");
466 video_duration = _duration * _session->nominal_frame_rate() / video_file_fps;
467 video_start_offset = _start_offset * _session->nominal_frame_rate();
469 if (auto_set_session_fps && video_file_fps != _session->timecode_frames_per_second()) {
470 switch ((int)floorf(video_file_fps*1000.0)) {
472 _session->config.set_timecode_format(timecode_23976);
475 _session->config.set_timecode_format(timecode_24);
479 _session->config.set_timecode_format(timecode_24976);
482 _session->config.set_timecode_format(timecode_25);
485 _session->config.set_timecode_format(timecode_2997drop);
488 _session->config.set_timecode_format(timecode_30);
491 _session->config.set_timecode_format(timecode_5994);
494 _session->config.set_timecode_format(timecode_60);
497 warning << string_compose (
498 _("Failed to set session-framerate: '%1' does not have a corresponding option setting in %2."),
499 video_file_fps, PROGRAM_NAME ) << endmsg;
502 _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
504 if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) {
505 warning << string_compose(
506 _("Video file's framerate is not equal to %1 session timecode's framerate: '%2' vs '%3'"),
507 PROGRAM_NAME, video_file_fps, _session->timecode_frames_per_second())
510 flush_local_cache ();
512 if (found_xjadeo() && local_file) {
513 GuiUpdate("set-xjadeo-sensitive-on");
514 if (vmonitor && vmonitor->is_started()) {
516 /* xjadeo <= 0.6.4 has a bug where changing the video-file may segfauls
517 * if the geometry changes to a different line-size alignment
519 reopen_vmonitor = true;
522 vmonitor->set_fps(video_file_fps);
523 vmonitor->open(video_filename);
526 } else if (!local_file) {
527 #if 1 /* temp debug/devel message */
528 // TODO - call xjremote remotely.
529 printf("the given video file can not be accessed on localhost, video monitoring is not currently supported for this case\n");
530 GuiUpdate("set-xjadeo-sensitive-off");
534 GuiUpdate("video-available");
539 VideoTimeLine::check_server ()
543 snprintf(url, sizeof(url), "%s%sstatus"
544 , video_server_url.c_str()
545 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
547 char* res = ArdourCurl::http_get (url, NULL);
549 if (strstr(res, "status: ok, online.")) { ok = true; }
556 VideoTimeLine::check_server_docroot ()
560 std::vector<std::vector<std::string> > lines;
562 if (video_server_url.find("/localhost:") == string::npos) {
565 snprintf(url, sizeof(url), "%s%src?format=csv"
566 , video_server_url.c_str()
567 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
569 char* res = ArdourCurl::http_get (url, NULL);
574 ParseCSV(std::string(res), lines);
576 || lines.at(0).empty()
577 || lines.at(0).at(0) != video_get_docroot(Config)) {
578 warning << string_compose(
579 _("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."),
580 PROGRAM_NAME, video_get_docroot(Config), lines.at(0).at(0))
582 ok = false; // TODO allow to override
589 VideoTimeLine::gui_update(std::string const & t) {
590 /* this is to be called via GuiUpdate() only. */
591 ENSURE_GUI_THREAD (*this, &VideoTimeLine::queue_visual_videotimeline_update)
592 if (t == "videotimeline-update") {
593 editor->queue_visual_videotimeline_update();
594 } else if (t == "set-xjadeo-active-off") {
595 editor->toggle_xjadeo_proc(0);
596 } else if (t == "set-xjadeo-active-on") {
597 editor->toggle_xjadeo_proc(1);
598 } else if (t == "set-xjadeo-sensitive-on") {
599 editor->set_xjadeo_sensitive(true);
600 } else if (t == "set-xjadeo-sensitive-off") {
601 editor->toggle_xjadeo_proc(0);
602 //close_video_monitor();
603 editor->set_xjadeo_sensitive(false);
604 } else if (t == "xjadeo-window-ontop-on") {
605 editor->toggle_xjadeo_viewoption(1, 1);
606 } else if (t == "xjadeo-window-ontop-off") {
607 editor->toggle_xjadeo_viewoption(1, 0);
608 } else if (t == "xjadeo-window-osd-timecode-on") {
609 editor->toggle_xjadeo_viewoption(2, 1);
610 } else if (t == "xjadeo-window-osd-timecode-off") {
611 editor->toggle_xjadeo_viewoption(2, 0);
612 } else if (t == "xjadeo-window-osd-frame-on") {
613 editor->toggle_xjadeo_viewoption(3, 1);
614 } else if (t == "xjadeo-window-osd-frame-off") {
615 editor->toggle_xjadeo_viewoption(3, 0);
616 } else if (t == "xjadeo-window-osd-box-on") {
617 editor->toggle_xjadeo_viewoption(4, 1);
618 } else if (t == "xjadeo-window-osd-box-off") {
619 editor->toggle_xjadeo_viewoption(4, 0);
620 } else if (t == "xjadeo-window-fullscreen-on") {
621 editor->toggle_xjadeo_viewoption(5, 1);
622 } else if (t == "xjadeo-window-fullscreen-off") {
623 editor->toggle_xjadeo_viewoption(5, 0);
624 } else if (t == "xjadeo-window-letterbox-on") {
625 editor->toggle_xjadeo_viewoption(6, 1);
626 } else if (t == "xjadeo-window-letterbox-off") {
627 editor->toggle_xjadeo_viewoption(6, 0);
628 } else if (t == "video-available") {
629 editor->set_close_video_sensitive(true);
630 } else if (t == "video-unavailable") {
631 editor->set_close_video_sensitive(false);
636 VideoTimeLine::set_height (int height) {
637 if (_session && bar_height != height) {
638 _session->set_dirty ();
645 VideoTimeLine::vmon_update () {
646 if (vmonitor && vmonitor->is_started()) {
647 vmonitor->set_offset(video_offset); // TODO proper re-init xjadeo w/o restart not just offset.
652 VideoTimeLine::flush_local_cache () {
658 VideoTimeLine::flush_cache () {
661 snprintf(url, sizeof(url), "%s%sadmin/flush_cache"
662 , video_server_url.c_str()
663 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
665 char* res = ArdourCurl::http_get (url, NULL);
669 if (vmonitor && vmonitor->is_started()) {
670 reopen_vmonitor=true;
673 video_file_info(video_filename, local_file);
678 VideoTimeLine::parameter_changed (std::string const & p)
680 if (p == "video-server-url") {
681 set_video_server_url (video_get_server_url(Config));
682 } else if (p == "video-server-docroot") {
683 set_video_server_docroot (video_get_docroot(Config));
684 } else if (p == "video-advanced-setup") {
685 set_video_server_url (video_get_server_url(Config));
686 set_video_server_docroot (video_get_docroot(Config));
688 if (p == "use-video-file-fps" || p == "videotimeline-pullup" ) { /* session->config parameter */
694 VideoTimeLine::set_video_server_url(std::string vsu) {
695 flush_local_cache ();
696 video_server_url = vsu;
701 VideoTimeLine::set_video_server_docroot(std::string vsr) {
702 flush_local_cache ();
703 server_docroot = vsr;
707 /* video-monitor for this timeline */
709 VideoTimeLine::xjadeo_readversion (std::string d, size_t /* s */) {
714 VideoTimeLine::find_xjadeo () {
715 if (!ArdourVideoToolPaths::xjadeo_exe(_xjadeo_bin)) {
716 warning << _("Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ "
717 "(a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. "
718 "It should point to an application compatible with xjadeo's remote-control interface 'xjremote').\n"
720 "see also http://manual.ardour.org/video-timeline/setup/")
724 if (found_xjadeo ()) {
725 ARDOUR::SystemExec version_check(_xjadeo_bin, X_("--version"));
727 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, _1 ,_2));
728 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, "\n" ,1));
729 if (version_check.start(2)) {
731 "Video-monitor 'xjadeo' cannot be launched."
733 _xjadeo_bin = X_("");
737 #ifdef PLATFORM_WINDOWS
738 version_check.wait (); // 40ms timeout
740 version_check.wait (WNOHANG);
744 while (xjadeo_version.empty() && --timeout) {
749 size_t vo = xjadeo_version.find(" version ");
750 if (vo != string::npos) {
751 int v_major, v_minor, v_micro;
752 if(sscanf(xjadeo_version.substr(vo + 9, string::npos).c_str(),"%d.%d.%d",
753 &v_major, &v_minor, &v_micro) == 3)
755 if (v_major >= 1) v_ok = true;
756 else if (v_major == 0 && v_minor >= 8) v_ok = true;
757 else if (v_major == 0 && v_minor >= 7 && v_micro >= 7) v_ok = true;
761 _xjadeo_bin = X_("");
763 "Video-monitor 'xjadeo' is too old. "
764 "Please install xjadeo version 0.7.7 or later. http://xjadeo.sf.net/"
771 VideoTimeLine::harvid_readversion (std::string d, size_t /* s */) {
776 VideoTimeLine::find_harvid () {
777 /* This is mainly for the benefit of the windows version:
778 * harvid >= 0.8.2 allows an empty docroot and ardour can
779 * pass the drive-letter along.
781 * It is a chicken/egg w.r.t. the video-server dialog
782 * but needed for default preferences and initial settings.
784 std::string harvid_bin;
785 if (VideoUtils::harvid_version != 0x0) {
788 if (!ArdourVideoToolPaths::harvid_exe(harvid_bin)) {
791 if (harvid_bin.empty ()) {
794 ARDOUR::SystemExec version_check(harvid_bin, X_("--version"));
796 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, _1 ,_2));
797 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, "\n" ,1));
798 if (version_check.start(2)) {
802 #ifdef PLATFORM_WINDOWS
803 version_check.wait (); // 40ms timeout
805 version_check.wait (WNOHANG);
809 while (harvid_version.empty() && --timeout) {
813 size_t vo = harvid_version.find("harvid v");
814 if (vo != string::npos) {
815 int v_major, v_minor, v_micro;
816 if(sscanf(harvid_version.substr(vo + 8, string::npos).c_str(),"%d.%d.%d",
817 &v_major, &v_minor, &v_micro) == 3)
819 VideoUtils::harvid_version = (v_major << 16) | (v_minor << 8) | v_micro;
820 info << "harvid version: "<< hex << VideoUtils::harvid_version << endmsg;
826 VideoTimeLine::open_video_monitor() {
827 if (!found_xjadeo()) return;
829 vmonitor = new VideoMonitor(editor, _xjadeo_bin);
830 vmonitor->set_session(_session);
831 vmonitor->set_offset(video_offset);
832 vmonitor->Terminated.connect (sigc::mem_fun (*this, &VideoTimeLine::terminated_video_monitor));
833 vmonitor->UiState.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
834 } else if (vmonitor->is_started()) {
840 * the idea is to selective ignore certain monitor window
841 * states if xjadeo is not running on the same host as ardour.
842 * However with the removal of the video-monitor-startup-dialogue
843 * (git rev 5a4d0fff0) these settings are currently not accessible.
845 int xj_settings_mask = vmonitor->restore_settings_mask();
847 /* load mask from Session */
848 XMLNode* node = _session->extra_xml (X_("XJRestoreSettings"));
850 XMLProperty const * prop = node->property (X_("mask"));
852 xj_settings_mask = atoi(prop->value());
857 vmonitor->restore_settings_mask(xj_settings_mask);
860 if (!vmonitor->start()) {
861 warning << "launching xjadeo failed.." << endmsg;
862 close_video_monitor();
864 GuiUpdate("set-xjadeo-active-on");
865 vmonitor->set_fps(video_file_fps);
866 vmonitor->open(video_filename);
869 XMLNode* node = _session->extra_xml (X_("Videomonitor"));
872 if (node->get_property (X_("active"), active) && !active) {
873 _session->set_dirty ();
876 _session->set_dirty ();
884 VideoTimeLine::close_video_monitor() {
885 if (vmonitor && vmonitor->is_started()) {
891 VideoTimeLine::control_video_monitor(int what, int param) {
892 if (!vmonitor || !vmonitor->is_started()) {
895 vmonitor->send_cmd(what, param);
900 VideoTimeLine::terminated_video_monitor () {
902 vmonitor->save_session();
906 GuiUpdate("set-xjadeo-active-off");
907 if (reopen_vmonitor) {
908 reopen_vmonitor=false;
909 open_video_monitor();
912 _session->set_dirty ();
918 VideoTimeLine::manual_seek_video_monitor (framepos_t pos)
920 if (!vmonitor) { return; }
921 if (!vmonitor->is_started()) { return; }
922 if (!vmonitor->synced_by_manual_seeks()) { return; }
923 vmonitor->manual_seek(pos, false, video_offset); // XXX -> set offset in xjadeo