mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 15:02:50 +02:00
our current experimental Neutrino branch
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@27 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: bc5bd4154e
Author: mrcolor <mrcolor@e54a6e83-5905-42d5-8d5c-058d10e6a962>
Date: 2009-12-08 (Tue, 08 Dec 2009)
------------------
This commit was generated by Migit
This commit is contained in:
18
lib/sectionsdclient/Makefile.am
Normal file
18
lib/sectionsdclient/Makefile.am
Normal file
@@ -0,0 +1,18 @@
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/lib \
|
||||
-I$(top_srcdir)/src/zapit/include \
|
||||
-I$(top_srcdir)/lib/connection \
|
||||
-I$(top_srcdir)/lib/libeventserver
|
||||
|
||||
noinst_LIBRARIES = libsectionsdclient.a
|
||||
|
||||
AM_CPPFLAGS = -fno-rtti -fno-exceptions
|
||||
|
||||
libsectionsdclient_a_SOURCES = sectionsdclient.cpp
|
||||
|
||||
bin_PROGRAMS = sectionsdcontrol
|
||||
|
||||
sectionsdcontrol_SOURCES = sectionsdcontrol.cpp
|
||||
sectionsdcontrol_LDADD = \
|
||||
$(top_builddir)/lib/sectionsdclient/libsectionsdclient.a \
|
||||
$(top_builddir)/lib/connection/libtuxbox-connection.a
|
375
lib/sectionsdclient/sectionsdMsg.h
Normal file
375
lib/sectionsdclient/sectionsdMsg.h
Normal file
@@ -0,0 +1,375 @@
|
||||
#ifndef SECTIONSDMSG_H
|
||||
#define SECTIONSDMSG_H
|
||||
//
|
||||
// $Id: sectionsdMsg.h,v 1.16 2007/01/07 23:34:55 guenther Exp $
|
||||
//
|
||||
// sectionsdMsg.h (header file with msg-definitions for sectionsd)
|
||||
// (dbox-II-project)
|
||||
//
|
||||
// Copyright (C) 2001 by fnbrd,
|
||||
// 2002 by thegoodguy
|
||||
//
|
||||
// Homepage: http://dbox2.elxsi.de
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
|
||||
#include <connection/basicmessage.h>
|
||||
#include <zapit/client/zapittypes.h> /* t_channel_id */
|
||||
|
||||
|
||||
#define SECTIONSD_UDS_NAME "/tmp/sectionsd.sock"
|
||||
|
||||
|
||||
struct sectionsd
|
||||
{
|
||||
static const CBasicMessage::t_version ACTVERSION = 5;
|
||||
|
||||
struct msgRequestHeader
|
||||
{
|
||||
unsigned char version;
|
||||
unsigned char command;
|
||||
unsigned short stuff_bytes;
|
||||
unsigned int dataLength;
|
||||
} __attribute__ ((packed)) ;
|
||||
|
||||
struct msgResponseHeader
|
||||
{
|
||||
unsigned int dataLength;
|
||||
} __attribute__ ((packed)) ;
|
||||
|
||||
enum commands
|
||||
{
|
||||
/* actualEPGchannelName=0,*/
|
||||
dummy1,
|
||||
dummy3, //actualEventListTVshort, // commandEventListTV
|
||||
/*currentNextInformation,*/
|
||||
dummy2,
|
||||
dumpStatusinformation, // commandDumpStatusInformation
|
||||
/*allEventsChannelName,*/
|
||||
allEventsChannelIDSearch, // commandAllEventsChannelIDSearch
|
||||
dummy4, // setHoursToCache,
|
||||
dummy5, // setHoursExtendedCache,
|
||||
dummy6, // setEventsAreOldInMinutes,
|
||||
dummy7, // dumpAllServices, // commandDumpAllServices
|
||||
dummy8, // actualEventListRadioshort, // commandEventListRadio
|
||||
dummy9, // getNextEPG, // commandGetNextEPG
|
||||
dummy10,// getNextShort, // commandGetNextShort
|
||||
pauseScanning, // commandPauseScanning // for the grabbers ;)
|
||||
getIsScanningActive, // commandGetIsScanningActive
|
||||
actualEPGchannelID, // commandActualEPGchannelID
|
||||
actualEventListTVshortIDs, // commandEventListTVids
|
||||
actualEventListRadioShortIDs, // commandEventListRadioIDs
|
||||
currentNextInformationID, // commandCurrentNextInfoChannelID
|
||||
epgEPGid, // commandEPGepgID
|
||||
epgEPGidShort, // commandEPGepgIDshort
|
||||
ComponentTagsUniqueKey, // commandComponentTagsUniqueKey
|
||||
allEventsChannelID_, // commandAllEventsChannelID
|
||||
timesNVODservice, // commandTimesNVODservice
|
||||
getEPGPrevNext, // commandGetEPGPrevNext
|
||||
getIsTimeSet, // commandGetIsTimeSet
|
||||
serviceChanged, // commandserviceChanged
|
||||
LinkageDescriptorsUniqueKey, // commandLinkageDescriptorsUniqueKey
|
||||
pauseSorting, // commandPauseSorting
|
||||
CMD_registerEvents, // commandRegisterEventClient
|
||||
CMD_unregisterEvents, // commandUnRegisterEventClient
|
||||
#ifdef ENABLE_PPT
|
||||
setPrivatePid, // commandSetPrivatePid
|
||||
#else
|
||||
dummy11_setPrivatePid,
|
||||
#endif
|
||||
setSectionsdScanMode, // commandSetSectionsdScanMode
|
||||
freeMemory, // commandFreeMemory
|
||||
readSIfromXML, // commandReadSIfromXML
|
||||
writeSI2XML, // commandWriteSI2XML
|
||||
|
||||
LoadLanguages, // commandLoadLanguages
|
||||
SaveLanguages, // commandSaveLanguages
|
||||
SetLanguages, // commandSetLanguages
|
||||
GetLanguages, // commandGetLanguages
|
||||
SetLanguageMode, // commandSetLanguageMode
|
||||
GetLanguageMode, // commandGetLanguageMode
|
||||
setConfig, // commandSetConfig
|
||||
Restart, // commandRestart
|
||||
ping,
|
||||
|
||||
numberOfCommands // <- no actual command, end of command marker
|
||||
};
|
||||
|
||||
struct commandGetEPGid
|
||||
{
|
||||
unsigned long long eventid;
|
||||
time_t starttime;
|
||||
} __attribute__ ((packed)) ;
|
||||
|
||||
struct commandSetServiceChanged
|
||||
{
|
||||
t_channel_id channel_id;
|
||||
bool requestEvent;
|
||||
};
|
||||
|
||||
struct responseIsTimeSet
|
||||
{
|
||||
bool IsTimeSet;
|
||||
};
|
||||
|
||||
struct commandSetConfig
|
||||
{
|
||||
int scanMode;
|
||||
int epg_cache;
|
||||
int epg_old_events;
|
||||
unsigned int epg_max_events;
|
||||
int network_ntprefresh;
|
||||
int network_ntpenable;
|
||||
int epg_extendedcache;
|
||||
// std::string network_ntpserver;
|
||||
// std::string epg_dir;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Description of Commands:
|
||||
//
|
||||
// If a command is recognize then sectionsd will always send a response.
|
||||
// When requested datas are not found the data length of the response is 0.
|
||||
//
|
||||
// actualEPGchannelName:
|
||||
// data of request:
|
||||
// is channel name with trailing 0 (c-string)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG (for
|
||||
// compatibility with old epgd)
|
||||
//
|
||||
// actualEventListTVshort:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// is a string (c-string) with all cached actual events,
|
||||
// 3 lines per service, first line unique-event-key, second line service name, third line event name
|
||||
//
|
||||
// currentNextInformation:
|
||||
// data of request:
|
||||
// is channel name with trailing 0 (c-string)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the current/next EPGs
|
||||
//
|
||||
// dumpStatusinformation:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// is a string (c-string) describing current status of sectionsd
|
||||
//
|
||||
// allEventsChannelName:
|
||||
// data of request:
|
||||
// is channel name with trailing 0 (c-string)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the cached events for the requestet channel
|
||||
// 1 line per event, format: uniqueEventKey DD.MM HH:MM durationInMinutes Event name
|
||||
//
|
||||
// setHoursToCache
|
||||
// data of request:
|
||||
// unsigned short (hours to cache)
|
||||
// data of response:
|
||||
// -
|
||||
//
|
||||
// setEventsAreOldInMinutes
|
||||
// data of request:
|
||||
// unsigned short (minutes after events are old (after their end time))
|
||||
// data of response:
|
||||
// -
|
||||
//
|
||||
// dumpAllServicesinformation:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// is a string (c-string) with all cached services
|
||||
// 3 lines per service
|
||||
// 1. line: unique-service-key, service-ID, service-type, eitScheduleFlag (bool),
|
||||
// eitPresentFollowingFlag (bool), runningStatus (bool),
|
||||
// freeCAmode (bool), number of nvod services
|
||||
// 2. line: service name
|
||||
// 3. line: provider name
|
||||
//
|
||||
// actualEventListRadioshort:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// is a string (c-string) with all cached actual events,
|
||||
// 3 lines per service, first line unique-event-key, second line service name, third line event name
|
||||
//
|
||||
// getNextEPG:
|
||||
// data of request:
|
||||
// 8 bytes (long long in 32 bit world) with unique key (binary) of the event for wich the next should be delivered
|
||||
// 4 bytes with start time (ctime) of the above event
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG:
|
||||
// unique key (long long, hex) 0xff name 0xff text 0xff extended text 0xff start time GMT (ctime, hex ) 0xff duration (seconds, hex)
|
||||
//
|
||||
// getNextShort:
|
||||
// data of request:
|
||||
// 8 bytes (long long in 32 bit world) with unique key (binary) of the event for wich the next should be delivered
|
||||
// 4 bytes with start time (ctime) of the above event
|
||||
// data of response:
|
||||
// is a string (c-string) describing the Event in short terms:
|
||||
// 1. line unique key (long long, hex), 2. line name, 3. line start time GMT (ctime, hex ), 4 line duration (seconds, hex)
|
||||
//
|
||||
// pauseScanning:
|
||||
// data of request:
|
||||
// int (1 = pause, 0 = continue)
|
||||
// data of response:
|
||||
// -
|
||||
//
|
||||
// actualEPGchannelID:
|
||||
// data of request:
|
||||
// is channel ID
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG:
|
||||
// unique key (long long, hex) 0xff name 0xff text 0xff extended text 0xff start time GMT (ctime, hex ) 0xff duration (seconds, hex) 0xff
|
||||
//
|
||||
// actualEventListTVshortIDs:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// for every service:
|
||||
// 1. unique-service-key (4 bytes)
|
||||
// 2. unique-event-key (8 bytes)
|
||||
// 3. event name (c-string with 0)
|
||||
//
|
||||
// actualEventListRadioShortIDs:
|
||||
// data of request:
|
||||
// -
|
||||
// data of response:
|
||||
// 1. unique-service-key (4 bytes)
|
||||
// 2. unique-event-key (8 bytes)
|
||||
// 3. event name (c-string with 0)
|
||||
//
|
||||
// currentNextInformationID:
|
||||
// data of request:
|
||||
// 4 byte channel ID (4 byte, onid<<16+sid)
|
||||
// 1 byte number of Events (noch nicht implementiert)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the current/next EPGs
|
||||
// every event:
|
||||
// 1. 8 bytes unique key (unsigned long long),
|
||||
// 2. struct sectionsdTime (8 bytes)
|
||||
// 3. name (c-string with 0)
|
||||
//
|
||||
// epgEPGid:
|
||||
// data of request:
|
||||
// unique epg ID (8 byte)
|
||||
// time_t starttime GMT (4 bytes)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG:
|
||||
// name 0xff text 0xff extended text 0xff start time GMT (ctime, hex ) 0xff duration (seconds, hex) 0xff
|
||||
//
|
||||
// epgEPGidShort:
|
||||
// data of request:
|
||||
// unique epg ID (8 byte)
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG:
|
||||
// name 0xff text 0xff extended text 0xff
|
||||
//
|
||||
// CurrentComponentTags
|
||||
// - gets all ComponentDescriptor-Tags for the currently running Event
|
||||
//
|
||||
// data of request:
|
||||
// is channel ID (4 byte, onid<<16+sid)
|
||||
// data of response:
|
||||
// for each component-descriptor (zB %02hhx %02hhx %02hhx\n%s\n)
|
||||
// componentTag
|
||||
// componentType
|
||||
// streamContent
|
||||
// component.c_str
|
||||
//
|
||||
// allEventsChannelID:
|
||||
// data of request:
|
||||
// is channel ID
|
||||
// data of response:
|
||||
// is a string (c-string) describing the cached events for the requestet channel
|
||||
// 1 line per event, format: uniqueEventKey DD.MM HH:MM durationInMinutes Event name
|
||||
//
|
||||
// timesNVODservice
|
||||
// data of request:
|
||||
// is channel ID
|
||||
// data of response:
|
||||
// for every (sub-)channel
|
||||
// channelID (4 byte, onid<<16+sid)
|
||||
// transportStreamID (2 byte)
|
||||
// start time (4 bytes ctime)
|
||||
// duration (4 bytes unsigned)
|
||||
//
|
||||
// getEPGPrevNext
|
||||
// data of request:
|
||||
// 8 bytes (long long in 32 bit world) with unique key (binary) of the event for wich the next should be delivered
|
||||
// 4 bytes with start time (ctime) of the above event
|
||||
// data of response:
|
||||
// is a string (c-string) describing the EPG:
|
||||
// unique key (long long, hex) 0xff start time GMT (ctime, hex ) for previous event
|
||||
// unique key (long long, hex) 0xff start time GMT (ctime, hex ) for next event
|
||||
|
||||
//
|
||||
// LoadLanguages
|
||||
// data of request:
|
||||
// none
|
||||
// data of response:
|
||||
// success status (sizeof(bool))
|
||||
//
|
||||
// SaveLanguages
|
||||
// data of request:
|
||||
// none
|
||||
// data of response:
|
||||
// success status (sizeof(bool))
|
||||
//
|
||||
// SetLanguages
|
||||
// data of request:
|
||||
// n * 3 bytes (iso_639_2 language codes)
|
||||
// data of response:
|
||||
// success status (sizeof(bool))
|
||||
//
|
||||
// GetLanguages
|
||||
// data of request:
|
||||
// none
|
||||
// data of response:
|
||||
// n * 3 bytes (iso_639_2 language codes)
|
||||
//
|
||||
// SetLanguageMode
|
||||
// data of request:
|
||||
// mode (sizeof(CSectionsdClient::SIlanguageMode_t),
|
||||
// ALL, FIRST_FIRST, FIRST_ALL, ALL_FIRST or ALL_ALL)
|
||||
// data of response:
|
||||
// success status (sizeof(bool))
|
||||
//
|
||||
// GetLanguageMode
|
||||
// data of request:
|
||||
// none
|
||||
// data of response:
|
||||
// mode (see above)
|
||||
//
|
||||
// setConfig
|
||||
// data of request:
|
||||
// int scanMode; -> updating of services and bouquets -> saved in auto_scanning
|
||||
// int epg_cache; -> in days -> saved in secondsToCache
|
||||
// int epg_old_events; -> in hours -> saved in oldEventsAre
|
||||
// unsigned int epg_max_events; -> #of saved events -> saved in max_events
|
||||
// int network_ntprefresh; -> time refresh intervall -> saved in ntprefresh
|
||||
// int network_ntpenable; -> time refresh via ntp server -> saved in ntpenable
|
||||
// std::string network_ntpserver; -> ntpserver -> saved in ntpserver
|
||||
// std::string epg_dir; -> epg_dir to im/export the epg xml files -> saved in epg_file
|
||||
// data of response:
|
||||
// -
|
||||
|
||||
#endif // SECTIONSDMSG_H
|
803
lib/sectionsdclient/sectionsdclient.cpp
Normal file
803
lib/sectionsdclient/sectionsdclient.cpp
Normal file
@@ -0,0 +1,803 @@
|
||||
/*
|
||||
Client-Interface f<>r zapit - DBoxII-Project
|
||||
|
||||
$Id: sectionsdclient.cpp,v 1.53 2007/01/12 22:57:57 houdini Exp $
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include <eventserver.h>
|
||||
|
||||
#include <sectionsdclient/sectionsdclient.h>
|
||||
#include <sectionsdclient/sectionsdMsg.h>
|
||||
|
||||
|
||||
const unsigned char CSectionsdClient::getVersion () const
|
||||
{
|
||||
return sectionsd::ACTVERSION;
|
||||
}
|
||||
|
||||
const char * CSectionsdClient::getSocketName() const
|
||||
{
|
||||
return SECTIONSD_UDS_NAME;
|
||||
}
|
||||
|
||||
int CSectionsdClient::readResponse(char* data,unsigned int size)
|
||||
{
|
||||
struct sectionsd::msgResponseHeader responseHeader;
|
||||
if (!receive_data((char*)&responseHeader, sizeof(responseHeader)))
|
||||
return 0;
|
||||
|
||||
if ( data != NULL )
|
||||
{
|
||||
if ( responseHeader.dataLength != (unsigned)size )
|
||||
return -1;
|
||||
else
|
||||
return receive_data(data, size);
|
||||
}
|
||||
else
|
||||
return responseHeader.dataLength;
|
||||
}
|
||||
|
||||
|
||||
bool CSectionsdClient::send(const unsigned char command, const char* data, const unsigned int size)
|
||||
{
|
||||
sectionsd::msgRequestHeader msgHead;
|
||||
|
||||
msgHead.version = getVersion();
|
||||
msgHead.command = command;
|
||||
msgHead.dataLength = size;
|
||||
|
||||
open_connection(); // if the return value is false, the next send_data call will return false, too
|
||||
|
||||
if (!send_data((char*)&msgHead, sizeof(msgHead)))
|
||||
return false;
|
||||
|
||||
if (size != 0)
|
||||
return send_data(data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSectionsdClient::registerEvent(const unsigned int eventID, const unsigned int clientID, const char * const udsName)
|
||||
{
|
||||
CEventServer::commandRegisterEvent msg2;
|
||||
|
||||
msg2.eventID = eventID;
|
||||
msg2.clientID = clientID;
|
||||
|
||||
strcpy(msg2.udsName, udsName);
|
||||
|
||||
send(sectionsd::CMD_registerEvents, (char*)&msg2, sizeof(msg2));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
|
||||
void CSectionsdClient::unRegisterEvent(const unsigned int eventID, const unsigned int clientID)
|
||||
{
|
||||
CEventServer::commandUnRegisterEvent msg2;
|
||||
|
||||
msg2.eventID = eventID;
|
||||
msg2.clientID = clientID;
|
||||
|
||||
send(sectionsd::CMD_unregisterEvents, (char*)&msg2, sizeof(msg2));
|
||||
|
||||
close_connection();
|
||||
}
|
||||
|
||||
bool CSectionsdClient::getIsTimeSet()
|
||||
{
|
||||
sectionsd::responseIsTimeSet rmsg;
|
||||
|
||||
if (send(sectionsd::getIsTimeSet))
|
||||
{
|
||||
readResponse((char*)&rmsg, sizeof(rmsg));
|
||||
close_connection();
|
||||
|
||||
return rmsg.IsTimeSet;
|
||||
}
|
||||
else
|
||||
{
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void CSectionsdClient::setEventsAreOldInMinutes(const unsigned short minutes)
|
||||
{
|
||||
send(sectionsd::setEventsAreOldInMinutes, (char*)&minutes, sizeof(minutes));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSectionsdClient::setPauseSorting(const bool doPause)
|
||||
{
|
||||
int PauseIt = (doPause) ? 1 : 0;
|
||||
|
||||
send(sectionsd::pauseSorting, (char*)&PauseIt, sizeof(PauseIt));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
void CSectionsdClient::setPauseScanning(const bool doPause)
|
||||
{
|
||||
int PauseIt = (doPause) ? 1 : 0;
|
||||
|
||||
send(sectionsd::pauseScanning, (char*)&PauseIt, sizeof(PauseIt));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
bool CSectionsdClient::getIsScanningActive()
|
||||
{
|
||||
int scanning;
|
||||
|
||||
if (send(sectionsd::getIsScanningActive))
|
||||
{
|
||||
readResponse((char*)&scanning, sizeof(scanning));
|
||||
close_connection();
|
||||
|
||||
return scanning;
|
||||
}
|
||||
else
|
||||
{
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CSectionsdClient::setServiceChanged(const t_channel_id channel_id, const bool requestEvent)
|
||||
{
|
||||
sectionsd::commandSetServiceChanged msg;
|
||||
|
||||
msg.channel_id = channel_id;
|
||||
msg.requestEvent = requestEvent;
|
||||
|
||||
send(sectionsd::serviceChanged, (char *)&msg, sizeof(msg));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
|
||||
bool CSectionsdClient::getComponentTagsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::ComponentTagList& tags)
|
||||
{
|
||||
if (send(sectionsd::ComponentTagsUniqueKey, (char*)&uniqueKey, sizeof(uniqueKey)))
|
||||
{
|
||||
tags.clear();
|
||||
|
||||
int nBufSize = readResponse();
|
||||
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
char* dp = pData;
|
||||
|
||||
int count= *(int *) pData;
|
||||
dp+= sizeof(int);
|
||||
|
||||
CSectionsdClient::responseGetComponentTags response;
|
||||
for (int i= 0; i<count; i++)
|
||||
{
|
||||
response.component = dp;
|
||||
dp+= strlen(dp)+1;
|
||||
response.componentType = *(unsigned char *) dp;
|
||||
dp+=sizeof(unsigned char);
|
||||
response.componentTag = *(unsigned char *) dp;
|
||||
dp+=sizeof(unsigned char);
|
||||
response.streamContent = *(unsigned char *) dp;
|
||||
dp+=sizeof(unsigned char);
|
||||
|
||||
tags.insert( tags.end(), response);
|
||||
}
|
||||
delete[] pData;
|
||||
close_connection();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CSectionsdClient::getLinkageDescriptorsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::LinkageDescriptorList& descriptors)
|
||||
{
|
||||
if (send(sectionsd::LinkageDescriptorsUniqueKey, (char*)&uniqueKey, sizeof(uniqueKey)))
|
||||
{
|
||||
descriptors.clear();
|
||||
|
||||
int nBufSize = readResponse();
|
||||
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
char* dp = pData;
|
||||
|
||||
int count= *(int *) pData;
|
||||
dp+= sizeof(int);
|
||||
|
||||
CSectionsdClient::responseGetLinkageDescriptors response;
|
||||
for (int i= 0; i<count; i++)
|
||||
{
|
||||
response.name = dp;
|
||||
dp+= strlen(dp)+1;
|
||||
response.transportStreamId = *(t_transport_stream_id *) dp;
|
||||
dp+=sizeof(t_transport_stream_id);
|
||||
response.originalNetworkId = *(t_original_network_id *) dp;
|
||||
dp+=sizeof(t_original_network_id);
|
||||
response.serviceId = *(t_service_id *) dp;
|
||||
dp+=sizeof(t_service_id);
|
||||
|
||||
descriptors.insert( descriptors.end(), response);
|
||||
}
|
||||
delete[] pData;
|
||||
close_connection();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CSectionsdClient::getNVODTimesServiceKey(const t_channel_id channel_id, CSectionsdClient::NVODTimesList& nvod_list)
|
||||
{
|
||||
if (send(sectionsd::timesNVODservice, (char*)&channel_id, sizeof(channel_id)))
|
||||
{
|
||||
nvod_list.clear();
|
||||
|
||||
int nBufSize = readResponse();
|
||||
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
char* dp = pData;
|
||||
|
||||
CSectionsdClient::responseGetNVODTimes response;
|
||||
|
||||
while( dp< pData+ nBufSize )
|
||||
{
|
||||
response.service_id = *(t_service_id *) dp; dp += sizeof(t_service_id);
|
||||
response.original_network_id = *(t_original_network_id *) dp; dp += sizeof(t_original_network_id);
|
||||
response.transport_stream_id = *(t_transport_stream_id *) dp; dp += sizeof(t_transport_stream_id);
|
||||
response.zeit = *(CSectionsdClient::sectionsdTime*) dp; dp += sizeof(CSectionsdClient::sectionsdTime);
|
||||
|
||||
nvod_list.insert( nvod_list.end(), response);
|
||||
}
|
||||
delete[] pData;
|
||||
close_connection();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CSectionsdClient::getCurrentNextServiceKey(const t_channel_id channel_id, CSectionsdClient::responseGetCurrentNextInfoChannelID& current_next)
|
||||
{
|
||||
if (send(sectionsd::currentNextInformationID, (char*)&channel_id, sizeof(channel_id)))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
char* dp = pData;
|
||||
|
||||
// current
|
||||
current_next.current_uniqueKey = *((event_id_t *)dp);
|
||||
dp+= sizeof(event_id_t);
|
||||
current_next.current_zeit = *(CSectionsdClient::sectionsdTime*) dp;
|
||||
dp+= sizeof(CSectionsdClient::sectionsdTime);
|
||||
current_next.current_name = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
// next
|
||||
current_next.next_uniqueKey = *((event_id_t *)dp);
|
||||
dp+= sizeof(event_id_t);
|
||||
current_next.next_zeit = *(CSectionsdClient::sectionsdTime*) dp;
|
||||
dp+= sizeof(CSectionsdClient::sectionsdTime);
|
||||
current_next.next_name = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
current_next.flags = *(unsigned*) dp;
|
||||
dp+= sizeof(unsigned);
|
||||
|
||||
current_next.current_fsk = *(char*) dp;
|
||||
|
||||
delete[] pData;
|
||||
close_connection();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_next.flags = 0;
|
||||
close_connection();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CChannelEventList CSectionsdClient::getChannelEvents(const bool tv_mode, t_channel_id *p_requested_channels, int size_requested_channels)
|
||||
{
|
||||
CChannelEventList eList;
|
||||
|
||||
if (send(tv_mode ? sectionsd::actualEventListTVshortIDs : sectionsd::actualEventListRadioShortIDs, (char*)p_requested_channels, size_requested_channels))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
|
||||
if( nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
while(dp < pData + nBufSize)
|
||||
{
|
||||
CChannelEvent aEvent;
|
||||
|
||||
aEvent.eventID = *((event_id_t *) dp);
|
||||
dp+=sizeof(aEvent.eventID);
|
||||
|
||||
aEvent.startTime = *((time_t *) dp);
|
||||
dp+=sizeof(aEvent.startTime);
|
||||
|
||||
aEvent.duration = *((unsigned *) dp);
|
||||
dp+=sizeof(aEvent.duration);
|
||||
|
||||
aEvent.description= dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
aEvent.text= dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
eList.push_back(aEvent);
|
||||
}
|
||||
delete[] pData;
|
||||
}
|
||||
}
|
||||
close_connection();
|
||||
return eList;
|
||||
}
|
||||
|
||||
//GU:EPG
|
||||
/* This function does initiate a search for a keyword in all EPG Event of the Channel channel_id in sectionsd.
|
||||
The parameter search_typ does specify the search mode
|
||||
0: none -> all EPG events of the channel are returned
|
||||
1: keyword search in EPG Title
|
||||
2: keyword search in EPG short description (INFO1)
|
||||
3: keyword search in EPG description (INFO2)
|
||||
In case of a match, the EPG event is added to the Eventlist eList.
|
||||
*/
|
||||
bool CSectionsdClient::getEventsServiceKeySearchAdd(CChannelEventList& eList,const t_channel_id channel_id,char search_typ,std::string& search_text)
|
||||
{
|
||||
int nBufSize=0;
|
||||
|
||||
nBufSize += sizeof(t_channel_id);
|
||||
nBufSize += sizeof(char);
|
||||
nBufSize += search_text.size()+1;
|
||||
|
||||
char* pSData = new char[nBufSize];
|
||||
char* pSData_ptr = pSData;
|
||||
|
||||
*(t_channel_id*)pSData_ptr = channel_id;
|
||||
pSData_ptr += sizeof(t_channel_id);
|
||||
*pSData_ptr = search_typ;
|
||||
pSData_ptr += sizeof(char);
|
||||
strcpy(pSData_ptr,search_text.c_str());
|
||||
|
||||
if (send(sectionsd::allEventsChannelIDSearch, pSData, nBufSize))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
|
||||
if( nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
// int a = eList.size();
|
||||
|
||||
while(dp < pData + nBufSize)
|
||||
{
|
||||
CChannelEvent aEvent;
|
||||
|
||||
aEvent.eventID = *((event_id_t *) dp);
|
||||
dp+=sizeof(aEvent.eventID);
|
||||
|
||||
aEvent.startTime = *((time_t *) dp);
|
||||
dp+=sizeof(aEvent.startTime);
|
||||
|
||||
aEvent.duration = *((unsigned *) dp);
|
||||
dp+=sizeof(aEvent.duration);
|
||||
|
||||
aEvent.description= dp;
|
||||
dp+=aEvent.description.length()+1;
|
||||
|
||||
aEvent.text= dp;
|
||||
dp+=aEvent.text.length()+1;
|
||||
|
||||
eList.push_back(aEvent);
|
||||
}
|
||||
// int b = eList.size() -a;
|
||||
delete[] pData;
|
||||
}
|
||||
}
|
||||
delete[] pSData;
|
||||
|
||||
close_connection();
|
||||
return true;
|
||||
}
|
||||
|
||||
CChannelEventList CSectionsdClient::getEventsServiceKey(const t_channel_id channel_id)
|
||||
{
|
||||
CChannelEventList eList;
|
||||
|
||||
if (send(sectionsd::allEventsChannelID_, (char*)&channel_id, sizeof(channel_id)))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
|
||||
if( nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
while(dp < pData + nBufSize)
|
||||
{
|
||||
CChannelEvent aEvent;
|
||||
|
||||
aEvent.eventID = *((event_id_t *) dp);
|
||||
dp+=sizeof(aEvent.eventID);
|
||||
|
||||
aEvent.startTime = *((time_t *) dp);
|
||||
dp+=sizeof(aEvent.startTime);
|
||||
|
||||
aEvent.duration = *((unsigned *) dp);
|
||||
dp+=sizeof(aEvent.duration);
|
||||
|
||||
aEvent.description= dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
aEvent.text= dp;
|
||||
dp+=strlen(dp)+1;
|
||||
|
||||
eList.push_back(aEvent);
|
||||
}
|
||||
delete[] pData;
|
||||
}
|
||||
}
|
||||
|
||||
close_connection();
|
||||
return eList;
|
||||
}
|
||||
void showhexdumpa (char *label, unsigned char * from, int len)
|
||||
{
|
||||
int i, j, k;
|
||||
char buf[128];
|
||||
char abuf[128];
|
||||
unsigned char fl, ol;
|
||||
|
||||
fl = len / 16;
|
||||
ol = len % 16;
|
||||
if (label) {
|
||||
time_t tt = time (0);
|
||||
printf("\n%s -- %s", label, ctime (&tt));
|
||||
printf("----------------------------------------------------\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < fl; i++) {
|
||||
j = i * 16;
|
||||
sprintf (buf, "%03X: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", i * 16, from[j + 0], from[j + 1], from[j + 2], from[j + 3], from[j + 4], from[j + 5], from[j + 6], from[j + 7], from[j + 8], from[j + 9], from[j + 10], from[j + 11], from[j + 12], from[j + 13], from[j + 14], from[j + 15]);
|
||||
printf ("%s ", buf);
|
||||
for (k = 0; k < 16; k++) {
|
||||
abuf[k] = (from[j + k] >= 0x20 && from[j + k] <= 0x7b) ? from[j + k] : 0x2E;
|
||||
}
|
||||
abuf[16] = 0;
|
||||
printf("%s\n", abuf);
|
||||
}
|
||||
if (ol) {
|
||||
j = fl * 16;
|
||||
sprintf (buf, "%03X: ", j);
|
||||
for (i = 0; i < ol; i++) {
|
||||
sprintf (&buf[5 + i * 3], "%02x ", from[j + i]);
|
||||
abuf[i] = (from[j + i] >= 0x20 && from[j + i] <= 0x7b) ? from[j + i] : 0x2E;
|
||||
}
|
||||
abuf[ol] = 0;
|
||||
for (i = ol; i < 16; i++)
|
||||
sprintf (&buf[5 + i * 3], " ");
|
||||
printf ("%s ", buf);
|
||||
printf ("%s\n", abuf);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
// 21.07.2005 - rainerk
|
||||
// Convert line-terminated extended events to vector of strings
|
||||
char * CSectionsdClient::parseExtendedEvents(char * dp, CEPGData * epgdata) {
|
||||
char * pItemDescriptions = dp, * pItemDescriptionStart;
|
||||
dp+=strlen(dp)+1;
|
||||
char * pItems = dp, * pItemStart;
|
||||
dp+=strlen(dp)+1;
|
||||
/* Clear vector since epgdata seems to be reused */
|
||||
epgdata->itemDescriptions.clear();
|
||||
while (*pItemDescriptions) {
|
||||
pItemDescriptionStart = pItemDescriptions;
|
||||
while (*pItemDescriptions && '\n' != *pItemDescriptions) {
|
||||
pItemDescriptions++;
|
||||
}
|
||||
char pp = *pItemDescriptions;
|
||||
*pItemDescriptions = 0;
|
||||
epgdata->itemDescriptions.push_back(pItemDescriptionStart);
|
||||
/*printf("CSectionsdClient::parseExtendedEvents: desc %s\n", pItemDescriptionStart);*/
|
||||
if(!pp)
|
||||
break;
|
||||
pItemDescriptions++;
|
||||
}
|
||||
/* Clear vector since epgdata seems to be reused */
|
||||
epgdata->items.clear();
|
||||
while (*pItems) {
|
||||
pItemStart = pItems;
|
||||
while (*pItems && '\n' != *pItems) {
|
||||
pItems++;
|
||||
}
|
||||
char pp = *pItemDescriptions;
|
||||
*pItems = 0;
|
||||
epgdata->items.push_back(pItemStart);
|
||||
/*printf("CSectionsdClient::parseExtendedEvents: item %s\n", pItemStart);*/
|
||||
if(!pp)
|
||||
break;
|
||||
pItems++;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
bool CSectionsdClient::getActualEPGServiceKey(const t_channel_id channel_id, CEPGData * epgdata)
|
||||
{
|
||||
epgdata->title = "";
|
||||
|
||||
if (send(sectionsd::actualEPGchannelID, (char*)&channel_id, sizeof(channel_id)))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
if( nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
close_connection();
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
epgdata->eventID = *((event_id_t *)dp);
|
||||
dp+= sizeof(epgdata->eventID);
|
||||
|
||||
epgdata->title = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info1 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info2 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
// 21.07.2005 - rainerk
|
||||
// Convert line-terminated extended events to vector of strings
|
||||
//showhexdumpa("Data:", (unsigned char *)pData, nBufSize);
|
||||
dp = parseExtendedEvents(dp, epgdata);
|
||||
|
||||
// *dp is the length, dp+1 is the chararray[]
|
||||
epgdata->contentClassification = std::string(dp+1, *dp);
|
||||
dp+=*dp+1;
|
||||
epgdata->userClassification = std::string(dp+1, *dp);
|
||||
dp+=*dp+1;
|
||||
|
||||
epgdata->fsk = *dp++;
|
||||
|
||||
epgdata->epg_times.startzeit = ((CSectionsdClient::sectionsdTime *) dp)->startzeit;
|
||||
epgdata->epg_times.dauer = ((CSectionsdClient::sectionsdTime *) dp)->dauer;
|
||||
dp+= sizeof(CSectionsdClient::sectionsdTime);
|
||||
|
||||
delete[] pData;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
printf("no response from sectionsd\n");
|
||||
}
|
||||
|
||||
close_connection();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CSectionsdClient::getEPGid(const event_id_t eventid, const time_t starttime, CEPGData * epgdata)
|
||||
{
|
||||
sectionsd::commandGetEPGid msg;
|
||||
|
||||
msg.eventid = eventid;
|
||||
msg.starttime = starttime;
|
||||
|
||||
if (send(sectionsd::epgEPGid, (char *)&msg, sizeof(msg)))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
if (nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
close_connection();
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
epgdata->eventID = *((event_id_t *)dp);
|
||||
dp+= sizeof(epgdata->eventID);
|
||||
|
||||
epgdata->title = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info1 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info2 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
// 21.07.2005 - rainerk
|
||||
// Convert line-terminated extended events to vector of strings
|
||||
dp = parseExtendedEvents(dp, epgdata);
|
||||
|
||||
// *dp is the length, dp+1 is the chararray[]
|
||||
epgdata->contentClassification = std::string(dp+1, *dp);
|
||||
dp+=*dp+1;
|
||||
epgdata->userClassification = std::string(dp+1, *dp);
|
||||
dp+=*dp+1;
|
||||
|
||||
epgdata->fsk = *dp++;
|
||||
|
||||
epgdata->epg_times.startzeit = ((CSectionsdClient::sectionsdTime *) dp)->startzeit;
|
||||
epgdata->epg_times.dauer = ((CSectionsdClient::sectionsdTime *) dp)->dauer;
|
||||
dp+= sizeof(CSectionsdClient::sectionsdTime);
|
||||
|
||||
delete[] pData;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
printf("no response from sectionsd\n");
|
||||
}
|
||||
|
||||
close_connection();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CSectionsdClient::getEPGidShort(const event_id_t eventid, CShortEPGData * epgdata)
|
||||
{
|
||||
if (send(sectionsd::epgEPGidShort, (char*)&eventid, sizeof(eventid)))
|
||||
{
|
||||
int nBufSize = readResponse();
|
||||
if( nBufSize > 0)
|
||||
{
|
||||
char* pData = new char[nBufSize];
|
||||
receive_data(pData, nBufSize);
|
||||
|
||||
close_connection();
|
||||
|
||||
char* dp = pData;
|
||||
|
||||
for(int i = 0; i < nBufSize;i++)
|
||||
if(((unsigned char)pData[i]) == 0xff)
|
||||
pData[i] = 0;
|
||||
|
||||
epgdata->title = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info1 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
epgdata->info2 = dp;
|
||||
dp+=strlen(dp)+1;
|
||||
// printf("titel: %s\n",epgdata->title.c_str());
|
||||
|
||||
|
||||
delete[] pData;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
printf("no response from sectionsd\n");
|
||||
}
|
||||
|
||||
close_connection();
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef ENABLE_PPT
|
||||
void CSectionsdClient::setPrivatePid(const unsigned short pid)
|
||||
{
|
||||
send(sectionsd::setPrivatePid, (char*)&pid, sizeof(pid));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
void CSectionsdClient::setSectionsdScanMode(const int scanMode)
|
||||
{
|
||||
send(sectionsd::setSectionsdScanMode, (char*)&scanMode, sizeof(scanMode));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSectionsdClient::freeMemory()
|
||||
{
|
||||
send(sectionsd::freeMemory);
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
void CSectionsdClient::readSIfromXML(const char * epgxmlname)
|
||||
{
|
||||
send(sectionsd::readSIfromXML, (char*) epgxmlname, strlen(epgxmlname));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
void CSectionsdClient::writeSI2XML(const char * epgxmlname)
|
||||
{
|
||||
send(sectionsd::writeSI2XML, (char*) epgxmlname, strlen(epgxmlname));
|
||||
|
||||
readResponse();
|
||||
close_connection();
|
||||
}
|
||||
|
||||
void CSectionsdClient::setConfig(const epg_config config)
|
||||
{
|
||||
sectionsd::commandSetConfig *msg;
|
||||
char* pData = new char[sizeof(sectionsd::commandSetConfig) + config.network_ntpserver.length() + 1 + config.epg_dir.length() + 1];
|
||||
msg = (sectionsd::commandSetConfig *)pData;
|
||||
|
||||
msg->scanMode = config.scanMode;
|
||||
msg->epg_cache = config.epg_cache;
|
||||
msg->epg_old_events = config.epg_old_events;
|
||||
msg->epg_max_events = config.epg_max_events;
|
||||
msg->network_ntprefresh = config.network_ntprefresh;
|
||||
msg->network_ntpenable = config.network_ntpenable;
|
||||
msg->epg_extendedcache = config.epg_extendedcache;
|
||||
// config.network_ntpserver:
|
||||
strcpy(&pData[sizeof(sectionsd::commandSetConfig)], config.network_ntpserver.c_str());
|
||||
// config.epg_dir:
|
||||
strcpy(&pData[sizeof(sectionsd::commandSetConfig) + config.network_ntpserver.length() + 1], config.epg_dir.c_str());
|
||||
|
||||
send(sectionsd::setConfig, (char*)pData, sizeof(sectionsd::commandSetConfig) + config.network_ntpserver.length() + 1 + config.epg_dir.length() + 1);
|
||||
readResponse();
|
||||
close_connection();
|
||||
delete[] pData;
|
||||
}
|
||||
|
||||
void CSectionsdClient::dumpStatus()
|
||||
{
|
||||
send(sectionsd::dumpStatusinformation);
|
||||
close_connection();
|
||||
}
|
251
lib/sectionsdclient/sectionsdclient.h
Normal file
251
lib/sectionsdclient/sectionsdclient.h
Normal file
@@ -0,0 +1,251 @@
|
||||
#ifndef __sectionsdclient__
|
||||
#define __sectionsdclient__
|
||||
/*
|
||||
Client-Interface f<>r zapit - DBoxII-Project
|
||||
|
||||
$Id: sectionsdclient.h,v 1.42 2007/01/12 22:57:57 houdini Exp $
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <connection/basicclient.h>
|
||||
|
||||
#include <sectionsdclient/sectionsdtypes.h>
|
||||
|
||||
class CShortEPGData
|
||||
{
|
||||
public:
|
||||
std::string title;
|
||||
std::string info1;
|
||||
std::string info2;
|
||||
|
||||
CShortEPGData()
|
||||
{
|
||||
title = "";
|
||||
info1 = "";
|
||||
info2 = "";
|
||||
};
|
||||
};
|
||||
|
||||
class CEPGData;
|
||||
|
||||
class CChannelEvent
|
||||
{
|
||||
public:
|
||||
t_channel_id get_channel_id(void) const { return GET_CHANNEL_ID_FROM_EVENT_ID(eventID); }
|
||||
event_id_t eventID;
|
||||
std::string description;
|
||||
std::string text;
|
||||
time_t startTime;
|
||||
unsigned duration;
|
||||
};
|
||||
|
||||
typedef std::vector<CChannelEvent> CChannelEventList;
|
||||
|
||||
class CSectionsdClient : private CBasicClient
|
||||
{
|
||||
private:
|
||||
virtual const unsigned char getVersion () const;
|
||||
virtual const char * getSocketName() const;
|
||||
|
||||
int readResponse(char* data = NULL, unsigned int size = 0);
|
||||
bool send(const unsigned char command, const char* data = NULL, const unsigned int size = 0);
|
||||
char * parseExtendedEvents(char * dp, CEPGData * epgdata);
|
||||
|
||||
public:
|
||||
enum SIlanguageMode_t {
|
||||
ALL,
|
||||
FIRST_FIRST,
|
||||
FIRST_ALL,
|
||||
ALL_FIRST,
|
||||
ALL_ALL,
|
||||
LANGUAGE_MODE_OFF
|
||||
};
|
||||
|
||||
enum events
|
||||
{
|
||||
EVT_TIMESET,
|
||||
EVT_GOT_CN_EPG,
|
||||
EVT_SERVICES_UPDATE,
|
||||
EVT_BOUQUETS_UPDATE,
|
||||
EVT_WRITE_SI_FINISHED
|
||||
};
|
||||
|
||||
struct epgflags {
|
||||
enum
|
||||
{
|
||||
has_anything = 0x01,
|
||||
has_later = 0x02,
|
||||
has_current = 0x04,
|
||||
not_broadcast = 0x08,
|
||||
has_next = 0x10,
|
||||
has_no_current= 0x20,
|
||||
current_has_linkagedescriptors= 0x40
|
||||
};
|
||||
};
|
||||
|
||||
struct responseGetComponentTags
|
||||
{
|
||||
std::string component; // Text aus dem Component Descriptor
|
||||
unsigned char componentType; // Component Descriptor
|
||||
unsigned char componentTag; // Component Descriptor
|
||||
unsigned char streamContent; // Component Descriptor
|
||||
};
|
||||
typedef std::vector<responseGetComponentTags> ComponentTagList;
|
||||
|
||||
struct responseGetLinkageDescriptors
|
||||
{
|
||||
std::string name;
|
||||
t_transport_stream_id transportStreamId;
|
||||
t_original_network_id originalNetworkId;
|
||||
t_service_id serviceId;
|
||||
};
|
||||
typedef std::vector<responseGetLinkageDescriptors> LinkageDescriptorList;
|
||||
|
||||
struct sectionsdTime
|
||||
{
|
||||
time_t startzeit;
|
||||
unsigned dauer;
|
||||
} __attribute__ ((packed)) ;
|
||||
|
||||
struct responseGetNVODTimes
|
||||
{
|
||||
t_service_id service_id;
|
||||
t_original_network_id original_network_id;
|
||||
t_transport_stream_id transport_stream_id;
|
||||
CSectionsdClient::sectionsdTime zeit;
|
||||
};
|
||||
typedef std::vector<responseGetNVODTimes> NVODTimesList;
|
||||
|
||||
struct responseGetCurrentNextInfoChannelID
|
||||
{
|
||||
event_id_t current_uniqueKey;
|
||||
CSectionsdClient::sectionsdTime current_zeit;
|
||||
std::string current_name;
|
||||
char current_fsk;
|
||||
event_id_t next_uniqueKey;
|
||||
CSectionsdClient::sectionsdTime next_zeit;
|
||||
std::string next_name;
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
struct CurrentNextInfo : public responseGetCurrentNextInfoChannelID
|
||||
{};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int scanMode;
|
||||
int epg_cache;
|
||||
int epg_old_events;
|
||||
int epg_max_events;
|
||||
int network_ntprefresh;
|
||||
int network_ntpenable;
|
||||
int epg_extendedcache;
|
||||
std::string network_ntpserver;
|
||||
std::string epg_dir;
|
||||
} epg_config;
|
||||
|
||||
bool getComponentTagsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::ComponentTagList& tags);
|
||||
|
||||
bool getLinkageDescriptorsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::LinkageDescriptorList& descriptors);
|
||||
|
||||
bool getNVODTimesServiceKey(const t_channel_id channel_id, CSectionsdClient::NVODTimesList& nvod_list);
|
||||
|
||||
bool getCurrentNextServiceKey(const t_channel_id channel_id, CSectionsdClient::responseGetCurrentNextInfoChannelID& current_next);
|
||||
|
||||
bool getIsTimeSet();
|
||||
|
||||
// void setEventsAreOldInMinutes(const unsigned short minutes);
|
||||
|
||||
void setPauseScanning(const bool doPause);
|
||||
|
||||
bool getIsScanningActive();
|
||||
|
||||
void setPauseSorting(const bool doPause);
|
||||
|
||||
void setServiceChanged(const t_channel_id channel_id, const bool requestEvent);
|
||||
|
||||
CChannelEventList getChannelEvents(const bool tv_mode = true, t_channel_id* = NULL, int size = 0);
|
||||
|
||||
CChannelEventList getEventsServiceKey(const t_channel_id channel_id);
|
||||
|
||||
bool getEventsServiceKeySearchAdd(CChannelEventList& evtlist,const t_channel_id channel_id,char m_search_typ,std::string& m_search_text);
|
||||
|
||||
bool getEPGid(const event_id_t eventid, const time_t starttime, CEPGData * epgdata);
|
||||
|
||||
bool getActualEPGServiceKey(const t_channel_id channel_id, CEPGData * epgdata);
|
||||
|
||||
bool getEPGidShort(const event_id_t eventid, CShortEPGData * epgdata);
|
||||
|
||||
void setPrivatePid(const unsigned short pid);
|
||||
|
||||
// void setSectionsdScanMode(const int scanMode);
|
||||
|
||||
void freeMemory();
|
||||
|
||||
void readSIfromXML(const char * epgxmlname);
|
||||
|
||||
void writeSI2XML(const char * epgxmlname);
|
||||
|
||||
/*
|
||||
ein beliebiges Event anmelden
|
||||
*/
|
||||
void registerEvent(const unsigned int eventID, const unsigned int clientID, const char * const udsName);
|
||||
|
||||
/*
|
||||
ein beliebiges Event abmelden
|
||||
*/
|
||||
void unRegisterEvent(const unsigned int eventID, const unsigned int clientID);
|
||||
|
||||
void setConfig(const epg_config config);
|
||||
void dumpStatus(void);
|
||||
|
||||
};
|
||||
|
||||
class CEPGData
|
||||
{
|
||||
public:
|
||||
unsigned long long eventID;
|
||||
CSectionsdClient::sectionsdTime epg_times;
|
||||
std::string title;
|
||||
std::string info1;
|
||||
std::string info2;
|
||||
// 21.07.2005 - extended event data
|
||||
std::vector<std::string> itemDescriptions;
|
||||
std::vector<std::string> items;
|
||||
char fsk;
|
||||
std::string contentClassification;
|
||||
std::string userClassification;
|
||||
|
||||
CEPGData()
|
||||
{
|
||||
eventID = 0;
|
||||
title = "";
|
||||
info1 = "";
|
||||
info2 = "";
|
||||
fsk = 0;
|
||||
contentClassification = "";
|
||||
userClassification = "";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
75
lib/sectionsdclient/sectionsdcontrol.cpp
Normal file
75
lib/sectionsdclient/sectionsdcontrol.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* $Header: /cvs/tuxbox/apps/tuxbox/neutrino/lib/sectionsdclient/sectionsdcontrol.cpp,v 1.2 2003/06/18 12:19:22 alexw Exp $
|
||||
*
|
||||
* Sectionsd command line interface - The Tuxbox Project
|
||||
*
|
||||
* (C) 2003 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
* License: GPL
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <sectionsdclient/sectionsdclient.h>
|
||||
|
||||
CSectionsdClient client;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "--pause"))
|
||||
{
|
||||
printf("setPauseScanning true\n");
|
||||
client.setPauseScanning(true);
|
||||
}
|
||||
else
|
||||
if (!strcmp(argv[i], "--nopause"))
|
||||
{
|
||||
printf("setPauseScanning false\n");
|
||||
client.setPauseScanning(false);
|
||||
}
|
||||
else
|
||||
if (!strcmp(argv[i], "--state"))
|
||||
printf("Scanning is active: %s\n", client.getIsScanningActive()?"true":"false");
|
||||
else
|
||||
if (!strcmp(argv[i], "--saveepg")) {
|
||||
if(argv[i+1]) {
|
||||
char path[255];
|
||||
sprintf(path, "%s/", argv[i+1]);
|
||||
printf("writing epg cache to %s...\n", path);
|
||||
client.writeSI2XML(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(argv[i], "--readepg")) {
|
||||
if(argv[i+1]) {
|
||||
char path[255];
|
||||
sprintf(path, "%s/", argv[i+1]);
|
||||
printf("Reading epg cache from %s....\n", path);
|
||||
client.readSIfromXML(path);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(argv[i], "--dump")) {
|
||||
client.dumpStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
33
lib/sectionsdclient/sectionsdtypes.h
Normal file
33
lib/sectionsdclient/sectionsdtypes.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* $Id: sectionsdtypes.h,v 1.1 2004/02/13 14:36:19 thegoodguy Exp $
|
||||
*
|
||||
* sectionsd's types which are used by the clientlib - d-box2 linux project
|
||||
*
|
||||
* (C) 2004 by thegoodguy <thegoodguy@berlios.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __sectionsdtypes_h__
|
||||
#define __sectionsdtypes_h__
|
||||
|
||||
#include <zapit/client/zapittypes.h> /* t_channel_id, t_service_id, t_original_network_id, t_transport_stream_id; */
|
||||
|
||||
typedef uint64_t event_id_t;
|
||||
#define CREATE_EVENT_ID(channel_id,event_nr) ((((event_id_t)channel_id) << 16) | event_nr)
|
||||
#define GET_CHANNEL_ID_FROM_EVENT_ID(event_id) ((t_channel_id)((event_id) >> 16))
|
||||
|
||||
#endif /* __sectionsdtypes_h__ */
|
Reference in New Issue
Block a user