- /* Get intrinsic duration */
- _intrinsic_duration = descriptor.ContainerDuration;
- } else {
- /* Guess intrinsic duration */
- _intrinsic_duration = latest_subtitle_out().as_editable_units (_edit_rate.numerator / _edit_rate.denominator);
+
+void
+SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader> reader)
+{
+ ASDCP::TimedText::TimedTextDescriptor descriptor;
+ reader->FillTimedTextDescriptor (descriptor);
+
+ _intrinsic_duration = descriptor.ContainerDuration;
+ /* The thing which is called AssetID in the descriptor is also known as the
+ * ResourceID of the MXF. We store that, at present just for verification
+ * purposes.
+ */
+ char id[64];
+ Kumu::bin2UUIDhex (descriptor.AssetID, ASDCP::UUIDlen, id, sizeof(id));
+ _resource_id = id;
+}
+
+
+void
+SMPTESubtitleAsset::set_key (Key key)
+{
+ /* See if we already have a key; if we do, and we have a file, we'll already
+ have read that file.
+ */
+ auto const had_key = static_cast<bool>(_key);
+ auto const had_key_id = static_cast<bool>(_key_id);
+
+ MXF::set_key (key);
+
+ if (!had_key_id || !_file || had_key) {
+ /* Either we don't have any data to read, it wasn't
+ encrypted, or we've already read it, so we don't
+ need to do anything else.
+ */
+ return;