Merge master.
[dcpomatic.git] / src / lib / audio_mapping.h
index 8804bde06174f8e9669a02a81ff207ecbd76310a..248d2570eca8a3eee084bfbfe4df957f85f55bf8 100644 (file)
 
 */
 
-#include <vector>
-#include <map>
-#include <boost/optional.hpp>
+#ifndef DCPOMATIC_AUDIO_MAPPING_H
+#define DCPOMATIC_AUDIO_MAPPING_H
+
+#include <list>
+#include <string>
 #include <libdcp/types.h>
+#include <boost/shared_ptr.hpp>
+#include "audio_content.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;
-};
-
-class AutomaticAudioMapping : public AudioMapping
-{
-public:
-       AutomaticAudioMapping (int);
+       void as_xml (xmlpp::Node *) const;
+       void set_from_xml (ContentList const &, boost::shared_ptr<const cxml::Node>);
+       
+       struct Channel {
+               Channel (boost::weak_ptr<const AudioContent> c, int i)
+                       : content (c)
+                       , index (i)
+               {}
+               
+               boost::weak_ptr<const AudioContent> content;
+               int index;
+       };
+
+       void add (Channel, libdcp::Channel);
 
-       boost::optional<libdcp::Channel> source_to_dcp (int c) const;
-       boost::optional<int> dcp_to_source (libdcp::Channel c) const;
        int dcp_channels () const;
-       
-private:
-       int _source_channels;
-};
+       std::list<Channel> dcp_to_content (libdcp::Channel) const;
+       std::list<std::pair<Channel, libdcp::Channel> > content_to_dcp () const {
+               return _content_to_dcp;
+       }
 
-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;
+       std::list<Channel> content_channels () const;
+       std::list<libdcp::Channel> content_to_dcp (Channel) const;
 
 private:
-       std::map<int, libdcp::Channel> _source_to_dcp;
+       std::list<std::pair<Channel, libdcp::Channel> > _content_to_dcp;
 };
+
+extern bool operator== (AudioMapping::Channel const &, AudioMapping::Channel const &);
+
+#endif