Bump version
[dcpomatic.git] / src / lib / dcp_content.cc
index 2eead3ee00d38be0212c411a7c695bfab771a0a5..fd092593514f76401699efcbbfe62b5f55c7817d 100644 (file)
@@ -60,6 +60,7 @@ int const DCPContentProperty::REFERENCE_VIDEO    = 602;
 int const DCPContentProperty::REFERENCE_AUDIO    = 603;
 int const DCPContentProperty::REFERENCE_SUBTITLE = 604;
 int const DCPContentProperty::NAME               = 605;
+int const DCPContentProperty::HAS_SUBTITLES      = 606;
 
 DCPContent::DCPContent (shared_ptr<const Film> film, boost::filesystem::path p)
        : Content (film)
@@ -129,10 +130,10 @@ void
 DCPContent::read_directory (boost::filesystem::path p)
 {
        for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
-               if (boost::filesystem::is_regular_file (i->path ())) {
-                       _paths.push_back (i->path ());
+               if (boost::filesystem::is_regular_file (i->path())) {
+                       _paths.push_back (i->path());
                } else if (boost::filesystem::is_directory (i->path ())) {
-                       read_directory (i->path ());
+                       read_directory (i->path());
                }
        }
 }
@@ -143,8 +144,11 @@ DCPContent::examine (shared_ptr<Job> job)
        bool const needed_assets = needs_assets ();
        bool const needed_kdm = needs_kdm ();
        string const old_name = name ();
+       bool had_subtitles = static_cast<bool> (subtitle);
 
-       job->set_progress_unknown ();
+       if (job) {
+               job->set_progress_unknown ();
+       }
        Content::examine (job);
 
        shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
@@ -163,12 +167,16 @@ DCPContent::examine (shared_ptr<Job> job)
 
        signal_changed (AudioContentProperty::STREAMS);
 
+       bool has_subtitles = false;
        {
                boost::mutex::scoped_lock lm (_mutex);
                _name = examiner->name ();
                if (examiner->has_subtitles ()) {
                        subtitle.reset (new SubtitleContent (this));
+               } else {
+                       subtitle.reset ();
                }
+               has_subtitles = static_cast<bool> (subtitle);
                _encrypted = examiner->encrypted ();
                _needs_assets = examiner->needs_assets ();
                _kdm_valid = examiner->kdm_valid ();
@@ -178,6 +186,10 @@ DCPContent::examine (shared_ptr<Job> job)
                _reel_lengths = examiner->reel_lengths ();
        }
 
+       if (had_subtitles != has_subtitles) {
+               signal_changed (DCPContentProperty::HAS_SUBTITLES);
+       }
+
        if (needed_assets != needs_assets ()) {
                signal_changed (DCPContentProperty::NEEDS_ASSETS);
        }
@@ -316,7 +328,7 @@ DCPContent::needs_assets () const
 vector<boost::filesystem::path>
 DCPContent::directories () const
 {
-       return dcp::DCP::directories_from_files (paths ());
+       return dcp::DCP::directories_from_files (paths());
 }
 
 void
@@ -481,7 +493,7 @@ DCPContent::can_reference_audio (list<string>& why_not) const
 {
        shared_ptr<DCPDecoder> decoder;
        try {
-               decoder.reset (new DCPDecoder (shared_from_this(), film()->log()));
+               decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false));
        } catch (dcp::DCPReadError) {
                /* We couldn't read the DCP, so it's probably missing */
                return false;
@@ -502,7 +514,7 @@ DCPContent::can_reference_subtitle (list<string>& why_not) const
 {
        shared_ptr<DCPDecoder> decoder;
        try {
-               decoder.reset (new DCPDecoder (shared_from_this(), film()->log()));
+               decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false));
        } catch (dcp::DCPReadError) {
                /* We couldn't read the DCP, so it's probably missing */
                return false;