diff --git a/addons/pvr.hts/resources/language/English/strings.xml b/addons/pvr.hts/resources/language/English/strings.xml
index 5b69906..d05fdfd 100644
--- a/addons/pvr.hts/resources/language/English/strings.xml
+++ b/addons/pvr.hts/resources/language/English/strings.xml
@@ -8,6 +8,14 @@
Password
Connect timeout in seconds
Response timeout in seconds
+ Enable transcoding
+ Audio codec
+ Video codec
+ Resolution
+
+
+ Connection
+ Transcoding
Disconnected from '%s'
diff --git a/addons/pvr.hts/resources/settings.xml b/addons/pvr.hts/resources/settings.xml
index 3ef0839..43aa760 100644
--- a/addons/pvr.hts/resources/settings.xml
+++ b/addons/pvr.hts/resources/settings.xml
@@ -1,5 +1,8 @@
+
+
+
@@ -7,4 +10,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp
index ce11fc1..25a4cdb 100644
--- a/xbmc/pvrclients/tvheadend/HTSPDemux.cpp
+++ b/xbmc/pvrclients/tvheadend/HTSPDemux.cpp
@@ -444,6 +444,13 @@ bool CHTSPDemux::SendSubscribe(int subscription, int channel)
htsmsg_add_str(m, "method" , "subscribe");
htsmsg_add_s32(m, "channelId" , channel);
htsmsg_add_s32(m, "subscriptionId", subscription);
+ if(g_bTranscode)
+ {
+ htsmsg_add_u32(m, "maxWidth" , g_iResolution * 16 / 9);
+ htsmsg_add_u32(m, "maxHeight" , g_iResolution);
+ htsmsg_add_str(m, "audioCodec" , g_strAudioCodec.c_str());
+ htsmsg_add_str(m, "videoCodec" , g_strVideoCodec.c_str());
+ }
return m_session->ReadSuccess(m, true, "subscribe to channel");
}
diff --git a/xbmc/pvrclients/tvheadend/client.cpp b/xbmc/pvrclients/tvheadend/client.cpp
index d9a89e6..5602fa4 100644
--- a/xbmc/pvrclients/tvheadend/client.cpp
+++ b/xbmc/pvrclients/tvheadend/client.cpp
@@ -45,21 +45,34 @@ std::string g_strUsername = "";
std::string g_strPassword = "";
std::string g_strUserPath = "";
std::string g_strClientPath = "";
+bool g_bTranscode = DEFAULT_TRANSCODE;
+std::string g_strAudioCodec = "";
+std::string g_strVideoCodec = "";
+int g_iResolution = DEFAULT_RESOLUTION;
CHelper_libXBMC_addon *XBMC = NULL;
CHelper_libXBMC_pvr *PVR = NULL;
CHTSPDemux * HTSPDemuxer = NULL;
CHTSPData * HTSPData = NULL;
+#define VIDEO_CODEC_LIST_SIZE 2
+#define AUDIO_CODEC_LIST_SIZE 2
+#define RESOLUTION_LIST_SIZE 6
+
+static const char *pVideoCodecList[VIDEO_CODEC_LIST_SIZE] = {"MPEG2VIDEO", "H264"};
+static const char *pAudioCodecList[AUDIO_CODEC_LIST_SIZE] = {"MPEG2AUDIO", "AAC"};
+static const int pResolutionList[RESOLUTION_LIST_SIZE] = {288, 384, 480, 576, 720, 1080};
+
extern "C" {
void ADDON_ReadSettings(void)
{
- /* read setting "host" from settings.xml */
+ uint32_t iEnumIndex;
char * buffer;
buffer = (char*) malloc (1024);
buffer[0] = 0; /* Set the end of string */
+ /* read setting "host" from settings.xml */
if (XBMC->GetSetting("host", buffer))
g_strHostname = buffer;
else
@@ -96,6 +109,34 @@ void ADDON_ReadSettings(void)
/* read setting "read_timeout" from settings.xml */
if (!XBMC->GetSetting("response_timeout", &g_iResponseTimeout))
g_iResponseTimeout = DEFAULT_RESPONSE_TIMEOUT;
+
+ /* read setting "transcode" from settings.xml */
+ if (!XBMC->GetSetting("transcode", &g_bTranscode))
+ g_bTranscode = DEFAULT_TRANSCODE;
+
+ /* read setting "audio_codec" from settings.xml */
+ if (!XBMC->GetSetting("audio_codec", &iEnumIndex))
+ g_strAudioCodec = "";
+ else if (iEnumIndex < AUDIO_CODEC_LIST_SIZE)
+ g_strAudioCodec = pAudioCodecList[iEnumIndex];
+ else
+ g_strAudioCodec = "";
+
+ /* read setting "video_codec" from settings.xml */
+ if (!XBMC->GetSetting("video_codec", &iEnumIndex))
+ g_strVideoCodec = "";
+ else if (iEnumIndex < VIDEO_CODEC_LIST_SIZE)
+ g_strVideoCodec = pVideoCodecList[iEnumIndex];
+ else
+ g_strVideoCodec = "";
+
+ /* read setting "video_res" from settings.xml */
+ if (!XBMC->GetSetting("video_res", &iEnumIndex))
+ g_iResolution = DEFAULT_RESOLUTION;
+ else if (iEnumIndex < RESOLUTION_LIST_SIZE)
+ g_iResolution = pResolutionList[iEnumIndex];
+ else
+ g_iResolution = DEFAULT_RESOLUTION;
}
ADDON_STATUS ADDON_Create(void* hdl, void* props)
@@ -266,6 +307,67 @@ ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
return ADDON_STATUS_OK;
}
}
+ else if (str == "transcode")
+ {
+ bool bNewValue = *(bool*) settingValue;
+ if (g_bTranscode != bNewValue)
+ {
+ XBMC->Log(LOG_INFO, "%s - Changed Setting 'transcode' from %u to %u", __FUNCTION__, g_bTranscode, bNewValue);
+ g_bTranscode = bNewValue;
+ return ADDON_STATUS_OK;
+ }
+ }
+ else if (str == "audio_codec")
+ {
+ uint32_t iEnumIndex = *(uint32_t*) settingValue;
+ string tmp_sAudioCodec = g_strAudioCodec;
+
+ if (iEnumIndex < AUDIO_CODEC_LIST_SIZE)
+ tmp_sAudioCodec = pAudioCodecList[iEnumIndex];
+ else
+ tmp_sAudioCodec = "";
+
+ if (tmp_sAudioCodec != g_strAudioCodec)
+ {
+ XBMC->Log(LOG_INFO, "%s - Changed Setting 'audio_codec' from %s to %s", __FUNCTION__, tmp_sAudioCodec.c_str(), g_strAudioCodec.c_str());
+ g_strAudioCodec = tmp_sAudioCodec;
+ return ADDON_STATUS_OK;
+ }
+ }
+ else if (str == "video_codec")
+ {
+ uint32_t iEnumIndex = *(uint32_t*) settingValue;
+ string tmp_sVideoCodec = g_strVideoCodec;
+
+ if (iEnumIndex < VIDEO_CODEC_LIST_SIZE)
+ tmp_sVideoCodec = pVideoCodecList[iEnumIndex];
+ else
+ tmp_sVideoCodec = "";
+
+ if (tmp_sVideoCodec != g_strVideoCodec)
+ {
+ XBMC->Log(LOG_INFO, "%s - Changed Setting 'video_codec' from %s to %s", __FUNCTION__, tmp_sVideoCodec.c_str(), g_strVideoCodec.c_str());
+ g_strVideoCodec = tmp_sVideoCodec;
+ return ADDON_STATUS_OK;
+ }
+ }
+ else if (str == "video_res")
+ {
+ uint32_t iEnumIndex = *(uint32_t*) settingValue;
+ int iNewValue = g_iResolution;
+
+ if (iEnumIndex < RESOLUTION_LIST_SIZE)
+ iNewValue = pResolutionList[iEnumIndex];
+ else
+ iNewValue = DEFAULT_RESOLUTION;
+
+ if (g_iResolution != iNewValue)
+ {
+ XBMC->Log(LOG_INFO, "%s - Changed Setting 'video_res' from %u to %u", __FUNCTION__, g_iResolution, iNewValue);
+ g_iResolution = iNewValue;
+ return ADDON_STATUS_OK;
+ }
+ }
return ADDON_STATUS_OK;
}
diff --git a/xbmc/pvrclients/tvheadend/client.h b/xbmc/pvrclients/tvheadend/client.h
index 27c8a81..f812c88 100644
--- a/xbmc/pvrclients/tvheadend/client.h
+++ b/xbmc/pvrclients/tvheadend/client.h
@@ -28,6 +28,8 @@
#define DEFAULT_HTSP_PORT 9982
#define DEFAULT_CONNECT_TIMEOUT 30
#define DEFAULT_RESPONSE_TIMEOUT 3
+#define DEFAULT_TRANSCODE false
+#define DEFAULT_RESOLUTION 480
extern bool m_bCreated;
extern std::string g_strHostname;
@@ -37,6 +39,10 @@ extern std::string g_strUsername;
extern std::string g_strPassword;
extern int g_iConnectTimeout;
extern int g_iResponseTimeout;
+extern bool g_bTranscode;
+extern std::string g_strAudioCodec;
+extern std::string g_strVideoCodec;
+extern int g_iResolution;
extern int g_iClientId;
extern unsigned int g_iPacketSequence;
extern bool g_bShowTimerNotifications;