diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-10-08 12:08:10 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-10-08 12:48:43 +0200 |
| commit | aab6630b945371038cc49e456a766ae45cab1f47 (patch) | |
| tree | a82f7ceaff2d091bff154e604b9c3e861b2994af /src/reel.cc | |
| parent | 99d2243b7674c0673fee5f6f6cd4a65da16db37c (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/reel.cc')
| -rw-r--r-- | src/reel.cc | 28 |
1 files changed, 21 insertions, 7 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); + } } |
