2 * Copyright (C) 2013-2016 Tim Mayberry <mojofunk@gmail.com>
3 * Copyright (C) 2013-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
5 * Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <sigc++/bind.h>
23 #include "ardour/tempo.h"
25 #include "pbd/file_utils.h"
26 #include "pbd/types_convert.h"
27 #include "ardour/filesystem_paths.h"
28 #include "ardour/session_directory.h"
30 #include "ardour_ui.h"
31 #include "ardour_http.h"
32 #include "public_editor.h"
33 #include "gui_thread.h"
34 #include "utils_videotl.h"
35 #include "rgb_macros.h"
36 #include "video_timeline.h"
38 #include <gtkmm2ext/utils.h>
40 #include <curl/curl.h>
45 using namespace ARDOUR;
47 using namespace Timecode;
48 using namespace VideoUtils;
50 VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Container *vbg, int initial_height)
53 , bar_height(initial_height)
55 video_start_offset = 0L;
59 auto_set_session_fps = false;
60 video_offset_lock = false;
61 video_aspect_ratio = 4.0/3.0;
62 Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
65 video_file_fps = 25.0;
66 _flush_frames = false;
68 reopen_vmonitor=false;
71 video_server_url = video_get_server_url(Config);
72 server_docroot = video_get_docroot(Config);
74 VtlUpdate.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
75 GuiUpdate.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
78 VideoTimeLine::~VideoTimeLine ()
83 /* close and save settings */
85 VideoTimeLine::save_session ()
91 XMLNode* node = new XMLNode(X_("Videomonitor"));
93 node->set_property (X_("active"), (vmonitor && vmonitor->is_started()));
94 _session->add_extra_xml (*node);
97 if (vmonitor->is_started()) {
98 vmonitor->query_full_state(true);
100 vmonitor->save_session();
104 node = _session->extra_xml (X_("Videotimeline"));
106 node->set_property (X_("id"), id());
107 node->set_property (X_("Height"), editor->get_videotl_bar_height());
108 node->set_property (X_("VideoOffsetLock"), video_offset_lock);
109 node->set_property (X_("VideoOffset"), video_offset);
110 node->set_property (X_("AutoFPS"), auto_set_session_fps);
113 /* close and save settings */
115 VideoTimeLine::close_session ()
117 if (video_duration == 0) {
120 sessionsave.disconnect();
121 close_video_monitor();
126 GuiUpdate("set-xjadeo-sensitive-off");
127 GuiUpdate("video-unavailable");
131 VideoTimeLine::sync_session_state ()
133 if (!_session || !vmonitor || !vmonitor->is_started()) {
139 /** load settings from session */
141 VideoTimeLine::set_session (ARDOUR::Session *s)
143 SessionHandlePtr::set_session (s);
144 if (!_session) { return ; }
146 _session->SessionSaveUnderway.connect_same_thread (sessionsave, boost::bind (&VideoTimeLine::save_session, this));
148 XMLNode* node = _session->extra_xml (X_("Videotimeline"));
150 if (!node || !node->property (X_("Filename"))) {
154 ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false);
159 if (node->get_property (X_("Height"), height)) {
160 editor->set_video_timeline_height(height);
162 #if 0 /* TODO THINK: set FPS first time only ?! */
163 XMLProperty const * propasfps = node->property (X_("AutoFPS"));
165 auto_set_session_fps = atoi(propasfps->value())?true:false;
169 if (node->get_property (X_("VideoOffset"), video_offset)) {
170 video_offset_p = video_offset;
173 node->get_property (X_("VideoOffsetLock"), video_offset_lock);
174 node->get_property (X_("LocalFile"), local_file);
176 std::string filename;
177 if (node->get_property (X_("Filename"), filename)) {
178 video_file_info (filename, local_file);
181 if ((node = _session->extra_xml (X_("Videomonitor")))) {
183 if (node->get_property (X_("active"), active) && active && found_xjadeo () &&
184 !video_filename.empty () && local_file) {
185 open_video_monitor();
189 _session->register_with_memento_command_factory(id(), this);
190 _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
194 VideoTimeLine::set_offset_locked (bool v) {
195 if (_session && v != video_offset_lock) {
196 _session->set_dirty ();
198 video_offset_lock = v;
202 VideoTimeLine::toggle_offset_locked () {
203 video_offset_lock = !video_offset_lock;
205 _session->set_dirty ();
210 VideoTimeLine::save_undo ()
212 if (_session && video_offset_p != video_offset) {
213 _session->set_dirty ();
215 video_offset_p = video_offset;
219 VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
221 node.get_property (X_("VideoOffset"), video_offset);
222 ARDOUR_UI::instance()->flush_videotimeline_cache(true);
227 VideoTimeLine::get_state ()
229 XMLNode* node = new XMLNode (X_("Videotimeline"));
230 node->set_property (X_("VideoOffset"), video_offset_p);
235 VideoTimeLine::remove_frames ()
237 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) {
238 VideoImageFrame* frame = (*i);
242 video_frames.clear();
246 VideoTimeLine::get_video_frame (samplepos_t vfn, int cut, int rightend)
249 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) {
250 VideoImageFrame* frame = (*i);
251 if (abs(frame->get_video_frame_number()-vfn)<=cut
252 && frame->get_rightend() == rightend) { return frame; }
258 VideoTimeLine::get_apv()
260 // XXX: dup code - TODO use this fn in update_video_timeline()
261 float apv = -1; /* audio samples per video frame; */
262 if (!_session) return apv;
264 if (_session->config.get_use_video_file_fps()) {
265 if (video_file_fps == 0 ) return apv;
267 if (_session->timecode_frames_per_second() == 0 ) return apv;
270 if (_session->config.get_videotimeline_pullup()) {
271 apv = _session->sample_rate();
273 apv = _session->nominal_sample_rate();
275 if (_session->config.get_use_video_file_fps()) {
276 apv /= video_file_fps;
278 apv /= _session->timecode_frames_per_second();
284 VideoTimeLine::update_video_timeline()
286 if (!_session) return;
288 if (_session->config.get_use_video_file_fps()) {
289 if (video_file_fps == 0 ) return;
291 if (_session->timecode_frames_per_second() == 0 ) return;
294 const double samples_per_pixel = editor->get_current_zoom();
295 const samplepos_t leftmost_sample = editor->leftmost_sample();
298 * 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
299 * 2) calculate first frame and distance between video-frames (according to zoom)
300 * 3) destroy/add frames
301 * 4) reposition existing frames
302 * 5) assign framenumber to frames -> request/decode video.
305 /* video-file and session properties */
306 double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
307 float apv; /* audio samples per video frame; */
308 samplepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
310 /* variables needed to render videotimeline -- what needs to computed first */
311 samplepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */
312 samplepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */
313 unsigned int visible_video_frames; /* number of frames that fit on current canvas */
315 if (_session->config.get_videotimeline_pullup()) {
316 apv = _session->sample_rate();
318 apv = _session->nominal_sample_rate();
320 if (_session->config.get_use_video_file_fps()) {
321 apv /= video_file_fps;
323 apv /= _session->timecode_frames_per_second();
326 display_vframe_width = bar_height * video_aspect_ratio;
328 if (apv > samples_per_pixel * display_vframe_width) {
329 /* high-zoom: need space between successive video-frames */
330 vtl_dist = rint(apv);
332 /* continous timeline: skip video-frames */
333 vtl_dist = ceil(display_vframe_width * samples_per_pixel / apv) * apv;
336 assert (vtl_dist > 0);
339 leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv);
341 vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv);
342 visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */
344 /* expand timeline (cache next/prev page images) */
345 vtl_start -= visible_video_frames * vtl_dist;
346 visible_video_frames *=3;
348 /* don't request frames that are too far to the right */
349 if (vtl_start < video_offset) {
350 visible_video_frames = std::max((double)0.0, (double)visible_video_frames + ceil((double)(vtl_start - video_offset)/vtl_dist));
351 vtl_start = video_offset;
354 /* apply video-file constraints
355 * (first frame in video is at video_start_offset) */
356 if (vtl_start > video_start_offset + video_duration + video_offset ) {
357 visible_video_frames = 0;
360 * end = position on timeline (video-offset) minus video-file's first frame position
361 * TODO optimize: compute rather than iterate */
362 while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + video_offset) {
363 --visible_video_frames;
368 _flush_frames = false;
371 while (video_frames.size() < visible_video_frames) {
372 VideoImageFrame *frame;
373 frame = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename());
374 frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
375 video_frames.push_back(frame);
378 VideoFrames outdated_video_frames;
379 std::list<int> remaining;
381 outdated_video_frames = video_frames;
384 /* when zoomed out, ignore shifts by +-1 sample
385 * which can occur due to rounding errors when
386 * scrolling to a new leftmost-audio sample.
389 if (vtl_dist/apv < 3.0) cut =0;
394 for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
395 samplepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-samples */
396 samplepos_t vframeno = rint ( (vfpos - video_offset) / apv); /* unit: video-frames */
397 vfpos = (vframeno * apv ) + video_offset; /* audio-sample corresponding to /rounded/ video-frame */
399 int rightend = -1; /* unit: pixels */
400 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
401 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
402 //printf("lf(e): %lu\n", vframeno); // XXX
404 VideoImageFrame* frame = get_video_frame(vframeno, cut, rightend);
406 frame->set_position(vfpos);
407 outdated_video_frames.remove (frame);
409 remaining.push_back(vfcount);
413 for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
414 VideoImageFrame* frame = (*i);
415 if (remaining.empty()) {
416 frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */
418 int vfcount = remaining.front();
419 remaining.pop_front();
420 samplepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-samples */
421 samplepos_t vframeno = rint ((vfpos - video_offset) / apv); /* unit: video-frames */
422 int rightend = -1; /* unit: pixels */
423 if (vfpos + vtl_dist > video_start_offset + video_duration + video_offset) {
424 rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist;
425 //printf("lf(n): %lu\n", vframeno); // XXX
427 frame->set_position(vfpos);
428 frame->set_videoframe(vframeno, rightend);
434 VideoTimeLine::translated_filename ()
437 return video_filename;
439 return video_map_path(server_docroot, video_filename);
444 VideoTimeLine::video_file_info (std::string filename, bool local)
448 if (Glib::path_is_absolute(filename) || !local_file)
450 video_filename = filename;
452 video_filename = Glib::build_filename (_session->session_directory().video_path(), filename);
455 long long int _duration;
456 double _start_offset;
458 if (!video_query_info(
459 video_server_url, translated_filename(),
460 video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
461 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;
463 GuiUpdate("set-xjadeo-sensitive-off");
464 GuiUpdate("video-unavailable");
467 video_duration = _duration * _session->nominal_sample_rate() / video_file_fps;
468 video_start_offset = _start_offset * _session->nominal_sample_rate();
470 if (auto_set_session_fps && video_file_fps != _session->timecode_frames_per_second()) {
471 switch ((int)floorf(video_file_fps*1000.0)) {
473 _session->config.set_timecode_format(timecode_23976);
476 _session->config.set_timecode_format(timecode_24);
480 _session->config.set_timecode_format(timecode_24976);
483 _session->config.set_timecode_format(timecode_25);
486 _session->config.set_timecode_format(timecode_2997drop);
489 _session->config.set_timecode_format(timecode_30);
492 _session->config.set_timecode_format(timecode_5994);
495 _session->config.set_timecode_format(timecode_60);
498 warning << string_compose (
499 _("Failed to set session-framerate: '%1' does not have a corresponding option setting in %2."),
500 video_file_fps, PROGRAM_NAME ) << endmsg;
503 _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
505 if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) {
506 warning << string_compose(
507 _("Video file's framerate is not equal to %1 session timecode's framerate: '%2' vs '%3'"),
508 PROGRAM_NAME, video_file_fps, _session->timecode_frames_per_second())
511 flush_local_cache ();
513 if (found_xjadeo() && local_file) {
514 GuiUpdate("set-xjadeo-sensitive-on");
515 if (vmonitor && vmonitor->is_started()) {
517 /* xjadeo <= 0.6.4 has a bug where changing the video-file may segfauls
518 * if the geometry changes to a different line-size alignment
520 reopen_vmonitor = true;
523 vmonitor->set_fps(video_file_fps);
524 vmonitor->open(video_filename);
527 } else if (!local_file) {
528 #if 1 /* temp debug/devel message */
529 // TODO - call xjremote remotely.
530 printf("the given video file can not be accessed on localhost, video monitoring is not currently supported for this case\n");
531 GuiUpdate("set-xjadeo-sensitive-off");
535 GuiUpdate("video-available");
540 VideoTimeLine::check_server ()
544 snprintf(url, sizeof(url), "%s%sstatus"
545 , video_server_url.c_str()
546 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
548 char* res = ArdourCurl::http_get (url, NULL, false);
550 if (strstr(res, "status: ok, online.")) { ok = true; }
557 VideoTimeLine::check_server_docroot ()
561 std::vector<std::vector<std::string> > lines;
563 if (video_server_url.find("/localhost:") == string::npos) {
566 snprintf(url, sizeof(url), "%s%src?format=csv"
567 , video_server_url.c_str()
568 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
570 char* res = ArdourCurl::http_get (url, NULL, false);
575 ParseCSV(std::string(res), lines);
577 || lines.at(0).empty()
578 || lines.at(0).at(0) != video_get_docroot(Config)) {
579 warning << string_compose(
580 _("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."),
581 PROGRAM_NAME, video_get_docroot(Config), lines.at(0).at(0))
583 ok = false; // TODO allow to override
590 VideoTimeLine::gui_update(std::string const & t) {
591 /* this is to be called via GuiUpdate() only. */
592 ENSURE_GUI_THREAD (*this, &VideoTimeLine::queue_visual_videotimeline_update)
593 if (t == "videotimeline-update") {
594 editor->queue_visual_videotimeline_update();
595 } else if (t == "set-xjadeo-active-off") {
596 editor->toggle_xjadeo_proc(0);
597 } else if (t == "set-xjadeo-active-on") {
598 editor->toggle_xjadeo_proc(1);
599 } else if (t == "set-xjadeo-sensitive-on") {
600 editor->set_xjadeo_sensitive(true);
601 } else if (t == "set-xjadeo-sensitive-off") {
602 editor->toggle_xjadeo_proc(0);
603 //close_video_monitor();
604 editor->set_xjadeo_sensitive(false);
605 } else if (t == "xjadeo-window-ontop-on") {
606 editor->toggle_xjadeo_viewoption(1, 1);
607 } else if (t == "xjadeo-window-ontop-off") {
608 editor->toggle_xjadeo_viewoption(1, 0);
609 } else if (t == "xjadeo-window-osd-timecode-on") {
610 editor->toggle_xjadeo_viewoption(2, 1);
611 } else if (t == "xjadeo-window-osd-timecode-off") {
612 editor->toggle_xjadeo_viewoption(2, 0);
613 } else if (t == "xjadeo-window-osd-frame-on") {
614 editor->toggle_xjadeo_viewoption(3, 1);
615 } else if (t == "xjadeo-window-osd-frame-off") {
616 editor->toggle_xjadeo_viewoption(3, 0);
617 } else if (t == "xjadeo-window-osd-box-on") {
618 editor->toggle_xjadeo_viewoption(4, 1);
619 } else if (t == "xjadeo-window-osd-box-off") {
620 editor->toggle_xjadeo_viewoption(4, 0);
621 } else if (t == "xjadeo-window-fullscreen-on") {
622 editor->toggle_xjadeo_viewoption(5, 1);
623 } else if (t == "xjadeo-window-fullscreen-off") {
624 editor->toggle_xjadeo_viewoption(5, 0);
625 } else if (t == "xjadeo-window-letterbox-on") {
626 editor->toggle_xjadeo_viewoption(6, 1);
627 } else if (t == "xjadeo-window-letterbox-off") {
628 editor->toggle_xjadeo_viewoption(6, 0);
629 } else if (t == "video-available") {
630 editor->set_close_video_sensitive(true);
631 } else if (t == "video-unavailable") {
632 editor->set_close_video_sensitive(false);
637 VideoTimeLine::set_height (int height) {
638 if (_session && bar_height != height) {
639 _session->set_dirty ();
646 VideoTimeLine::vmon_update () {
647 if (vmonitor && vmonitor->is_started()) {
648 vmonitor->set_offset(video_offset); // TODO proper re-init xjadeo w/o restart not just offset.
653 VideoTimeLine::flush_local_cache () {
654 _flush_frames = true;
659 VideoTimeLine::flush_cache () {
662 snprintf(url, sizeof(url), "%s%sadmin/flush_cache"
663 , video_server_url.c_str()
664 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
666 char* res = ArdourCurl::http_get (url, NULL, false);
670 if (vmonitor && vmonitor->is_started()) {
671 reopen_vmonitor=true;
674 video_file_info(video_filename, local_file);
679 VideoTimeLine::parameter_changed (std::string const & p)
681 if (p == "video-server-url") {
682 set_video_server_url (video_get_server_url(Config));
683 } else if (p == "video-server-docroot") {
684 set_video_server_docroot (video_get_docroot(Config));
685 } else if (p == "video-advanced-setup") {
686 set_video_server_url (video_get_server_url(Config));
687 set_video_server_docroot (video_get_docroot(Config));
689 if (p == "use-video-file-fps" || p == "videotimeline-pullup" ) { /* session->config parameter */
695 VideoTimeLine::set_video_server_url(std::string vsu) {
696 flush_local_cache ();
697 video_server_url = vsu;
702 VideoTimeLine::set_video_server_docroot(std::string vsr) {
703 flush_local_cache ();
704 server_docroot = vsr;
708 /* video-monitor for this timeline */
710 VideoTimeLine::xjadeo_readversion (std::string d, size_t /* s */) {
715 VideoTimeLine::find_xjadeo () {
716 if (!ArdourVideoToolPaths::xjadeo_exe(_xjadeo_bin)) {
717 warning << _("Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ "
718 "(a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. "
719 "It should point to an application compatible with xjadeo's remote-control interface 'xjremote').\n"
721 "see also http://manual.ardour.org/video-timeline/setup/")
725 if (found_xjadeo ()) {
726 ARDOUR::SystemExec version_check(_xjadeo_bin, X_("--version"));
728 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, _1 ,_2));
729 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::xjadeo_readversion, this, "\n" ,1));
730 if (version_check.start (ARDOUR::SystemExec::MergeWithStdin)) {
732 "Video-monitor 'xjadeo' cannot be launched."
734 _xjadeo_bin = X_("");
738 #ifdef PLATFORM_WINDOWS
739 version_check.wait (); // 40ms timeout
741 version_check.wait (WNOHANG);
745 while (xjadeo_version.empty() && --timeout) {
750 size_t vo = xjadeo_version.find(" version ");
751 if (vo != string::npos) {
752 int v_major, v_minor, v_micro;
753 if(sscanf(xjadeo_version.substr(vo + 9, string::npos).c_str(),"%d.%d.%d",
754 &v_major, &v_minor, &v_micro) == 3)
756 if (v_major >= 1) v_ok = true;
757 else if (v_major == 0 && v_minor >= 8) v_ok = true;
758 else if (v_major == 0 && v_minor >= 7 && v_micro >= 7) v_ok = true;
762 _xjadeo_bin = X_("");
764 "Video-monitor 'xjadeo' is too old. "
765 "Please install xjadeo version 0.7.7 or later. http://xjadeo.sf.net/"
772 VideoTimeLine::harvid_readversion (std::string d, size_t /* s */) {
777 VideoTimeLine::find_harvid () {
778 /* This is mainly for the benefit of the windows version:
779 * harvid >= 0.8.2 allows an empty docroot and ardour can
780 * pass the drive-letter along.
782 * It is a chicken/egg w.r.t. the video-server dialog
783 * but needed for default preferences and initial settings.
785 std::string harvid_bin;
786 if (VideoUtils::harvid_version != 0x0) {
789 if (!ArdourVideoToolPaths::harvid_exe(harvid_bin)) {
792 if (harvid_bin.empty ()) {
795 ARDOUR::SystemExec version_check(harvid_bin, X_("--version"));
797 version_check.ReadStdout.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, _1 ,_2));
798 version_check.Terminated.connect_same_thread (*this, boost::bind (&VideoTimeLine::harvid_readversion, this, "\n" ,1));
799 if (version_check.start (ARDOUR::SystemExec::MergeWithStdin)) {
803 #ifdef PLATFORM_WINDOWS
804 version_check.wait (); // 40ms timeout
806 version_check.wait (WNOHANG);
810 while (harvid_version.empty() && --timeout) {
814 size_t vo = harvid_version.find("harvid v");
815 if (vo != string::npos) {
816 int v_major, v_minor, v_micro;
817 if(sscanf(harvid_version.substr(vo + 8, string::npos).c_str(),"%d.%d.%d",
818 &v_major, &v_minor, &v_micro) == 3)
820 VideoUtils::harvid_version = (v_major << 16) | (v_minor << 8) | v_micro;
821 info << "harvid version: "<< hex << VideoUtils::harvid_version << endmsg;
827 VideoTimeLine::open_video_monitor() {
828 if (!found_xjadeo()) return;
830 vmonitor = new VideoMonitor(editor, _xjadeo_bin);
831 vmonitor->set_session(_session);
832 vmonitor->set_offset(video_offset);
833 vmonitor->Terminated.connect (sigc::mem_fun (*this, &VideoTimeLine::terminated_video_monitor));
834 vmonitor->UiState.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
835 } else if (vmonitor->is_started()) {
841 * the idea is to selective ignore certain monitor window
842 * states if xjadeo is not running on the same host as ardour.
843 * However with the removal of the video-monitor-startup-dialogue
844 * (git rev 5a4d0fff0) these settings are currently not accessible.
846 int xj_settings_mask = vmonitor->restore_settings_mask();
848 /* load mask from Session */
849 XMLNode* node = _session->extra_xml (X_("XJRestoreSettings"));
851 XMLProperty const * prop = node->property (X_("mask"));
853 xj_settings_mask = atoi(prop->value());
858 vmonitor->restore_settings_mask(xj_settings_mask);
861 if (!vmonitor->start()) {
862 warning << "launching xjadeo failed.." << endmsg;
863 close_video_monitor();
865 GuiUpdate("set-xjadeo-active-on");
866 vmonitor->set_fps(video_file_fps);
867 vmonitor->open(video_filename);
870 XMLNode* node = _session->extra_xml (X_("Videomonitor"));
873 if (node->get_property (X_("active"), active) && !active) {
874 _session->set_dirty ();
877 _session->set_dirty ();
885 VideoTimeLine::close_video_monitor() {
886 if (vmonitor && vmonitor->is_started()) {
892 VideoTimeLine::control_video_monitor(int what, int param) {
893 if (!vmonitor || !vmonitor->is_started()) {
896 vmonitor->send_cmd(what, param);
901 VideoTimeLine::terminated_video_monitor () {
903 vmonitor->save_session();
907 GuiUpdate("set-xjadeo-active-off");
908 if (reopen_vmonitor) {
909 reopen_vmonitor=false;
910 open_video_monitor();
913 _session->set_dirty ();
919 VideoTimeLine::manual_seek_video_monitor (samplepos_t pos)
921 if (!vmonitor) { return; }
922 if (!vmonitor->is_started()) { return; }
923 if (!vmonitor->synced_by_manual_seeks()) { return; }
924 vmonitor->manual_seek(pos, false, video_offset); // XXX -> set offset in xjadeo