#include <cassert>
#include <stdexcept>
+#include <cerrno>
#include <glib.h>
#include <glib/gstdio.h>
namespace ARDOUR
{
-ExportProfileManager::ExportProfileManager (Session & s, std::string xml_node_name)
- : xml_node_name (xml_node_name)
+ExportProfileManager::ExportProfileManager (Session & s, ExportType type)
+ : type(type)
, handler (s.get_export_handler())
, session (s)
- , session_range (new Location (s))
, ranges (new LocationList ())
, single_range_mode (false)
, format_list (new FormatList ())
{
+ switch(type) {
+ case RegularExport:
+ xml_node_name = X_("ExportProfile");
+ break;
+ case RangeExport:
+ xml_node_name = X_("RangeExportProfile");
+ break;
+ case SelectionExport:
+ xml_node_name = X_("SelectionExportProfile");
+ break;
+ case RegionExport:
+ xml_node_name = X_("RegionExportProfile");
+ break;
+ case StemExport:
+ xml_node_name = X_("StemExportProfile");
+ break;
+ }
+
/* Initialize path variables */
export_config_dir = Glib::build_filename (user_config_directory(), export_dir_name);
}
// ...and each channel config
- filename->include_channel_config = (channel_configs.size() > 1);
+ filename->include_channel_config = (type == StemExport) ||
+ (channel_configs.size() > 1);
for(ChannelConfigStateList::iterator cc_it = channel_configs.begin(); cc_it != channel_configs.end(); ++cc_it) {
handler->add_export_config (*ts_it, (*cc_it)->config, (*format_it)->format, filename, b);
}
}
if (timespans.empty()) {
- TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
+ TimespanStatePtr state (new TimespanState (selection_range, ranges));
timespans.push_back (state);
// Add session as default selection
+ Location * session_range = session.locations()->session_range_location();
+ if (!session_range) { return false; }
+
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name (session_range->name());
- timespan->set_range_id ("session");
+ timespan->set_range_id (session_range->id().to_s());
timespan->set_range (session_range->start(), session_range->end());
state->timespans->push_back (timespan);
return false;
ExportProfileManager::TimespanStatePtr
ExportProfileManager::deserialize_timespan (XMLNode & root)
{
- TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
+ TimespanStatePtr state (new TimespanState (selection_range, ranges));
XMLProperty const * prop;
XMLNodeList spans = root.children ("Range");
if (!prop) { continue; }
string id = prop->value();
+ Location * location = 0;
for (LocationList::iterator it = ranges->begin(); it != ranges->end(); ++it) {
- if ((!id.compare ("session") && *it == session_range.get()) ||
- (!id.compare ("selection") && *it == selection_range.get()) ||
- (!id.compare ((*it)->id().to_s()))) {
- ExportTimespanPtr timespan = handler->add_timespan();
- timespan->set_name ((*it)->name());
- timespan->set_range_id (id);
- timespan->set_range ((*it)->start(), (*it)->end());
- state->timespans->push_back (timespan);
+ if ((id == "selection" && *it == selection_range.get()) ||
+ (id == (*it)->id().to_s())) {
+ location = *it;
+ break;
}
}
+
+ if (!location) { continue; }
+
+ ExportTimespanPtr timespan = handler->add_timespan();
+ timespan->set_name (location->name());
+ timespan->set_range_id (location->id().to_s());
+ timespan->set_range (location->start(), location->end());
+ state->timespans->push_back (timespan);
}
if ((prop = root.property ("format"))) {
state->time_format = (TimeFormat) string_2_enum (prop->value(), TimeFormat);
}
+ if (state->timespans->empty()) {
+ return TimespanStatePtr();
+ }
+
return state;
}
XMLNode * span;
update_ranges ();
-
for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
if ((span = root.add_child ("Range"))) {
span->add_property ("id", (*it)->range_id());
/* Session */
- session_range->set_name (_("Session"));
- session_range->set (session.current_start_frame(), session.current_end_frame());
- ranges->push_back (session_range.get());
+ Location * session_range = session.locations()->session_range_location();
+ if (session_range) {
+ ranges->push_back (session_range);
+ }
/* Selection */
channel_configs.push_back (config);
// Add master outs as default
+ if (!session.master_out()) { return false; }
+
IO* master_out = session.master_out()->output().get();
if (!master_out) { return false; }
format.reset (new ExportFormatSpecification (*original));
} else {
format = handler->add_format();
- format->set_name ("empty format");
+ format->set_name (_("empty format"));
}
std::string path = save_format_to_disk (format);
ExportProfileManager::deserialize_format (XMLNode & root)
{
XMLProperty * prop;
- UUID id;
+ PBD::UUID id;
if ((prop = root.property ("id"))) {
id = prop->value();