2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "audio_mapping.h"
26 using boost::shared_ptr;
29 AudioMapping::add (Channel c, libdcp::Channel d)
31 _content_to_dcp.push_back (make_pair (c, d));
34 /* XXX: this is grotty */
36 AudioMapping::dcp_channels () const
38 for (list<pair<Channel, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) {
39 if (((int) i->second) > 2) {
47 list<AudioMapping::Channel>
48 AudioMapping::dcp_to_content (libdcp::Channel d) const
50 list<AudioMapping::Channel> c;
51 for (list<pair<Channel, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) {
53 c.push_back (i->first);
60 list<AudioMapping::Channel>
61 AudioMapping::content_channels () const
63 list<AudioMapping::Channel> c;
64 for (list<pair<Channel, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) {
65 if (find (c.begin(), c.end(), i->first) == c.end ()) {
66 c.push_back (i->first);
74 AudioMapping::content_to_dcp (Channel c) const
76 list<libdcp::Channel> d;
77 for (list<pair<Channel, libdcp::Channel> >::const_iterator i = _content_to_dcp.begin(); i != _content_to_dcp.end(); ++i) {
79 d.push_back (i->second);
87 operator== (AudioMapping::Channel const & a, AudioMapping::Channel const & b)
89 shared_ptr<const AudioContent> sa = a.content.lock ();
90 shared_ptr<const AudioContent> sb = b.content.lock ();
91 return sa == sb && a.index == b.index;