/*
- Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
+/** @file src/lib/audio_mapping.h
+ * @brief AudioMapping class.
+ */
+
+#ifndef DCPOMATIC_AUDIO_MAPPING_H
+#define DCPOMATIC_AUDIO_MAPPING_H
+
#include <vector>
-#include <map>
-#include <boost/optional.hpp>
-#include <libdcp/types.h>
+#include <boost/shared_ptr.hpp>
+#include <dcp/types.h>
+#include <libcxml/cxml.h>
-class AudioMapping
-{
-public:
- virtual boost::optional<libdcp::Channel> source_to_dcp (int c) const = 0;
- virtual boost::optional<int> dcp_to_source (libdcp::Channel c) const = 0;
-};
+namespace xmlpp {
+ class Node;
+}
+
+namespace cxml {
+ class Node;
+}
-class AutomaticAudioMapping : public AudioMapping
+/** @class AudioMapping.
+ * @brief A many-to-many mapping from some content channels to DCP channels.
+ *
+ * The number of content channels is set on construction and fixed,
+ * and then each of those content channels are mapped to each DCP channel
+ * by a linear gain.
+ */
+class AudioMapping
{
public:
- AutomaticAudioMapping (int);
+ AudioMapping ();
+ AudioMapping (int channels);
+ AudioMapping (cxml::ConstNodePtr, int);
- boost::optional<libdcp::Channel> source_to_dcp (int c) const;
- boost::optional<int> dcp_to_source (libdcp::Channel c) const;
- int dcp_channels () const;
+ /* Default copy constructor is fine */
-private:
- int _source_channels;
-};
+ void as_xml (xmlpp::Node *) const;
-class ConfiguredAudioMapping : public AudioMapping
-{
-public:
- boost::optional<libdcp::Channel> source_to_dcp (int c) const;
- boost::optional<int> dcp_to_source (libdcp::Channel c) const;
+ void make_default ();
+
+ void set (int, dcp::Channel, float);
+ float get (int, dcp::Channel) const;
+ int content_channels () const {
+ return _content_channels;
+ }
+
+ std::string digest () const;
+
private:
- std::map<int, libdcp::Channel> _source_to_dcp;
+ void setup (int);
+
+ int _content_channels;
+ std::vector<std::vector<float> > _gain;
};
+
+#endif