Copy SingleStreamAudioContent into DCPContent and SndfileContent.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Apr 2016 17:39:56 +0000 (18:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 May 2016 10:50:29 +0000 (11:50 +0100)
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/single_stream_audio_content.cc [deleted file]
src/lib/single_stream_audio_content.h [deleted file]
src/lib/sndfile_content.cc
src/lib/sndfile_content.h
src/lib/wscript
src/wx/content_properties_dialog.cc

index 81068262b9fc87a5e312d12bfe95a9c4348c7ac8..a81a152c1865bd4ea36ff64afe434e7608112f2c 100644 (file)
@@ -42,6 +42,7 @@ using std::string;
 using std::cout;
 using std::distance;
 using std::pair;
+using std::vector;
 using std::list;
 using boost::shared_ptr;
 using boost::scoped_ptr;
@@ -54,7 +55,7 @@ int const DCPContentProperty::REFERENCE_SUBTITLE = 603;
 
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
-       , SingleStreamAudioContent (film)
+       , AudioContent (film)
        , _has_subtitles (false)
        , _encrypted (false)
        , _kdm_valid (false)
@@ -71,7 +72,8 @@ DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
 
 DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
-       , SingleStreamAudioContent (film, node, version)
+       , AudioContent (film, node)
+       , _audio_stream (new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
 {
        video.reset (new VideoContent (this, film, node, version));
        subtitle.reset (new SubtitleContent (this, film, node, version));
@@ -111,7 +113,16 @@ DCPContent::examine (shared_ptr<Job> job)
        shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
        video->take_from_video_examiner (examiner);
        set_default_colour_conversion ();
-       take_from_audio_examiner (examiner);
+
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
+               AudioMapping m = _audio_stream->mapping ();
+               film()->make_audio_mapping_default (m);
+               _audio_stream->set_mapping (m);
+       }
+
+       signal_changed (AudioContentProperty::AUDIO_STREAMS);
 
        {
                boost::mutex::scoped_lock lm (_mutex);
@@ -148,7 +159,9 @@ DCPContent::as_xml (xmlpp::Node* node) const
 
        Content::as_xml (node);
        video->as_xml (node);
-       SingleStreamAudioContent::as_xml (node);
+       AudioContent::as_xml (node);
+       node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_stream()->frame_rate ()));
+       audio_stream()->mapping().as_xml (node->add_child("AudioMapping"));
        subtitle->as_xml (node);
 
        boost::mutex::scoped_lock lm (_mutex);
@@ -213,7 +226,7 @@ DCPContent::directory () const
 void
 DCPContent::add_properties (list<UserProperty>& p) const
 {
-       SingleStreamAudioContent::add_properties (p);
+       AudioContent::add_properties (p);
 }
 
 void
@@ -347,3 +360,11 @@ DCPContent::subtitle_video_frame_rate () const
 {
        return video->video_frame_rate ();
 }
+
+vector<AudioStreamPtr>
+DCPContent::audio_streams () const
+{
+       vector<AudioStreamPtr> s;
+       s.push_back (_audio_stream);
+       return s;
+}
index 81432b6d310adc4d62a168e086d6753ce2d4b031..f3cd6bf65ae679eb05400355319bd8005059e72f 100644 (file)
@@ -24,7 +24,7 @@
  *  @brief DCPContent class.
  */
 
-#include "single_stream_audio_content.h"
+#include "audio_content.h"
 #include <libcxml/cxml.h>
 #include <dcp/encrypted_kdm.h>
 
@@ -40,7 +40,7 @@ public:
 /** @class DCPContent
  *  @brief An existing DCP used as input.
  */
-class DCPContent : public SingleStreamAudioContent
+class DCPContent : public AudioContent
 {
 public:
        DCPContent (boost::shared_ptr<const Film>, boost::filesystem::path p);
@@ -120,6 +120,12 @@ public:
 
        bool can_reference_subtitle (std::list<std::string> &) const;
 
+       std::vector<AudioStreamPtr> audio_streams () const;
+
+       AudioStreamPtr audio_stream () const {
+               return _audio_stream;
+       }
+
 protected:
        void add_properties (std::list<UserProperty>& p) const;
 
@@ -147,6 +153,8 @@ private:
         *  rather than by rewrapping.
         */
        bool _reference_subtitle;
+
+       boost::shared_ptr<AudioStream> _audio_stream;
 };
 
 #endif
diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc
deleted file mode 100644 (file)
index b1291df..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-    Copyright (C) 2014-2015 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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "single_stream_audio_content.h"
-#include "audio_examiner.h"
-#include "film.h"
-#include "raw_convert.h"
-#include <libxml++/libxml++.h>
-#include <iostream>
-
-#include "i18n.h"
-
-using std::string;
-using std::cout;
-using std::vector;
-using std::list;
-using std::pair;
-using boost::shared_ptr;
-
-SingleStreamAudioContent::SingleStreamAudioContent (shared_ptr<const Film> film)
-       : Content (film)
-       , AudioContent (film)
-{
-
-}
-
-SingleStreamAudioContent::SingleStreamAudioContent (shared_ptr<const Film> film, boost::filesystem::path p)
-       : Content (film, p)
-       , AudioContent (film, p)
-{
-
-}
-
-SingleStreamAudioContent::SingleStreamAudioContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
-       : Content (film, node)
-       , AudioContent (film, node)
-       , _audio_stream (new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
-{
-
-}
-
-void
-SingleStreamAudioContent::as_xml (xmlpp::Node* node) const
-{
-       AudioContent::as_xml (node);
-       node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_stream()->frame_rate ()));
-       audio_stream()->mapping().as_xml (node->add_child("AudioMapping"));
-}
-
-void
-SingleStreamAudioContent::take_from_audio_examiner (shared_ptr<AudioExaminer> examiner)
-{
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-               _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
-               AudioMapping m = _audio_stream->mapping ();
-               film()->make_audio_mapping_default (m);
-               _audio_stream->set_mapping (m);
-       }
-
-       signal_changed (AudioContentProperty::AUDIO_STREAMS);
-}
-
-vector<AudioStreamPtr>
-SingleStreamAudioContent::audio_streams () const
-{
-       vector<AudioStreamPtr> s;
-       s.push_back (_audio_stream);
-       return s;
-}
-
diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h
deleted file mode 100644 (file)
index 7ae6dba..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-    Copyright (C) 2014-2015 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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file  src/lib/single_stream_audio_content.h
- *  @brief SingleStreamAudioContent class.
- */
-
-#ifndef DCPOMATIC_SINGLE_STREAM_AUDIO_CONTENT_H
-#define DCPOMATIC_SINGLE_STREAM_AUDIO_CONTENT_H
-
-#include "audio_content.h"
-
-class AudioExaminer;
-
-/** @class SingleStreamAudioContent
- *  @brief A piece of AudioContent that has a single audio stream.
- */
-class SingleStreamAudioContent : public AudioContent
-{
-public:
-       SingleStreamAudioContent (boost::shared_ptr<const Film>);
-       SingleStreamAudioContent (boost::shared_ptr<const Film>, boost::filesystem::path);
-       SingleStreamAudioContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr node, int version);
-
-       void as_xml (xmlpp::Node* node) const;
-
-       std::vector<AudioStreamPtr> audio_streams () const;
-
-       AudioStreamPtr audio_stream () const {
-               return _audio_stream;
-       }
-
-       void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>);
-
-protected:
-       boost::shared_ptr<AudioStream> _audio_stream;
-};
-
-#endif
index f9eb62a2bb790a6e1e2c5841db82f751e8a36814..d8435613d6123a7a3bfa74a6448e4bada940aebf 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
 
 using std::string;
 using std::cout;
+using std::vector;
 using boost::shared_ptr;
 
 SndfileContent::SndfileContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film, p)
-       , SingleStreamAudioContent (film, p)
+       , AudioContent (film, p)
 {
 
 }
 
 SndfileContent::SndfileContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
-       , SingleStreamAudioContent (film, node, version)
+       , AudioContent (film, node)
        , _audio_length (node->number_child<Frame> ("AudioLength"))
+       , _audio_stream (new AudioStream (node->number_child<int> ("AudioFrameRate"), AudioMapping (node->node_child ("AudioMapping"), version)))
 {
 
 }
@@ -56,7 +58,9 @@ SndfileContent::as_xml (xmlpp::Node* node) const
 {
        node->add_child("Type")->add_child_text ("Sndfile");
        Content::as_xml (node);
-       SingleStreamAudioContent::as_xml (node);
+       AudioContent::as_xml (node);
+       node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_stream()->frame_rate ()));
+       audio_stream()->mapping().as_xml (node->add_child("AudioMapping"));
        node->add_child("AudioLength")->add_child_text (raw_convert<string> (audio_length ()));
 }
 
@@ -97,10 +101,16 @@ SndfileContent::examine (shared_ptr<Job> job)
 void
 SndfileContent::take_from_audio_examiner (shared_ptr<AudioExaminer> examiner)
 {
-       SingleStreamAudioContent::take_from_audio_examiner (examiner);
-
-       boost::mutex::scoped_lock lm (_mutex);
-       _audio_length = examiner->audio_length ();
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ()));
+               AudioMapping m = _audio_stream->mapping ();
+               film()->make_audio_mapping_default (m);
+               _audio_stream->set_mapping (m);
+               _audio_length = examiner->audio_length ();
+       }
+
+       signal_changed (AudioContentProperty::AUDIO_STREAMS);
 }
 
 DCPTime
@@ -109,3 +119,11 @@ SndfileContent::full_length () const
        FrameRateChange const frc (audio_video_frame_rate(), film()->video_frame_rate());
        return DCPTime::from_frames (audio_length() / frc.speed_up, audio_stream()->frame_rate ());
 }
+
+vector<AudioStreamPtr>
+SndfileContent::audio_streams () const
+{
+       vector<AudioStreamPtr> s;
+       s.push_back (_audio_stream);
+       return s;
+}
index 9dcf954b5e55b09b9c6e1a088dd78a80f0d370f2..5f89b7cc807fe712cc155646b7fe4118201a1777 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
 #ifndef DCPOMATIC_SNDFILE_CONTENT_H
 #define DCPOMATIC_SNDFILE_CONTENT_H
 
-#include "single_stream_audio_content.h"
+#include "audio_content.h"
 
-class SndfileContent : public SingleStreamAudioContent
+class AudioExaminer;
+
+class SndfileContent : public AudioContent
 {
 public:
        SndfileContent (boost::shared_ptr<const Film>, boost::filesystem::path);
@@ -42,6 +44,12 @@ public:
 
        void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>);
 
+       std::vector<AudioStreamPtr> audio_streams () const;
+
+       AudioStreamPtr audio_stream () const {
+               return _audio_stream;
+       }
+
        static bool valid_file (boost::filesystem::path);
 
 private:
@@ -51,6 +59,8 @@ private:
        }
 
        Frame _audio_length;
+
+       boost::shared_ptr<AudioStream> _audio_stream;
 };
 
 #endif
index d6d85af49b372f6d6fad8185ae13bfe30106bd7a..4104e57a70496856af7e5590e0b25055a45aa03e 100644 (file)
@@ -113,7 +113,6 @@ sources = """
           send_kdm_email_job.cc
           send_problem_report_job.cc
           server.cc
-          single_stream_audio_content.cc
           sndfile_base.cc
           sndfile_content.cc
           sndfile_decoder.cc
index fb583c751312595b1755d2d060f8bde1bb28b13e..bae4ff2415bc837fbe14e0559b1bebf86beb0d2f 100644 (file)
@@ -23,7 +23,6 @@
 #include "lib/content.h"
 #include "lib/video_content.h"
 #include "lib/audio_content.h"
-#include "lib/single_stream_audio_content.h"
 #include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>