23 #include <sigc++/bind.h>
24 #include <curl/curl.h>
46 #define PREVIEW_WIDTH (240)
47 #define PREVIEW_HEIGHT (180)
50 #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
55 , seek_slider (0,1000,1)
57 , pi_tcin (
"-",
Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER, false)
58 , pi_tcout (
"-",
Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER, false)
59 , pi_aspect (
"-",
Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER, false)
60 , pi_fps (
"-",
Gtk::ALIGN_LEFT,
Gtk::ALIGN_CENTER, false)
61 , chooser (FILE_CHOOSER_ACTION_OPEN)
62 , xjadeo_checkbox (
_(
"Open Video Monitor Window"))
63 , set_session_fps_checkbox (
_(
"Adjust Session Framerate to Match Video Framerate"))
65 , harvid_reset (
_(
"Reload docroot"))
66 , harvid_list (ListStore::create(harvid_list_columns))
67 , harvid_list_view (harvid_list)
68 , show_advanced(false)
69 , loaded_docroot(false)
72 set_name (
"AddVideoDialog");
74 set_skip_taskbar_hint (
true);
76 set_size_request (800, -1);
97 Gtk::ScrolledWindow *scroll = manage(
new ScrolledWindow);
99 scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
101 HBox* hbox = manage (
new HBox);
113 chooser.signal_selection_changed().connect (mem_fun (
chooser, &Widget::queue_draw));
115 chooser.set_current_folder (dstdir);
117 Gtk::FileFilter video_filter;
118 Gtk::FileFilter matchall_filter;
120 video_filter.set_name (
_(
"Video files"));
122 matchall_filter.add_pattern (
"*.*");
123 matchall_filter.set_name (
_(
"All files"));
125 chooser.add_filter (video_filter);
126 chooser.add_filter (matchall_filter);
127 chooser.set_select_multiple (
false);
133 VBox* options_box = manage (
new VBox);
135 l = manage (
new Label (
_(
"<b>Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER,
false));
136 l->set_use_markup ();
138 options_box->pack_start (*l,
false,
true, 4);
143 VBox* previewpane = manage (
new VBox);
144 Gtk::Table *table = manage(
new Table(5,2));
146 table->set_row_spacings(2);
147 table->set_col_spacings(4);
149 l = manage (
new Label (
_(
"<b>Video Information</b>"), Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER,
false));
150 l->set_use_markup ();
151 table->attach (*l, 0, 2, 0, 1, FILL, FILL);
152 l = manage (
new Label (
_(
"Start:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER,
false));
153 table->attach (*l, 0, 1, 1, 2, FILL, FILL);
154 table->attach (
pi_tcin, 1, 2, 1, 2, FILL, FILL);
155 l = manage (
new Label (
_(
"End:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER,
false));
156 table->attach (*l, 0, 1, 2, 3, FILL, FILL);
157 table->attach (
pi_tcout, 1, 2, 2, 3, FILL, FILL);
158 l = manage (
new Label (
_(
"Frame rate:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER,
false));
159 table->attach (*l, 0, 1, 3, 4, FILL, FILL);
160 table->attach (
pi_fps, 1, 2, 3, 4, FILL, FILL);
161 l = manage (
new Label (
_(
"Aspect Ratio:"), Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER,
false));
162 table->attach (*l, 0, 1, 4, 5, FILL, FILL);
163 table->attach (
pi_aspect, 1, 2, 4, 5, FILL, FILL);
172 hbox = manage (
new HBox);
173 hbox->pack_start (*table,
true,
false);
175 Gtk::Alignment *al = manage(
new Gtk::Alignment());
176 al->set_size_request(-1, 20);
179 previewpane->pack_start (
seek_slider,
false,
false);
180 previewpane->pack_start (*al,
false,
false);
181 previewpane->pack_start (*hbox,
true,
true, 6);
185 hbox = manage (
new HBox);
187 hbox->pack_start (*previewpane,
false,
false);
189 get_vbox()->set_spacing (4);
190 get_vbox()->pack_start (*hbox,
true,
true);
191 get_vbox()->pack_start (*options_box,
false,
false);
199 printf(
"xjadeo was not found or video-server docroot is unset (remote video-server)\n");
208 add_button (Stock::CANCEL, RESPONSE_CANCEL);
209 ok_button = add_button (Stock::OK, RESPONSE_ACCEPT);
230 for (
int i =
notebook.get_n_pages(); i > 0 ; --i) {
243 if (
Config->get_video_advanced_setup()) {
259 show_all_children ();
266 const char* suffixes[] = {
284 ".matroska",
".MATROSKA",
287 ".dirac" ,
".DIRAC" ,
293 for (
size_t n = 0; n <
sizeof(suffixes)/
sizeof(suffixes[0]); ++n) {
294 if (file.rfind (suffixes[n]) == file.length() - strlen (suffixes[n])) {
311 int n =
notebook.get_current_page ();
317 Gtk::TreeModel::iterator iter =
harvid_list_view.get_selection()->get_selected();
325 && !video_server_url.compare(0, 16,
"http://localhost"))
330 curl = curl_easy_init();
331 char *ue = curl_easy_unescape(curl, uri.c_str(), uri.length(), &plen);
332 #ifdef PLATFORM_WINDOWS
334 while (tmp = strchr(ue,
'/')) *tmp =
'\\';
337 if (!::access(path.c_str(), R_OK)) {
341 curl_easy_cleanup(curl);
351 int n =
notebook.get_current_page ();
396 if (
chooser.get_filename().size() > 0) {
397 std::string path =
chooser.get_filename();
400 && Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK)
401 && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR);
415 if (
chooser.get_filename().size() > 0) {
416 std::string path =
chooser.get_filename();
420 && Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_REGULAR | Glib::FILE_TEST_IS_SYMLINK)
421 && !Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR);
423 Gtk::Dialog::response(RESPONSE_ACCEPT);
432 Gtk::TreeModel::iterator iter =
harvid_list_view.get_selection()->get_selected();
449 Gtk::TreeModel::iterator iter =
harvid_list->get_iter(path);
455 printf (
"A: %s %s %s\n",
461 if (type == Gtk::Stock::DIRECTORY.
id) {
464 Gtk::Dialog::response(RESPONSE_ACCEPT);
475 snprintf(url,
sizeof(url),
"%s%sindex/"
476 , video_server_url.c_str()
477 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) ==
'/')?
"":
"/");
503 snprintf(url,
sizeof(url),
"%s?format=csv", u.c_str());
509 printf(
"request failed\n");
516 size_t se = u.find_last_of(
"/", u.size()-2);
517 size_t ss = u.find(
"/index/");
518 if (se != string::npos && ss != string::npos && se > ss) {
519 TreeModel::iterator new_row =
harvid_list->append();
520 TreeModel::Row row = *new_row;
525 if (se != string::npos) {
527 std::string path = u.substr(ss + 6);
529 curl = curl_easy_init();
530 char *ue = curl_easy_unescape(curl, path.c_str(), path.length(), &plen);
532 curl_easy_cleanup(curl);
540 std::vector<std::vector<std::string> > lines;
542 for (std::vector<std::vector<std::string> >::iterator i = lines.begin(); i != lines.end(); ++i) {
543 TreeModel::iterator new_row =
harvid_list->append();
544 TreeModel::Row row = *new_row;
546 if (i->at(0) ==
X_(
"D")) {
572 double video_file_fps;
573 long long int video_duration;
574 double video_start_offset;
575 double video_aspect_ratio;
579 int clip_xoff, clip_yoff;
582 video_file_fps, video_duration, video_start_offset, video_aspect_ratio))
584 printf(
"image preview info request failed\n");
599 clip_height =
MIN(PREVIEW_HEIGHT, rint(clip_width / video_aspect_ratio));
602 pi_tcin.set_text(Timecode::timecode_format_sampletime(
603 video_start_offset, video_file_fps, video_file_fps, rint(video_file_fps*100.0)==2997));
604 pi_tcout.set_text(Timecode::timecode_format_sampletime(
605 video_start_offset + video_duration, video_file_fps, video_file_fps, rint(video_file_fps*100.0)==2997));
608 const int arc = rint(video_aspect_ratio*100);
678 clip_yoff = (PREVIEW_HEIGHT - clip_height)/2;
681 snprintf(url,
sizeof(url),
"%s%s?frame=%lli&w=%d&h=%di&file=%s&format=rgb"
682 , video_server_url.c_str()
683 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) ==
'/')?
"":
"/"
684 , (
long long) (video_duration *
seek_slider.get_value() / 1000.0)
685 , clip_width, clip_height, u.c_str());
689 printf(
"image preview request failed %s\n", url);
694 Glib::RefPtr<Gdk::Pixbuf> tmp;
695 tmp = Gdk::Pixbuf::create_from_data ((guint8*) data, Gdk::COLORSPACE_RGB,
false, 8, clip_width, clip_height, clip_width*3);
696 if (clip_width !=
PREVIEW_WIDTH || clip_height != PREVIEW_HEIGHT) {
699 tmp->copy_area (0, 0, clip_width, clip_height,
imgbuf, clip_xoff, clip_yoff);
std::string video_get_docroot(ARDOUR::RCConfiguration *config)
void harvid_list_view_selected()
bool video_query_info(std::string video_server_url, std::string filepath, double &video_file_fps, long long int &video_duration, double &video_start_offset, double &video_aspect_ratio)
Gtk::TreeModelColumn< std::string > uri
void video_draw_cross(Glib::RefPtr< Gdk::Pixbuf > img)
char * a3_curl_http_get(const char *u, int *status)
const std::string video_path() const
static ARDOUR_UI * instance()
void ParseCSV(const std::string &csv, std::vector< std::vector< std::string > > &lines)
Gtk::TreeView harvid_list_view
VtlImportOption import_option()
std::string video_map_path(std::string server_docroot, std::string filepath)
void request_preview(std::string vpath)
AddVideoDialog(ARDOUR::Session *)
Glib::RefPtr< Gtk::ListStore > harvid_list
bool auto_set_session_fps()
Gtk::VBox server_index_box
LIBARDOUR_API RCConfiguration * Config
void harvid_request(std::string u)
Gtk::CheckButton set_session_fps_checkbox
Gtk::VBox file_chooser_box
HarvidColumns harvid_list_columns
static bool check_video_file_extension(std::string file)
Gtk::Image * preview_image
common functions used for video-file im/export
Gtk::CellRendererPixbuf pixBufRenderer
std::string video_dest_dir(const std::string, const std::string)
void set_action_ok(bool yn)
Gtk::FileChooserWidget chooser
std::string video_get_server_url(ARDOUR::RCConfiguration *config)
Gtk::TreeModelColumn< std::string > filename
void harvid_load_docroot()
void file_selection_changed()
Gtk::CheckButton xjadeo_checkbox
void clear_preview_image()
std::string file_name(bool &local_file)
virtual void set_session(ARDOUR::Session *)
#define RGBA_TO_UINT(r, g, b, a)
bool on_video_filter(const Gtk::FileFilter::Info &filter_info)
const SessionDirectory & session_directory() const
ARDOUR::Session * _session
void harvid_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
std::string string_compose(const std::string &fmt, const T1 &o1)
Gtk::TreeModelColumn< std::string > id
Glib::RefPtr< Gdk::Pixbuf > imgbuf
Gtk::HBox browser_container