1 /* 2 * Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com> 3 * Copyright (C) 2013-2018 Robin Gareus <robin@gareus.org> 4 * 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. 9 * 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. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 #ifndef __ardour_video_timeline_h__ 20 #define __ardour_video_timeline_h__ 21 22 #include <string> 23 24 #include <sigc++/signal.h> 25 #include "ardour/ardour.h" 26 #include "ardour/session.h" 27 #include "ardour/session_handle.h" 28 #include "video_image_frame.h" 29 #include "video_monitor.h" 30 #include "pbd/signals.h" 31 #include "canvas/container.h" 32 33 namespace ARDOUR { 34 class Session; 35 } 36 37 class PublicEditor; 38 39 /** @class VideoTimeLine 40 * @brief video-timline controller and display 41 * 42 * The video-timeline can be displayed in a canvas-group. Given a filename 43 * it queries the video-server about file-information and 44 * creates \ref VideoImageFrame as neccesary (which 45 * query the server for image-data). 46 * 47 * This class contains the algorithm to position the single frames 48 * on the timeline according to current-zoom level and video-file 49 * attributes. see \ref update_video_timeline() 50 * 51 * The VideoTimeLine class includes functionality to launch a video-monitor 52 * corresponding to its currently diplayed file. 53 */ 54 class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList, public PBD::StatefulDestructible 55 { 56 public: 57 VideoTimeLine (PublicEditor*, ArdourCanvas::Container*, int); 58 virtual ~VideoTimeLine (); 59 60 void set_session (ARDOUR::Session *s); 61 void update_video_timeline (); 62 void set_height (int); 63 64 void save_undo (void); 65 XMLNode& get_state (); 66 int set_state (const XMLNode&, int version); 67 68 bool video_file_info (std::string, bool); get_video_file_fps()69 double get_video_file_fps () { return video_file_fps; } 70 void set_update_session_fps (bool v=true) { auto_set_session_fps = v; } 71 72 void set_offset_locked (bool v); 73 void toggle_offset_locked (); is_offset_locked()74 bool is_offset_locked () { return video_offset_lock; } 75 get_video_start_offset()76 ARDOUR::sampleoffset_t get_video_start_offset() { return video_start_offset; } 77 78 void open_video_monitor (); 79 void close_video_monitor (); 80 void control_video_monitor (int, int); 81 void terminated_video_monitor (); 82 void manual_seek_video_monitor (samplepos_t pos); 83 84 void parameter_changed (std::string const & p); 85 void set_video_server_url (std::string); 86 void set_video_server_docroot (std::string); 87 found_xjadeo()88 bool found_xjadeo () { return ((_xjadeo_bin.empty())?false:true); } 89 bool check_server (); 90 bool check_server_docroot (); 91 void flush_local_cache (); 92 void vmon_update (); 93 void flush_cache (); 94 void save_session (); 95 void close_session (); 96 void sync_session_state (); /* video-monitor does not actively report window/pos changes, query it */ 97 float get_apv(); /* audio samples per video frame; */ get_duration()98 ARDOUR::samplecnt_t get_duration () { return video_duration;} get_offset()99 ARDOUR::sampleoffset_t get_offset () { return video_offset;} quantify_samples_to_apv(ARDOUR::sampleoffset_t offset)100 ARDOUR::sampleoffset_t quantify_samples_to_apv (ARDOUR::sampleoffset_t offset) { return rint(offset/get_apv())*get_apv(); } set_offset(ARDOUR::sampleoffset_t offset)101 void set_offset (ARDOUR::sampleoffset_t offset) { video_offset = quantify_samples_to_apv(offset); } // this function does not update video_offset_p, call save_undo() to finalize changes to this! - this fn is currently only used from editor_drag.cc 102 103 protected: 104 105 PublicEditor *editor; 106 ArdourCanvas::Container *videotl_group; 107 int bar_height; 108 109 std::string _xjadeo_bin; 110 void find_xjadeo (); 111 void find_harvid (); 112 113 114 ARDOUR::sampleoffset_t video_start_offset; /**< unit: audio-samples - video-file */ 115 ARDOUR::sampleoffset_t video_offset; /**< unit: audio-samples - session */ 116 ARDOUR::sampleoffset_t video_offset_p; /**< used for undo from editor_drag.cc */ 117 samplepos_t video_duration; /**< unit: audio-samples */ 118 std::string video_filename; 119 bool local_file; 120 double video_aspect_ratio; 121 double video_file_fps; 122 bool auto_set_session_fps; 123 bool video_offset_lock; 124 125 std::string video_server_url; 126 std::string server_docroot; 127 128 void xjadeo_readversion (std::string d, size_t s); 129 void harvid_readversion (std::string d, size_t s); 130 std::string xjadeo_version; 131 std::string harvid_version; 132 133 typedef std::list<VideoImageFrame*> VideoFrames; 134 VideoFrames video_frames; 135 VideoImageFrame* get_video_frame (samplepos_t vfn, int cut=0, int rightend = -1); 136 137 void remove_frames (); 138 bool _flush_frames; 139 140 std::string translated_filename (); 141 142 VideoMonitor *vmonitor; 143 bool reopen_vmonitor; 144 145 PBD::Signal0<void> VtlUpdate; 146 PBD::Signal1<void,std::string> GuiUpdate; 147 void gui_update (const std::string &); 148 149 PBD::ScopedConnection sessionsave; 150 }; 151 152 #endif /* __ardour_video_timeline_h__ */ 153