Fix macOS build warning.
[libdcp.git] / src / verify.cc
index e27f6f3606c256fe7437d28131ad15aaca91ea92..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;
@@ -377,7 +379,7 @@ enum class VerifyAssetResult {
 
 
 static VerifyAssetResult
-verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelEncryptableAsset> reel_file_asset, function<void (float)> progress)
+verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelFileAsset> reel_file_asset, function<void (float)> progress)
 {
        auto const actual_hash = reel_file_asset->asset_ref()->hash(progress);
 
@@ -422,7 +424,7 @@ verify_language_tag (string tag, vector<VerificationNote>& notes)
 
 
 static void
-verify_picture_asset (shared_ptr<const ReelEncryptableAsset> reel_file_asset, boost::filesystem::path file, vector<VerificationNote>& notes, function<void (float)> progress)
+verify_picture_asset (shared_ptr<const ReelFileAsset> reel_file_asset, boost::filesystem::path file, vector<VerificationNote>& notes, function<void (float)> progress)
 {
        int biggest_frame = 0;
        auto asset = dynamic_pointer_cast<PictureAsset>(reel_file_asset->asset_ref().asset());
@@ -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 ReelEncryptableAsset, so it's possible for
-                                * ReelEncryptableAssets 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());
                                }
                        }
                }
@@ -1233,8 +1236,8 @@ dcp::verify (
                                        if ((i->intrinsic_duration() * i->edit_rate().denominator / i->edit_rate().numerator) < 1) {
                                                notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_INTRINSIC_DURATION, i->id()});
                                        }
-                                       auto file_asset = dynamic_pointer_cast<ReelEncryptableAsset>(i);
-                                       if (file_asset && !file_asset->hash()) {
+                                       auto file_asset = dynamic_pointer_cast<ReelFileAsset>(i);
+                                       if (i->encryptable() && !file_asset->hash()) {
                                                notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::MISSING_HASH, i->id()});
                                        }
                                }