+ case ASDCP::TimedText::MT_PNG:
+ {
+ auto j = _subtitles.begin();
+ while (j != _subtitles.end() && ((!dynamic_pointer_cast<SubtitleImage>(*j)) || dynamic_pointer_cast<SubtitleImage>(*j)->id() != id)) {
+ ++j;
+ }
+
+ if (j != _subtitles.end()) {
+ dynamic_pointer_cast<SubtitleImage>(*j)->set_png_image (ArrayData(data, buffer.Size()));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ _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.
+ */
+ 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))
+ )
+ );