Ardour  9.0-pre0-582-g084a23a80d
export_formats.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2010 Sakari Bergen <sakari.bergen@beatwaves.net>
3  * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
5  * Copyright (C) 2018-2019 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #pragma once
23 
24 #include <list>
25 #include <memory>
26 
27 #include "pbd/failed_constructor.h"
28 #include "pbd/signals.h"
29 
32 
33 namespace ARDOUR {
34 
36 {
37 public:
38  virtual const char* what () const throw ()
39  {
40  return "Export format constructor failed: Format incompatible with system";
41  }
42 };
43 
46 {
47 public:
50 
51  virtual bool set_compatibility_state (ExportFormatCompatibility const& compatibility) = 0;
52 
53  virtual Type get_type () const = 0;
54 
56  {
57  return *format_ids.begin ();
58  }
59 
61  {
62  return *qualities.begin ();
63  }
64 
67 
69 
70  /* If the format has a specific sample format, this function should be overridden
71  * if the format has a selectable sample format, do not override this!
72  */
74  {
75  return SF_None;
76  }
77 
78  /* If the above is not overridden, this one should be */
80  {
81  return SF_None;
82  }
83 
84  /* If the format has a channel count limit, override this */
85  virtual uint32_t get_channel_limit () const
86  {
87  return 256;
88  }
89 
90  /* If the format can be tagged with metadata override this */
91  virtual bool supports_tagging () const
92  {
93  return false;
94  }
95 
96  /* If the format contains broadcast info override this */
97  virtual bool has_broadcast_info () const
98  {
99  return false;
100  }
101 
102 protected:
104  {
105  sample_rates.insert (rate);
106  }
107 
108  void add_endianness (Endianness endianness)
109  {
110  endiannesses.insert (endianness);
111  }
112 
114  {
115  format_ids.clear ();
116  format_ids.insert (id);
117  }
118 
119  void set_quality (Quality value)
120  {
121  qualities.clear ();
122  qualities.insert (value);
123  }
124 };
125 
127 {
128 public:
129  struct CodecQuality {
130  CodecQuality (std::string const& n, int q)
131  : name (n)
132  , quality (q)
133  {}
134 
135  std::string name;
136  int quality;
137  };
138 
139  typedef std::shared_ptr<CodecQuality> CodecQualityPtr;
140  typedef std::list<CodecQualityPtr> CodecQualityList;
141 
142  virtual ~HasCodecQuality () {}
143 
144  void add_codec_quality (std::string const& name, int q)
145  {
146  CodecQualityPtr ptr (new CodecQuality (name, q));
147  _codec_qualties.push_back (ptr);
148  }
149 
151  {
152  return _codec_qualties;
153  }
154 
155  virtual int default_codec_quality () const = 0;
156 
157 protected:
159 };
160 
163 {
164 public:
166  {
167  public:
169  : format (format)
170  {
171  set_name (name);
172  }
173 
175  };
176 
178  {
179  public:
181  : type (type)
182  {
183  set_name (name);
184  }
185 
187  };
188 
189  typedef std::shared_ptr<SampleFormatState> SampleFormatPtr;
190  typedef std::weak_ptr<SampleFormatState> WeakSampleFormatPtr;
191  typedef std::list<SampleFormatPtr> SampleFormatList;
192 
193  typedef std::shared_ptr<DitherTypeState> DitherTypePtr;
194  typedef std::weak_ptr<DitherTypeState> WeakDitherTypePtr;
195  typedef std::list<DitherTypePtr> DitherTypeList;
196 
197 public:
199  virtual ~HasSampleFormat (){};
200 
202 
204  {
205  return sample_format_states;
206  }
207 
209  {
210  return dither_type_states;
211  }
212 
215 
216  /* Proxies for signals from sample formats and dither types */
219 
222 
224 
225 protected:
226  /* State lists */
229 
230 private:
231  /* Connected to signals */
235 
236  /* Reference to ExportFormatBase::sample_formats */
238 };
239 
241 {
242 public:
243  ExportFormatLinear (std::string name, FormatId format_id);
245 
247  Type get_type () const
248  {
249  return T_Sndfile;
250  }
251 
252  void add_endianness (Endianness endianness)
253  {
254  endiannesses.insert (endianness);
255  }
256 
258  {
259  _default_sample_format = sf;
260  }
261 
263  {
264  return _default_sample_format;
265  }
266 
267 protected:
269 };
270 
272 {
273 public:
274  ExportFormatTaggedLinear (std::string name, FormatId format_id)
275  : ExportFormatLinear (name, format_id)
276  {
277  }
278 
279  virtual bool supports_tagging () const
280  {
281  return true;
282  }
283 };
284 
286 {
287 public:
290 
292  Type get_type () const
293  {
294  return T_Sndfile;
295  }
297  {
298  return SF_Vorbis;
299  }
300  virtual bool supports_tagging () const
301  {
302  return true;
303  }
305  {
306  return 40;
307  }
308 };
309 
311 {
312 public:
315 
317  Type get_type () const
318  {
319  return T_Sndfile;
320  }
321  uint32_t get_channel_limit () const
322  {
323  return 8;
324  }
326  {
327  return SF_16;
328  }
329  virtual bool supports_tagging () const
330  {
331  return true;
332  }
333 };
334 
336 {
337 public:
340 
342 
343  Type get_type () const
344  {
345  return T_Sndfile;
346  }
348  {
349  return SF_16;
350  }
351  virtual bool has_broadcast_info () const
352  {
353  return true;
354  }
355 };
356 
358 {
359 public:
362 
364 
365  Type get_type () const
366  {
367  return T_Sndfile;
368  }
370  {
371  return SF_Opus;
372  }
374  {
375  return 49;
376  }
377  virtual bool supports_tagging () const
378  {
379  return true;
380  }
381 };
382 
384 {
385 public:
386  ExportFormatMPEG (std::string const& name, std::string const& ext);
388 
390 
391  Type get_type () const
392  {
393  return T_Sndfile;
394  }
396  {
397  return SF_MPEG_LAYER_III;
398  }
400  {
401  return 40;
402  }
403  virtual bool supports_tagging () const
404  {
405  return true;
406  }
407 };
408 
410 {
411 public:
412  ExportFormatFFMPEG (std::string const& name, std::string const& ext);
414 
416 
417  Type get_type () const
418  {
419  return T_FFMPEG;
420  }
422  {
423  return SF_Float;
424  }
426  {
427  return -2;
428  }
429  virtual bool supports_tagging () const
430  {
431  return true;
432  }
433 };
434 
435 } // namespace ARDOUR
436 
virtual bool has_broadcast_info() const
SampleFormat default_sample_format() const
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
Class for managing selection and compatibility states.
std::set< SampleFormat > SampleFormatSet
Allows adding to all sets. A format should be able to test if it is compatible with this.
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
virtual bool supports_tagging() const
ExportFormatFFMPEG(std::string const &name, std::string const &ext)
SampleFormat get_explicit_sample_format() const
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
uint32_t get_channel_limit() const
virtual bool supports_tagging() const
SampleFormat default_sample_format() const
virtual const char * what() const
ExportFormatLinear(std::string name, FormatId format_id)
void add_endianness(Endianness endianness)
void set_default_sample_format(SampleFormat sf)
SampleFormat default_sample_format() const
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
SampleFormat _default_sample_format
virtual bool supports_tagging() const
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
int default_codec_quality() const
SampleFormat default_sample_format() const
ExportFormatMPEG(std::string const &name, std::string const &ext)
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
SampleFormat get_explicit_sample_format() const
virtual bool supports_tagging() const
virtual bool supports_tagging() const
SampleFormat get_explicit_sample_format() const
bool set_compatibility_state(ExportFormatCompatibility const &compatibility)
virtual bool supports_tagging() const
ExportFormatTaggedLinear(std::string name, FormatId format_id)
Base class for formats.
virtual uint32_t get_channel_limit() const
void add_sample_rate(SampleRate rate)
void set_quality(Quality value)
FormatId get_format_id() const
Quality get_quality() const
void set_format_id(FormatId id)
void add_endianness(Endianness endianness)
bool sample_format_is_compatible(SampleFormat format) const
virtual ExportFormat::SampleFormat default_sample_format() const
virtual Type get_type() const =0
virtual SampleFormat get_explicit_sample_format() const
virtual bool has_broadcast_info() const
virtual bool supports_tagging() const
virtual bool set_compatibility_state(ExportFormatCompatibility const &compatibility)=0
std::shared_ptr< CodecQuality > CodecQualityPtr
std::list< CodecQualityPtr > CodecQualityList
CodecQualityList _codec_qualties
CodecQualityList const & get_codec_qualities() const
void add_codec_quality(std::string const &name, int q)
virtual int default_codec_quality() const =0
ExportFormatBase::DitherType type
DitherTypeState(ExportFormatBase::DitherType type, Glib::ustring name)
ExportFormatBase::SampleFormat format
SampleFormatState(ExportFormatBase::SampleFormat format, std::string name)
Class to be inherited by export formats that have a selectable sample format.
std::weak_ptr< DitherTypeState > WeakDitherTypePtr
void add_dither_type(ExportFormatBase::DitherType type, std::string name)
DitherTypeList dither_type_states
SampleFormatList const & get_sample_formats() const
std::shared_ptr< DitherTypeState > DitherTypePtr
DitherTypeList const & get_dither_types() const
std::weak_ptr< SampleFormatState > WeakSampleFormatPtr
DitherTypePtr get_selected_dither_type()
std::list< SampleFormatPtr > SampleFormatList
ExportFormatBase::SampleFormatSet & _sample_formats
std::shared_ptr< SampleFormatState > SampleFormatPtr
PBD::Signal< void(bool, WeakSampleFormatPtr)> SampleFormatSelectChanged
SampleFormatPtr get_selected_sample_format()
PBD::Signal< void(bool, WeakSampleFormatPtr)> SampleFormatCompatibleChanged
std::list< DitherTypePtr > DitherTypeList
void update_sample_format_selection(bool)
static std::string get_sample_format_name(ExportFormatBase::SampleFormat format)
void update_dither_type_selection(bool)
PBD::Signal< void(bool, WeakDitherTypePtr)> DitherTypeSelectChanged
void add_sample_format(ExportFormatBase::SampleFormat format)
HasSampleFormat(ExportFormatBase::SampleFormatSet &sample_formats)
SampleFormatList sample_format_states
PBD::Signal< void(bool, WeakDitherTypePtr)> DitherTypeCompatibleChanged
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
CodecQuality(std::string const &n, int q)