+
+ /* Get intrinsic duration */
+ _intrinsic_duration = descriptor.ContainerDuration;
+}
+
+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.
+ */
+ bool const had_key = static_cast<bool> (_key);
+
+ MXF::set_key (key);
+
+ if (!_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;
+ }
+
+ /* Our data was encrypted; now we can decrypt it */
+
+ shared_ptr<ASDCP::TimedText::MXFReader> reader (new ASDCP::TimedText::MXFReader ());
+ Kumu::Result_t r = reader->OpenRead (_file->string().c_str ());
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (
+ DCPReadError (
+ String::compose ("Could not read encrypted subtitle MXF (%1)", static_cast<int> (r))
+ )
+ );
+ }
+
+ string s;
+ shared_ptr<DecryptionContext> dec (new DecryptionContext (key));
+ reader->ReadTimedTextResource (s, dec->decryption());
+ shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
+ xml->read_string (s);
+ parse_xml (xml);
+ read_mxf_descriptor (reader, dec);