Remove unnecessary Playlist argument to Film::audio_analysis_path.
[dcpomatic.git] / src / lib / film.cc
index 90bfad6a2cbba3c7d0b80e8e2fd08c58920b5b98..769ef72b6f56b2337469cde50c61a86d439fd170 100644 (file)
@@ -42,6 +42,7 @@
 #include "environment_info.h"
 #include "raw_convert.h"
 #include "audio_processor.h"
+#include "md5_digester.h"
 #include <libcxml/cxml.h>
 #include <dcp/cpl.h>
 #include <dcp/signer.h>
@@ -71,6 +72,7 @@ using std::map;
 using std::vector;
 using std::setfill;
 using std::min;
+using std::max;
 using std::make_pair;
 using std::endl;
 using std::cout;
@@ -134,7 +136,7 @@ Film::Film (boost::filesystem::path dir, bool log)
        set_isdcf_date_today ();
 
        _playlist_changed_connection = _playlist->Changed.connect (bind (&Film::playlist_changed, this));
-       _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
+       _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2, _3));
        
        /* Make state.directory a complete path without ..s (where possible)
           (Code swiped from Adam Bowen on stackoverflow)
@@ -219,13 +221,13 @@ Film::info_file () const
 }
 
 boost::filesystem::path
-Film::internal_video_mxf_dir () const
+Film::internal_video_asset_dir () const
 {
        return dir ("video");
 }
 
 boost::filesystem::path
-Film::internal_video_mxf_filename () const
+Film::internal_video_asset_filename () const
 {
        return video_identifier() + ".mxf";
 }
@@ -247,9 +249,28 @@ Film::filename_safe_name () const
 }
 
 boost::filesystem::path
-Film::audio_analysis_dir () const
+Film::audio_analysis_path () const
 {
-       return dir ("analysis");
+       boost::filesystem::path p = dir ("analysis");
+
+       MD5Digester digester;
+       BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+               shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i);
+               if (!ac) {
+                       continue;
+               }
+               
+               digester.add (ac->digest ());
+               digester.add (ac->audio_mapping().digest ());
+               digester.add (ac->audio_gain ());
+       }
+
+       if (audio_processor ()) {
+               digester.add (audio_processor()->id ());
+       }
+
+       p /= digester.get ();
+       return p;
 }
 
 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
@@ -785,6 +806,7 @@ Film::set_audio_processor (AudioProcessor const * processor)
 {
        _audio_processor = processor;
        signal_changed (AUDIO_PROCESSOR);
+       signal_changed (AUDIO_CHANNELS);
 }
 
 void
@@ -873,12 +895,6 @@ Film::cpls () const
        return out;
 }
 
-shared_ptr<Player>
-Film::make_player () const
-{
-       return shared_ptr<Player> (new Player (shared_from_this (), _playlist));
-}
-
 void
 Film::set_signed (bool s)
 {
@@ -997,7 +1013,7 @@ Film::active_frame_rate_change (DCPTime t) const
 }
 
 void
-Film::playlist_content_changed (boost::weak_ptr<Content> c, int p)
+Film::playlist_content_changed (boost::weak_ptr<Content> c, int p, bool frequent)
 {
        if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
                set_video_frame_rate (_playlist->best_dcp_frame_rate ());
@@ -1005,7 +1021,7 @@ Film::playlist_content_changed (boost::weak_ptr<Content> c, int p)
                signal_changed (NAME);
        }
 
-       emit (boost::bind (boost::ref (ContentChanged), c, p));
+       emit (boost::bind (boost::ref (ContentChanged), c, p, frequent));
 }
 
 void
@@ -1112,8 +1128,8 @@ bool
 Film::should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const
 {
        /* Create a test file and see if we can hard-link it */
-       boost::filesystem::path test = internal_video_mxf_dir() / "test";
-       boost::filesystem::path test2 = internal_video_mxf_dir() / "test2";
+       boost::filesystem::path test = internal_video_asset_dir() / "test";
+       boost::filesystem::path test2 = internal_video_asset_dir() / "test2";
        can_hard_link = true;
        FILE* f = fopen_boost (test, "w");
        if (f) {
@@ -1127,7 +1143,7 @@ Film::should_be_enough_disk_space (double& required, double& available, bool& ca
                boost::filesystem::remove (test2);
        }
 
-       boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ());
+       boost::filesystem::space_info s = boost::filesystem::space (internal_video_asset_dir ());
        required = double (required_disk_space ()) / 1073741824.0f;
        if (!can_hard_link) {
                required *= 2;