Wouldn't it be nice if plugin presets had a description/comment?
[ardour.git] / libs / ardour / export_format_specification.cc
index 5275ddba6ce31473fe22c1764cbf6b944b0a1f8b..d976cd6e97830750a92061dc1dccde7ac3d7254f 100644 (file)
@@ -77,7 +77,7 @@ ExportFormatSpecification::Time::get_state ()
                node->set_property ("hours", timecode.hours);
                node->set_property ("minutes", timecode.minutes);
                node->set_property ("seconds", timecode.seconds);
-               node->set_property ("samples", timecode.frames);
+               node->set_property ("frames", timecode.frames);
                break;
          case BBT:
                node->set_property ("bars", bbt.bars);
@@ -107,7 +107,7 @@ ExportFormatSpecification::Time::set_state (const XMLNode & node)
                node.get_property ("hours", timecode.hours);
                node.get_property ("minutes", timecode.minutes);
                node.get_property ("seconds", timecode.seconds);
-               node.get_property ("samples", timecode.frames);
+               node.get_property ("frames", timecode.frames);
                break;
 
        case BBT:
@@ -131,9 +131,9 @@ ExportFormatSpecification::Time::set_state (const XMLNode & node)
 
 ExportFormatSpecification::ExportFormatSpecification (Session & s)
        : session (s)
-
        , has_sample_format (false)
        , supports_tagging (false)
+       , _has_codec_quality (false)
        , _has_broadcast_info (false)
        , _channel_limit (0)
        , _dither_type (D_None)
@@ -156,6 +156,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
        , _soundcloud_upload (false)
        , _command ("")
        , _analyse (true)
+       , _codec_quality (0)
 {
        format_ids.insert (F_None);
        endiannesses.insert (E_FileDefault);
@@ -166,9 +167,9 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
 
 ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const & state)
        : session (s)
-
        , has_sample_format (false)
        , supports_tagging (false)
+       , _has_codec_quality (false)
        , _has_broadcast_info (false)
        , _channel_limit (0)
        , _dither_type (D_None)
@@ -191,6 +192,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const
        , _soundcloud_upload (false)
        , _command ("")
        , _analyse (true)
+       , _codec_quality (0)
 {
        _silence_beginning.type = Time::Timecode;
        _silence_end.type = Time::Timecode;
@@ -203,8 +205,13 @@ ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification
        , session (other.session)
        , _silence_beginning (other.session)
        , _silence_end (other.session)
+       , _with_toc (other._with_toc)
+       , _with_cue (other._with_cue)
+       , _with_mp4chaps (other._with_mp4chaps)
        , _soundcloud_upload (false)
+       , _command (other._command)
        , _analyse (other._analyse)
+       , _codec_quality (other._codec_quality)
 {
        if (modify_name) {
                set_name (other.name() + " (copy)");
@@ -214,8 +221,8 @@ ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification
 
        _format_name = other._format_name;
        has_sample_format = other.has_sample_format;
-
        supports_tagging = other.supports_tagging;
+       _has_codec_quality = other._has_codec_quality;
        _has_broadcast_info = other._has_broadcast_info;
        _channel_limit = other._channel_limit;
 
@@ -277,6 +284,11 @@ ExportFormatSpecification::get_state ()
        node = root->add_child ("SRCQuality");
        node->set_property ("quality", src_quality());
 
+       if (_has_codec_quality) {
+               node = root->add_child ("CodecQuality");
+               node->set_property ("quality", codec_quality());
+       }
+
        XMLNode * enc_opts = root->add_child ("EncodingOptions");
 
        add_option (enc_opts, "sample-format", to_string(sample_format()));
@@ -384,6 +396,28 @@ ExportFormatSpecification::set_state (const XMLNode & root)
                child->get_property ("quality", _src_quality);
        }
 
+       if ((child = root.child ("CodecQuality"))) {
+               child->get_property ("quality", _codec_quality);
+               _has_codec_quality = true;
+       } else {
+               _has_codec_quality = false;
+       }
+
+       /* fixup codec quality for old states */
+       if (!_has_codec_quality) {
+               /* We'd need an instance of ExportFormatManager to look up
+                * defaults for a given type -- in the future there may even be
+                * difference qualities depending on sub-type, so we just
+                * hardcode them here for the time being.
+                */
+               if (format_id() == F_FFMPEG) {
+                       _codec_quality = -2; // ExportFormatOggVorbis::default_codec_quality();
+               }
+               else if (format_id() == F_Ogg) {
+                       _codec_quality = 40; // ExportFormatFFMPEG::default_codec_quality();
+               }
+       }
+
        /* Encoding options */
 
        if ((child = root.child ("EncodingOptions"))) {
@@ -508,7 +542,10 @@ void
 ExportFormatSpecification::set_format (boost::shared_ptr<ExportFormat> format)
 {
        if (format) {
-               set_format_id (format->get_format_id ());
+               FormatId new_fmt = format->get_format_id ();
+               bool fmt_changed = format_id() != new_fmt;
+               set_format_id (new_fmt);
+
                set_type (format->get_type());
                set_extension (format->extension());
 
@@ -524,6 +561,13 @@ ExportFormatSpecification::set_format (boost::shared_ptr<ExportFormat> format)
                        _has_broadcast_info = true;
                }
 
+               _has_codec_quality = format->has_codec_quality();
+               if (!_has_codec_quality) {
+                       _codec_quality = 0;
+               } else if (fmt_changed) {
+                       _codec_quality = boost::dynamic_pointer_cast<HasCodecQuality> (format)->default_codec_quality();
+               }
+
                supports_tagging = format->supports_tagging ();
                _channel_limit = format->get_channel_limit();
 
@@ -536,6 +580,7 @@ ExportFormatSpecification::set_format (boost::shared_ptr<ExportFormat> format)
                has_sample_format = false;
                supports_tagging = false;
                _channel_limit = 0;
+               _codec_quality = 0;
                _format_name = "";
        }
 }