Fix macOS build warning.
[libdcp.git] / src / verify.cc
index ce79bc2e1aa64380888aeeb125b9c5cd48f0032f..c9d9b24d04e6081663490b77f6d67de1011c836c 100644 (file)
 #include "raw_convert.h"
 #include "reel.h"
 #include "reel_closed_caption_asset.h"
+#include "reel_interop_subtitle_asset.h"
 #include "reel_markers_asset.h"
 #include "reel_picture_asset.h"
 #include "reel_sound_asset.h"
+#include "reel_smpte_subtitle_asset.h"
 #include "reel_subtitle_asset.h"
 #include "smpte_subtitle_asset.h"
 #include "stereo_picture_asset.h"
@@ -154,22 +156,22 @@ private:
 class DCPErrorHandler : public ErrorHandler
 {
 public:
-       void warning(const SAXParseException& e)
+       void warning(const SAXParseException& e) override
        {
                maybe_add (XMLValidationError(e));
        }
 
-       void error(const SAXParseException& e)
+       void error(const SAXParseException& e) override
        {
                maybe_add (XMLValidationError(e));
        }
 
-       void fatalError(const SAXParseException& e)
+       void fatalError(const SAXParseException& e) override
        {
                maybe_add (XMLValidationError(e));
        }
 
-       void resetErrors() {
+       void resetErrors() override {
                _errors.clear ();
        }
 
@@ -244,7 +246,7 @@ public:
                add("http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL", "SMPTE-429-10-2008.xsd");
        }
 
-       InputSource* resolveEntity(XMLCh const *, XMLCh const * system_id)
+       InputSource* resolveEntity(XMLCh const *, XMLCh const * system_id) override
        {
                if (!system_id) {
                        return 0;
@@ -991,7 +993,13 @@ verify_text_timing (vector<shared_ptr<Reel>> reels, vector<VerificationNote>& no
                                return static_cast<bool>(reel->main_subtitle());
                        },
                        [](shared_ptr<Reel> reel) {
-                               return reel->main_subtitle()->asset()->raw_xml();
+                               auto interop = dynamic_pointer_cast<ReelInteropSubtitleAsset>(reel->main_subtitle());
+                               if (interop) {
+                                       return interop->asset()->raw_xml();
+                               }
+                               auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(reel->main_subtitle());
+                               DCP_ASSERT (smpte);
+                               return smpte->asset()->raw_xml();
                        },
                        [](shared_ptr<Reel> reel) {
                                return reel->main_subtitle()->actual_duration();
@@ -1080,14 +1088,9 @@ pkl_has_encrypted_assets (shared_ptr<DCP> dcp, shared_ptr<PKL> pkl)
        for (auto i: dcp->cpls()) {
                for (auto j: i->reel_file_assets()) {
                        if (j->asset_ref().resolved()) {
-                               /* It's a bit surprising / broken but Interop subtitle assets are represented
-                                * in reels by ReelSubtitleAsset which inherits ReelFileAsset, so it's possible for
-                                * ReelFileAssets to have assets which are not MXFs.
-                                */
-                               if (auto asset = dynamic_pointer_cast<MXF>(j->asset_ref().asset())) {
-                                       if (asset->encrypted()) {
-                                               encrypted.push_back(j->asset_ref().id());
-                                       }
+                               auto mxf = dynamic_pointer_cast<MXF>(j->asset_ref().asset());
+                               if (mxf && mxf->encrypted()) {
+                                       encrypted.push_back(j->asset_ref().id());
                                }
                        }
                }
@@ -1234,7 +1237,7 @@ dcp::verify (
                                                notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_INTRINSIC_DURATION, i->id()});
                                        }
                                        auto file_asset = dynamic_pointer_cast<ReelFileAsset>(i);
-                                       if (file_asset && !file_asset->hash()) {
+                                       if (i->encryptable() && !file_asset->hash()) {
                                                notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_HASH, i->id()});
                                        }
                                }