diff --git a/inputstream.ffmpegdirect/addon.xml.in b/inputstream.ffmpegdirect/addon.xml.in
index 074e413..52015e6 100644
--- a/inputstream.ffmpegdirect/addon.xml.in
+++ b/inputstream.ffmpegdirect/addon.xml.in
@@ -10,7 +10,7 @@
name="ffmpegdirect"
extension=""
tags="true"
- listitemprops="program_number|stream_mode|open_mode|manifest_type|default_url|is_realtime_stream|playback_as_live|programme_start_time|programme_end_time|catchup_url_format_string|catchup_url_near_live_format_string|catchup_buffer_start_time|catchup_buffer_end_time|catchup_buffer_offset|catchup_terminates|catchup_granularity|timezone_shift|default_programme_duration|programme_catchup_id"
+ listitemprops="program_number|stream_mode|open_mode|manifest_type|default_url|is_realtime_stream|playback_as_live|programme_start_time|programme_end_time|catchup_url_format_string|catchup_url_near_live_format_string|catchup_buffer_start_time|catchup_buffer_end_time|catchup_buffer_offset|catchup_terminates|catchup_granularity|timezone_shift|default_programme_duration|programme_catchup_id|crypto_key|crypto_iv"
library_@PLATFORM@="@LIBRARY_FILENAME@" />
diff --git a/src/StreamManager.cpp b/src/StreamManager.cpp
index 59f58f5..7467969 100644
--- a/src/StreamManager.cpp
+++ b/src/StreamManager.cpp
@@ -154,6 +154,14 @@ bool InputStreamFFmpegDirect::Open(const kodi::addon::InputstreamProperty& props
{
m_properties.m_programmeCatchupId = prop.second;
}
+ else if (CRYPTO_KEY == prop.first)
+ {
+ m_properties.m_cryptoKey = prop.second;
+ }
+ else if (CRYPTO_IV == prop.first)
+ {
+ m_properties.m_cryptoIv = prop.second;
+ }
}
m_streamUrl = props.GetURL();
diff --git a/src/StreamManager.h b/src/StreamManager.h
index a067f09..ff1e285 100644
--- a/src/StreamManager.h
+++ b/src/StreamManager.h
@@ -35,6 +35,8 @@ static const std::string CATCHUP_GRANULARITY = "inputstream.ffmpegdirect.catchup
static const std::string TIMEZONE_SHIFT = "inputstream.ffmpegdirect.timezone_shift";
static const std::string DEFAULT_PROGRAMME_DURATION = "inputstream.ffmpegdirect.default_programme_duration";
static const std::string PROGRAMME_CATCHUP_ID = "inputstream.ffmpegdirect.programme_catchup_id";
+static const std::string CRYPTO_KEY = "inputstream.ffmpegdirect.crypto_key";
+static const std::string CRYPTO_IV = "inputstream.ffmpegdirect.crypto_iv";
class ATTRIBUTE_HIDDEN InputStreamFFmpegDirect
: public kodi::addon::CInstanceInputStream, ffmpegdirect::IManageDemuxPacket
diff --git a/src/stream/FFmpegStream.cpp b/src/stream/FFmpegStream.cpp
index 8fd9c00..824f876 100644
--- a/src/stream/FFmpegStream.cpp
+++ b/src/stream/FFmpegStream.cpp
@@ -132,6 +132,8 @@ FFmpegStream::FFmpegStream(IManageDemuxPacket* demuxPacketManager, const Propert
m_openMode(props.m_openMode),
m_streamMode(props.m_streamMode),
m_manifestType(props.m_manifestType),
+ m_cryptoKey(props.m_cryptoKey),
+ m_cryptoIv(props.m_cryptoIv),
m_curlInput(curlInput),
m_httpProxy(httpProxy),
m_paused(false)
@@ -674,21 +676,21 @@ bool FFmpegStream::Open(bool fileinfo)
//m_pInput = streamUrl;
strFile = m_streamUrl;//m_pInput->GetFileName();
- if (m_mimeType.length() > 0)
- {
- std::string content = m_mimeType;
- StringUtils::ToLower(content);
-
- /* check if we can get a hint from content */
- if (content.compare("video/x-vobsub") == 0)
- iformat = av_find_input_format("mpeg");
- else if (content.compare("video/x-dvd-mpeg") == 0)
- iformat = av_find_input_format("mpeg");
- else if (content.compare("video/mp2t") == 0)
- iformat = av_find_input_format("mpegts");
- else if (content.compare("multipart/x-mixed-replace") == 0)
- iformat = av_find_input_format("mjpeg");
- }
+// if (m_mimeType.length() > 0)
+// {
+// std::string content = m_mimeType;
+// StringUtils::ToLower(content);
+//
+// /* check if we can get a hint from content */
+// if (content.compare("video/x-vobsub") == 0)
+// iformat = av_find_input_format("mpeg");
+// else if (content.compare("video/x-dvd-mpeg") == 0)
+// iformat = av_find_input_format("mpeg");
+// else if (content.compare("video/mp2t") == 0)
+// iformat = av_find_input_format("mpegts");
+// else if (content.compare("multipart/x-mixed-replace") == 0)
+// iformat = av_find_input_format("mjpeg");
+// }
// open the demuxer
m_pFormatContext = avformat_alloc_context();
@@ -927,8 +929,12 @@ bool FFmpegStream::OpenWithFFmpeg(AVInputFormat* iformat, const AVIOInterruptCB&
if (!kodi::GetSettingBoolean("useFastOpenForManifestStreams") || m_manifestType.empty())
{
m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT;
- if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
+ int err = avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options);
+ if (err < 0)
{
+ char errbuf[128];
+ av_strerror(err, errbuf, 128);
+
Log(LOGLEVEL_DEBUG, "Error, could not open file %s", CURL::GetRedacted(strFile).c_str());
Dispose();
av_dict_free(&options);
@@ -2084,7 +2090,7 @@ AVDictionary* FFmpegStream::GetFFMpegOptionsFromInput()
AVDictionary* options = nullptr;
// For a local file we need the following protocol whitelist
- if (url.GetProtocol().empty() || url.IsProtocol("file"))
+// if (url.GetProtocol().empty() || url.IsProtocol("file"))
av_dict_set(&options, "protocol_whitelist", "file,http,https,tcp,tls,crypto", 0);
if (url.IsProtocol("http") || url.IsProtocol("https"))
@@ -2210,6 +2216,12 @@ AVDictionary* FFmpegStream::GetFFMpegOptionsFromInput()
av_dict_set(&options, "http_proxy", urlStream.str().c_str(), 0);
}
+ if (!m_cryptoKey.empty() && !m_cryptoIv.empty())
+ {
+ av_dict_set(&options, "decryption_key", m_cryptoKey.c_str(), 0);
+ av_dict_set(&options, "decryption_iv", m_cryptoIv.c_str(), 0);
+ }
+
return options;
}
diff --git a/src/stream/FFmpegStream.h b/src/stream/FFmpegStream.h
index 851b260..237f860 100644
--- a/src/stream/FFmpegStream.h
+++ b/src/stream/FFmpegStream.h
@@ -190,6 +190,8 @@ private:
std::string m_mimeType;
std::string m_programProperty;
std::string m_manifestType;
+ std::string m_cryptoKey;
+ std::string m_cryptoIv;
bool m_opened;
HttpProxy m_httpProxy;
diff --git a/src/utils/Properties.h b/src/utils/Properties.h
index e068052..fa0365e 100644
--- a/src/utils/Properties.h
+++ b/src/utils/Properties.h
@@ -49,5 +49,7 @@ namespace ffmpegdirect
int m_timezoneShiftSecs = 0;
int m_defaultProgrammeDurationSecs = 4 * 60 * 60; //Four hours
std::string m_programmeCatchupId;
+ std::string m_cryptoKey;
+ std::string m_cryptoIv;
};
-} //namespace ffmpegdirect
\ No newline at end of file
+} //namespace ffmpegdirect