Permalink
Browse files

Fixed usage of channel id and dvblink channel id so EPG should work o…

…n both MCE and dvblink recorder

Added preliminary support for transcoding
  • Loading branch information...
1 parent 163a83a commit 953197de14cb08f2e1e349b77e9c0edcc7fcd366 @zeroniak committed Oct 9, 2012
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.dvblink"
- version="0.0.2a"
+ version="0.0.4"
name="PVR DVBLink Client"
provider-name="Barcode Madness">
<requires>
@@ -1,3 +1,11 @@
+[B]0.0.4[/B]
+Fixed: EPG data from when using MCE recorder
+Added: Preliminary (Have not been tested) support for transcoding
+Changed: Reordered settings
+
+[B]0.0.3[/B]
+Added: Fix for using channel handle instead of client id when stopping channels
+
[B]0.0.2[/B]
Added: Scheduling of recordings using EPG based timers
Added: Enabled removal of timers
@@ -1,15 +1,32 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<!-- settings labels -->
- <string id="30041">DvbLink Connect Server Hostname</string>
- <string id="30042">DvbLink Connect Server Port</string>
- <string id="30043">Client name</string>
- <string id="30044">Connect timeout (s)</string>
- <string id="30031">Stream type</string>
- <string id="30045">Username</string>
- <string id="30046">Password</string>
- <string id="30047">Use channel handle instead of client id</string>
+ <string id="30001">Server Address</string>
+ <string id="30002">Server Port</string>
+ <string id="30003">Client name</string>
+ <string id="30004">Connection timeout (s)</string>
+ <string id="30005">Username</string>
+ <string id="30006">Password</string>
+
+
+
+ <string id="40002">Stream format</string>
+ <string id="40003">Height</string>
+ <string id="40004">Width</string>
+ <string id="40005">Bitrate</string>
+ <string id="40006">Audio track</string>
+ <string id="40007">HTTP</string>
+ <string id="40008">RTP</string>
+ <string id="40009">HLS</string>
+ <string id="40010">ASF</string>
+
+ <string id="50001">Use channel handle instead of client id</string>
+
+
<!-- category labels -->
- <string id="30040">Connection</string>
- <string id="30030">Stream</string>
+ <string id="30000">General</string>
+ <string id="40000">Stream</string>
+ <string id="50000">Advanced</string>
+
+
</strings>
@@ -1,17 +1,26 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<!-- Connection -->
- <category label="30040">
- <setting id="host" type="text" label="30041" option="urlencoded" default="127.0.0.1" />
- <setting id="port" type="number" option="int" label="30042" default="8080" />
- <setting id="timeout" visible="false" type="enum" label="30044" values="0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20" default="10"/>
- <setting id="client" type="text" label="30043" default="xbmc" />
- <setting id="username" type="text" label="30045" default="" />
- <setting id="password" type="text" label="30046" default="" />
- <setting id="ch_handle" type="bool" label="30047" default="true" />
+ <category label="30000">
+ <setting id="host" type="text" label="30001" option="urlencoded" default="127.0.0.1" />
+ <setting id="port" type="number" option="int" label="30002" default="8080" />
+ <setting id="timeout" visible="false" type="enum" label="30004" values="0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20" default="10"/>
+ <setting id="client" type="text" label="30003" default="xbmc" />
+ <setting id="username" type="text" label="30005" default="" />
+ <setting id="password" type="text" label="30006" default="" option="hidden" enable="!eq(-1,)" />
+
</category>
<!-- Stream -->
- <category label="30030">
- <setting id="streamtype" type="enum" label="30031" values="http" default="http"/>
+ <category label="40000">
+ <setting id="streamtype" type="enum" label="40002" lvalues="40007|40008|40009|40010" default="0" />
+ <setting id="height" enable="gt(-1,0)" type="number" label="40003" default="720" />
+ <setting id="width" enable="gt(-2,0)" type="number" label="40004" default="576" />
+ <setting id="bitrate" enable="gt(-3,0)" type="number" label="40005" default="512" />
+ <setting id="audiotrack" enable="gt(-4,0)" type="text" label="40006" default="eng" />
+ </category>
+ <!-- Advanced -->
+ <category label="50000">
+
+ <setting id="ch_handle" type="bool" label="50001" default="true" />
</category>
</settings>
@@ -2,16 +2,15 @@
#include "..\util\StdString.h"
-DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon *XBMC, CHelper_libXBMC_pvr *PVR,DVBLINK_STREAMTYPE streamtype,std::string clientname, std::string hostname, long port, std::string username, std::string password)
+DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon *XBMC, CHelper_libXBMC_pvr *PVR,std::string clientname, std::string hostname, long port, std::string username, std::string password)
{
this->PVR = PVR;
this->XBMC = XBMC;
- this->streamtype = streamtype;
this->clientname = clientname;
this->hostname = hostname;
connected = false;
httpClient = new CurlHttpClient();
- dvblinkRemoteCommunication = DVBLinkRemote::Connect((HttpClient&)*httpClient, hostname.c_str(), port, username.c_str(), password.c_str());
+ dvblinkRemoteCommunication = DVBLinkRemote::Connect((HttpClient&)*httpClient, hostname.c_str(), 8080, username.c_str(), password.c_str());
DVBLinkRemoteStatusCode status;
channels = NULL;
@@ -25,9 +24,10 @@ DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon *XBMC, CHelper_libXBMC_pvr *
if ((status = dvblinkRemoteCommunication->GetChannels(*request, *channels)) == DVBLINK_REMOTE_STATUS_OK) {
connected = true;
+ XBMC->Log(LOG_INFO, "Connected to DVBLink Server");
}else
{
- XBMC->Log(LOG_ERROR, "Could not get channels from DVBLink Server '%s' on port '%i'", hostname, port);
+ XBMC->Log(LOG_ERROR, "Could not get channels from DVBLink Server '%s' on port '%i'", hostname,port);
}
delete(request);
}
@@ -57,7 +57,7 @@ PVR_ERROR DVBLinkClient::GetChannels(ADDON_HANDLE handle, bool bRadio)
xbmcChannel.bIsRadio = false;
xbmcChannel.iChannelNumber =channel->Number;
xbmcChannel.iEncryptionSystem = 0;
- xbmcChannel.iUniqueId = channel->GetDvbLinkID();
+ xbmcChannel.iUniqueId = atoi(channel->GetID().c_str());
PVR_STRCPY(xbmcChannel.strChannelName,channel->GetName().c_str());
CStdString stream;
if(channel->Type == RD_CHANNEL_RADIO)
@@ -133,11 +133,11 @@ PVR_ERROR DVBLinkClient::AddTimer(const PVR_TIMER &timer)
DVBLinkRemoteStatusCode status;
AddScheduleRequest * addScheduleRequest = NULL;
char channelId [33];
- _itoa (timer.iClientChannelUid,channelId,10);
+ PVR_INT2STR(channelId,timer.iClientChannelUid);
if (timer.iEpgUid != 0)
{
char programId [33];
- _itoa (timer.iEpgUid,programId,10);
+ PVR_INT2STR(programId,timer.iEpgUid);
addScheduleRequest = new AddScheduleByEpgRequest(channelId,programId,timer.bIsRepeating);
}else{
@@ -159,7 +159,8 @@ PVR_ERROR DVBLinkClient::DeleteTimer(const PVR_TIMER &timer)
PLATFORM::CLockObject critsec(m_mutex);
DVBLinkRemoteStatusCode status;
char scheduleId [33];
- _itoa (timer.iClientIndex,scheduleId,10);
+ PVR_INT2STR(scheduleId,timer.iClientIndex);
+ //_itoa (timer.iClientIndex,scheduleId,10);
RemoveScheduleRequest * removeSchedule = new RemoveScheduleRequest(scheduleId);
@@ -287,19 +288,49 @@ PVR_ERROR DVBLinkClient::GetRecordings(ADDON_HANDLE handle)
return result;
}
-const char * DVBLinkClient::GetLiveStreamURL(const PVR_CHANNEL &channel)
+Channel * DVBLinkClient::FindChannelByChannelID(const std::string& channelId)
+{
+
+ for (std::vector<Channel*>::iterator it = channels->begin(); it < channels->end(); it++)
+ {
+ Channel* channel = (*it);
+ if (channelId.compare(channel->GetID()) == 0)
+ {
+ return channel;
+ }
+ }
+
+ return NULL;
+}
+const char * DVBLinkClient::GetLiveStreamURL(const PVR_CHANNEL &channel, DVBLINK_STREAMTYPE streamtype, int width, int height, int bitrate, std::string audiotrack)
{
PLATFORM::CLockObject critsec(m_mutex);
StreamRequest * streamRequest = NULL;
+ TranscodingOptions * options = new TranscodingOptions(width, height);
+ options->SetBitrate(bitrate);
+ options->SetAudioTrack(audiotrack);
+ char channelId[33];
+ PVR_INT2STR(channelId,channel.iUniqueId);
+ Channel * c = FindChannelByChannelID(channelId);
+ DVBLinkRemoteStatusCode status;
switch(streamtype)
{
case HTTP:
- streamRequest = new RawHttpStreamRequest(hostname.c_str(), channel.iUniqueId, clientname.c_str());
- DVBLinkRemoteStatusCode status;
- if ((status = dvblinkRemoteCommunication->PlayChannel(*streamRequest, *stream)) != DVBLINK_REMOTE_STATUS_OK) {
- XBMC->Log(LOG_ERROR,"Could not get stream for channel %i", channel.iUniqueId);
- }
+ streamRequest = new RawHttpStreamRequest(hostname.c_str(), c->GetDvbLinkID(), clientname.c_str());
+ break;
+ case RTP:
+ streamRequest = new RealTimeTransportProtocolStreamRequest(hostname.c_str(), c->GetDvbLinkID(), clientname.c_str(), *options);
break;
+ case HLS:
+ streamRequest = new HttpLiveStreamRequest(hostname.c_str(), c->GetDvbLinkID(), clientname.c_str(), *options);
+ break;
+ case ASF:
+ streamRequest = new WindowsMediaStreamRequest(hostname.c_str(), c->GetDvbLinkID(), clientname.c_str(), *options);
+ break;
+ }
+
+ if ((status = dvblinkRemoteCommunication->PlayChannel(*streamRequest, *stream)) != DVBLINK_REMOTE_STATUS_OK) {
+ XBMC->Log(LOG_ERROR,"Could not get stream for channel %i", channel.iUniqueId);
}
if (streamRequest != NULL)
@@ -388,7 +419,7 @@ PVR_ERROR DVBLinkClient::GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL
PVR_ERROR result = PVR_ERROR_FAILED;
PLATFORM::CLockObject critsec(m_mutex);
char channelId [33];
- _itoa (channel.iUniqueId,channelId,10);
+ PVR_INT2STR(channelId,channel.iUniqueId);
EpgSearchRequest* epgSearchRequest = new EpgSearchRequest(channelId, iStart, iEnd);
EpgSearchResult* epgSearchResult = new EpgSearchResult();
DVBLinkRemoteStatusCode status;
@@ -20,7 +20,7 @@ using namespace ADDON;
class DVBLinkClient
{
public:
- DVBLinkClient(CHelper_libXBMC_addon *XBMC, CHelper_libXBMC_pvr *PVR, DVBLINK_STREAMTYPE streamtype, std::string clientname, std::string hostname, long port, std::string username, std::string password);
+ DVBLinkClient(CHelper_libXBMC_addon *XBMC, CHelper_libXBMC_pvr *PVR, std::string clientname, std::string hostname, long port, std::string username, std::string password);
~DVBLinkClient(void);
int GetChannelsAmount();
PVR_ERROR GetChannels(ADDON_HANDLE handle, bool bRadio);
@@ -33,7 +33,7 @@ class DVBLinkClient
PVR_ERROR AddTimer(const PVR_TIMER &timer);
PVR_ERROR DeleteTimer(const PVR_TIMER &timer);
bool GetStatus();
- const char * GetLiveStreamURL(const PVR_CHANNEL &channel);
+ const char * GetLiveStreamURL(const PVR_CHANNEL &channel, DVBLINK_STREAMTYPE streamtype, int width, int height, int bitrate, std::string audiotrack);
void StopStreaming(bool bUseChlHandle);
private:
@@ -46,20 +46,23 @@ class DVBLinkClient
long timerCount;
long recordingCount;
- PLATFORM::CMutex m_mutex;
+ PLATFORM::CMutex m_mutex;
CHelper_libXBMC_pvr *PVR;
CHelper_libXBMC_addon *XBMC;
DVBLINK_STREAMTYPE streamtype;
std::string clientname;
std::string hostname;
+
void SetEPGGenre(Program *program, EPG_TAG *tag);
std::string GetBuildInRecorderObjectID();
std::string GetRecordedTVByDateObjectID(const std::string& buildInRecoderObjectID);
+ Channel * FindChannelByChannelID(const std::string& channelId);
};
/*!
* @brief PVR macros for string exchange
*/
#define PVR_STRCPY(dest, source) do { strncpy(dest, source, sizeof(dest)-1); dest[sizeof(dest)-1] = '\0'; } while(0)
-#define PVR_STRCLR(dest) memset(dest, 0, sizeof(dest))
+#define PVR_STRCLR(dest) memset(dest, 0, sizeof(dest))
+#define PVR_INT2STR(dest, source) sprintf(dest, "%d", source)
Oops, something went wrong.

0 comments on commit 953197d

Please sign in to comment.