X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_mapping.cc;h=3620001251ec688857c172c80c2883f1b8add42a;hb=d7b23d44dec9d6357619e8e009e564e475215470;hp=d0aa33657fb383c9fbddcdde996186a9485e4b92;hpb=a183c1776cfd020a37d028ebb0f641352f49697b;p=dcpomatic.git diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index d0aa33657..362000125 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -1,5 +1,3 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* Copyright (C) 2013 Carl Hetherington @@ -34,6 +32,7 @@ using boost::lexical_cast; using boost::dynamic_pointer_cast; AudioMapping::AudioMapping () + : _content_channels (0) { } @@ -42,13 +41,20 @@ AudioMapping::AudioMapping () * @param c Number of channels. */ AudioMapping::AudioMapping (int c) + : _content_channels (c) { - if (c == 1) { + +} + +void +AudioMapping::make_default () +{ + if (_content_channels == 1) { /* Mono -> Centre */ add (0, libdcp::CENTRE); } else { /* 1:1 mapping */ - for (int i = 0; i < c; ++i) { + for (int i = 0; i < _content_channels; ++i) { add (i, static_cast (i)); } } @@ -56,8 +62,10 @@ AudioMapping::AudioMapping (int c) AudioMapping::AudioMapping (shared_ptr node) { - list > const c = node->node_children ("Map"); - for (list >::const_iterator i = c.begin(); i != c.end(); ++i) { + _content_channels = node->number_child ("ContentChannels"); + + list const c = node->node_children ("Map"); + for (list::const_iterator i = c.begin(); i != c.end(); ++i) { add ((*i)->number_child ("ContentIndex"), static_cast ((*i)->number_child ("DCP"))); } } @@ -81,22 +89,11 @@ AudioMapping::dcp_to_content (libdcp::Channel d) const return c; } -list -AudioMapping::content_channels () const -{ - list c; - for (list >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) { - if (find (c.begin(), c.end(), i->first) == c.end ()) { - c.push_back (i->first); - } - } - - return c; -} - list AudioMapping::content_to_dcp (int c) const { + assert (c < _content_channels); + list d; for (list >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) { if (i->first == c) { @@ -110,6 +107,8 @@ AudioMapping::content_to_dcp (int c) const void AudioMapping::as_xml (xmlpp::Node* node) const { + node->add_child ("ContentChannels")->add_child_text (lexical_cast (_content_channels)); + for (list >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) { xmlpp::Node* t = node->add_child ("Map"); t->add_child ("ContentIndex")->add_child_text (lexical_cast (i->first));