From 9c44c5fa8eaf00ef4e61c08273b8df55047ac082 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 19 Oct 2018 22:50:47 +0100 Subject: [PATCH] Add decryption support. --- src/lib/ffmpeg.cc | 3 +++ src/lib/ffmpeg_content.cc | 5 ++++- src/lib/ffmpeg_content.h | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 5171166d5..1502b3de9 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -128,6 +128,9 @@ FFmpeg::setup_general () */ av_dict_set (&options, "analyzeduration", raw_convert (5 * 60 * 1000000).c_str(), 0); av_dict_set (&options, "probesize", raw_convert (5 * 60 * 1000000).c_str(), 0); + if (_ffmpeg_content->decryption_key()) { + av_dict_set (&options, "decryption_key", _ffmpeg_content->decryption_key()->c_str(), 0); + } int e = avformat_open_input (&_format_context, 0, 0, &options); if (e < 0) { diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 961c0b0a3..70b867172 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -125,7 +125,7 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no _color_trc = get_optional_enum(node, "ColorTransferCharacteristic"); _colorspace = get_optional_enum(node, "Colorspace"); _bits_per_pixel = node->optional_number_child ("BitsPerPixel"); - + _decryption_key = node->optional_string_child ("DecryptionKey"); } FFmpegContent::FFmpegContent (shared_ptr film, vector > c) @@ -246,6 +246,9 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const if (_bits_per_pixel) { node->add_child("BitsPerPixel")->add_child_text (raw_convert (*_bits_per_pixel)); } + if (_decryption_key) { + node->add_child("DecryptionKey")->add_child_text (_decryption_key.get()); + } } void diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 64f6f9ff8..87a892e68 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -93,6 +93,11 @@ public: void signal_subtitle_stream_changed (); + boost::optional decryption_key () const { + boost::mutex::scoped_lock lm (_mutex); + return _decryption_key; + } + private: void add_properties (std::list &) const; @@ -110,6 +115,7 @@ private: boost::optional _color_trc; boost::optional _colorspace; boost::optional _bits_per_pixel; + boost::optional _decryption_key; }; #endif -- 2.30.2