1 /*
2  * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef __gtk_ardour_transcode_video_dialog_h__
19 #define __gtk_ardour_transcode_video_dialog_h__
20 
21 #include <string>
22 
23 #include <gtkmm/adjustment.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/button.h>
26 #include <gtkmm/checkbutton.h>
27 #include <gtkmm/comboboxtext.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/progressbar.h>
31 #include <gtkmm/spinbutton.h>
32 
33 #include "ardour/types.h"
34 #include "ardour/template_utils.h"
35 #include "ardour_dialog.h"
36 
37 #include "transcode_ffmpeg.h"
38 
39 enum VtlTranscodeOption {
40  VTL_IMPORT_REFERENCE = 0,
41  VTL_IMPORT_TRANSCODED = 1,
42  VTL_IMPORT_NO_VIDEO = 2
43 };
44 
45 /** @class TranscodeVideoDialog
46  *  @brief dialog-box and controller for importing video-files
47  */
48 class TranscodeVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
49 {
50 public:
51 	TranscodeVideoDialog (ARDOUR::Session*, std::string);
52 	~TranscodeVideoDialog ();
53 
get_filename()54 	std::string get_filename () { return path_entry.get_text(); }
get_audiofile()55 	std::string get_audiofile () { return audiofile; }
56 	VtlTranscodeOption import_option ();
detect_ltc()57 	bool detect_ltc () { return ltc_detect.get_active (); }
58 
on_response(int response_id)59 	void on_response (int response_id) {
60 		Gtk::Dialog::on_response (response_id);
61 	}
62 
63 private:
64 	void on_show ();
65 	void open_browse_dialog ();
66 	void abort_clicked ();
67 	void scale_combo_changed ();
68 	void audio_combo_changed ();
69 	void video_combo_changed ();
70 	void aspect_checkbox_toggled ();
71 	void bitrate_checkbox_toggled ();
72 	void update_bitrate ();
73 	void launch_audioonly ();
74 	void launch_transcode ();
75 	void launch_extract ();
76 	void dialog_progress_mode ();
77 	bool aborted;
78 	bool pending_audio_extract;
79 	std::string audiofile;
80 	std::string infn;
81 	double m_aspect;
82 
83 	PBD::Signal0<void> StartNextStage;
84 	void finished ();
85 	void update_progress (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
86 
87 	TranscodeFfmpeg *transcoder;
88 
89 	Gtk::Label        path_label;
90 	Gtk::Entry        path_entry;
91 	Gtk::Button       browse_button;
92 	Gtk::Button       transcode_button;
93 
94 	Gtk::VBox* vbox;
95 	Gtk::Button *cancel_button;
96 	Gtk::Button abort_button;
97 
98 	Gtk::VBox*  progress_box;
99 	Gtk::Label  progress_label;
100 	Gtk::ProgressBar pbar;
101 
102 	Gtk::ComboBoxText video_combo;
103 	Gtk::ComboBoxText scale_combo;
104 	Gtk::CheckButton  aspect_checkbox;
105 	Gtk::Adjustment   height_adjustment;
106 	Gtk::SpinButton   height_spinner;
107 	Gtk::ComboBoxText audio_combo;
108 	Gtk::CheckButton  ltc_detect;
109 	Gtk::CheckButton  bitrate_checkbox;
110 	Gtk::Adjustment   bitrate_adjustment;
111 	Gtk::SpinButton   bitrate_spinner;
112 #if 1 /* tentative debug mode */
113 	Gtk::CheckButton  debug_checkbox;
114 #endif
115 
116 };
117 
118 #endif /* __gtk_ardour_transcode_video_dialog_h__ */
119