Skip to content

Commit bbc212d

Browse files
authored
Merge pull request #34 from phunkyfish/proxy-stopping
Proxy support and Inputstream API 2.2.0
2 parents 0358090 + 551db75 commit bbc212d

30 files changed

+364
-74
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ set(CATCHUP_HEADERS src/StreamManager.h
5252
src/stream/threads/Timer.h
5353
src/stream/threads/TimeUtils.h
5454
src/stream/threads/platform/ThreadImpl.h
55+
src/utils/HttpProxy.h
5556
src/utils/Log.h
5657
src/stream/url/URL.h
5758
src/stream/url/UrlOptions.h

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ Note that the steps in the following section need to be performed before the add
4949

5050
If you would prefer to run the rebuild steps manually instead of using the above helper script check the appendix [here](#manual-steps-to-rebuild-the-addon-on-macosx)
5151

52+
## Settings
53+
54+
### HTTP Proxy
55+
Settings for configuring the HTTP Proxy
56+
57+
* **Use HTTP proxy**: Whether or not a proxy should be used.
58+
* **Server**: Configure the proxy server address.
59+
* **Port**: Configure the proxy server port.
60+
* **Username**: Configure the proxy server username.
61+
* **Password**: Configure the proxy server password.
62+
5263
## Using the addon
5364

5465
The addon can be accessed like any other inputstream in Kodi. The following example will show how to manually choose this addon for playback when using IPTV Simple Client with the following entry in the M3U file (Note that the IPTV Simple Client will in fact automatcially detect a catchup stream and use the addon based on configured settings).

inputstream.ffmpegdirect/addon.xml.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon
33
id="inputstream.ffmpegdirect"
4-
version="1.8.2"
4+
version="1.9.0"
55
name="Inputstream FFmpeg Direct"
66
provider-name="phunkyfish">
77
<requires>@ADDON_DEPENDS@</requires>
@@ -23,6 +23,11 @@
2323
<fanart>fanart.jpg</fanart>
2424
</assets>
2525
<news>
26+
v1.9.0
27+
- Added: HTTP Proxy support
28+
- Update: Remove PauseStream for Inputstream API 2.2.0
29+
- Fixed: fix changelog.in for debian packaging
30+
2631
v1.8.2
2732
- Fixed: Ubuntu packaging
2833
- Added: Updated RTP patch

inputstream.ffmpegdirect/changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v1.9.0
2+
- Added: HTTP Proxy support
3+
- Update: Remove PauseStream for Inputstream API 2.2.0
4+
- Fixed: fix changelog.in for debian packaging
5+
16
v1.8.2
27
- Fixed: Ubuntu packaging
38
- Added: Updated RTP patch
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Kodi Media Center language file
2+
# Addon Name: Inputstream.ffmpegdirect
3+
# Addon id: inputstream.ffmpegdirect
4+
# Addon Provider: phunkyfish
5+
6+
msgid ""
7+
msgstr ""
8+
9+
"MIME-Version: 1.0\n"
10+
"Content-Type: text/plain; charset=UTF-8\n"
11+
"Content-Transfer-Encoding: 8bit\n"
12+
"Language: en\n"
13+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
14+
15+
#. settings labels
16+
17+
#. label-category: httpProxy
18+
#. label-group: HTTP proxy - httpProxt
19+
msgctxt "#30000"
20+
msgid "HTTP proxy"
21+
msgstr ""
22+
23+
#. label: HTTP proxy - useHttpProxy
24+
msgctxt "#30001"
25+
msgid "Use HTTP proxy"
26+
msgstr ""
27+
28+
#. label-option: HTTP proxy - httpProxyHost
29+
msgctxt "#30002"
30+
msgid "Server"
31+
msgstr ""
32+
33+
#. label-option: HTTP proxy - httpProxyPort
34+
msgctxt "#30003"
35+
msgid "Port"
36+
msgstr ""
37+
38+
#. label-option: HTTP proxy - httpProxyUser
39+
msgctxt "#30004"
40+
msgid "Username"
41+
msgstr ""
42+
43+
#. label-option: HTTP proxy - httpProxyPassword
44+
msgctxt "#30005"
45+
msgid "Password"
46+
msgstr ""
47+
48+
#empty strings from id 30007 to 30600
49+
50+
#. ############
51+
#. help info #
52+
#. ############
53+
54+
#. help info - HTTP Proxy
55+
56+
#. help-category: httpProxy
57+
msgctxt "#30600"
58+
msgid "This categoty contains the settings for how the proxy is configured."
59+
msgstr ""
60+
61+
#. help: HTTP Proxy - useHttpProxy
62+
msgctxt "#30601"
63+
msgid "Whether or not a proxy should be used."
64+
msgstr ""
65+
66+
#. help: HTTP Proxy - httpProxyHost
67+
msgctxt "#30602"
68+
msgid "Configure the proxy server address."
69+
msgstr ""
70+
71+
#. help: HTTP Proxy - httpProxyPort
72+
msgctxt "#30603"
73+
msgid "Configure the proxy server port."
74+
msgstr ""
75+
76+
#. help: HTTP Proxy - httpProxyUser
77+
msgctxt "#30604"
78+
msgid "Configure the proxy server username."
79+
msgstr ""
80+
81+
#. help: HTTP Proxy - httpProxyPassword
82+
msgctxt "#30605"
83+
msgid "Configure the proxy server password."
84+
msgstr ""
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
<settings version="1">
3+
<section id="inputstream.ffmpegdirect">
4+
<category id="httpProxy" label="30000" help="30600">
5+
<group id="1" label="30000">
6+
<setting id="useHttpProxy" type="boolean" label="30001" help="30601">
7+
<level>1</level>
8+
<default>false</default>
9+
<control type="toggle" />
10+
</setting>
11+
<setting id="httpProxyHost" type="string" parent="useHttpProxy" label="30002" help="30602">
12+
<level>1</level>
13+
<default></default>
14+
<constraints>
15+
<allowempty>true</allowempty>
16+
</constraints>
17+
<dependencies>
18+
<dependency type="enable" setting="useHttpProxy">true</dependency>
19+
</dependencies>
20+
<control type="edit" format="string" />
21+
</setting>
22+
<setting id="httpProxyPort" type="integer" parent="useHttpProxy" label="30003" help="30603">
23+
<level>1</level>
24+
<default>8080</default>
25+
<constraints>
26+
<minimum>1</minimum>
27+
<step>1</step>
28+
<maximum>65535</maximum>
29+
</constraints>
30+
<dependencies>
31+
<dependency type="enable" setting="useHttpProxy">true</dependency>
32+
</dependencies>
33+
<control type="edit" format="integer" />
34+
</setting>
35+
<setting id="httpProxyUser" type="string" parent="useHttpProxy" label="30004" help="30604">
36+
<level>1</level>
37+
<default></default>
38+
<constraints>
39+
<allowempty>true</allowempty>
40+
</constraints>
41+
<dependencies>
42+
<dependency type="enable" setting="useHttpProxy">true</dependency>
43+
</dependencies>
44+
<control type="edit" format="string" />
45+
</setting>
46+
<setting id="httpProxyPassword" type="string" parent="useHttpProxy" label="30005" help="30605">
47+
<level>1</level>
48+
<default></default>
49+
<constraints>
50+
<allowempty>true</allowempty>
51+
</constraints>
52+
<dependencies>
53+
<dependency type="enable" setting="useHttpProxy">true</dependency>
54+
</dependencies>
55+
<control type="edit" format="string">
56+
<hidden>true</hidden>
57+
</control>
58+
</setting>
59+
</group>
60+
</category>
61+
</section>
62+
</settings>

src/StreamManager.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
#include "StreamManager.h"
1010

11+
#include "utils/HttpProxy.h"
1112
#include "utils/Log.h"
1213

1314
#include <p8-platform/util/StringUtils.h>
1415

16+
using namespace ffmpegdirect::utils;
17+
1518
/***********************************************************
1619
* InputSteam Client AddOn specific public library functions
1720
***********************************************************/
@@ -120,8 +123,26 @@ bool CInputStreamLibavformat::Open(INPUTSTREAM& props)
120123

121124
m_streamUrl = props.m_strURL;
122125

126+
HttpProxy httpProxy;
127+
128+
bool useHttpProxy = kodi::GetSettingBoolean("useHttpProxy");
129+
if (useHttpProxy)
130+
{
131+
httpProxy.SetProxyHost(kodi::GetSettingString("httpProxyHost"));
132+
kodi::Log(ADDON_LOG_NOTICE, "HttpProxy host set: '%s'", httpProxy.GetProxyHost().c_str());
133+
134+
httpProxy.SetProxyPort(static_cast<uint16_t>(kodi::GetSettingInt("httpProxyPort")));
135+
kodi::Log(ADDON_LOG_NOTICE, "HttpProxy port set: %d", static_cast<int>(httpProxy.GetProxyPort()));
136+
137+
httpProxy.SetProxyUser(kodi::GetSettingString("httpProxyUser"));
138+
kodi::Log(ADDON_LOG_NOTICE, "HttpProxy user set: '%s'", httpProxy.GetProxyUser().c_str());
139+
140+
httpProxy.SetProxyPassword(kodi::GetSettingString("httpProxyPassword"));
141+
}
142+
123143
if (m_streamMode == StreamMode::CATCHUP)
124144
m_stream = std::make_shared<FFmpegCatchupStream>(static_cast<IManageDemuxPacket*>(this),
145+
httpProxy,
125146
m_defaultUrl,
126147
m_playbackAsLive,
127148
m_programmeStartTime,
@@ -135,7 +156,7 @@ bool CInputStreamLibavformat::Open(INPUTSTREAM& props)
135156
m_defaultProgrammeDurationSecs,
136157
m_programmeCatchupId);
137158
else
138-
m_stream = std::make_shared<FFmpegStream>(static_cast<IManageDemuxPacket*>(this));
159+
m_stream = std::make_shared<FFmpegStream>(static_cast<IManageDemuxPacket*>(this), httpProxy);
139160

140161
m_stream->SetVideoResolution(m_videoWidth, m_videoHeight);
141162

@@ -281,11 +302,6 @@ int64_t CInputStreamLibavformat::LengthStream()
281302
return m_stream->LengthStream();
282303
}
283304

284-
void CInputStreamLibavformat::PauseStream(double time)
285-
{
286-
// Unused when inputsream has it's own demuxer
287-
}
288-
289305
bool CInputStreamLibavformat::IsRealTimeStream()
290306
{
291307
return m_stream->IsRealTimeStream();

src/StreamManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class CInputStreamLibavformat
7979
virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) override;
8080
virtual int64_t PositionStream() override;
8181
virtual int64_t LengthStream() override;
82-
virtual void PauseStream(double time) override;
8382
virtual bool IsRealTimeStream() override; // { return true; }
8483

8584
DemuxPacket* AllocateDemuxPacketFromInputStreamAPI(int dataSize) override;

src/stream/FFmpegCatchupStream.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "threads/SingleLock.h"
1212
#include "../utils/Log.h"
1313

14+
using namespace ffmpegdirect::utils;
15+
1416
#ifdef TARGET_POSIX
1517
#include "platform/posix/XTimeUtils.h"
1618
#endif
@@ -41,6 +43,7 @@ extern "C" {
4143
***********************************************************/
4244

4345
FFmpegCatchupStream::FFmpegCatchupStream(IManageDemuxPacket* demuxPacketManager,
46+
const HttpProxy& httpProxy,
4447
std::string& defaultUrl,
4548
bool playbackAsLive,
4649
time_t programmeStartTime,
@@ -53,7 +56,7 @@ FFmpegCatchupStream::FFmpegCatchupStream(IManageDemuxPacket* demuxPacketManager,
5356
int timezoneShift,
5457
int defaultProgrammeDuration,
5558
std::string& programmeCatchupId)
56-
: FFmpegStream(demuxPacketManager), m_bIsOpening(false), m_seekOffset(0),
59+
: FFmpegStream(demuxPacketManager, httpProxy), m_bIsOpening(false), m_seekOffset(0),
5760
m_defaultUrl(defaultUrl), m_playbackAsLive(playbackAsLive),
5861
m_programmeStartTime(programmeStartTime), m_programmeEndTime(programmeEndTime),
5962
m_catchupUrlFormatString(catchupUrlFormatString),

src/stream/FFmpegCatchupStream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
#pragma once
1010

1111
#include "FFmpegStream.h"
12+
#include "../utils/HttpProxy.h"
1213

1314
class FFmpegCatchupStream : public FFmpegStream
1415
{
1516
public:
1617
FFmpegCatchupStream(IManageDemuxPacket* demuxPacketManager,
18+
const ffmpegdirect::utils::HttpProxy& httpProxy,
1719
std::string& defaultUrl,
1820
bool playbackAsLive,
1921
time_t programmeStartTime,

0 commit comments

Comments
 (0)