+
+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);
+
+ 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 */
+
+ auto reader = make_shared<ASDCP::TimedText::MXFReader>();
+ auto r = reader->OpenRead (_file->string().c_str ());
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (
+ ReadError (
+ String::compose ("Could not read encrypted subtitle MXF (%1)", static_cast<int> (r))
+ )
+ );
+ }
+
+ auto dec = make_shared<DecryptionContext>(key, Standard::SMPTE);
+ reader->ReadTimedTextResource (_raw_xml, dec->context(), dec->hmac());
+ auto xml = make_shared<cxml::Document>("SubtitleReel");
+ xml->read_string (_raw_xml);
+ parse_xml (xml);
+ read_mxf_descriptor (reader, dec);
+}
+
+
+vector<shared_ptr<LoadFontNode>>