Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Image cache and webroot support #141

Closed
wants to merge 3 commits into from

2 participants

@adamsutton

This adds support for a couple of new optional features in TVH:

  1. Webroot - allows TVH to server web pages from an alternative context, useful for those setting up TVH behind a rev proxy under a diff path.

  2. Image cache - images (channel logos etc..) can now be cached by TVH. To keep things clean and consistent (since these images can also be accessed directly via HTSP) the URIs provided a relative to server root (without webroot). So HTSPv8 clients must prepend the protocol and server details.

@opdenkamp opdenkamp commented on the diff
addons/pvr.hts/src/HTSPData.cpp
@@ -867,10 +867,32 @@ void CHTSPData::ParseChannelUpdate(htsmsg_t* msg)
if((strIconPath = htsmsg_get_str(msg, "channelIcon")))
{
- if (channel.icon != strIconPath)
+ CStdString strIconURL;
+
+ if (strIconPath[0] != '/' || strIconPath[0] == '\0')
@opdenkamp Owner

strIconPath.empty() is quicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
addons/pvr.hts/src/HTSPData.cpp
@@ -867,10 +867,32 @@ void CHTSPData::ParseChannelUpdate(htsmsg_t* msg)
if((strIconPath = htsmsg_get_str(msg, "channelIcon")))
{
- if (channel.icon != strIconPath)
+ CStdString strIconURL;
+
+ if (strIconPath[0] != '/' || strIconPath[0] == '\0')
+ {
+ strIconURL = strIconPath;
+ }
+ else
+ {
+ strIconURL = "http://";
+
+ if (g_strUsername != "")
@opdenkamp Owner

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
addons/pvr.hts/src/HTSPData.cpp
@@ -867,10 +867,32 @@ void CHTSPData::ParseChannelUpdate(htsmsg_t* msg)
if((strIconPath = htsmsg_get_str(msg, "channelIcon")))
{
- if (channel.icon != strIconPath)
+ CStdString strIconURL;
+
+ if (strIconPath[0] != '/' || strIconPath[0] == '\0')
+ {
+ strIconURL = strIconPath;
+ }
+ else
+ {
+ strIconURL = "http://";
+
+ if (g_strUsername != "")
+ {
+ strIconURL += g_strUsername;
+ if (g_strPassword != "")
@opdenkamp Owner

and here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
addons/pvr.hts/src/HTSPData.cpp
@@ -867,10 +867,32 @@ void CHTSPData::ParseChannelUpdate(htsmsg_t* msg)
if((strIconPath = htsmsg_get_str(msg, "channelIcon")))
{
- if (channel.icon != strIconPath)
+ CStdString strIconURL;
+
+ if (strIconPath[0] != '/' || strIconPath[0] == '\0')
+ {
+ strIconURL = strIconPath;
+ }
+ else
+ {
+ strIconURL = "http://";
+
+ if (g_strUsername != "")
+ {
+ strIconURL += g_strUsername;
@opdenkamp Owner

and please use Format() for these things instead of concat

@opdenkamp Owner

probably :) (and I didn't write it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@adamsutton

Sorry, messing about trying to tidy stuff up. So going to re-submit this one.

@adamsutton adamsutton closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
33 addons/pvr.hts/src/HTSPConnection.cpp
@@ -47,7 +47,6 @@ CHTSResult::~CHTSResult(void)
htsmsg_destroy(message);
}
-
string CHTSResult::GetErrorMessage(void)
{
if (m_strError.empty())
@@ -107,6 +106,32 @@ CHTSPConnection::~CHTSPConnection()
delete m_reconnect;
}
+const CStdString CHTSPConnection::GetWebURL (const char *fmt, ...) const
+{
+ CStdString url;
+ CStdString auth;
+
+ /* Authentication */
+ if (!g_strUsername.empty()) {
+ auth = g_strUsername;
+ if (!g_strPassword.empty())
+ auth.AppendFormat(":%s", g_strPassword.c_str());
+ auth += "@";
+ } else {
+ auth = "";
+ }
+
+ /* URL root */
+ url.Format("http://%s%s:%i%s", auth.c_str(), g_strHostname.c_str(), g_iPortHTTP, m_strWebroot.c_str());
+
+ va_list args;
+ va_start(args, fmt);
+ url.AppendFormatV(fmt, args);
+ va_end(args);
+
+ return url;
+}
+
void CHTSPConnection::SetReadTimeout(int iTimeout)
{
CLockObject lock(m_mutex);
@@ -421,7 +446,7 @@ bool CHTSPConnection::SendGreeting(void)
{
htsmsg_t *m, *cap;
htsmsg_field_t *f;
- const char *server, *version;
+ const char *server, *version, *webroot;
const void * chall = NULL;
size_t chall_len = 0;
int32_t proto = 0;
@@ -430,7 +455,7 @@ bool CHTSPConnection::SendGreeting(void)
m = htsmsg_create_map();
htsmsg_add_str(m, "method", "hello");
htsmsg_add_str(m, "clientname", "XBMC Media Center");
- htsmsg_add_u32(m, "htspversion", 7);
+ htsmsg_add_u32(m, "htspversion", 8);
CLockObject lock(m_mutex);
@@ -457,6 +482,7 @@ bool CHTSPConnection::SendGreeting(void)
version = htsmsg_get_str(m, "serverversion");
htsmsg_get_bin(m, "challenge", &chall, &chall_len);
cap = htsmsg_get_list(m, "servercapability");
+ webroot = htsmsg_get_str(m, "webroot");
// process capabilities
m_bTimeshiftSupport = false;
@@ -481,6 +507,7 @@ bool CHTSPConnection::SendGreeting(void)
m_strServerName = server;
m_strVersion = version;
m_iProtocol = proto;
+ m_strWebroot = webroot ?: "";
if(chall && chall_len)
{
View
3  addons/pvr.hts/src/HTSPConnection.h
@@ -100,6 +100,8 @@ class CHTSPConnection : private PLATFORM::CThread
int GetProtocol() const { return m_iProtocol; }
const char *GetServerName() const { return m_strServerName.c_str(); }
const char *GetVersion() const { return m_strVersion.c_str(); }
+ const char *GetWebroot() const { return m_strWebroot.c_str(); }
+ const CStdString GetWebURL(const char *fmt, ...) const;
bool TransmitMessage(htsmsg_t* m);
void ReadResult(htsmsg_t *m, CHTSResult &result, const char* strAction = NULL);
@@ -131,6 +133,7 @@ class CHTSPConnection : private PLATFORM::CThread
std::string m_strPassword;
std::string m_strVersion;
std::string m_strHostname;
+ std::string m_strWebroot;
bool m_bIsConnected;
bool m_bTimeshiftSupport;
bool m_bTimeshiftSeekSupport;
View
32 addons/pvr.hts/src/HTSPData.cpp
@@ -306,7 +306,7 @@ PVR_ERROR CHTSPData::GetRecordings(ADDON_HANDLE handle)
for(SRecordings::const_iterator it = recordings.begin(); it != recordings.end(); ++it)
{
SRecording recording = it->second;
- CStdString strStreamURL = "http://";
+ CStdString strStreamURL;
CStdString strRecordingId;
CStdString strDirectory = "/";
std::string strChannelName = "";
@@ -319,25 +319,12 @@ PVR_ERROR CHTSPData::GetRecordings(ADDON_HANDLE handle)
strChannelName = itr->second.name.c_str();
/* HTSPv7+ - use HTSP */
- if (GetProtocol() >= 7) {
+ if (GetProtocol() >= 7)
strStreamURL = "";
/* HTSPv6- - use HTTP */
- } else {
- strStreamURL = "http://";
-
- if (g_strUsername != "")
- {
- strStreamURL += g_strUsername;
- if (g_strPassword != "")
- {
- strStreamURL += ":";
- strStreamURL += g_strPassword;
- }
- strStreamURL += "@";
- }
- strStreamURL.Format("%s%s:%i/dvrfile/%i", strStreamURL.c_str(), g_strHostname.c_str(), g_iPortHTTP, recording.id);
- }
+ else
+ strStreamURL = m_session->GetWebURL("dvrfile/%i", recording.id);
}
strRecordingId.Format("%i", recording.id);
@@ -867,10 +854,17 @@ void CHTSPData::ParseChannelUpdate(htsmsg_t* msg)
if((strIconPath = htsmsg_get_str(msg, "channelIcon")))
{
- if (channel.icon != strIconPath)
+ CStdString strIconURL;
+
+ if (strIconPath[0] != '/' || strIconPath[0] == '\0')
@opdenkamp Owner

strIconPath.empty() is quicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ strIconURL = strIconPath;
+ else
+ strIconURL = m_session->GetWebURL("%s", strIconPath);
+
+ if (channel.icon != strIconURL)
{
bChannelChanged = true;
- channel.icon = strIconPath;
+ channel.icon = strIconURL;
}
}
Something went wrong with that request. Please try again.