Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdembski committed Jan 19, 2014
2 parents 192c52d + 9021115 commit 1c27030
Show file tree
Hide file tree
Showing 35 changed files with 442 additions and 399 deletions.
2 changes: 1 addition & 1 deletion addons/pvr.argustv/addon/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.argustv"
version="1.9.171"
version="1.9.172"
name="ARGUS TV client"
provider-name="Fred Hoogduin, Marcel Groothuis">
<requires>
Expand Down
2 changes: 2 additions & 0 deletions addons/pvr.argustv/addon/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v1.9.172 (23-12-2013)
- base new timers on templates retrieved from ARGUS TV server.
v1.9.171 (11-12-2013)
- removed redundant notification
v1.9.170 (28-09-2013)
Expand Down
135 changes: 102 additions & 33 deletions addons/pvr.argustv/src/argustvrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,33 @@ namespace ArgusTV
return retval;
}

/**
* \brief Retrieve an empty schedule from the server
*/
int GetEmptySchedule(Json::Value& response)
{
int retval = -1;
XBMC->Log(LOG_DEBUG, "GetEmptySchedule");

retval = ArgusTVJSONRPC("ArgusTV/Scheduler/EmptySchedule/0/82", "", response);

if(retval >= 0)
{
if( response.type() != Json::objectValue)
{
XBMC->Log(LOG_DEBUG, "Unknown response format. Expected Json::objectValue\n");
return -1;
}
}
else
{
XBMC->Log(LOG_DEBUG, "GetEmptySchedule failed. Return value: %i\n", retval);
}

return retval;
}


/**
* \brief Add a xbmc timer as a one time schedule
*/
Expand All @@ -1072,26 +1099,52 @@ namespace ArgusTV
struct tm* convert = localtime(&starttime);
struct tm tm_start = *convert;

// Format: ArgusTV/Scheduler/SaveSchedule
// argument: {"ChannelType":0,"IsActive":true,"IsOneTime":true,"KeepUntilMode":0,"KeepUntilValue":null,
// "LastModifiedTime":"\/Date(1297889326000+0100)\/","Name":"Astro TV","PostRecordSeconds":null,
// "PreRecordSeconds":null,"ProcessingCommands":[],"RecordingFileFormatId":null,
// "Rules":[{"Arguments":["Astro TV"],"Type":"TitleEquals"},{"Arguments":["2011-02-17T00:00:00+01:00"],"Type":"OnDate"},{"Arguments":["00:45:00"],"Type":"AroundTime"},{"Arguments":["ed49a4ef-5777-40c4-80b8-715e4c87f1a6"],"Type":"Channels"}],
// "ScheduleId":"00000000-0000-0000-0000-000000000000","SchedulePriority":0,"ScheduleType":82,"Version":0}
// Get empty schedule from the server
Json::Value newSchedule;
if (ArgusTV::GetEmptySchedule(newSchedule) < 0) return retval;

time_t now = time(NULL);
std::string modifiedtime = TimeTToWCFDate(mktime(localtime(&now)));
// Fill relevant members
CStdString modifiedtitle = title;
modifiedtitle.Replace("\"", "\\\"");
char arguments[1024];
snprintf( arguments, sizeof(arguments),
"{\"ChannelType\":0,\"IsActive\":true,\"IsOneTime\":true,\"KeepUntilMode\":\"%i\",\"KeepUntilValue\":\"%i\",\"LastModifiedTime\":\"%s\",\"Name\":\"%s\",\"PostRecordSeconds\":%i,\"PreRecordSeconds\":%i,\"ProcessingCommands\":[],\"RecordingFileFormatId\":null,\"Rules\":[{\"Arguments\":[\"%s\"],\"Type\":\"TitleEquals\"},{\"Arguments\":[\"%i-%02i-%02iT00:00:00\"],\"Type\":\"OnDate\"},{\"Arguments\":[\"%02i:%02i:%02i\"],\"Type\":\"AroundTime\"},{\"Arguments\":[\"%s\"],\"Type\":\"Channels\"}],\"ScheduleId\":\"00000000-0000-0000-0000-000000000000\",\"SchedulePriority\":0,\"ScheduleType\":82,\"Version\":0}",
lifetimeToKeepUntilMode(lifetime), lifetimeToKeepUntilValue(lifetime), modifiedtime.c_str(), modifiedtitle.c_str(), postrecordseconds, prerecordseconds, modifiedtitle.c_str(),
tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday,
tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec,
channelid.c_str());

retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", arguments, response);
newSchedule["IsOneTime"] = Json::Value(true);
newSchedule["KeepUntilMode"] = Json::Value(lifetimeToKeepUntilMode(lifetime));
newSchedule["KeepUntilValue"] = Json::Value(lifetimeToKeepUntilValue(lifetime));
newSchedule["Name"] = Json::Value(modifiedtitle.c_str());
newSchedule["PostRecordSeconds"] = Json::Value(postrecordseconds);
newSchedule["PreRecordSeconds"] = Json::Value(prerecordseconds);

Json::Value rule(Json::objectValue);
rule["Arguments"] = Json::arrayValue;
rule["Arguments"].append(Json::Value(modifiedtitle.c_str()));
rule["Type"] = Json::Value("TitleEquals");
newSchedule["Rules"].append(rule);

char formatbuffer[256];
rule = Json::objectValue;
rule["Arguments"] = Json::arrayValue;
snprintf(formatbuffer, sizeof(formatbuffer), "%i-%02i-%02iT00:00:00", tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday);
rule["Arguments"].append(Json::Value(formatbuffer));
rule["Type"] = Json::Value("OnDate");
newSchedule["Rules"].append(rule);

rule = Json::objectValue;
rule["Arguments"] = Json::arrayValue;
snprintf(formatbuffer, sizeof(formatbuffer), "%02i:%02i:%02i", tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec);
rule["Arguments"].append(Json::Value(formatbuffer));
rule["Type"] = Json::Value("AroundTime");
newSchedule["Rules"].append(rule);

rule = Json::objectValue;
rule["Arguments"] = Json::arrayValue;
rule["Arguments"].append(Json::Value(channelid.c_str()));
rule["Type"] = Json::Value("Channels");
newSchedule["Rules"].append(rule);

Json::FastWriter writer;
std::string tmparguments = writer.write(newSchedule);

retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", tmparguments.c_str(), response);

if(retval >= 0)
{
Expand Down Expand Up @@ -1126,28 +1179,44 @@ namespace ArgusTV
recordingduration /= 60;
int duration_hrs = recordingduration;

// Format: ArgusTV/Scheduler/SaveSchedule
// argument: {"ChannelType":0,"IsActive":true,"IsOneTime":true,"KeepUntilMode":0,"KeepUntilValue":null,
// "LastModifiedTime":"\/Date(1307645182000+0100)\/","Name":"XBMC (manual) - blup","PostRecordSeconds":600,
// "PreRecordSeconds":120,"ProcessingCommands":[],"RecordingFileFormatId":null,
// "Rules":[{"Arguments":["2011-06-11T22:10:00", "01:13:00"],"Type":"ManualSchedule"},{"Arguments":["6a14caaf-5e39-4750-b7b7-eae8c741c094"],"Type":"Channels"}],
// "ScheduleId":"00000000-0000-0000-0000-000000000000","SchedulePriority":0,"ScheduleType":82,"Version":0}
// Get empty schedule from the server
Json::Value newSchedule;
if (ArgusTV::GetEmptySchedule(newSchedule) < 0) return retval;

time_t now = time(NULL);
std::string modifiedtime = TimeTToWCFDate(mktime(localtime(&now)));
// Fill relevant members
CStdString modifiedtitle = title;
modifiedtitle.Replace("\"", "\\\"");
char arguments[1024];
snprintf( arguments, sizeof(arguments),
"{\"ChannelType\":0,\"IsActive\":true,\"IsOneTime\":true,\"KeepUntilMode\":\"%i\",\"KeepUntilValue\":\"%i\",\"LastModifiedTime\":\"%s\",\"Name\":\"%s (manual)\",\"PostRecordSeconds\":%i,\"PreRecordSeconds\":%i,\"ProcessingCommands\":[],\"RecordingFileFormatId\":null,"
"\"Rules\":[{\"Arguments\":[\"%i-%02i-%02iT%02i:%02i:%02i\", \"%02i:%02i:%02i\"],\"Type\":\"ManualSchedule\"},{\"Arguments\":[\"%s\"],\"Type\":\"Channels\"}],\"ScheduleId\":\"00000000-0000-0000-0000-000000000000\",\"SchedulePriority\":0,\"ScheduleType\":82,\"Version\":0}",
lifetimeToKeepUntilMode(lifetime), lifetimeToKeepUntilValue(lifetime), modifiedtime.c_str(), modifiedtitle.c_str(), postrecordseconds, prerecordseconds,

newSchedule["IsOneTime"] = Json::Value(true);
newSchedule["KeepUntilMode"] = Json::Value(lifetimeToKeepUntilMode(lifetime));
newSchedule["KeepUntilValue"] = Json::Value(lifetimeToKeepUntilValue(lifetime));
newSchedule["Name"] = Json::Value(modifiedtitle.c_str());
newSchedule["PostRecordSeconds"] = Json::Value(postrecordseconds);
newSchedule["PreRecordSeconds"] = Json::Value(prerecordseconds);

Json::Value rule(Json::objectValue);
char formatbuffer[256];
rule["Arguments"] = Json::arrayValue;
snprintf(formatbuffer, sizeof(formatbuffer), "%i-%02i-%02iT%02i:%02i:%02i",
tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday,
tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec,
duration_hrs, duration_min, duration_sec,
channelid.c_str());
tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec);
rule["Arguments"].append(Json::Value(formatbuffer));
snprintf(formatbuffer, sizeof(formatbuffer), "%02i:%02i:%02i",
duration_hrs, duration_min, duration_sec);
rule["Arguments"].append(Json::Value(formatbuffer));
rule["Type"] = Json::Value("ManualSchedule");
newSchedule["Rules"].append(rule);

rule = Json::objectValue;
rule["Arguments"] = Json::arrayValue;
rule["Arguments"].append(Json::Value(channelid.c_str()));
rule["Type"] = Json::Value("Channels");
newSchedule["Rules"].append(rule);

Json::FastWriter writer;
std::string tmparguments = writer.write(newSchedule);

retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", arguments, response);
retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", tmparguments, response);

if(retval >= 0)
{
Expand Down
5 changes: 5 additions & 0 deletions addons/pvr.argustv/src/argustvrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ namespace ArgusTV
*/
int CancelUpcomingProgram(const std::string& scheduleid, const std::string& channelid, const time_t starttime, const std::string& upcomingprogramid);

/**
* \brief Retrieve an empty schedule from the server
*/
int GetEmptySchedule(Json::Value& response);

/**
* \brief Add a xbmc timer as a one time schedule
*/
Expand Down
1 change: 1 addition & 0 deletions addons/pvr.argustv/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void ADDON_FreeSettings()

void ADDON_Announce(const char *flag, const char *sender, const char *message, const void *data)
{
(void) flag; (void) sender; (void) message; (void) data;
}

/***********************************************************
Expand Down
2 changes: 1 addition & 1 deletion addons/pvr.demo/src/PVRDemoData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ bool PVRDemoData::LoadDemoData(void)
time_t timeNow = time(NULL);
struct tm* now = localtime(&timeNow);

int delim = strTmp.Find(':');
CStdString::size_type delim = strTmp.Find(':');
if (delim != CStdString::npos)
{
now->tm_hour = (int)strtol(strTmp.Left(delim), NULL, 0);
Expand Down
2 changes: 1 addition & 1 deletion addons/pvr.dvblink/src/HttpPostClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int HttpPostClient::SendPostRequest(HttpWebRequest& request)
sprintf(content_header, "Authorization: Basic %s\r\n",base64_encode((const char*)content_header,strlen(content_header)).c_str());
buffer.append(content_header);
}
sprintf(content_header,"Content-Length: %d\r\n",request.ContentLength);
sprintf(content_header,"Content-Length: %ld\r\n",request.ContentLength);
buffer.append(content_header);
buffer.append("\r\n");
buffer.append(request.GetRequestData());
Expand Down
2 changes: 1 addition & 1 deletion addons/pvr.hts/src/HTSPData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ PVR_ERROR CHTSPData::GetRecordings(ADDON_HANDLE handle)

if (recording.path != "")
{
size_t i, idx = recording.path.rfind("/");
size_t idx = recording.path.rfind("/");
if (idx == 0 || idx == std::string::npos) {
strDirectory = "/";
} else {
Expand Down
21 changes: 9 additions & 12 deletions addons/pvr.hts/src/HTSPDemux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ inline void HTSPSetDemuxStreamInfoLanguage(PVR_STREAM_PROPERTIES::PVR_STREAM &st

void CHTSPDemux::ParseSubscriptionStart(htsmsg_t *m)
{
vector<PVR_STREAM_PROPERTIES::PVR_STREAM> newStreams;
vector<XbmcPvrStream> newStreams;

htsmsg_t *streams;
htsmsg_field_t *f;
Expand All @@ -316,12 +316,6 @@ void CHTSPDemux::ParseSubscriptionStart(htsmsg_t *m)
const char* type;
htsmsg_t* sub;

if (newStreams.size() >= PVR_STREAM_MAX_STREAMS)
{
XBMC->Log(LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__);
break;
}

if (f->hmf_type != HMF_MAP)
continue;

Expand All @@ -334,7 +328,7 @@ void CHTSPDemux::ParseSubscriptionStart(htsmsg_t *m)
continue;

bool bValidStream(true);
PVR_STREAM_PROPERTIES::PVR_STREAM newStream;
XbmcPvrStream newStream;
m_streams.GetStreamData(index, &newStream);

CodecDescriptor codecId = CodecDescriptor::GetCodecByName(type);
Expand All @@ -345,10 +339,13 @@ void CHTSPDemux::ParseSubscriptionStart(htsmsg_t *m)

if (codecId.Codec().codec_type == XBMC_CODEC_TYPE_SUBTITLE)
{
uint32_t composition_id = 0, ancillary_id = 0;
htsmsg_get_u32(sub, "composition_id", &composition_id);
htsmsg_get_u32(sub, "ancillary_id" , &ancillary_id);
newStream.iIdentifier = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16);
if (!strcmp(type, "DVBSUB"))
{
uint32_t composition_id = 0, ancillary_id = 0;
htsmsg_get_u32(sub, "composition_id", &composition_id);
htsmsg_get_u32(sub, "ancillary_id" , &ancillary_id);
newStream.iIdentifier = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16);
}
HTSPSetDemuxStreamInfoLanguage(newStream, sub);
}
}
Expand Down
89 changes: 1 addition & 88 deletions addons/pvr.hts/src/HTSPTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,97 +28,10 @@
#include "platform/util/StdString.h"
#include "libXBMC_codec.h"
#include "client.h"

class CodecDescriptor
{
public:
CodecDescriptor(void)
{
m_codec.codec_id = XBMC_INVALID_CODEC_ID;
m_codec.codec_type = XBMC_CODEC_TYPE_UNKNOWN;
}

CodecDescriptor(xbmc_codec_t codec, const char* name) :
m_codec(codec),
m_strName(name) {}
virtual ~CodecDescriptor(void) {}

const std::string& Name(void) const { return m_strName; }
xbmc_codec_t Codec(void) const { return m_codec; }

static CodecDescriptor GetCodecByName(const char* strCodecName)
{
CodecDescriptor retVal;
// some of Tvheadend's and VDR's codec names don't match ffmpeg's, so translate them to something ffmpeg understands
if (!strcmp(strCodecName, "MPEG2AUDIO"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MP2"), strCodecName);
else if (!strcmp(strCodecName, "MPEGTS"))
retVal = CodecDescriptor(CODEC->GetCodecByName("MPEG2VIDEO"), strCodecName);
else
retVal = CodecDescriptor(CODEC->GetCodecByName(strCodecName), strCodecName);

return retVal;
}

private:
xbmc_codec_t m_codec;
std::string m_strName;
};
#include "xbmc_codec_descriptor.hpp"

typedef std::vector<CodecDescriptor> CodecVector;

typedef struct htsmsg htsmsg_t;

template<typename T>
class const_circular_iter :
public std::iterator< typename std::iterator_traits<T>::iterator_category,
typename std::iterator_traits<T>::value_type,
typename std::iterator_traits<T>::difference_type,
typename std::iterator_traits<T>::pointer,
typename std::iterator_traits<T>::reference>
{
protected:
T begin;
T end;
T iter;

public:
typedef typename std::iterator_traits<T>::value_type value_type;
typedef typename std::iterator_traits<T>::difference_type difference_type;
typedef typename std::iterator_traits<T>::pointer pointer;
typedef typename std::iterator_traits<T>::reference reference;

const_circular_iter(const const_circular_iter& src) : begin(src.begin), end(src.end), iter(src.iter) {};
const_circular_iter(const T& b, const T& e) : begin(b), end(e), iter(b) {};
const_circular_iter(const T& b, const T& e, const T& c) : begin(b), end(e), iter(c) {};
const_circular_iter<T>& operator++()
{
if(begin == end)
return(*this);
++iter;
if (iter == end)
iter = begin;
return(*this);
}

const_circular_iter<T>& operator--()
{
if(begin == end)
return(*this);
if (iter == begin)
iter = end;
iter--;
return(*this);
}

reference operator*() const { return (*iter); }
const pointer operator->() const { return &(*iter); }
bool operator==(const const_circular_iter<T>& rhs) const { return (iter == rhs.iter); }
bool operator==(const T& rhs) const { return (iter == rhs); }
bool operator!=(const const_circular_iter<T>& rhs) const { return ! operator==(rhs); }
bool operator!=(const T& rhs) const { return ! operator==(rhs); }
};

struct STag
{
int id;
Expand Down
2 changes: 1 addition & 1 deletion addons/pvr.mediaportal.tvserver/src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ int Socket::receive ( char* data, const unsigned int buffersize, const unsigned
}


int Socket::recvfrom ( char* data, const int buffersize, const int minpacketsize, struct sockaddr* from, socklen_t* fromlen) const
int Socket::recvfrom ( char* data, const int buffersize, struct sockaddr* from, socklen_t* fromlen) const
{
int status = ::recvfrom(_sd, data, buffersize, 0, from, fromlen);

Expand Down
3 changes: 1 addition & 2 deletions addons/pvr.mediaportal.tvserver/src/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,11 @@ class Socket
*
* \param data Pointer to a character array of size buffersize. Used to store the received data.
* \param buffersize Size of the 'data' buffer
* \param minpacketsize Do not return before at least 'minpacketsize' bytes are in the buffer.
* \param from Optional: pointer to a sockaddr struct that will get the address from which the data is received
* \param fromlen Optional, only required if 'from' is given: length of from struct
* \return Number of bytes received or SOCKET_ERROR
*/
int recvfrom ( char* data, const int buffersize, const int minpacketsize, struct sockaddr* from = NULL, socklen_t* fromlen = NULL) const;
int recvfrom ( char* data, const int buffersize, struct sockaddr* from = NULL, socklen_t* fromlen = NULL) const;

bool set_non_blocking ( const bool );

Expand Down
Loading

0 comments on commit 1c27030

Please sign in to comment.