Specify correct number of channels for LEQ(m) analyses of single pieces of content...
[dcpomatic.git] / src / lib / dcp_examiner.cc
index ca851db2d941d3dda1cdaacce36b3f2f603f165a..b431cec26b94a3fc13d0504a2ff6e4329c949a3a 100644 (file)
@@ -53,7 +53,10 @@ using std::cout;
 using std::runtime_error;
 using std::map;
 using std::shared_ptr;
+using std::string;
 using std::dynamic_pointer_cast;
+using boost::optional;
+
 
 DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
        : DCP (content, tolerant)
@@ -108,6 +111,15 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
        _name = cpl->content_title_text ();
        _content_kind = cpl->content_kind ();
 
+       auto try_to_parse_language = [](optional<string> lang) -> boost::optional<dcp::LanguageTag> {
+               try {
+                       if (lang) {
+                               return dcp::LanguageTag (*lang);
+                       }
+               } catch (...) {}
+               return boost::none;
+       };
+
        for (auto i: cpl->reels()) {
 
                if (i->main_picture ()) {
@@ -159,6 +171,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                        }
 
                        _audio_length += i->main_sound()->actual_duration();
+                       _audio_language = try_to_parse_language (asset->language());
                }
 
                if (i->main_subtitle ()) {
@@ -169,6 +182,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                        }
 
                        _text_count[static_cast<int>(TextType::OPEN_SUBTITLE)] = 1;
+                       _open_subtitle_language = try_to_parse_language (i->main_subtitle()->language());
                }
 
                for (auto j: i->closed_captions()) {
@@ -179,11 +193,11 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                        }
 
                        _text_count[static_cast<int>(TextType::CLOSED_CAPTION)]++;
-                       _dcp_text_tracks.push_back (DCPTextTrack(j->annotation_text(), j->language().get_value_or(_("Unknown"))));
+                       _dcp_text_tracks.push_back (DCPTextTrack(j->annotation_text(), try_to_parse_language(j->language())));
                }
 
                if (i->main_markers ()) {
-                       map<dcp::Marker, dcp::Time> rm = i->main_markers()->get();
+                       auto rm = i->main_markers()->get();
                        _markers.insert (rm.begin(), rm.end());
                }
 
@@ -263,8 +277,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content, bool tolerant)
                _kdm_valid = false;
        }
 
-       DCPOMATIC_ASSERT (cpl->standard ());
-       _standard = cpl->standard().get();
+       _standard = cpl->standard();
        _three_d = !cpl->reels().empty() && cpl->reels().front()->main_picture() &&
                dynamic_pointer_cast<dcp::StereoPictureAsset> (cpl->reels().front()->main_picture()->asset());
        _ratings = cpl->ratings();