diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-20 16:21:55 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-20 16:21:55 +0100 |
| commit | 0c66eaeac227d6aeb63a7a36e202ef87081dc222 (patch) | |
| tree | fe59970e8ca5d6bfc7859fa6f901b1f1ed04eb33 /src/lib/audio_mapping.cc | |
| parent | 56aa7eef1572e48c96ff198ee52a5a5fe17a6bf0 (diff) | |
Some basics of AudioMapping.
Diffstat (limited to 'src/lib/audio_mapping.cc')
| -rw-r--r-- | src/lib/audio_mapping.cc | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index e1fa0c220..d0aa33657 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -1,3 +1,5 @@ +/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ + /* Copyright (C) 2013 Carl Hetherington <cth@carlh.net> @@ -18,6 +20,7 @@ */ #include <boost/lexical_cast.hpp> +#include <libxml++/libxml++.h> #include <libcxml/cxml.h> #include "audio_mapping.h" @@ -30,23 +33,39 @@ using boost::shared_ptr; using boost::lexical_cast; using boost::dynamic_pointer_cast; -void -AudioMapping::add (int c, libdcp::Channel d) +AudioMapping::AudioMapping () { - _content_to_dcp.push_back (make_pair (c, d)); + } -/* XXX: this is grotty */ -int -AudioMapping::dcp_channels () const +/** Create a default AudioMapping for a given channel count. + * @param c Number of channels. + */ +AudioMapping::AudioMapping (int c) { - for (list<pair<int, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) { - if (((int) i->second) >= 2) { - return 6; + if (c == 1) { + /* Mono -> Centre */ + add (0, libdcp::CENTRE); + } else { + /* 1:1 mapping */ + for (int i = 0; i < c; ++i) { + add (i, static_cast<libdcp::Channel> (i)); } } +} + +AudioMapping::AudioMapping (shared_ptr<const cxml::Node> node) +{ + list<shared_ptr<cxml::Node> > const c = node->node_children ("Map"); + for (list<shared_ptr<cxml::Node> >::const_iterator i = c.begin(); i != c.end(); ++i) { + add ((*i)->number_child<int> ("ContentIndex"), static_cast<libdcp::Channel> ((*i)->number_child<int> ("DCP"))); + } +} - return 2; +void +AudioMapping::add (int c, libdcp::Channel d) +{ + _content_to_dcp.push_back (make_pair (c, d)); } list<int> @@ -97,12 +116,3 @@ AudioMapping::as_xml (xmlpp::Node* node) const t->add_child ("DCP")->add_child_text (lexical_cast<string> (i->second)); } } - -void -AudioMapping::set_from_xml (shared_ptr<const cxml::Node> node) -{ - list<shared_ptr<cxml::Node> > const c = node->node_children ("Map"); - for (list<shared_ptr<cxml::Node> >::const_iterator i = c.begin(); i != c.end(); ++i) { - add ((*i)->number_child<int> ("ContentIndex"), static_cast<libdcp::Channel> ((*i)->number_child<int> ("DCP"))); - } -} |
