#include "tvmedia.h"
#include <climits>
-#define VOMP_PROTOCOLL_VERSION 0x00000500
+#define VOMP_PROTOCOL_VERSION 0x00000500
VDR* VDR::instance = NULL;
#ifdef VOMP_MEDIAPLAYER
ULONG requestID;
ULONG userDataLength;
- UCHAR* userData;
+ void* userData;
ULONG streamID;
ULONG flag;
{
timeNow = time(NULL);
- readSuccess = tcp->readData((UCHAR*)&channelID, sizeof(ULONG)); // 2s timeout atm
+ readSuccess = tcp->readData(&channelID, sizeof(ULONG)); // 2s timeout atm
if (!readSuccess)
{
if (channelID == CHANNEL_REQUEST_RESPONSE)
{
- if (!tcp->readData((UCHAR*)&requestID, sizeof(ULONG))) break;
+ if (!tcp->readData(&requestID, sizeof(ULONG))) break;
requestID = ntohl(requestID);
- if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break;
+ if (!tcp->readData(&userDataLength, sizeof(ULONG))) break;
userDataLength = ntohl(userDataLength);
if (userDataLength > 5000000) break; // how big can these packets get?
userData = NULL;
if (userDataLength > 0)
{
- userData = (UCHAR*)malloc(userDataLength);
+ userData = malloc(userDataLength);
if (!userData) break;
if (!tcp->readData(userData, userDataLength)) break;
}
vresp = new VDR_ResponsePacket();
- vresp->setResponse(requestID, userData, userDataLength);
+ vresp->setResponse(requestID, reinterpret_cast<UCHAR*>(userData), userDataLength);
logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength);
if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() )
}
else if (channelID == CHANNEL_STREAM || channelID == CHANNEL_TVMEDIA)
{
- if (!tcp->readData((UCHAR*)&streamID, sizeof(ULONG))) break;
+ if (!tcp->readData(&streamID, sizeof(ULONG))) break;
streamID = ntohl(streamID);
- if (!tcp->readData((UCHAR*)&flag, sizeof(ULONG))) break;
+ if (!tcp->readData(&flag, sizeof(ULONG))) break;
flag = ntohl(flag);
- if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break;
+ if (!tcp->readData(&userDataLength, sizeof(ULONG))) break;
userDataLength = ntohl(userDataLength);
userData = NULL;
if (userDataLength > 0)
{
- userData = (UCHAR*)malloc(userDataLength);
+ userData = malloc(userDataLength);
if (!userData) break;
if (!tcp->readData(userData, userDataLength)) break;
}
vresp = new VDR_ResponsePacket();
- vresp->setStream(streamID, flag, userData, userDataLength, channelID);
+ vresp->setStream(streamID, flag, reinterpret_cast<UCHAR*>(userData), userDataLength, channelID);
//logger->log("VDR", Log::DEBUG, "Rxd a stream packet, streamID=%lu, flag=%lu, len=%lu", streamID, flag, userDataLength);
if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() )
else if (channelID == CHANNEL_KEEPALIVE)
{
ULONG KAreply = 0;
- if (!tcp->readData((UCHAR*)&KAreply, sizeof(ULONG))) break;
- KAreply = (ULONG)ntohl(KAreply);
+ if (!tcp->readData(&KAreply, sizeof(ULONG))) break;
+ KAreply = ntohl(KAreply);
if (KAreply == lastKAsent) // successful KA response
{
lastKAsent = 0;
VDR_ResponsePacket* vresp;
while(receivers.size())
{
- vdrpr = (VDR_PacketReceiver*) *(receivers.begin());
+ vdrpr = dynamic_cast<VDR_PacketReceiver*>(*(receivers.begin()));
if (vdrpr->receiverChannel == CHANNEL_REQUEST_RESPONSE)
{
vresp = new VDR_ResponsePacket();
edLock();
for(EDRL::iterator i = receivers.begin(); i != receivers.end(); i++)
- if ((VDR_PacketReceiver*)*i == vdrpr) { receivers.erase(i); break; }
+ if (dynamic_cast<VDR_PacketReceiver*>(*i) == vdrpr) { receivers.erase(i); break; }
}
}
edUnlock();
// edr is a VDR_PacketReceiver object made in VDR::RequestResponse
// userTag is a VDR_ResponsePacket made in threadMethod
- VDR_PacketReceiver* vdrpr = (VDR_PacketReceiver*)edr;
- VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+ VDR_PacketReceiver* vdrpr = dynamic_cast<VDR_PacketReceiver*>(edr);
+ VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
// Is vresp for vdrpr ?
// It's a RR. Save vresp and, signal the waiting thread and return.
// VDR::RequestResponse will be blocking waiting for this to happen.
// That function has a pointer to this object and can read save_vresp.
- save_vresp = (VDR_ResponsePacket*)userTag;
+ save_vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
r_deregisterEDR = true;
r_wakeThread = true;
{
// It's a stream packet. Pass off the stream data to streamReceiver,
// delete the vresp. Keep this PacketReceiver for the next stream packet.
- VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+ VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
streamReceiver->streamReceive(vresp->getFlag(), vresp->getUserData(), vresp->getUserDataLength());
delete vresp;
// but am going to try setting this to false because I don't know that there is a thread to signal
// delete the EDR. It's made once per media requested and wasn't owned/deleted by anything before
- VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+ VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia Pictures arrived VDR %x", vresp->getStreamID());
OsdVector *osd=dynamic_cast<OsdVector*>(Osd::getInstance());
if (osd) osd->getPictReader()->receivePicture(vresp);
*v_server_min=version_min;
unsigned int version_max=vresp->extractULONG();
*v_server_max=version_max;
- *v_client=VOMP_PROTOCOLL_VERSION;
+ *v_client=VOMP_PROTOCOL_VERSION;
if (0x00000302 <= version_max) {
unsigned int numlangcodes = vresp->extractULONG();
delete vresp;
- if ((version_min > VOMP_PROTOCOLL_VERSION)
- || (version_max < VOMP_PROTOCOLL_VERSION) ) {
+ if ((version_min > VOMP_PROTOCOL_VERSION)
+ || (version_max < VOMP_PROTOCOL_VERSION) ) {
return 0;
time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
LOCALTIME_R(&eventStartTime, &btime);
- strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
+ strftime(tempA, 300, "%d/%m/%y %H:%M ", &btime);
LOCALTIME_R(&eventEndTime, &btime);
- strftime(tempB, 299, "- %H:%M ", &btime);
- //#endif
- sprintf(tempC, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
+ strftime(tempB, 300, "- %H:%M ", &btime);
+ int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
+ if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
// New TVMedia stuff
TVMediaInfo *info= new TVMediaInfo();
info->setPosterThumb(channelNumber, currentEvent->id);
time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
LOCALTIME_R(&eventStartTime, &btime);
- strftime(tempA, 299, "%H:%M ", &btime);
+ strftime(tempA, 300, "%H:%M ", &btime);
LOCALTIME_R(&eventEndTime, &btime);
- strftime(tempB, 299, "- %H:%M ", &btime);
- //#endif
- sprintf(tempC, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
-
+ strftime(tempB, 300, "- %H:%M ", &btime);
+ int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
+ if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
} else {
sprintf(tempC, "\n%s", chan->name);