Skip to content

Commit

Permalink
CDVDDemuxFFmpeg: Support HTTP proxies with the new http_proxy option
Browse files Browse the repository at this point in the history
Since v3.0, FFmpeg has supported the http_proxy option for the HTTP
protocol.

Previously, CDVDDemuxFFmpeg would pass Kodi httpproxy CURL protocol
option through as a HTTP header, which the server would (hopefully)
ignore. With this change, if Kodi is built with an older version of
FFmpeg, FFmpeg will simply ignore the option - which is an
improvement over sending spurious HTTP headers.
  • Loading branch information
jhol committed Mar 22, 2016
1 parent 9214175 commit 84f2f09
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Expand Up @@ -20,6 +20,7 @@

#include "DVDDemuxFFmpeg.h"

#include <sstream>
#include <utility>

#include "commons/Exception.h"
Expand Down Expand Up @@ -601,6 +602,9 @@ void CDVDDemuxFFmpeg::SetSpeed(int iSpeed)

AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput()
{
const CDVDInputStreamFFmpeg *const input =
dynamic_cast<CDVDInputStreamFFmpeg*>(m_pInput);

const CURL url = m_pInput->GetURL();
AVDictionary *options = NULL;

Expand Down Expand Up @@ -638,6 +642,33 @@ AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput()
av_dict_set(&options, "cookies", cookies.c_str(), 0);

}

if (input)
{
const std::string host = input->GetProxyHost();
if (!host.empty() && input->GetProxyType() == "http")
{
std::ostringstream urlStream;

const uint16_t port = input->GetProxyPort();
const std::string user = input->GetProxyUser();
const std::string password = input->GetProxyPassword();

urlStream << "http://";

if (!user.empty()) {
urlStream << user;
if (!password.empty())
urlStream << ":" << password;
urlStream << "@";
}

urlStream << host << ':' << port;

av_dict_set(&options, "http_proxy", urlStream.str().c_str(), 0);
}
}

return options;
}

Expand Down

0 comments on commit 84f2f09

Please sign in to comment.