Wouldn't it be nice if plugin presets had a description/comment?
[ardour.git] / libs / ardour / export_format_specification.cc
index bf2585a28113a79b5d79bd94decaa54a9829a345..d976cd6e97830750a92061dc1dccde7ac3d7254f 100644 (file)
 
 #include "ardour/export_format_specification.h"
 
-#include <sstream>
-
 #include "ardour/export_format_compatibility.h"
 #include "ardour/export_formats.h"
 #include "ardour/session.h"
+#include "ardour/types_convert.h"
 
 #include "pbd/error.h"
 #include "pbd/xml++.h"
 #include "pbd/enumwriter.h"
-#include "pbd/convert.h"
-
-#include "i18n.h"
+#include "pbd/enum_convert.h"
+#include "pbd/string_convert.h"
+#include "pbd/types_convert.h"
+
+#include "pbd/i18n.h"
+
+namespace PBD {
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::FormatId)
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::SampleRate)
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::SampleFormat)
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::DitherType)
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::SRCQuality)
+       DEFINE_ENUM_CONVERT (ARDOUR::ExportFormatBase::Type)
+}
 
 namespace ARDOUR
 {
 
 using namespace PBD;
 using std::string;
+using std::list;
 
 ExportFormatSpecification::Time &
 ExportFormatSpecification::Time::operator= (AnyTime const & other)
@@ -46,11 +57,11 @@ ExportFormatSpecification::Time::operator= (AnyTime const & other)
        return *this;
 }
 
-framecnt_t
-ExportFormatSpecification::Time::get_frames_at (framepos_t position, framecnt_t target_rate) const
+samplecnt_t
+ExportFormatSpecification::Time::get_samples_at (samplepos_t position, samplecnt_t target_rate) const
 {
-       framecnt_t duration = session.any_duration_to_frames (position, *this);
-       return ((double) target_rate / session.frame_rate()) * duration + 0.5;
+       samplecnt_t duration = session.any_duration_to_samples (position, *this);
+       return ((double) target_rate / session.sample_rate()) * duration + 0.5;
 }
 
 XMLNode &
@@ -59,25 +70,25 @@ ExportFormatSpecification::Time::get_state ()
 
        XMLNode * node = new XMLNode ("Duration");
 
-       node->add_property ("format", enum_2_string (type));
+       node->set_property ("format", type);
 
        switch (type) {
          case Timecode:
-               node->add_property ("hours", to_string (timecode.hours, std::dec));
-               node->add_property ("minutes", to_string (timecode.minutes, std::dec));
-               node->add_property ("seconds", to_string (timecode.seconds, std::dec));
-               node->add_property ("frames", to_string (timecode.frames, std::dec));
+               node->set_property ("hours", timecode.hours);
+               node->set_property ("minutes", timecode.minutes);
+               node->set_property ("seconds", timecode.seconds);
+               node->set_property ("frames", timecode.frames);
                break;
          case BBT:
-               node->add_property ("bars", to_string (bbt.bars, std::dec));
-               node->add_property ("beats", to_string (bbt.beats, std::dec));
-               node->add_property ("ticks", to_string (bbt.ticks, std::dec));
+               node->set_property ("bars", bbt.bars);
+               node->set_property ("beats", bbt.beats);
+               node->set_property ("ticks", bbt.ticks);
                break;
-         case Frames:
-               node->add_property ("frames", to_string (frames, std::dec));
+         case Samples:
+               node->set_property ("samples", samples);
                break;
          case Seconds:
-               node->add_property ("seconds", to_string (seconds, std::dec));
+               node->set_property ("seconds", seconds);
                break;
        }
 
@@ -87,63 +98,32 @@ ExportFormatSpecification::Time::get_state ()
 int
 ExportFormatSpecification::Time::set_state (const XMLNode & node)
 {
-       XMLProperty const * prop;
-
-       prop = node.property ("format");
-
-       if (!prop) { return -1; }
-
-       type = (Type) string_2_enum (prop->value(), Type);
+       if (!node.get_property ("format", type)) {
+               return -1;
+       }
 
        switch (type) {
-         case Timecode:
-               if ((prop = node.property ("hours"))) {
-                       timecode.hours = atoi (prop->value());
-               }
-
-               if ((prop = node.property ("minutes"))) {
-                       timecode.minutes = atoi (prop->value());
-               }
-
-               if ((prop = node.property ("seconds"))) {
-                       timecode.seconds = atoi (prop->value());
-               }
-
-               if ((prop = node.property ("frames"))) {
-                       timecode.frames = atoi (prop->value());
-               }
-
+       case Timecode:
+               node.get_property ("hours", timecode.hours);
+               node.get_property ("minutes", timecode.minutes);
+               node.get_property ("seconds", timecode.seconds);
+               node.get_property ("frames", timecode.frames);
                break;
 
-         case BBT:
-               if ((prop = node.property ("bars"))) {
-                       bbt.bars = atoi (prop->value());
-               }
-
-               if ((prop = node.property ("beats"))) {
-                       bbt.beats = atoi (prop->value());
-               }
-
-               if ((prop = node.property ("ticks"))) {
-                       bbt.ticks = atoi (prop->value());
-               }
-
+       case BBT:
+               node.get_property ("bars", bbt.bars);
+               node.get_property ("beats", bbt.beats);
+               node.get_property ("ticks", bbt.ticks);
                break;
 
-         case Frames:
-               if ((prop = node.property ("frames"))) {
-                       std::istringstream iss (prop->value());
-                       iss >> frames;
-               }
-
+       case Samples:
+               node.get_property ("samples", samples);
                break;
 
-         case Seconds:
-               if ((prop = node.property ("seconds"))) {
-                       seconds = atof (prop->value());
-               }
-
+       case Seconds:
+               node.get_property ("seconds", seconds);
                break;
+
        }
 
        return 0;
@@ -151,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)
@@ -166,7 +146,17 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
        , _silence_end (s)
 
        , _normalize (false)
-       , _normalize_target (1.0)
+       , _normalize_loudness (false)
+       , _normalize_dbfs (GAIN_COEFF_UNITY)
+       , _normalize_lufs (-23)
+       , _normalize_dbtp (-1)
+       , _with_toc (false)
+       , _with_cue (false)
+       , _with_mp4chaps (false)
+       , _soundcloud_upload (false)
+       , _command ("")
+       , _analyse (true)
+       , _codec_quality (0)
 {
        format_ids.insert (F_None);
        endiannesses.insert (E_FileDefault);
@@ -177,8 +167,32 @@ 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)
+       , _src_quality (SRC_SincBest)
+       , _tag (true)
+
+       , _trim_beginning (false)
        , _silence_beginning (s)
+       , _trim_end (false)
        , _silence_end (s)
+
+       , _normalize (false)
+       , _normalize_loudness (false)
+       , _normalize_dbfs (GAIN_COEFF_UNITY)
+       , _normalize_lufs (-23)
+       , _normalize_dbtp (-1)
+       , _with_toc (false)
+       , _with_cue (false)
+       , _with_mp4chaps (false)
+       , _soundcloud_upload (false)
+       , _command ("")
+       , _analyse (true)
+       , _codec_quality (0)
 {
        _silence_beginning.type = Time::Timecode;
        _silence_end.type = Time::Timecode;
@@ -186,18 +200,29 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const
        set_state (state);
 }
 
-ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification const & other)
+ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name)
        : ExportFormatBase(other)
        , 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)
 {
-       set_name (other.name() + " (copy)");
+       if (modify_name) {
+               set_name (other.name() + " (copy)");
+       } else {
+               set_name (other.name());
+       }
 
        _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;
 
@@ -213,13 +238,16 @@ ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification
        set_trim_beginning (other.trim_beginning());
        set_trim_end (other.trim_end());
        set_normalize (other.normalize());
-       set_normalize_target (other.normalize_target());
+       set_normalize_loudness (other.normalize_loudness());
+       set_normalize_dbfs (other.normalize_dbfs());
+       set_normalize_lufs (other.normalize_lufs());
+       set_normalize_dbtp (other.normalize_dbtp());
 
        set_tag (other.tag());
 
        set_silence_beginning (other.silence_beginning_time());
        set_silence_end (other.silence_end_time());
-       
+
        set_extension(other.extension());
 }
 
@@ -233,53 +261,67 @@ ExportFormatSpecification::get_state ()
        XMLNode * node;
        XMLNode * root = new XMLNode ("ExportFormatSpecification");
 
-       root->add_property ("name", _name);
-       root->add_property ("id", _id.to_s());
+       root->set_property ("name", _name);
+       root->set_property ("id", _id.to_s());
+       root->set_property ("with-cue", _with_cue);
+       root->set_property ("with-toc", _with_toc);
+       root->set_property ("with-mp4chaps", _with_mp4chaps);
+       root->set_property ("command", _command);
+       root->set_property ("analyse", _analyse);
+       root->set_property ("soundcloud-upload", _soundcloud_upload);
 
        node = root->add_child ("Encoding");
-       node->add_property ("id", enum_2_string (format_id()));
-       node->add_property ("type", enum_2_string (type()));
-       node->add_property ("extension", extension());
-       node->add_property ("name", _format_name);
-       node->add_property ("has-sample-format", has_sample_format ? "true" : "false");
-       node->add_property ("channel-limit", to_string (_channel_limit, std::dec));
+       node->set_property ("id", format_id());
+       node->set_property ("type", type());
+       node->set_property ("extension", extension());
+       node->set_property ("name", _format_name);
+       node->set_property ("has-sample-format", has_sample_format);
+       node->set_property ("channel-limit", _channel_limit);
 
        node = root->add_child ("SampleRate");
-       node->add_property ("rate", to_string (sample_rate(), std::dec));
+       node->set_property ("rate", sample_rate());
 
        node = root->add_child ("SRCQuality");
-       node->add_property ("quality", enum_2_string (src_quality()));
+       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", enum_2_string (sample_format()));
-       add_option (enc_opts, "dithering", enum_2_string (dither_type()));
-       add_option (enc_opts, "tag-metadata", _tag ? "true" : "false");
-       add_option (enc_opts, "tag-support", supports_tagging ? "true" : "false");
-       add_option (enc_opts, "broadcast-info", _has_broadcast_info ? "true" : "false");
+       add_option (enc_opts, "sample-format", to_string(sample_format()));
+       add_option (enc_opts, "dithering", to_string (dither_type()));
+       add_option (enc_opts, "tag-metadata", to_string (_tag));
+       add_option (enc_opts, "tag-support", to_string (supports_tagging));
+       add_option (enc_opts, "broadcast-info", to_string (_has_broadcast_info));
 
        XMLNode * processing = root->add_child ("Processing");
 
        node = processing->add_child ("Normalize");
-       node->add_property ("enabled", normalize() ? "true" : "false");
-       node->add_property ("target", to_string (normalize_target(), std::dec));
+       node->set_property ("enabled", normalize());
+       node->set_property ("loudness", normalize_loudness());
+       node->set_property ("dbfs", normalize_dbfs());
+       node->set_property ("lufs", normalize_lufs());
+       node->set_property ("dbtp", normalize_dbtp());
 
        XMLNode * silence = processing->add_child ("Silence");
        XMLNode * start = silence->add_child ("Start");
        XMLNode * end = silence->add_child ("End");
 
        node = start->add_child ("Trim");
-       node->add_property ("enabled", trim_beginning() ? "true" : "false");
+       node->set_property ("enabled", trim_beginning());
 
        node = start->add_child ("Add");
-       node->add_property ("enabled", _silence_beginning.not_zero() ? "true" : "false");
+       node->set_property ("enabled", _silence_beginning.not_zero());
        node->add_child_nocopy (_silence_beginning.get_state());
 
        node = end->add_child ("Trim");
-       node->add_property ("enabled", trim_end() ? "true" : "false");
+       node->set_property ("enabled", trim_end());
 
        node = end->add_child ("Add");
-       node->add_property ("enabled", _silence_end.not_zero() ? "true" : "false");
+       node->set_property ("enabled", _silence_end.not_zero());
        node->add_child_nocopy (_silence_end.get_state());
 
        return *root;
@@ -288,55 +330,91 @@ ExportFormatSpecification::get_state ()
 int
 ExportFormatSpecification::set_state (const XMLNode & root)
 {
-       XMLProperty const * prop;
        XMLNode const * child;
-       string value;
+       string str;
+
+       root.get_property ("name", _name);
 
-       if ((prop = root.property ("name"))) {
-               _name = prop->value();
+       if (root.get_property ("id", str)) {
+               _id = str;
        }
 
-       if ((prop = root.property ("id"))) {
-               _id = prop->value();
+       if (!root.get_property ("with-cue", _with_cue)) {
+               _with_cue = false;
        }
 
-       /* Encoding and SRC */
+       if (!root.get_property ("with-toc", _with_toc)) {
+               _with_toc = false;
+       }
 
-       if ((child = root.child ("Encoding"))) {
-               if ((prop = child->property ("id"))) {
-                       set_format_id ((FormatId) string_2_enum (prop->value(), FormatId));
-               }
+       if (!root.get_property ("with-mp4chaps", _with_mp4chaps)) {
+               _with_mp4chaps = false;
+       }
 
-               if ((prop = child->property ("type"))) {
-                       set_type ((Type) string_2_enum (prop->value(), Type));
-               }
+       if (!root.get_property ("command", _command)) {
+               _command = "";
+       }
 
-               if ((prop = child->property ("extension"))) {
-                       set_extension (prop->value());
-               }
+       if (!root.get_property ("analyse", _analyse)) {
+               _analyse = false;
+       }
+
+       if (!root.get_property ("soundcloud-upload", _soundcloud_upload)) {
+               _soundcloud_upload = false;
+       }
+
+       /* Encoding and SRC */
 
-               if ((prop = child->property ("name"))) {
-                       _format_name = prop->value();
+       if ((child = root.child ("Encoding"))) {
+               FormatId fid;
+               if (child->get_property ("id", fid)) {
+                       set_format_id (fid);
                }
 
-               if ((prop = child->property ("has-sample-format"))) {
-                       has_sample_format = !prop->value().compare ("true");
+               ExportFormatBase::Type type;
+               if (child->get_property ("type", type)) {
+                       set_type (type);
                }
 
-               if ((prop = child->property ("channel-limit"))) {
-                       _channel_limit = atoi (prop->value());
+               if (child->get_property ("extension", str)) {
+                       set_extension (str);
                }
+
+               child->get_property ("name", _format_name);
+               child->get_property ("has-sample-format", has_sample_format);
+               child->get_property ("channel-limit", _channel_limit);
        }
 
        if ((child = root.child ("SampleRate"))) {
-               if ((prop = child->property ("rate"))) {
-                       set_sample_rate ( (SampleRate) string_2_enum (prop->value(), SampleRate));
+               SampleRate rate;
+               if (child->get_property ("rate", rate)) {
+                       set_sample_rate (rate);
                }
        }
 
        if ((child = root.child ("SRCQuality"))) {
-               if ((prop = child->property ("quality"))) {
-                       _src_quality = (SRCQuality) string_2_enum (prop->value(), SRCQuality);
+               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();
                }
        }
 
@@ -345,9 +423,9 @@ ExportFormatSpecification::set_state (const XMLNode & root)
        if ((child = root.child ("EncodingOptions"))) {
                set_sample_format ((SampleFormat) string_2_enum (get_option (child, "sample-format"), SampleFormat));
                set_dither_type ((DitherType) string_2_enum (get_option (child, "dithering"), DitherType));
-               set_tag (!(get_option (child, "tag-metadata").compare ("true")));
-               supports_tagging = (!(get_option (child, "tag-support").compare ("true")));
-               _has_broadcast_info = (!(get_option (child, "broadcast-info").compare ("true")));
+               set_tag (string_to<bool>(get_option (child, "tag-metadata")));
+               supports_tagging = string_to<bool>(get_option (child, "tag-support"));
+               _has_broadcast_info = string_to<bool>(get_option (child, "broadcast-info"));
        }
 
        /* Processing */
@@ -356,13 +434,13 @@ ExportFormatSpecification::set_state (const XMLNode & root)
        if (!proc) { std::cerr << X_("Could not load processing for export format") << std::endl; return -1; }
 
        if ((child = proc->child ("Normalize"))) {
-               if ((prop = child->property ("enabled"))) {
-                       _normalize = (!prop->value().compare ("true"));
-               }
-
-               if ((prop = child->property ("target"))) {
-                       _normalize_target = atof (prop->value());
-               }
+               child->get_property ("enabled", _normalize);
+               // old formats before ~ 4.7-930ish
+               child->get_property ("target", _normalize_dbfs);
+               child->get_property ("loudness", _normalize_loudness);
+               child->get_property ("dbfs", _normalize_dbfs);
+               child->get_property ("lufs", _normalize_lufs);
+               child->get_property ("dbtp", _normalize_dbtp);
        }
 
        XMLNode const * silence = proc->child ("Silence");
@@ -375,40 +453,33 @@ ExportFormatSpecification::set_state (const XMLNode & root)
        /* Silence start */
 
        if ((child = start->child ("Trim"))) {
-               if ((prop = child->property ("enabled"))) {
-                       _trim_beginning = (!prop->value().compare ("true"));
-               }
+               child->get_property ("enabled", _trim_beginning);
        }
 
+       bool enabled;
        if ((child = start->child ("Add"))) {
-               if ((prop = child->property ("enabled"))) {
-                       if (!prop->value().compare ("true")) {
-                               if ((child = child->child ("Duration"))) {
-                                       _silence_beginning.set_state (*child);
-                               }
-                       } else {
-                               _silence_beginning.type = Time::Timecode;
+               if (child->get_property ("enabled", enabled) && enabled) {
+                       if ((child = child->child ("Duration"))) {
+                               _silence_beginning.set_state (*child);
                        }
+               } else {
+                       _silence_beginning.type = Time::Timecode;
                }
        }
 
        /* Silence end */
 
        if ((child = end->child ("Trim"))) {
-               if ((prop = child->property ("enabled"))) {
-                       _trim_end = (!prop->value().compare ("true"));
-               }
+               child->get_property ("enabled", _trim_end);
        }
 
        if ((child = end->child ("Add"))) {
-               if ((prop = child->property ("enabled"))) {
-                       if (!prop->value().compare ("true")) {
-                               if ((child = child->child ("Duration"))) {
-                                       _silence_end.set_state (*child);
-                               }
-                       } else {
-                               _silence_end.type = Time::Timecode;
+               if (child->get_property ("enabled", enabled) && enabled) {
+                       if ((child = child->child ("Duration"))) {
+                               _silence_end.set_state (*child);
                        }
+               } else {
+                               _silence_end.type = Time::Timecode;
                }
        }
 
@@ -471,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());
 
@@ -487,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();
 
@@ -499,61 +580,97 @@ ExportFormatSpecification::set_format (boost::shared_ptr<ExportFormat> format)
                has_sample_format = false;
                supports_tagging = false;
                _channel_limit = 0;
+               _codec_quality = 0;
                _format_name = "";
        }
 }
 
 string
-ExportFormatSpecification::description ()
+ExportFormatSpecification::description (bool include_name)
 {
-       string desc;
-
-       desc = _name + ": ";
+       list<string> components;
 
        if (_normalize) {
-               desc += _("normalize, ");
+               if (_normalize_loudness) {
+                       components.push_back (_("normalize loudness"));
+               } else {
+                       components.push_back (_("normalize peak"));
+               }
        }
 
        if (_trim_beginning && _trim_end) {
-               desc += _("trim, ");
+               components.push_back ( _("trim"));
        } else if (_trim_beginning) {
-               desc += _("trim start, ");
+               components.push_back (_("trim start"));
        } else if (_trim_end) {
-               desc += "trim end, ";
+               components.push_back (_("trim end"));
        }
 
-       desc += _format_name + ", ";
+       if (_format_name != "") {
+               components.push_back (_format_name);
+       }
 
        if (has_sample_format) {
-               desc += HasSampleFormat::get_sample_format_name (sample_format())  + ", ";
+               components.push_back (HasSampleFormat::get_sample_format_name (sample_format()));
        }
 
        switch (sample_rate()) {
-         case SR_22_05:
-               desc += "22,5 kHz";
+       case SR_8:
+               components.push_back ("8 kHz");
+               break;
+       case SR_22_05:
+               components.push_back ("22,5 kHz");
+               break;
+       case SR_44_1:
+               components.push_back ("44,1 kHz");
                break;
-         case SR_44_1:
-               desc += "44,1 kHz";
+       case SR_48:
+               components.push_back ("48 kHz");
                break;
-         case SR_48:
-               desc += "48 kHz";
+       case SR_88_2:
+               components.push_back ("88,2 kHz");
                break;
-         case SR_88_2:
-               desc += "88,2 kHz";
+       case SR_96:
+               components.push_back ("96 kHz");
                break;
-         case SR_96:
-               desc += "96 kHz";
+       case SR_176_4:
+               components.push_back ("176.4 kHz");
                break;
-         case SR_192:
-               desc += "192 kHz";
+       case SR_192:
+               components.push_back ("192 kHz");
                break;
-         case SR_Session:
-               desc += _("Session rate");
+       case SR_Session:
+               components.push_back (_("Session rate"));
                break;
-         case SR_None:
+       case SR_None:
                break;
        }
 
+       if (_with_toc) {
+               components.push_back ("TOC");
+       }
+
+       if (_with_cue) {
+               components.push_back ("CUE");
+       }
+
+       if (_with_mp4chaps) {
+               components.push_back ("MP4ch");
+       }
+
+       if (!_command.empty()) {
+               components.push_back ("+");
+       }
+
+       string desc;
+       if (include_name) {
+               desc = _name + ": ";
+       }
+
+       for (list<string>::const_iterator it = components.begin(); it != components.end(); ++it) {
+               if (it != components.begin()) { desc += ", "; }
+               desc += *it;
+       }
        return desc;
 }
 
@@ -561,8 +678,8 @@ void
 ExportFormatSpecification::add_option (XMLNode * node, std::string const & name, std::string const & value)
 {
        node = node->add_child ("Option");
-       node->add_property ("name", name);
-       node->add_property ("value", value);
+       node->set_property ("name", name);
+       node->set_property ("value", value);
 }
 
 std::string
@@ -571,11 +688,10 @@ ExportFormatSpecification::get_option (XMLNode const * node, std::string const &
        XMLNodeList list (node->children ("Option"));
 
        for (XMLNodeList::iterator it = list.begin(); it != list.end(); ++it) {
-               XMLProperty * prop = (*it)->property ("name");
-               if (prop && !name.compare (prop->value())) {
-                       prop = (*it)->property ("value");
-                       if (prop) {
-                               return prop->value();
+               std::string str;
+               if ((*it)->get_property ("name", str) && name == str) {
+                       if ((*it)->get_property ("value", str)) {
+                               return str;
                        }
                }
        }