summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-10-08 12:08:10 +0200
committerCarl Hetherington <cth@carlh.net>2021-10-08 12:48:43 +0200
commitaab6630b945371038cc49e456a766ae45cab1f47 (patch)
treea82f7ceaff2d091bff154e604b9c3e861b2994af /src
parent99d2243b7674c0673fee5f6f6cd4a65da16db37c (diff)
Fix problems when adding KDMs to a VF, before adding the OV.v1.8.2
If we have a KDM which contains keys for all the assets referred to by a VF (even the ones in the OV) we would previously throw an exception because we tried to give the KDM to the resolved assets when it was given to the Reel. Here we change things so that the addition of KDMs to assets can be deferred if the asset is not yet resolved.
Diffstat (limited to 'src')
-rw-r--r--src/reel.cc28
-rw-r--r--src/reel.h9
-rw-r--r--src/sound_asset.h4
3 files changed, 30 insertions, 11 deletions
diff --git a/src/reel.cc b/src/reel.cc
index daa1067c..cca62ed8 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -312,28 +312,38 @@ Reel::all_encrypted () const
void
Reel::add (DecryptedKDM const & kdm)
{
- auto keys = kdm.keys ();
+ give_kdm_to_assets (kdm);
+ /* We have to keep the KDMs that we are given, as they will not be passed to unresolved assets.
+ * After we resolve some assets we will re-call give_kdm_to_assets() with all the KDMs that
+ * we have been given so far.
+ */
+ _kdms.push_back (kdm);
+}
+
- for (auto const& i: keys) {
- if (_main_picture && i.id() == _main_picture->key_id()) {
+void
+Reel::give_kdm_to_assets (DecryptedKDM const & kdm)
+{
+ for (auto const& i: kdm.keys()) {
+ if (_main_picture && i.id() == _main_picture->key_id() && _main_picture->asset_ref().resolved()) {
_main_picture->asset()->set_key (i.key());
}
- if (_main_sound && i.id() == _main_sound->key_id()) {
+ if (_main_sound && i.id() == _main_sound->key_id() && _main_sound->asset_ref().resolved()) {
_main_sound->asset()->set_key (i.key());
}
if (_main_subtitle) {
auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(_main_subtitle);
- if (smpte && i.id() == smpte->key_id()) {
+ if (smpte && i.id() == smpte->key_id() && smpte->asset_ref().resolved()) {
smpte->smpte_asset()->set_key(i.key());
}
}
for (auto j: _closed_captions) {
auto smpte = dynamic_pointer_cast<ReelSMPTESubtitleAsset>(j);
- if (smpte && i.id() == smpte->key_id()) {
+ if (smpte && i.id() == smpte->key_id() && smpte->asset_ref().resolved()) {
smpte->smpte_asset()->set_key(i.key());
}
}
- if (_atmos && i.id() == _atmos->key_id()) {
+ if (_atmos && i.id() == _atmos->key_id() && _atmos->asset_ref().resolved()) {
_atmos->asset()->set_key (i.key());
}
}
@@ -424,6 +434,10 @@ Reel::resolve_refs (vector<shared_ptr<Asset>> assets)
if (_atmos) {
_atmos->asset_ref().resolve (assets);
}
+
+ for (auto const& i: _kdms) {
+ give_kdm_to_assets (i);
+ }
}
diff --git a/src/reel.h b/src/reel.h
index d3ea7f0c..9a3c38d3 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -41,11 +41,12 @@
#define LIBDCP_REEL_H
+#include "decrypted_kdm.h"
#include "key.h"
-#include "types.h"
#include "ref.h"
-#include <memory>
+#include "types.h"
#include <boost/function.hpp>
+#include <memory>
namespace cxml {
@@ -136,12 +137,16 @@ public:
void resolve_refs (std::vector<std::shared_ptr<Asset>>);
private:
+ void give_kdm_to_assets (dcp::DecryptedKDM const& kdm);
+
std::shared_ptr<ReelPictureAsset> _main_picture;
std::shared_ptr<ReelSoundAsset> _main_sound;
std::shared_ptr<ReelSubtitleAsset> _main_subtitle;
std::shared_ptr<ReelMarkersAsset> _main_markers;
std::vector<std::shared_ptr<ReelClosedCaptionAsset>> _closed_captions;
std::shared_ptr<ReelAtmosAsset> _atmos;
+
+ std::vector<dcp::DecryptedKDM> _kdms;
};
}
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 799e671c..c943d88b 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -55,7 +55,7 @@ namespace dcp {
extern std::shared_ptr<dcp::SoundAsset> simple_sound (
- boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate
+ boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate, boost::optional<dcp::Key>
);
@@ -112,7 +112,7 @@ public:
private:
friend class SoundAssetWriter;
friend std::shared_ptr<dcp::SoundAsset> (::simple_sound) (
- boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate
+ boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language, int frames, int sample_rate, boost::optional<dcp::Key>
);
std::string pkl_type (Standard standard) const override {