1 /* 2 * Copyright (C) 2008-2013 Paul Davis <paul@linuxaudiosystems.com> 3 * Copyright (C) 2009 David Robillard <d@drobilla.net> 4 * Copyright (C) 2011-2012 Sakari Bergen <sakari.bergen@beatwaves.net> 5 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com> 6 * Copyright (C) 2016-2018 Robin Gareus <robin@gareus.org> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc., 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 */ 22 23 #ifndef __ardour_export_format_manager_h__ 24 #define __ardour_export_format_manager_h__ 25 26 #include <list> 27 #include <string> 28 29 #include <boost/shared_ptr.hpp> 30 31 #include "pbd/signals.h" 32 33 #include "ardour/export_formats.h" 34 #include "ardour/export_pointers.h" 35 36 namespace ARDOUR 37 { 38 39 class ExportFormat; 40 class ExportFormatCompatibility; 41 class ExportFormatSpecification; 42 class AnyTime; 43 44 class LIBARDOUR_API ExportFormatManager : public PBD::ScopedConnectionList 45 { 46 public: 47 48 typedef std::list<ExportFormatCompatibilityPtr> CompatList; 49 typedef std::list<ExportFormatPtr> FormatList; 50 51 typedef HasSampleFormat::SampleFormatPtr SampleFormatPtr; 52 typedef HasSampleFormat::SampleFormatList SampleFormatList; 53 typedef HasSampleFormat::WeakSampleFormatPtr WeakSampleFormatPtr; 54 55 typedef HasSampleFormat::DitherTypePtr DitherTypePtr; 56 typedef HasSampleFormat::WeakDitherTypePtr WeakDitherTypePtr; 57 58 /* Quality states */ 59 60 class QualityState : public ExportFormatBase::SelectableCompatible { 61 public: QualityState(ExportFormatBase::Quality quality,std::string name)62 QualityState (ExportFormatBase::Quality quality, std::string name) : 63 quality (quality) { set_name (name); } 64 ExportFormatBase::Quality quality; 65 }; 66 typedef boost::shared_ptr<QualityState> QualityPtr; 67 typedef boost::weak_ptr<QualityState> WeakQualityPtr; 68 typedef std::list<QualityPtr> QualityList; 69 70 /* Sample rate states */ 71 72 class SampleRateState : public ExportFormatBase::SelectableCompatible { 73 public: SampleRateState(ExportFormatBase::SampleRate rate,std::string name)74 SampleRateState (ExportFormatBase::SampleRate rate, std::string name) 75 : rate (rate) { set_name (name); } 76 ExportFormatBase::SampleRate rate; 77 }; 78 typedef boost::shared_ptr<SampleRateState> SampleRatePtr; 79 typedef boost::weak_ptr<SampleRateState> WeakSampleRatePtr; 80 typedef std::list<SampleRatePtr> SampleRateList; 81 82 public: 83 84 explicit ExportFormatManager (ExportFormatSpecPtr specification); 85 ~ExportFormatManager (); 86 87 /* Signals */ 88 89 PBD::Signal1<void,bool> CompleteChanged; 90 PBD::Signal0<void> DescriptionChanged; 91 92 /* Access to lists */ 93 get_compatibilities()94 CompatList const & get_compatibilities () { return compatibilities; } get_qualities()95 QualityList const & get_qualities () { return qualities; } get_formats()96 FormatList const & get_formats () { return formats; } get_sample_rates()97 SampleRateList const & get_sample_rates () { return sample_rates; } 98 99 /* Non interactive selections */ 100 101 void set_name (std::string name); 102 103 void select_with_cue (bool); 104 void select_with_toc (bool); 105 void select_with_mp4chaps (bool); 106 void select_upload (bool); 107 void set_command (std::string); 108 void select_src_quality (ExportFormatBase::SRCQuality value); 109 void select_codec_quality (int); 110 void select_trim_beginning (bool value); 111 void select_silence_beginning (AnyTime const & time); 112 void select_trim_end (bool value); 113 void select_silence_end (AnyTime const & time); 114 void select_normalize (bool value); 115 void select_normalize_loudness (bool value); 116 void select_tp_limiter (bool value); 117 void select_normalize_dbfs (float value); 118 void select_normalize_lufs (float value); 119 void select_normalize_dbtp (float value); 120 void select_tagging (bool tag); 121 void select_demo_noise_level (float value); 122 void select_demo_noise_duration (int value); 123 void select_demo_noise_interval (int value); 124 125 private: 126 127 void init_compatibilities (); 128 void init_qualities (); 129 void init_formats (); 130 void init_sample_rates (); 131 132 void add_compatibility (ExportFormatCompatibilityPtr ptr); 133 void add_quality (QualityPtr ptr); 134 void add_format (ExportFormatPtr ptr); 135 void add_sample_rate (SampleRatePtr ptr); 136 137 /* Connected to signals */ 138 139 void change_compatibility_selection (bool select, WeakExportFormatCompatibilityPtr const & compat); 140 void change_quality_selection (bool select, WeakQualityPtr const & quality); 141 void change_format_selection (bool select, WeakExportFormatPtr const & format); 142 void change_sample_rate_selection (bool select, WeakSampleRatePtr const & rate); 143 144 void change_sample_format_selection (bool select, WeakSampleFormatPtr const & format); 145 void change_dither_type_selection (bool select, WeakDitherTypePtr const & type); 146 147 /* Do actual selection */ 148 149 void select_compatibility (WeakExportFormatCompatibilityPtr const & compat); 150 void select_quality (QualityPtr const & quality); 151 void select_format (ExportFormatPtr const & format); 152 void select_sample_rate (SampleRatePtr const & rate); 153 154 void select_sample_format (SampleFormatPtr const & format); 155 void select_dither_type (DitherTypePtr const & type); 156 157 bool pending_selection_change; 158 void selection_changed (); 159 void check_for_description_change (); 160 161 /* Formats and compatibilities */ 162 163 QualityPtr get_selected_quality (); 164 ExportFormatPtr get_selected_format (); 165 SampleRatePtr get_selected_sample_rate (); 166 167 SampleFormatPtr get_selected_sample_format (); 168 169 ExportFormatBasePtr get_compatibility_intersection (); 170 171 ExportFormatBasePtr universal_set; 172 ExportFormatSpecPtr current_selection; 173 174 CompatList compatibilities; 175 QualityList qualities; 176 FormatList formats; 177 SampleRateList sample_rates; 178 179 std::string prev_description; 180 181 }; 182 183 } // namespace ARDOUR 184 185 #endif /* __ardour_export_format_manager_h__ */ 186