Emit no audio from DCPs if none is mapped
[dcpomatic.git] / src / lib / dcp_examiner.h
index 6b88a3c0d412d13d2cf636b7ac49854a28dca682..04fa31ea4281c611e16ed237616aff749d76e328 100644 (file)
@@ -38,7 +38,7 @@ class DCPContent;
 class DCPExaminer : public VideoExaminer, public AudioExaminer
 {
 public:
-       explicit DCPExaminer (std::shared_ptr<const DCPContent>, bool tolerant);
+       DCPExaminer(std::shared_ptr<const DCPContent>, bool tolerant);
 
        bool has_video () const override {
                return _has_video;
@@ -48,10 +48,8 @@ public:
                return _video_frame_rate;
        }
 
-       dcp::Size video_size () const override {
-               DCPOMATIC_ASSERT (_has_video);
-               DCPOMATIC_ASSERT (_video_size);
-               return *_video_size;
+       boost::optional<dcp::Size> video_size() const override {
+               return _video_size;
        }
 
        Frame video_length () const override {
@@ -90,6 +88,10 @@ public:
                return _audio_channels.get_value_or (0);
        }
 
+       int active_audio_channels() const {
+               return _active_audio_channels.get_value_or(0);
+       }
+
        Frame audio_length () const override {
                return _audio_length;
        }
@@ -103,10 +105,12 @@ public:
        }
 
        /** @param type TEXT_OPEN_SUBTITLE or TEXT_CLOSED_CAPTION.
-        *  @return Number of assets of this type in this DCP.
+        *  @return the number of "streams" of this type in the DCP.
+        *  Reels do not affect the return value of this method: if a DCP
+        *  has any subtitles, type=TEXT_OPEN_SUBTITLE will return 1.
         */
        int text_count (TextType type) const {
-               return _text_count[static_cast<int>(type)];
+               return _text_count[type];
        }
 
        boost::optional<dcp::LanguageTag> open_subtitle_language () const {
@@ -167,16 +171,14 @@ public:
                return _atmos_edit_rate;
        }
 
-       /** @return fonts in each reel */
-       std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> fonts() const {
-               return _fonts;
-       }
+       void add_fonts(std::shared_ptr<TextContent> content);
 
 private:
        boost::optional<double> _video_frame_rate;
        boost::optional<dcp::Size> _video_size;
        Frame _video_length = 0;
        boost::optional<int> _audio_channels;
+       boost::optional<int> _active_audio_channels;
        boost::optional<int> _audio_frame_rate;
        Frame _audio_length = 0;
        std::string _name;
@@ -186,7 +188,7 @@ private:
        bool _has_audio = false;
        boost::optional<dcp::LanguageTag> _audio_language;
        /** number of different assets of each type (OCAP/CCAP) */
-       int _text_count[static_cast<int>(TextType::COUNT)];
+       EnumIndexedVector<int, TextType> _text_count;
        boost::optional<dcp::LanguageTag> _open_subtitle_language;
        /** the DCPTextTracks for each of our CCAPs */
        std::vector<DCPTextTrack> _dcp_text_tracks;
@@ -204,5 +206,19 @@ private:
        bool _has_atmos = false;
        Frame _atmos_length = 0;
        dcp::Fraction _atmos_edit_rate;
-       std::vector<std::vector<std::shared_ptr<dcpomatic::Font>>> _fonts;
+
+       struct Font
+       {
+               Font(int reel_index_, std::string asset_id_, std::shared_ptr<dcpomatic::Font> font_)
+                       : reel_index(reel_index_)
+                       , asset_id(asset_id_)
+                       , font(font_)
+               {}
+
+               int reel_index;
+               std::string asset_id;
+               std::shared_ptr<dcpomatic::Font> font;
+       };
+
+       std::vector<Font> _fonts;
 };