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.
20 #ifndef __ardour_video_timeline_h__
21 #define __ardour_video_timeline_h__
25 #include <sigc++/signal.h>
26 #include "ardour/ardour.h"
27 #include "ardour/session.h"
28 #include "ardour/session_handle.h"
29 #include "video_image_frame.h"
30 #include "video_monitor.h"
31 #include "pbd/signals.h"
32 #include "canvas/container.h"
40 /** @class VideoTimeLine
41 * @brief video-timline controller and display
43 * The video-timeline can be displayed in a canvas-group. Given a filename
44 * it queries the video-server about file-information and
45 * creates \ref VideoImageFrame as neccesary (which
46 * query the server for image-data).
48 * This class contains the algorithm to position the single frames
49 * on the timeline according to current-zoom level and video-file
50 * attributes. see \ref update_video_timeline()
52 * The VideoTimeLine class includes functionality to launch a video-monitor
53 * corresponding to its currently diplayed file.
55 class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList, public PBD::StatefulDestructible
58 VideoTimeLine (PublicEditor*, ArdourCanvas::Container*, int);
59 virtual ~VideoTimeLine ();
61 void set_session (ARDOUR::Session *s);
62 void update_video_timeline ();
63 void set_height (int);
65 void save_undo (void);
66 XMLNode& get_state ();
67 int set_state (const XMLNode&, int version);
69 bool video_file_info (std::string, bool);
70 double get_video_file_fps () { return video_file_fps; }
71 void set_update_session_fps (bool v=true) { auto_set_session_fps = v; }
73 void set_offset_locked (bool v);
74 void toggle_offset_locked ();
75 bool is_offset_locked () { return video_offset_lock; }
77 ARDOUR::sampleoffset_t get_video_start_offset() { return video_start_offset; }
79 void open_video_monitor ();
80 void close_video_monitor ();
81 void control_video_monitor (int, int);
82 void terminated_video_monitor ();
83 void manual_seek_video_monitor (samplepos_t pos);
85 void parameter_changed (std::string const & p);
86 void set_video_server_url (std::string);
87 void set_video_server_docroot (std::string);
89 bool found_xjadeo () { return ((_xjadeo_bin.empty())?false:true); }
91 bool check_server_docroot ();
92 void flush_local_cache ();
96 void close_session ();
97 void sync_session_state (); /* video-monitor does not actively report window/pos changes, query it */
98 float get_apv(); /* audio samples per video frame; */
99 ARDOUR::samplecnt_t get_duration () { return video_duration;}
100 ARDOUR::sampleoffset_t get_offset () { return video_offset;}
101 ARDOUR::sampleoffset_t quantify_samples_to_apv (ARDOUR::sampleoffset_t offset) { return rint(offset/get_apv())*get_apv(); }
102 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
106 PublicEditor *editor;
107 ArdourCanvas::Container *videotl_group;
110 std::string _xjadeo_bin;
115 ARDOUR::sampleoffset_t video_start_offset; /**< unit: audio-samples - video-file */
116 ARDOUR::sampleoffset_t video_offset; /**< unit: audio-samples - session */
117 ARDOUR::sampleoffset_t video_offset_p; /**< used for undo from editor_drag.cc */
118 samplepos_t video_duration; /**< unit: audio-samples */
119 std::string video_filename;
121 double video_aspect_ratio;
122 double video_file_fps;
123 bool auto_set_session_fps;
124 bool video_offset_lock;
126 std::string video_server_url;
127 std::string server_docroot;
129 void xjadeo_readversion (std::string d, size_t s);
130 void harvid_readversion (std::string d, size_t s);
131 std::string xjadeo_version;
132 std::string harvid_version;
134 typedef std::list<VideoImageFrame*> VideoFrames;
135 VideoFrames video_frames;
136 VideoImageFrame* get_video_frame (samplepos_t vfn, int cut=0, int rightend = -1);
138 void remove_frames ();
141 std::string translated_filename ();
143 VideoMonitor *vmonitor;
144 bool reopen_vmonitor;
146 PBD::Signal0<void> VtlUpdate;
147 PBD::Signal1<void,std::string> GuiUpdate;
148 void gui_update (const std::string &);
150 PBD::ScopedConnection sessionsave;
153 #endif /* __ardour_video_timeline_h__ */