mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Reformatted debug messages.
This commit is contained in:
parent
e75080b1a8
commit
26a0adceb5
4
config.c
4
config.c
@ -18,7 +18,7 @@ cIptvConfig::cIptvConfig(void)
|
|||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
|
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
|
||||||
disabledFiltersM[i] = -1;
|
disabledFiltersM[i] = -1;
|
||||||
memset(configDirectoryM, '\0', sizeof(configDirectoryM));
|
memset(configDirectoryM, 0, sizeof(configDirectoryM));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
|
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
|
||||||
@ -42,6 +42,6 @@ void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP)
|
|||||||
|
|
||||||
void cIptvConfig::SetConfigDirectory(const char *directoryP)
|
void cIptvConfig::SetConfigDirectory(const char *directoryP)
|
||||||
{
|
{
|
||||||
debug("cIptvConfig::SetConfigDirectory(%s)\n", directoryP);
|
debug("cIptvConfig::%s(%s)", __FUNCTION__, directoryP);
|
||||||
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
|
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
|
||||||
}
|
}
|
||||||
|
60
device.c
60
device.c
@ -57,7 +57,7 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
|
|||||||
|
|
||||||
cIptvDevice::~cIptvDevice()
|
cIptvDevice::~cIptvDevice()
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::~cIptvDevice(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
// Stop section handler of iptv device
|
// Stop section handler of iptv device
|
||||||
StopSectionHandler();
|
StopSectionHandler();
|
||||||
DELETE_POINTER(pIptvStreamerM);
|
DELETE_POINTER(pIptvStreamerM);
|
||||||
@ -86,7 +86,7 @@ cIptvDevice::~cIptvDevice()
|
|||||||
|
|
||||||
bool cIptvDevice::Initialize(unsigned int deviceCountP)
|
bool cIptvDevice::Initialize(unsigned int deviceCountP)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::Initialize(): DeviceCount=%d\n", deviceCountP);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceCountP);
|
||||||
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
|
new cIptvSourceParam(IPTV_SOURCE_CHARACTER, "IPTV");
|
||||||
if (deviceCountP > IPTV_MAX_DEVICES)
|
if (deviceCountP > IPTV_MAX_DEVICES)
|
||||||
deviceCountP = IPTV_MAX_DEVICES;
|
deviceCountP = IPTV_MAX_DEVICES;
|
||||||
@ -100,7 +100,7 @@ bool cIptvDevice::Initialize(unsigned int deviceCountP)
|
|||||||
unsigned int cIptvDevice::Count(void)
|
unsigned int cIptvDevice::Count(void)
|
||||||
{
|
{
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
debug("cIptvDevice::Count()\n");
|
debug("cIptvDevice::%s()", __FUNCTION__);
|
||||||
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
||||||
if (IptvDevicesS[i] != NULL)
|
if (IptvDevicesS[i] != NULL)
|
||||||
count++;
|
count++;
|
||||||
@ -110,10 +110,10 @@ unsigned int cIptvDevice::Count(void)
|
|||||||
|
|
||||||
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
|
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetIptvDevice(%d)\n", cardIndexP);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, cardIndexP);
|
||||||
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
|
||||||
if ((IptvDevicesS[i] != NULL) && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
|
if ((IptvDevicesS[i] != NULL) && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
|
||||||
//debug("cIptvDevice::GetIptvDevice(%d): FOUND!\n", cardIndexP);
|
//debug("cIptvDevice::%s(%d): found!", __FUNCTION__, cardIndexP);
|
||||||
return IptvDevicesS[i];
|
return IptvDevicesS[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
|
|||||||
|
|
||||||
cString cIptvDevice::GetGeneralInformation(void)
|
cString cIptvDevice::GetGeneralInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetGeneralInformation(%d)\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
|
return cString::sprintf("IPTV device: %d\nCardIndex: %d\nStream: %s\nStream bitrate: %s\n%sChannel: %s",
|
||||||
deviceIndexM, CardIndex(),
|
deviceIndexM, CardIndex(),
|
||||||
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "",
|
pIptvStreamerM ? *pIptvStreamerM->GetInformation() : "",
|
||||||
@ -133,13 +133,13 @@ cString cIptvDevice::GetGeneralInformation(void)
|
|||||||
|
|
||||||
cString cIptvDevice::GetPidsInformation(void)
|
cString cIptvDevice::GetPidsInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetPidsInformation(%d)\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return GetPidStatistic();
|
return GetPidStatistic();
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::GetFiltersInformation(void)
|
cString cIptvDevice::GetFiltersInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetFiltersInformation(%d)\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
cString s("Active section filters:\n");
|
cString s("Active section filters:\n");
|
||||||
// loop through active section filters
|
// loop through active section filters
|
||||||
@ -187,37 +187,37 @@ cString cIptvDevice::GetInformation(unsigned int pageP)
|
|||||||
|
|
||||||
cString cIptvDevice::DeviceType(void) const
|
cString cIptvDevice::DeviceType(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::DeviceType(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return "IPTV";
|
return "IPTV";
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvDevice::DeviceName(void) const
|
cString cIptvDevice::DeviceName(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::DeviceName(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return cString::sprintf("IPTV %d", deviceIndexM);
|
return cString::sprintf("IPTV %d", deviceIndexM);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvDevice::SignalStrength(void) const
|
int cIptvDevice::SignalStrength(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::SignalStrength(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (100);
|
return (100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvDevice::SignalQuality(void) const
|
int cIptvDevice::SignalQuality(void) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::SignalQuality(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (100);
|
return (100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesSource(int sourceP) const
|
bool cIptvDevice::ProvidesSource(int sourceP) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER));
|
return (cSource::IsType(sourceP, IPTV_SOURCE_CHARACTER));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const
|
bool cIptvDevice::ProvidesTransponder(const cChannel *channelP) const
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return (ProvidesSource(channelP->Source()));
|
return (ProvidesSource(channelP->Source()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ bool cIptvDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool
|
|||||||
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
|
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
|
||||||
bool needsDetachReceivers = false;
|
bool needsDetachReceivers = false;
|
||||||
|
|
||||||
debug("cIptvDevice::ProvidesChannel(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
|
||||||
if (channelP && ProvidesTransponder(channelP)) {
|
if (channelP && ProvidesTransponder(channelP)) {
|
||||||
result = hasPriority;
|
result = hasPriority;
|
||||||
@ -258,7 +258,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
|
|||||||
cIptvProtocolIf *protocol;
|
cIptvProtocolIf *protocol;
|
||||||
cIptvTransponderParameters itp(channelP->Parameters());
|
cIptvTransponderParameters itp(channelP->Parameters());
|
||||||
|
|
||||||
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
|
|
||||||
if (isempty(itp.Address())) {
|
if (isempty(itp.Address())) {
|
||||||
error("Unrecognized IPTV address: %s", channelP->Parameters());
|
error("Unrecognized IPTV address: %s", channelP->Parameters());
|
||||||
@ -299,14 +299,14 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
|
|||||||
|
|
||||||
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
|
bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndexM, handleP->pid, typeP, onP);
|
debug("cIptvDevice::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP->pid, typeP, onP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::DeleteFilter(unsigned int indexP)
|
bool cIptvDevice::DeleteFilter(unsigned int indexP)
|
||||||
{
|
{
|
||||||
if ((indexP < eMaxSecFilterCount) && secFiltersM[indexP]) {
|
if ((indexP < eMaxSecFilterCount) && secFiltersM[indexP]) {
|
||||||
//debug("cIptvDevice::DeleteFilter(%d) Index=%d\n", deviceIndexM, indexP);
|
//debug("cIptvDevice::%s(%d): index=%d", __FUNCTION__, deviceIndexM, indexP);
|
||||||
cIptvSectionFilter *tmp = secFiltersM[indexP];
|
cIptvSectionFilter *tmp = secFiltersM[indexP];
|
||||||
secFiltersM[indexP] = NULL;
|
secFiltersM[indexP] = NULL;
|
||||||
delete tmp;
|
delete tmp;
|
||||||
@ -317,7 +317,7 @@ bool cIptvDevice::DeleteFilter(unsigned int indexP)
|
|||||||
|
|
||||||
bool cIptvDevice::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
|
bool cIptvDevice::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::IsBlackListed(%d) Pid=%d Tid=%02X Mask=%02X\n", deviceIndexM, pidP, tidP, maskP);
|
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X", __FUNCTION__, deviceIndexM, pidP, tidP, maskP);
|
||||||
// loop through section filter table
|
// loop through section filter table
|
||||||
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
|
||||||
int index = IptvConfig.GetDisabledFilters(i);
|
int index = IptvConfig.GetDisabledFilters(i);
|
||||||
@ -325,7 +325,7 @@ bool cIptvDevice::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
|
|||||||
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
|
if ((index >= 0) && (index < SECTION_FILTER_TABLE_SIZE) &&
|
||||||
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
|
(section_filter_table[index].pid == pidP) && (section_filter_table[index].tid == tidP) &&
|
||||||
(section_filter_table[index].mask == maskP)) {
|
(section_filter_table[index].mask == maskP)) {
|
||||||
//debug("cIptvDevice::IsBlackListed(%d) Found=%s\n", deviceIndexM, section_filter_table[index].description);
|
//debug("cIptvDevice::%s(%d): found %s", __FUNCTION__, deviceIndexM, section_filter_table[index].description);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
|
|||||||
// Search the next free filter slot
|
// Search the next free filter slot
|
||||||
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
|
||||||
if (!secFiltersM[i]) {
|
if (!secFiltersM[i]) {
|
||||||
//debug("cIptvDevice::OpenFilter(%d): Pid=%d Tid=%02X Mask=%02X Index=%d\n", deviceIndexM, pidP, tidP, maskP, i);
|
//debug("cIptvDevice::%s(%d): pid=%d tid=%02X mask=%02X index=%d", __FUNCTION__, deviceIndexM, pidP, tidP, maskP, i);
|
||||||
secFiltersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
|
secFiltersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
|
||||||
if (secFiltersM[i])
|
if (secFiltersM[i])
|
||||||
return i;
|
return i;
|
||||||
@ -363,7 +363,7 @@ int cIptvDevice::ReadFilter(int handleP, void *bufferP, size_t lengthP)
|
|||||||
// ... and load
|
// ... and load
|
||||||
if (secFiltersM[handleP]) {
|
if (secFiltersM[handleP]) {
|
||||||
return secFiltersM[handleP]->Read(bufferP, lengthP);
|
return secFiltersM[handleP]->Read(bufferP, lengthP);
|
||||||
//debug("cIptvDevice::ReadFilter(%d): %d %d\n", deviceIndexM, handleP, lengthP);
|
//debug("cIptvDevice::%s(%d): handle=%d length=%d", __FUNCTION__, deviceIndexM, handleP, lengthP);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -374,14 +374,14 @@ void cIptvDevice::CloseFilter(int handleP)
|
|||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
// ... and load
|
// ... and load
|
||||||
if (secFiltersM[handleP]) {
|
if (secFiltersM[handleP]) {
|
||||||
//debug("cIptvDevice::CloseFilter(%d): %d\n", deviceIndexM, handleP);
|
//debug("cIptvDevice::%s(%d): handle=%d", __FUNCTION__, deviceIndexM, handleP);
|
||||||
DeleteFilter(handleP);
|
DeleteFilter(handleP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::OpenDvr(void)
|
bool cIptvDevice::OpenDvr(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::OpenDvr(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
isPacketDeliveredM = false;
|
isPacketDeliveredM = false;
|
||||||
tsBufferM->Clear();
|
tsBufferM->Clear();
|
||||||
ResetBuffering();
|
ResetBuffering();
|
||||||
@ -395,7 +395,7 @@ bool cIptvDevice::OpenDvr(void)
|
|||||||
|
|
||||||
void cIptvDevice::CloseDvr(void)
|
void cIptvDevice::CloseDvr(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::CloseDvr(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
|
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
|
||||||
pSidScannerM->Close();
|
pSidScannerM->Close();
|
||||||
if (pIptvStreamerM)
|
if (pIptvStreamerM)
|
||||||
@ -405,19 +405,19 @@ void cIptvDevice::CloseDvr(void)
|
|||||||
|
|
||||||
bool cIptvDevice::HasLock(int timeoutMsP) const
|
bool cIptvDevice::HasLock(int timeoutMsP) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::HasLock(%d): %d\n", deviceIndexM, timeoutMsP);
|
//debug("cIptvDevice::%s(%d): timeoutMs=%d", __FUNCTION__, deviceIndexM, timeoutMsP);
|
||||||
return (!IsBuffering());
|
return (!IsBuffering());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvDevice::HasInternalCam(void)
|
bool cIptvDevice::HasInternalCam(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::HasInternalCam(%d)\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvDevice::ResetBuffering(void)
|
void cIptvDevice::ResetBuffering(void)
|
||||||
{
|
{
|
||||||
debug("cIptvDevice::ResetBuffering(%d)\n", deviceIndexM);
|
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
// pad prefill to multiple of TS_SIZE
|
// pad prefill to multiple of TS_SIZE
|
||||||
tsBufferPrefillM = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
tsBufferPrefillM = (unsigned int)MEGABYTE(IptvConfig.GetTsBufferSize()) *
|
||||||
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
IptvConfig.GetTsBufferPrefillRatio() / 100;
|
||||||
@ -426,7 +426,7 @@ void cIptvDevice::ResetBuffering(void)
|
|||||||
|
|
||||||
bool cIptvDevice::IsBuffering(void) const
|
bool cIptvDevice::IsBuffering(void) const
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::IsBuffering(%d): %d\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (tsBufferPrefillM && tsBufferM && tsBufferM->Available() < tsBufferPrefillM)
|
if (tsBufferPrefillM && tsBufferM && tsBufferM->Available() < tsBufferPrefillM)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -436,7 +436,7 @@ bool cIptvDevice::IsBuffering(void) const
|
|||||||
|
|
||||||
bool cIptvDevice::GetTSPacket(uchar *&Data)
|
bool cIptvDevice::GetTSPacket(uchar *&Data)
|
||||||
{
|
{
|
||||||
//debug("cIptvDevice::GetTSPacket(%d)\n", deviceIndexM);
|
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
|
||||||
if (tsBufferM && !IsBuffering()) {
|
if (tsBufferM && !IsBuffering()) {
|
||||||
if (isPacketDeliveredM) {
|
if (isPacketDeliveredM) {
|
||||||
tsBufferM->Del(TS_SIZE);
|
tsBufferM->Del(TS_SIZE);
|
||||||
|
38
iptv.c
38
iptv.c
@ -54,7 +54,7 @@ public:
|
|||||||
cPluginIptv::cPluginIptv(void)
|
cPluginIptv::cPluginIptv(void)
|
||||||
: deviceCountM(1)
|
: deviceCountM(1)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::cPluginIptv()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Initialize any member variables here.
|
// Initialize any member variables here.
|
||||||
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
|
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
|
||||||
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
|
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
|
||||||
@ -62,20 +62,20 @@ cPluginIptv::cPluginIptv(void)
|
|||||||
|
|
||||||
cPluginIptv::~cPluginIptv()
|
cPluginIptv::~cPluginIptv()
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::~cPluginIptv()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Clean up after yourself!
|
// Clean up after yourself!
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cPluginIptv::CommandLineHelp(void)
|
const char *cPluginIptv::CommandLineHelp(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::CommandLineHelp()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a string that describes all known command line options.
|
// Return a string that describes all known command line options.
|
||||||
return " -d <num>, --devices=<number> number of devices to be created\n";
|
return " -d <num>, --devices=<number> number of devices to be created\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::ProcessArgs()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Implement command line argument processing here if applicable.
|
// Implement command line argument processing here if applicable.
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "devices", required_argument, NULL, 'd' },
|
{ "devices", required_argument, NULL, 'd' },
|
||||||
@ -97,7 +97,7 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
|
|||||||
|
|
||||||
bool cPluginIptv::Initialize(void)
|
bool cPluginIptv::Initialize(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Initialize()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Initialize any background activities the plugin shall perform.
|
// Initialize any background activities the plugin shall perform.
|
||||||
IptvConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
|
IptvConfig.SetConfigDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
|
||||||
return cIptvDevice::Initialize(deviceCountM);
|
return cIptvDevice::Initialize(deviceCountM);
|
||||||
@ -105,7 +105,7 @@ bool cPluginIptv::Initialize(void)
|
|||||||
|
|
||||||
bool cPluginIptv::Start(void)
|
bool cPluginIptv::Start(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Start()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Start any background activities the plugin shall perform.
|
// Start any background activities the plugin shall perform.
|
||||||
if (curl_global_init(CURL_GLOBAL_ALL) == CURLE_OK) {
|
if (curl_global_init(CURL_GLOBAL_ALL) == CURLE_OK) {
|
||||||
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
|
||||||
@ -116,61 +116,61 @@ bool cPluginIptv::Start(void)
|
|||||||
|
|
||||||
void cPluginIptv::Stop(void)
|
void cPluginIptv::Stop(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Stop()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Stop any background activities the plugin is performing.
|
// Stop any background activities the plugin is performing.
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPluginIptv::Housekeeping(void)
|
void cPluginIptv::Housekeeping(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::Housekeeping()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform any cleanup or other regular tasks.
|
// Perform any cleanup or other regular tasks.
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPluginIptv::MainThreadHook(void)
|
void cPluginIptv::MainThreadHook(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::MainThreadHook()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform actions in the context of the main program thread.
|
// Perform actions in the context of the main program thread.
|
||||||
// WARNING: Use with great care - see PLUGINS.html!
|
// WARNING: Use with great care - see PLUGINS.html!
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cPluginIptv::Active(void)
|
cString cPluginIptv::Active(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::Active()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a message string if shutdown should be postponed
|
// Return a message string if shutdown should be postponed
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t cPluginIptv::WakeupTime(void)
|
time_t cPluginIptv::WakeupTime(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::WakeupTime()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return custom wakeup time for shutdown script
|
// Return custom wakeup time for shutdown script
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cOsdObject *cPluginIptv::MainMenuAction(void)
|
cOsdObject *cPluginIptv::MainMenuAction(void)
|
||||||
{
|
{
|
||||||
//debug("cPluginIptv::MainMenuAction()\n");
|
//debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Perform the action when selected from the main VDR menu.
|
// Perform the action when selected from the main VDR menu.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cMenuSetupPage *cPluginIptv::SetupMenu(void)
|
cMenuSetupPage *cPluginIptv::SetupMenu(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SetupMenu()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Return a setup menu in case the plugin supports one.
|
// Return a setup menu in case the plugin supports one.
|
||||||
return new cIptvPluginSetup();
|
return new cIptvPluginSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
|
int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::ParseFilters(%s)\n", valueP);
|
debug("cPluginIptv::%s(%s)", __FUNCTION__, valueP);
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) {
|
while (valueP && *valueP && (n < SECTION_FILTER_TABLE_SIZE)) {
|
||||||
strn0cpy(buffer, valueP, sizeof(buffer));
|
strn0cpy(buffer, valueP, sizeof(buffer));
|
||||||
int i = atoi(buffer);
|
int i = atoi(buffer);
|
||||||
//debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
|
//debug("cPluginIptv::%s(): filters[%d]=%d", __FUNCTION__, n, i);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
filtersP[n++] = i;
|
filtersP[n++] = i;
|
||||||
if ((valueP = strchr(valueP, ' ')) != NULL)
|
if ((valueP = strchr(valueP, ' ')) != NULL)
|
||||||
@ -181,7 +181,7 @@ int cPluginIptv::ParseFilters(const char *valueP, int *filtersP)
|
|||||||
|
|
||||||
bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
|
bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SetupParse()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
// Parse your own setup parameters and store their values.
|
// Parse your own setup parameters and store their values.
|
||||||
if (!strcasecmp(nameP, "TsBufferSize"))
|
if (!strcasecmp(nameP, "TsBufferSize"))
|
||||||
IptvConfig.SetTsBufferSize(atoi(valueP));
|
IptvConfig.SetTsBufferSize(atoi(valueP));
|
||||||
@ -206,7 +206,7 @@ bool cPluginIptv::SetupParse(const char *nameP, const char *valueP)
|
|||||||
|
|
||||||
bool cPluginIptv::Service(const char *idP, void *dataP)
|
bool cPluginIptv::Service(const char *idP, void *dataP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::Service()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
if (strcmp(idP,"IptvService-v1.0") == 0) {
|
if (strcmp(idP,"IptvService-v1.0") == 0) {
|
||||||
if (dataP) {
|
if (dataP) {
|
||||||
IptvService_v1_0 *data = reinterpret_cast<IptvService_v1_0*>(dataP);
|
IptvService_v1_0 *data = reinterpret_cast<IptvService_v1_0*>(dataP);
|
||||||
@ -223,7 +223,7 @@ bool cPluginIptv::Service(const char *idP, void *dataP)
|
|||||||
|
|
||||||
const char **cPluginIptv::SVDRPHelpPages(void)
|
const char **cPluginIptv::SVDRPHelpPages(void)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SVDRPHelpPages()\n");
|
debug("cPluginIptv::%s()", __FUNCTION__);
|
||||||
static const char *HelpPages[] = {
|
static const char *HelpPages[] = {
|
||||||
"INFO [ <page> ]\n"
|
"INFO [ <page> ]\n"
|
||||||
" Print IPTV device information and statistics.\n"
|
" Print IPTV device information and statistics.\n"
|
||||||
@ -238,7 +238,7 @@ const char **cPluginIptv::SVDRPHelpPages(void)
|
|||||||
|
|
||||||
cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
|
cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
|
||||||
{
|
{
|
||||||
debug("cPluginIptv::SVDRPCommand('%s', %s')\n", commandP, optionP);
|
debug("cPluginIptv::%s(%s, %s)", __FUNCTION__, commandP, optionP);
|
||||||
if (strcasecmp(commandP, "INFO") == 0) {
|
if (strcasecmp(commandP, "INFO") == 0) {
|
||||||
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
|
||||||
if (device) {
|
if (device) {
|
||||||
|
20
pidscanner.c
20
pidscanner.c
@ -22,17 +22,17 @@ cPidScanner::cPidScanner(void)
|
|||||||
numVpidsM(0),
|
numVpidsM(0),
|
||||||
numApidsM(0)
|
numApidsM(0)
|
||||||
{
|
{
|
||||||
debug("cPidScanner::cPidScanner()\n");
|
debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cPidScanner::~cPidScanner()
|
cPidScanner::~cPidScanner()
|
||||||
{
|
{
|
||||||
debug("cPidScanner::~cPidScanner()\n");
|
debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPidScanner::SetChannel(const tChannelID &channelIdP)
|
void cPidScanner::SetChannel(const tChannelID &channelIdP)
|
||||||
{
|
{
|
||||||
debug("cPidScanner::SetChannel(): %s\n", *channelIdP.ToString());
|
debug("cPidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
|
||||||
channelIdM = channelIdP;
|
channelIdM = channelIdP;
|
||||||
vPidM = 0xFFFF;
|
vPidM = 0xFFFF;
|
||||||
numVpidsM = 0;
|
numVpidsM = 0;
|
||||||
@ -44,13 +44,13 @@ void cPidScanner::SetChannel(const tChannelID &channelIdP)
|
|||||||
|
|
||||||
void cPidScanner::Process(const uint8_t* bufP)
|
void cPidScanner::Process(const uint8_t* bufP)
|
||||||
{
|
{
|
||||||
//debug("cPidScanner::Process()\n");
|
//debug("cPidScanner::%s()", __FUNCTION__);
|
||||||
if (!processM)
|
if (!processM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stop scanning after defined timeout
|
// Stop scanning after defined timeout
|
||||||
if (timeoutM.TimedOut()) {
|
if (timeoutM.TimedOut()) {
|
||||||
debug("cPidScanner::Process: Timed out determining pids\n");
|
debug("cPidScanner::%s(): timed out determining pids", __FUNCTION__);
|
||||||
processM = false;
|
processM = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,24 +85,24 @@ void cPidScanner::Process(const uint8_t* bufP)
|
|||||||
// Stream ID
|
// Stream ID
|
||||||
if ((sid >= 0xC0) && (sid <= 0xDF)) {
|
if ((sid >= 0xC0) && (sid <= 0xDF)) {
|
||||||
if (pid < aPidM) {
|
if (pid < aPidM) {
|
||||||
debug("cPidScanner::Process: Found lower Apid: 0x%X instead of 0x%X\n", pid, aPidM);
|
debug("cPidScanner::%s(): found lower Apid: 0x%X instead of 0x%X", __FUNCTION__, pid, aPidM);
|
||||||
aPidM = pid;
|
aPidM = pid;
|
||||||
numApidsM = 1;
|
numApidsM = 1;
|
||||||
}
|
}
|
||||||
else if (pid == aPidM) {
|
else if (pid == aPidM) {
|
||||||
++numApidsM;
|
++numApidsM;
|
||||||
debug("cPidScanner::Process: Incrementing Apids, now at %d\n", numApidsM);
|
debug("cPidScanner::%s(): incrementing Apids, now at %d", __FUNCTION__, numApidsM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
|
else if ((sid >= 0xE0) && (sid <= 0xEF)) {
|
||||||
if (pid < vPidM) {
|
if (pid < vPidM) {
|
||||||
debug("cPidScanner::Process: Found lower Vpid: 0x%X instead of 0x%X\n", pid, vPidM);
|
debug("cPidScanner::%s(): found lower Vpid: 0x%X instead of 0x%X", __FUNCTION__, pid, vPidM);
|
||||||
vPidM = pid;
|
vPidM = pid;
|
||||||
numVpidsM = 1;
|
numVpidsM = 1;
|
||||||
}
|
}
|
||||||
else if (pid == vPidM) {
|
else if (pid == vPidM) {
|
||||||
++numVpidsM;
|
++numVpidsM;
|
||||||
debug("cPidScanner::Process: Incrementing Vpids, now at %d\n", numVpidsM);
|
debug("cPidScanner::%s(): incrementing Vpids, now at %d", __FUNCTION__, numVpidsM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ void cPidScanner::Process(const uint8_t* bufP)
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < MAXSPIDS; ++i)
|
for (unsigned int i = 0; i < MAXSPIDS; ++i)
|
||||||
Spids[i] = IptvChannel->Spid(i);
|
Spids[i] = IptvChannel->Spid(i);
|
||||||
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", vPidM, aPidM);
|
debug("cPidScanner::%s(): vpid=0x%04X, apid=0x%04X", __FUNCTION__, vPidM, aPidM);
|
||||||
IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
|
IptvChannel->SetPids(vPidM, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
|
||||||
}
|
}
|
||||||
Channels.Unlock();
|
Channels.Unlock();
|
||||||
|
@ -28,7 +28,7 @@ cIptvProtocolCurl::cIptvProtocolCurl()
|
|||||||
connectedM(false),
|
connectedM(false),
|
||||||
pausedM(false)
|
pausedM(false)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolCurl::cIptvProtocolCurl()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
if (ringBufferM)
|
if (ringBufferM)
|
||||||
ringBufferM->SetTimeouts(100, 0);
|
ringBufferM->SetTimeouts(100, 0);
|
||||||
Connect();
|
Connect();
|
||||||
@ -36,7 +36,7 @@ cIptvProtocolCurl::cIptvProtocolCurl()
|
|||||||
|
|
||||||
cIptvProtocolCurl::~cIptvProtocolCurl()
|
cIptvProtocolCurl::~cIptvProtocolCurl()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolCurl::~cIptvProtocolCurl()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
DELETE_POINTER(ringBufferM);
|
DELETE_POINTER(ringBufferM);
|
||||||
@ -46,7 +46,7 @@ size_t cIptvProtocolCurl::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP,
|
|||||||
{
|
{
|
||||||
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
||||||
size_t len = sizeP * nmembP;
|
size_t len = sizeP * nmembP;
|
||||||
//debug("cIptvProtocolCurl::WriteCallback(%zu)\n", len);
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
if (obj && !obj->PutData((unsigned char *)ptrP, (int)len))
|
if (obj && !obj->PutData((unsigned char *)ptrP, (int)len))
|
||||||
return CURL_WRITEFUNC_PAUSE;
|
return CURL_WRITEFUNC_PAUSE;
|
||||||
@ -59,7 +59,7 @@ size_t cIptvProtocolCurl::WriteRtspCallback(void *ptrP, size_t sizeP, size_t nme
|
|||||||
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
||||||
size_t len = sizeP * nmembP;
|
size_t len = sizeP * nmembP;
|
||||||
unsigned char *p = (unsigned char *)ptrP;
|
unsigned char *p = (unsigned char *)ptrP;
|
||||||
//debug("cIptvProtocolCurl::WriteRtspCallback(%zu)\n", len);
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
// validate packet header ('$') and channel (0)
|
// validate packet header ('$') and channel (0)
|
||||||
if (obj && (p[0] == 0x24 ) && (p[1] == 0)) {
|
if (obj && (p[0] == 0x24 ) && (p[1] == 0)) {
|
||||||
@ -101,14 +101,14 @@ size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmem
|
|||||||
{
|
{
|
||||||
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
||||||
size_t len = sizeP * nmembP;
|
size_t len = sizeP * nmembP;
|
||||||
//debug("cIptvProtocolCurl::DescribeCallback(%zu)\n", len);
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
cString control = "";
|
cString control = "";
|
||||||
char *p = (char *)ptrP;
|
char *p = (char *)ptrP;
|
||||||
char *r = strtok(p, "\r\n");
|
char *r = strtok(p, "\r\n");
|
||||||
|
|
||||||
while (r) {
|
while (r) {
|
||||||
//debug("cIptvProtocolCurl::DescribeCallback(%zu): %s\n", len, r);
|
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
|
||||||
if (strstr(r, "a=control")) {
|
if (strstr(r, "a=control")) {
|
||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
if (sscanf(r, "a=control:%64ms", &s) == 1)
|
if (sscanf(r, "a=control:%64ms", &s) == 1)
|
||||||
@ -128,13 +128,13 @@ size_t cIptvProtocolCurl::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP
|
|||||||
{
|
{
|
||||||
//cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
//cIptvProtocolCurl *obj = reinterpret_cast<cIptvProtocolCurl *>(dataP);
|
||||||
size_t len = sizeP * nmembP;
|
size_t len = sizeP * nmembP;
|
||||||
//debug("cIptvProtocolCurl::HeaderCallback(%zu)\n", len);
|
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
|
||||||
|
|
||||||
char *p = (char *)ptrP;
|
char *p = (char *)ptrP;
|
||||||
char *r = strtok(p, "\r\n");
|
char *r = strtok(p, "\r\n");
|
||||||
|
|
||||||
while (r) {
|
while (r) {
|
||||||
//debug("cIptvProtocolCurl::HeaderCallback(%zu): %s\n", len, r);
|
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r);
|
||||||
r = strtok(NULL, "\r\n");
|
r = strtok(NULL, "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,20 +144,20 @@ size_t cIptvProtocolCurl::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP
|
|||||||
void cIptvProtocolCurl::SetRtspControl(const char *controlP)
|
void cIptvProtocolCurl::SetRtspControl(const char *controlP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug("cIptvProtocolCurl::SetRtspControl('%s')\n", controlP);
|
debug("cIptvProtocolCurl::%s(%s)", __FUNCTION__, controlP);
|
||||||
rtspControlM = controlP;
|
rtspControlM = controlP;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
|
bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
//debug("cIptvProtocolCurl::PutData(%d)\n", lenP);
|
//debug("cIptvProtocolCurl::%s(%d)", __FUNCTION__, lenP);
|
||||||
if (pausedM)
|
if (pausedM)
|
||||||
return false;
|
return false;
|
||||||
if (ringBufferM && (lenP >= 0)) {
|
if (ringBufferM && (lenP >= 0)) {
|
||||||
// should be pause the transfer?
|
// should be pause the transfer?
|
||||||
if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) {
|
if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) {
|
||||||
debug("cIptvProtocolCurl::PutData(pause): free=%d available=%d len=%d", ringBufferM->Free(), ringBufferM->Available(), lenP);
|
debug("cIptvProtocolCurl::%s(pause): free=%d available=%d len=%d", __FUNCTION__, ringBufferM->Free(), ringBufferM->Available(), lenP);
|
||||||
pausedM = true;
|
pausedM = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -172,14 +172,14 @@ bool cIptvProtocolCurl::PutData(unsigned char *dataP, int lenP)
|
|||||||
void cIptvProtocolCurl::DelData(int lenP)
|
void cIptvProtocolCurl::DelData(int lenP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
//debug("cIptvProtocolCurl::DelData()\n");
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
if (ringBufferM && (lenP >= 0))
|
if (ringBufferM && (lenP >= 0))
|
||||||
ringBufferM->Del(lenP);
|
ringBufferM->Del(lenP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolCurl::ClearData()
|
void cIptvProtocolCurl::ClearData()
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolCurl::ClearData()\n");
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
if (ringBufferM)
|
if (ringBufferM)
|
||||||
ringBufferM->Clear();
|
ringBufferM->Clear();
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ void cIptvProtocolCurl::ClearData()
|
|||||||
unsigned char *cIptvProtocolCurl::GetData(unsigned int *lenP)
|
unsigned char *cIptvProtocolCurl::GetData(unsigned int *lenP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
//debug("cIptvProtocolCurl::GetData()\n");
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
*lenP = 0;
|
*lenP = 0;
|
||||||
if (ringBufferM) {
|
if (ringBufferM) {
|
||||||
@ -219,7 +219,7 @@ unsigned char *cIptvProtocolCurl::GetData(unsigned int *lenP)
|
|||||||
bool cIptvProtocolCurl::Connect()
|
bool cIptvProtocolCurl::Connect()
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug("cIptvProtocolCurl::Connect()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
if (connectedM)
|
if (connectedM)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ bool cIptvProtocolCurl::Connect()
|
|||||||
bool cIptvProtocolCurl::Disconnect()
|
bool cIptvProtocolCurl::Disconnect()
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
debug("cIptvProtocolCurl::Disconnect()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
if (handleM) {
|
if (handleM) {
|
||||||
// mode specific tricks
|
// mode specific tricks
|
||||||
switch (modeM) {
|
switch (modeM) {
|
||||||
@ -393,20 +393,20 @@ bool cIptvProtocolCurl::Disconnect()
|
|||||||
|
|
||||||
bool cIptvProtocolCurl::Open(void)
|
bool cIptvProtocolCurl::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolCurl::Open()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
return Connect();
|
return Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolCurl::Close(void)
|
bool cIptvProtocolCurl::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolCurl::Close()\n");
|
debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolCurl::Read()\n");
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (ringBufferM) {
|
if (ringBufferM) {
|
||||||
// fill up the buffer
|
// fill up the buffer
|
||||||
@ -437,7 +437,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
// shall be continue filling up the buffer?
|
// shall be continue filling up the buffer?
|
||||||
mutexM.Lock();
|
mutexM.Lock();
|
||||||
if (pausedM && (ringBufferM->Free() > ringBufferM->Available())) {
|
if (pausedM && (ringBufferM->Free() > ringBufferM->Available())) {
|
||||||
debug("cIptvProtocolCurl::Read(continue): free=%d available=%d\n", ringBufferM->Free(), ringBufferM->Available());
|
debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__, ringBufferM->Free(), ringBufferM->Available());
|
||||||
pausedM = false;
|
pausedM = false;
|
||||||
curl_easy_pause(handleM, CURLPAUSE_CONT);
|
curl_easy_pause(handleM, CURLPAUSE_CONT);
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
int msgcount;
|
int msgcount;
|
||||||
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
|
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
|
||||||
if (msg && (msg->msg == CURLMSG_DONE)) {
|
if (msg && (msg->msg == CURLMSG_DONE)) {
|
||||||
debug("cIptvProtocolCurl::Read(done): %s (%d)\n", curl_easy_strerror(msg->data.result), msg->data.result);
|
debug("cIptvProtocolCurl::%s(done): %s (%d)", __FUNCTION__, curl_easy_strerror(msg->data.result), msg->data.result);
|
||||||
Disconnect();
|
Disconnect();
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
memcpy(bufferAddrP, p, bufferLenP);
|
memcpy(bufferAddrP, p, bufferLenP);
|
||||||
DelData(bufferLenP);
|
DelData(bufferLenP);
|
||||||
len = bufferLenP;
|
len = bufferLenP;
|
||||||
//debug("cIptvProtocolCurl::Read(): get %d bytes\n", len);
|
//debug("cIptvProtocolCurl::%s(): get %d bytes", __FUNCTION__, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +476,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
|
|
||||||
bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const int indexP)
|
bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolCurl::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvProtocolCurl::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
// Disconnect
|
// Disconnect
|
||||||
Disconnect();
|
Disconnect();
|
||||||
@ -498,7 +498,6 @@ bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const i
|
|||||||
modeM = eModeUnknown;
|
modeM = eModeUnknown;
|
||||||
// Update stream parameter
|
// Update stream parameter
|
||||||
streamParamM = parameterP;
|
streamParamM = parameterP;
|
||||||
//debug("%s [%d]\n", *streamUrlM, streamParamM);
|
|
||||||
// Reconnect
|
// Reconnect
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -507,6 +506,6 @@ bool cIptvProtocolCurl::Set(const char* locationP, const int parameterP, const i
|
|||||||
|
|
||||||
cString cIptvProtocolCurl::GetInformation(void)
|
cString cIptvProtocolCurl::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolCurl::GetInformation()");
|
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
|
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
|
||||||
}
|
}
|
||||||
|
@ -29,21 +29,21 @@ cIptvProtocolExt::cIptvProtocolExt()
|
|||||||
scriptParameterM(0),
|
scriptParameterM(0),
|
||||||
streamPortM(0)
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::cIptvProtocolExt()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolExt::~cIptvProtocolExt()
|
cIptvProtocolExt::~cIptvProtocolExt()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::~cIptvProtocolExt()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Drop the socket connection
|
// Drop the socket connection
|
||||||
cIptvProtocolExt::Close();
|
cIptvProtocolExt::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolExt::ExecuteScript(void)
|
void cIptvProtocolExt::ExecuteScript(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::ExecuteScript()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Check if already executing
|
// Check if already executing
|
||||||
if (isActive || isempty(scriptFileM))
|
if (isActiveM || isempty(scriptFileM))
|
||||||
return;
|
return;
|
||||||
if (pidM > 0) {
|
if (pidM > 0) {
|
||||||
error("Cannot execute script!");
|
error("Cannot execute script!");
|
||||||
@ -59,7 +59,7 @@ void cIptvProtocolExt::ExecuteScript(void)
|
|||||||
close(i);
|
close(i);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
cString cmd = cString::sprintf("%s %d %d", *scriptFileM, scriptParameterM, streamPortM);
|
cString cmd = cString::sprintf("%s %d %d", *scriptFileM, scriptParameterM, streamPortM);
|
||||||
debug("cIptvProtocolExt::ExecuteScript(child): %s\n", *cmd);
|
debug("cIptvProtocolExt::%s(child): %s", __FUNCTION__, *cmd);
|
||||||
// Create a new session for a process group
|
// Create a new session for a process group
|
||||||
ERROR_IF_RET(setsid() == -1, "setsid()", _exit(-1));
|
ERROR_IF_RET(setsid() == -1, "setsid()", _exit(-1));
|
||||||
if (execl(EXTSHELL, "sh", "-c", *cmd, (char *)NULL) == -1) {
|
if (execl(EXTSHELL, "sh", "-c", *cmd, (char *)NULL) == -1) {
|
||||||
@ -69,14 +69,14 @@ void cIptvProtocolExt::ExecuteScript(void)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug("cIptvProtocolExt::ExecuteScript(): pid=%d\n", pidM);
|
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvProtocolExt::TerminateScript(void)
|
void cIptvProtocolExt::TerminateScript(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::TerminateScript(): pid=%d\n", pidM);
|
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM);
|
||||||
if (!isActive || isempty(scriptFileM))
|
if (!isActiveM || isempty(scriptFileM))
|
||||||
return;
|
return;
|
||||||
if (pidM > 0) {
|
if (pidM > 0) {
|
||||||
const unsigned int timeoutms = 100;
|
const unsigned int timeoutms = 100;
|
||||||
@ -99,7 +99,7 @@ void cIptvProtocolExt::TerminateScript(void)
|
|||||||
retval = waitpid(pidM, &waitStatus, WNOHANG);
|
retval = waitpid(pidM, &waitStatus, WNOHANG);
|
||||||
#else // __FreeBSD__
|
#else // __FreeBSD__
|
||||||
siginfo_t waitStatus;
|
siginfo_t waitStatus;
|
||||||
memset(&waitStatus, '\0', sizeof(waitStatus));
|
memset(&waitStatus, 0, sizeof(waitStatus));
|
||||||
retval = waitid(P_PID, pidM, &waitStatus, (WNOHANG | WEXITED));
|
retval = waitid(P_PID, pidM, &waitStatus, (WNOHANG | WEXITED));
|
||||||
#endif // __FreeBSD__
|
#endif // __FreeBSD__
|
||||||
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
|
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
|
||||||
@ -111,7 +111,7 @@ void cIptvProtocolExt::TerminateScript(void)
|
|||||||
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pidM) &&
|
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pidM) &&
|
||||||
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
|
((waitStatus.si_code == CLD_EXITED) || (waitStatus.si_code == CLD_KILLED))) {
|
||||||
#endif // __FreeBSD__
|
#endif // __FreeBSD__
|
||||||
debug("Child (%d) exited as expected\n", pidM);
|
debug("cIptvProtocolExt::%s(): child (%d) exited as expected", __FUNCTION__, pidM);
|
||||||
waitOver = true;
|
waitOver = true;
|
||||||
}
|
}
|
||||||
// Unsuccessful wait, avoid busy looping
|
// Unsuccessful wait, avoid busy looping
|
||||||
@ -124,7 +124,7 @@ void cIptvProtocolExt::TerminateScript(void)
|
|||||||
|
|
||||||
bool cIptvProtocolExt::Open(void)
|
bool cIptvProtocolExt::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Open()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Reject empty script files
|
// Reject empty script files
|
||||||
if (!strlen(*scriptFileM))
|
if (!strlen(*scriptFileM))
|
||||||
return false;
|
return false;
|
||||||
@ -132,16 +132,16 @@ bool cIptvProtocolExt::Open(void)
|
|||||||
OpenSocket(streamPortM);
|
OpenSocket(streamPortM);
|
||||||
// Execute the external script
|
// Execute the external script
|
||||||
ExecuteScript();
|
ExecuteScript();
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolExt::Close(void)
|
bool cIptvProtocolExt::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Close()\n");
|
debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
// Terminate the external script
|
// Terminate the external script
|
||||||
TerminateScript();
|
TerminateScript();
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return true;
|
return true;
|
||||||
@ -154,7 +154,7 @@ int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
|
|
||||||
bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const int indexP)
|
bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolExt::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvProtocolExt::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
// Update script file and parameter
|
// Update script file and parameter
|
||||||
@ -172,6 +172,6 @@ bool cIptvProtocolExt::Set(const char* locationP, const int parameterP, const in
|
|||||||
|
|
||||||
cString cIptvProtocolExt::GetInformation(void)
|
cString cIptvProtocolExt::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolExt::GetInformation()");
|
//debug("cIptvProtocolExt::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM);
|
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM);
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,12 @@ cIptvProtocolFile::cIptvProtocolFile()
|
|||||||
fileStreamM(NULL),
|
fileStreamM(NULL),
|
||||||
isActiveM(false)
|
isActiveM(false)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::cIptvProtocolFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolFile::~cIptvProtocolFile()
|
cIptvProtocolFile::~cIptvProtocolFile()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::~cIptvProtocolFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Drop open handles
|
// Drop open handles
|
||||||
cIptvProtocolFile::Close();
|
cIptvProtocolFile::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
@ -34,7 +34,7 @@ cIptvProtocolFile::~cIptvProtocolFile()
|
|||||||
|
|
||||||
bool cIptvProtocolFile::OpenFile(void)
|
bool cIptvProtocolFile::OpenFile(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::OpenFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActiveM && !isempty(fileLocationM)) {
|
if (!isActiveM && !isempty(fileLocationM)) {
|
||||||
fileStreamM = fopen(fileLocationM, "rb");
|
fileStreamM = fopen(fileLocationM, "rb");
|
||||||
@ -47,7 +47,7 @@ bool cIptvProtocolFile::OpenFile(void)
|
|||||||
|
|
||||||
void cIptvProtocolFile::CloseFile(void)
|
void cIptvProtocolFile::CloseFile(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::CloseFile()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check that file stream is valid
|
// Check that file stream is valid
|
||||||
if (isActiveM && !isempty(fileLocationM)) {
|
if (isActiveM && !isempty(fileLocationM)) {
|
||||||
fclose(fileStreamM);
|
fclose(fileStreamM);
|
||||||
@ -58,10 +58,10 @@ void cIptvProtocolFile::CloseFile(void)
|
|||||||
|
|
||||||
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolFile::Read()\n");
|
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Check errors
|
// Check errors
|
||||||
if (ferror(fileStreamM)) {
|
if (ferror(fileStreamM)) {
|
||||||
debug("Read error\n");
|
debug("cIptvProtocolFile::%s(): stream error", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Rewind if EOF
|
// Rewind if EOF
|
||||||
@ -81,7 +81,7 @@ int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
|
|
||||||
bool cIptvProtocolFile::Open(void)
|
bool cIptvProtocolFile::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Open()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Open the file stream
|
// Open the file stream
|
||||||
OpenFile();
|
OpenFile();
|
||||||
return true;
|
return true;
|
||||||
@ -89,7 +89,7 @@ bool cIptvProtocolFile::Open(void)
|
|||||||
|
|
||||||
bool cIptvProtocolFile::Close(void)
|
bool cIptvProtocolFile::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Close()\n");
|
debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
// Close the file stream
|
// Close the file stream
|
||||||
CloseFile();
|
CloseFile();
|
||||||
return true;
|
return true;
|
||||||
@ -97,7 +97,7 @@ bool cIptvProtocolFile::Close(void)
|
|||||||
|
|
||||||
bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const int indexP)
|
bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolFile::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvProtocolFile::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
// Close the file stream
|
// Close the file stream
|
||||||
CloseFile();
|
CloseFile();
|
||||||
@ -112,6 +112,6 @@ bool cIptvProtocolFile::Set(const char* locationP, const int parameterP, const i
|
|||||||
|
|
||||||
cString cIptvProtocolFile::GetInformation(void)
|
cString cIptvProtocolFile::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolFile::GetInformation()");
|
//debug("cIptvProtocolFile::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
|
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,12 @@ cIptvProtocolHttp::cIptvProtocolHttp()
|
|||||||
streamPathM(strdup("/")),
|
streamPathM(strdup("/")),
|
||||||
streamPortM(0)
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::cIptvProtocolHttp()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolHttp::~cIptvProtocolHttp()
|
cIptvProtocolHttp::~cIptvProtocolHttp()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::~cIptvProtocolHttp()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Close the socket
|
// Close the socket
|
||||||
cIptvProtocolHttp::Close();
|
cIptvProtocolHttp::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
@ -38,9 +38,9 @@ cIptvProtocolHttp::~cIptvProtocolHttp()
|
|||||||
|
|
||||||
bool cIptvProtocolHttp::Connect(void)
|
bool cIptvProtocolHttp::Connect(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Connect()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActive && !isempty(streamAddrM) && !isempty(streamPathM)) {
|
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) {
|
||||||
// Ensure that socket is valid and connect
|
// Ensure that socket is valid and connect
|
||||||
OpenSocket(streamPortM, streamAddrM);
|
OpenSocket(streamPortM, streamAddrM);
|
||||||
if (!ConnectSocket()) {
|
if (!ConnectSocket()) {
|
||||||
@ -55,7 +55,7 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
"Connection: Close\r\n"
|
"Connection: Close\r\n"
|
||||||
"\r\n", streamPathM, streamAddrM,
|
"\r\n", streamPathM, streamAddrM,
|
||||||
PLUGIN_NAME_I18N, VERSION);
|
PLUGIN_NAME_I18N, VERSION);
|
||||||
debug("Sending http request: %s\n", *buffer);
|
debug("cIptvProtocolHttp::%s(): requesting: %s", __FUNCTION__, *buffer);
|
||||||
if (!Write(*buffer, (unsigned int)strlen(*buffer))) {
|
if (!Write(*buffer, (unsigned int)strlen(*buffer))) {
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
@ -66,19 +66,19 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Disconnect(void)
|
bool cIptvProtocolHttp::Disconnect(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Disconnect()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
if (isActive) {
|
if (isActiveM) {
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ bool cIptvProtocolHttp::Disconnect(void)
|
|||||||
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
|
bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
|
||||||
unsigned int &recvLenP)
|
unsigned int &recvLenP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::GetHeaderLine()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
bool linefeed = false;
|
bool linefeed = false;
|
||||||
bool newline = false;
|
bool newline = false;
|
||||||
char *bufptr = destP;
|
char *bufptr = destP;
|
||||||
@ -127,7 +127,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
|
|||||||
|
|
||||||
bool cIptvProtocolHttp::ProcessHeaders(void)
|
bool cIptvProtocolHttp::ProcessHeaders(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::ProcessHeaders()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
unsigned int lineLength = 0;
|
unsigned int lineLength = 0;
|
||||||
int version = 0, response = 0;
|
int version = 0, response = 0;
|
||||||
bool responseFound = false;
|
bool responseFound = false;
|
||||||
@ -138,7 +138,7 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
|
|||||||
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
|
snprintf(fmt, sizeof(fmt), "HTTP/1.%%%zui %%%zui ", sizeof(version) - 1, sizeof(response) - 1);
|
||||||
|
|
||||||
while (!responseFound || lineLength != 0) {
|
while (!responseFound || lineLength != 0) {
|
||||||
memset(buf, '\0', sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
|
if (!GetHeaderLine(buf, sizeof(buf), lineLength))
|
||||||
return false;
|
return false;
|
||||||
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
|
if (!responseFound && sscanf(buf, fmt, &version, &response) != 2) {
|
||||||
@ -158,14 +158,14 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
|
|||||||
|
|
||||||
bool cIptvProtocolHttp::Open(void)
|
bool cIptvProtocolHttp::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Open()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Connect the socket
|
// Connect the socket
|
||||||
return Connect();
|
return Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvProtocolHttp::Close(void)
|
bool cIptvProtocolHttp::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Close()\n");
|
debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
// Disconnect the current stream
|
// Disconnect the current stream
|
||||||
Disconnect();
|
Disconnect();
|
||||||
return true;
|
return true;
|
||||||
@ -178,7 +178,7 @@ int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
|
|
||||||
bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const int indexP)
|
bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvProtocolHttp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
// Disconnect the current socket
|
// Disconnect the current socket
|
||||||
Disconnect();
|
Disconnect();
|
||||||
@ -192,7 +192,6 @@ bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const i
|
|||||||
else
|
else
|
||||||
streamPathM = strcpyrealloc(streamPathM, "/");
|
streamPathM = strcpyrealloc(streamPathM, "/");
|
||||||
streamPortM = parameterP;
|
streamPortM = parameterP;
|
||||||
//debug("http://%s:%d%s\n", streamAddrM, streamPortM, streamPathM);
|
|
||||||
// Re-connect the socket
|
// Re-connect the socket
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
@ -201,6 +200,6 @@ bool cIptvProtocolHttp::Set(const char* locationP, const int parameterP, const i
|
|||||||
|
|
||||||
cString cIptvProtocolHttp::GetInformation(void)
|
cString cIptvProtocolHttp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolHttp::GetInformation()");
|
//debug("cIptvProtocolHttp::%s()", __FUNCTION__);
|
||||||
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
|
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ cIptvProtocolUdp::cIptvProtocolUdp()
|
|||||||
streamAddrM(strdup("")),
|
streamAddrM(strdup("")),
|
||||||
streamPortM(0)
|
streamPortM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::cIptvProtocolUdp()\n");
|
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvProtocolUdp::~cIptvProtocolUdp()
|
cIptvProtocolUdp::~cIptvProtocolUdp()
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::~cIptvProtocolUdp()\n");
|
debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
// Drop the multicast group and close the socket
|
// Drop the multicast group and close the socket
|
||||||
cIptvProtocolUdp::Close();
|
cIptvProtocolUdp::Close();
|
||||||
// Free allocated memory
|
// Free allocated memory
|
||||||
@ -39,7 +39,7 @@ cIptvProtocolUdp::~cIptvProtocolUdp()
|
|||||||
|
|
||||||
bool cIptvProtocolUdp::Open(void)
|
bool cIptvProtocolUdp::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Open(): '%s'\n", streamAddrM);
|
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
|
||||||
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
||||||
if (!isempty(streamAddrM)) {
|
if (!isempty(streamAddrM)) {
|
||||||
// Join a new multicast group
|
// Join a new multicast group
|
||||||
@ -50,7 +50,7 @@ bool cIptvProtocolUdp::Open(void)
|
|||||||
|
|
||||||
bool cIptvProtocolUdp::Close(void)
|
bool cIptvProtocolUdp::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Close(): '%s'\n", streamAddrM);
|
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM);
|
||||||
if (!isempty(streamAddrM)) {
|
if (!isempty(streamAddrM)) {
|
||||||
// Drop the multicast group
|
// Drop the multicast group
|
||||||
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
OpenSocket(streamPortM, streamAddrM, sourceAddrM, isIGMPv3M);
|
||||||
@ -72,7 +72,7 @@ int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
|
|||||||
|
|
||||||
bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const int indexP)
|
bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const int indexP)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolUdp::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvProtocolUdp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
// Drop the multicast group
|
// Drop the multicast group
|
||||||
if (!isempty(streamAddrM)) {
|
if (!isempty(streamAddrM)) {
|
||||||
@ -105,7 +105,7 @@ bool cIptvProtocolUdp::Set(const char* locationP, const int parameterP, const in
|
|||||||
|
|
||||||
cString cIptvProtocolUdp::GetInformation(void)
|
cString cIptvProtocolUdp::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvProtocolUdp::GetInformation()");
|
//debug("cIptvProtocolUdp::%s()", __FUNCTION__);
|
||||||
if (isIGMPv3M)
|
if (isIGMPv3M)
|
||||||
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
|
return cString::sprintf("udp://%s@%s:%d", sourceAddrM, streamAddrM, streamPortM);
|
||||||
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);
|
return cString::sprintf("udp://%s:%d", streamAddrM, streamPortM);
|
||||||
|
@ -19,7 +19,7 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
|
|||||||
pidM(pidP),
|
pidM(pidP),
|
||||||
devIdM(deviceIndexP)
|
devIdM(deviceIndexP)
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionFilter::cIptvSectionFilter(%d, %d)\n", devIdM, pidM);
|
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(secBufBaseM, 0, sizeof(secBufBaseM));
|
memset(secBufBaseM, 0, sizeof(secBufBaseM));
|
||||||
@ -56,7 +56,7 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
|
|||||||
|
|
||||||
cIptvSectionFilter::~cIptvSectionFilter()
|
cIptvSectionFilter::~cIptvSectionFilter()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionFilter::~cIptvSectionfilter(%d, %d)\n", devIdM, pidM);
|
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, devIdM, pidM);
|
||||||
DELETE_POINTER(ringbufferM);
|
DELETE_POINTER(ringbufferM);
|
||||||
secBufM = NULL;
|
secBufM = NULL;
|
||||||
}
|
}
|
||||||
|
6
setup.c
6
setup.c
@ -112,7 +112,7 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
|
|||||||
|
|
||||||
cIptvPluginSetup::cIptvPluginSetup()
|
cIptvPluginSetup::cIptvPluginSetup()
|
||||||
{
|
{
|
||||||
debug("cIptvPluginSetup::cIptvPluginSetup()\n");
|
debug("cIptvPluginSetup::%s()", __FUNCTION__);
|
||||||
tsBufferSizeM = IptvConfig.GetTsBufferSize();
|
tsBufferSizeM = IptvConfig.GetTsBufferSize();
|
||||||
tsBufferPrefillM = IptvConfig.GetTsBufferPrefillRatio();
|
tsBufferPrefillM = IptvConfig.GetTsBufferPrefillRatio();
|
||||||
extProtocolBasePortM = IptvConfig.GetExtProtocolBasePort();
|
extProtocolBasePortM = IptvConfig.GetExtProtocolBasePort();
|
||||||
@ -164,7 +164,7 @@ void cIptvPluginSetup::Setup(void)
|
|||||||
|
|
||||||
eOSState cIptvPluginSetup::ShowInfo(void)
|
eOSState cIptvPluginSetup::ShowInfo(void)
|
||||||
{
|
{
|
||||||
debug("cIptvPluginSetup::ShowInfo()\n");
|
debug("cIptvPluginSetup::%s()", __FUNCTION__);
|
||||||
if (HasSubMenu())
|
if (HasSubMenu())
|
||||||
return osContinue;
|
return osContinue;
|
||||||
return AddSubMenu(new cIptvMenuInfo());
|
return AddSubMenu(new cIptvMenuInfo());
|
||||||
@ -209,7 +209,7 @@ void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP)
|
|||||||
q += strlen(s);
|
q += strlen(s);
|
||||||
}
|
}
|
||||||
*q = 0;
|
*q = 0;
|
||||||
debug("cIptvPluginSetup::StoreFilters(): %s=%s\n", nameP, buffer);
|
debug("cIptvPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, buffer);
|
||||||
SetupStore(nameP, buffer);
|
SetupStore(nameP, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
sidscanner.c
20
sidscanner.c
@ -16,25 +16,25 @@ cSidScanner::cSidScanner(void)
|
|||||||
nidFoundM(false),
|
nidFoundM(false),
|
||||||
tidFoundM(false)
|
tidFoundM(false)
|
||||||
{
|
{
|
||||||
debug("cSidScanner::cSidScanner()\n");
|
debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
Set(0x00, 0x00); // PAT
|
Set(0x00, 0x00); // PAT
|
||||||
Set(0x10, 0x40); // NIT
|
Set(0x10, 0x40); // NIT
|
||||||
}
|
}
|
||||||
|
|
||||||
cSidScanner::~cSidScanner()
|
cSidScanner::~cSidScanner()
|
||||||
{
|
{
|
||||||
debug("cSidScanner::~cSidScanner()\n");
|
debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSidScanner::SetStatus(bool onP)
|
void cSidScanner::SetStatus(bool onP)
|
||||||
{
|
{
|
||||||
debug("cSidScanner::SetStatus(%d)\n", onP);
|
debug("cSidScanner::%s(%d)", __FUNCTION__, onP);
|
||||||
cFilter::SetStatus(onP);
|
cFilter::SetStatus(onP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSidScanner::SetChannel(const tChannelID &channelIdP)
|
void cSidScanner::SetChannel(const tChannelID &channelIdP)
|
||||||
{
|
{
|
||||||
debug("cSidScanner::SetChannel('%s')\n", *channelIdP.ToString());
|
debug("cSidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString());
|
||||||
channelIdM = channelIdP;
|
channelIdM = channelIdP;
|
||||||
sidFoundM = false;
|
sidFoundM = false;
|
||||||
nidFoundM = false;
|
nidFoundM = false;
|
||||||
@ -45,10 +45,10 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
|
|||||||
{
|
{
|
||||||
int newSid = -1, newNid = -1, newTid = -1;
|
int newSid = -1, newNid = -1, newTid = -1;
|
||||||
|
|
||||||
//debug("cSidScanner::Process()\n");
|
//debug("cSidScanner::%s()", __FUNCTION__);
|
||||||
if (channelIdM.Valid()) {
|
if (channelIdM.Valid()) {
|
||||||
if ((pidP == 0x00) && (tidP == 0x00)) {
|
if ((pidP == 0x00) && (tidP == 0x00)) {
|
||||||
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", pidP, tidP);
|
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
|
||||||
SI::PAT pat(dataP, false);
|
SI::PAT pat(dataP, false);
|
||||||
if (!pat.CheckCRCAndParse())
|
if (!pat.CheckCRCAndParse())
|
||||||
return;
|
return;
|
||||||
@ -56,7 +56,7 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
|
|||||||
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
||||||
if (!assoc.isNITPid()) {
|
if (!assoc.isNITPid()) {
|
||||||
if (assoc.getServiceId() != channelIdM.Sid()) {
|
if (assoc.getServiceId() != channelIdM.Sid()) {
|
||||||
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
|
debug("cSidScanner::%s(): sid=%d", __FUNCTION__, assoc.getServiceId());
|
||||||
newSid = assoc.getServiceId();
|
newSid = assoc.getServiceId();
|
||||||
}
|
}
|
||||||
sidFoundM = true;
|
sidFoundM = true;
|
||||||
@ -65,21 +65,21 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pidP == 0x10) && (tidP == 0x40)) {
|
else if ((pidP == 0x10) && (tidP == 0x40)) {
|
||||||
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", pidP, tidP);
|
debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP);
|
||||||
SI::NIT nit(dataP, false);
|
SI::NIT nit(dataP, false);
|
||||||
if (!nit.CheckCRCAndParse())
|
if (!nit.CheckCRCAndParse())
|
||||||
return;
|
return;
|
||||||
SI::NIT::TransportStream ts;
|
SI::NIT::TransportStream ts;
|
||||||
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
|
for (SI::Loop::Iterator it; nit.transportStreamLoop.getNext(ts, it); ) {
|
||||||
if (ts.getTransportStreamId() != channelIdM.Tid()) {
|
if (ts.getTransportStreamId() != channelIdM.Tid()) {
|
||||||
debug("cSidScanner::Process(): TSid=%d\n", ts.getTransportStreamId());
|
debug("cSidScanner::%s(): tsid=%d", __FUNCTION__, ts.getTransportStreamId());
|
||||||
newTid = ts.getTransportStreamId();
|
newTid = ts.getTransportStreamId();
|
||||||
}
|
}
|
||||||
tidFoundM = true;
|
tidFoundM = true;
|
||||||
break; // default to the first one
|
break; // default to the first one
|
||||||
}
|
}
|
||||||
if (nit.getNetworkId() != channelIdM.Nid()) {
|
if (nit.getNetworkId() != channelIdM.Nid()) {
|
||||||
debug("cSidScanner::Process(): Nid=%d\n", ts.getTransportStreamId());
|
debug("cSidScanner::%s(): nid=%d\n", __FUNCTION__, ts.getTransportStreamId());
|
||||||
newNid = nit.getNetworkId();
|
newNid = nit.getNetworkId();
|
||||||
}
|
}
|
||||||
nidFoundM = true;
|
nidFoundM = true;
|
||||||
|
255
socket.c
255
socket.c
@ -19,93 +19,90 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
|
||||||
cIptvSocket::cIptvSocket()
|
cIptvSocket::cIptvSocket()
|
||||||
: socketPort(0),
|
: socketPortM(0),
|
||||||
socketDesc(-1),
|
socketDescM(-1),
|
||||||
isActive(false)
|
isActiveM(false)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::cIptvSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
memset(&sockAddr, '\0', sizeof(sockAddr));
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvSocket::~cIptvSocket()
|
cIptvSocket::~cIptvSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::~cIptvSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvSocket::OpenSocket(const int Port, const bool isUdp)
|
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::OpenSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// If socket is there already and it is bound to a different port, it must
|
// If socket is there already and it is bound to a different port, it must
|
||||||
// be closed first
|
// be closed first
|
||||||
if (Port != socketPort) {
|
if (portP != socketPortM) {
|
||||||
debug("cIptvSocket::OpenSocket(): Socket tear-down\n");
|
debug("cIptvSocket::%s(): socket tear-down", __FUNCTION__);
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
}
|
}
|
||||||
// Bind to the socket if it is not active already
|
// Bind to the socket if it is not active already
|
||||||
if (socketDesc < 0) {
|
if (socketDescM < 0) {
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
// Create socket
|
// Create socket
|
||||||
if (isUdp)
|
if (isUdpP)
|
||||||
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
socketDescM = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
else
|
else
|
||||||
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
|
socketDescM = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
|
ERROR_IF_RET(socketDescM < 0, "socket()", return false);
|
||||||
// Make it use non-blocking I/O to avoid stuck read calls
|
// Make it use non-blocking I/O to avoid stuck read calls
|
||||||
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
|
ERROR_IF_FUNC(fcntl(socketDescM, F_SETFL, O_NONBLOCK), "fcntl(O_NONBLOCK)",
|
||||||
CloseSocket(), return false);
|
CloseSocket(), return false);
|
||||||
// Allow multiple sockets to use the same PORT number
|
// Allow multiple sockets to use the same PORT number
|
||||||
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)",
|
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0, "setsockopt(SO_REUSEADDR)",
|
||||||
CloseSocket(), return false);
|
CloseSocket(), return false);
|
||||||
#ifndef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
// Allow packet information to be fetched
|
// Allow packet information to be fetched
|
||||||
ERROR_IF_FUNC(setsockopt(socketDesc, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)",
|
ERROR_IF_FUNC(setsockopt(socketDescM, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0, "setsockopt(IP_PKTINFO)",
|
||||||
CloseSocket(), return false);
|
CloseSocket(), return false);
|
||||||
#endif // __FreeBSD__
|
#endif // __FreeBSD__
|
||||||
// Bind socket
|
// Bind socket
|
||||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
sockAddr.sin_family = AF_INET;
|
sockAddrM.sin_family = AF_INET;
|
||||||
sockAddr.sin_port = htons((uint16_t)(Port & 0xFFFF));
|
sockAddrM.sin_port = htons((uint16_t)(portP & 0xFFFF));
|
||||||
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
sockAddrM.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
if (isUdp) {
|
if (isUdpP)
|
||||||
int err = bind(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
ERROR_IF_FUNC(bind(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)) < 0, "bind()", CloseSocket(), return false);
|
||||||
ERROR_IF_FUNC(err < 0, "bind()", CloseSocket(), return false);
|
|
||||||
}
|
|
||||||
// Update socket port
|
// Update socket port
|
||||||
socketPort = Port;
|
socketPortM = portP;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvSocket::CloseSocket(void)
|
void cIptvSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvSocket::CloseSocket()\n");
|
debug("cIptvSocket::%s()", __FUNCTION__);
|
||||||
// Check if socket exists
|
// Check if socket exists
|
||||||
if (socketDesc >= 0) {
|
if (socketDescM >= 0) {
|
||||||
close(socketDesc);
|
close(socketDescM);
|
||||||
socketDesc = -1;
|
socketDescM = -1;
|
||||||
socketPort = 0;
|
socketPortM = 0;
|
||||||
memset(&sockAddr, 0, sizeof(sockAddr));
|
memset(&sockAddrM, 0, sizeof(sockAddrM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvSocket::CheckAddress(const char *Addr, in_addr_t *InAddr)
|
bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
|
||||||
{
|
{
|
||||||
if (InAddr) {
|
if (inAddrP) {
|
||||||
// First try only the IP address
|
// First try only the IP address
|
||||||
*InAddr = htonl(inet_addr(Addr));
|
*inAddrP = htonl(inet_addr(addrP));
|
||||||
if (*InAddr == htonl(INADDR_NONE)) {
|
if (*inAddrP == htonl(INADDR_NONE)) {
|
||||||
debug("Cannot convert %s directly to internet address\n", Addr);
|
debug("cIptvSocket::%s(%s): cannot convert to address", __FUNCTION__, addrP);
|
||||||
// It may be a host name, get the name
|
// It may be a host name, get the name
|
||||||
struct hostent *host;
|
struct hostent *host = gethostbyname(addrP);
|
||||||
host = gethostbyname(Addr);
|
|
||||||
if (!host) {
|
if (!host) {
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
error("gethostbyname() failed: %s is not valid address: %s", Addr, strerror_r(h_errno, tmp, sizeof(tmp)));
|
error("gethostbyname() failed: %s is not valid address: %s", addrP, strerror_r(h_errno, tmp, sizeof(tmp)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*InAddr = htonl(inet_addr(*host->h_addr_list));
|
*inAddrP = htonl(inet_addr(*host->h_addr_list));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -114,52 +111,52 @@ bool cIptvSocket::CheckAddress(const char *Addr, in_addr_t *InAddr)
|
|||||||
|
|
||||||
// UDP socket class
|
// UDP socket class
|
||||||
cIptvUdpSocket::cIptvUdpSocket()
|
cIptvUdpSocket::cIptvUdpSocket()
|
||||||
: streamAddr(htonl(INADDR_ANY)),
|
: streamAddrM(htonl(INADDR_ANY)),
|
||||||
sourceAddr(htonl(INADDR_ANY)),
|
sourceAddrM(htonl(INADDR_ANY)),
|
||||||
useIGMPv3(false)
|
useIGMPv3M(false)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::cIptvUdpSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvUdpSocket::~cIptvUdpSocket()
|
cIptvUdpSocket::~cIptvUdpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::~cIptvUdpSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvUdpSocket::OpenSocket(const int Port)
|
bool cIptvUdpSocket::OpenSocket(const int portP)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::OpenSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
streamAddr = htonl(INADDR_ANY);
|
streamAddrM = htonl(INADDR_ANY);
|
||||||
sourceAddr = htonl(INADDR_ANY);
|
sourceAddrM = htonl(INADDR_ANY);
|
||||||
useIGMPv3 = false;
|
useIGMPv3M = false;
|
||||||
return cIptvSocket::OpenSocket(Port, true);
|
return cIptvSocket::OpenSocket(portP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvUdpSocket::OpenSocket(const int Port, const char *StreamAddr, const char *SourceAddr, bool UseIGMPv3)
|
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::OpenSocket()\n");
|
debug("cIptvUdpSocket::%s(%d, %s, %s, %d)", __FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
|
||||||
CheckAddress(StreamAddr, &streamAddr);
|
CheckAddress(streamAddrP, &streamAddrM);
|
||||||
CheckAddress(SourceAddr, &sourceAddr);
|
CheckAddress(sourceAddrP, &sourceAddrM);
|
||||||
useIGMPv3 = UseIGMPv3;
|
useIGMPv3M = useIGMPv3P;
|
||||||
return cIptvSocket::OpenSocket(Port, true);
|
return cIptvSocket::OpenSocket(portP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvUdpSocket::CloseSocket(void)
|
void cIptvUdpSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::CloseSocket()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
streamAddr = htonl(INADDR_ANY);
|
streamAddrM = htonl(INADDR_ANY);
|
||||||
sourceAddr = htonl(INADDR_ANY);
|
sourceAddrM = htonl(INADDR_ANY);
|
||||||
useIGMPv3 = false;
|
useIGMPv3M = false;
|
||||||
cIptvSocket::CloseSocket();
|
cIptvSocket::CloseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvUdpSocket::JoinMulticast(void)
|
bool cIptvUdpSocket::JoinMulticast(void)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::JoinMulticast()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
// Check if socket exists
|
// Check if socket exists
|
||||||
if (!isActive && (socketDesc >= 0)) {
|
if (!isActiveM && (socketDescM >= 0)) {
|
||||||
// Join a new multicast group
|
// Join a new multicast group
|
||||||
if (useIGMPv3) {
|
if (useIGMPv3M) {
|
||||||
// Source-specific multicast (SSM) is used
|
// Source-specific multicast (SSM) is used
|
||||||
struct group_source_req gsr;
|
struct group_source_req gsr;
|
||||||
struct sockaddr_in *grp;
|
struct sockaddr_in *grp;
|
||||||
@ -167,33 +164,33 @@ bool cIptvUdpSocket::JoinMulticast(void)
|
|||||||
gsr.gsr_interface = 0; // if_nametoindex("any") ?
|
gsr.gsr_interface = 0; // if_nametoindex("any") ?
|
||||||
grp = (struct sockaddr_in*)&gsr.gsr_group;
|
grp = (struct sockaddr_in*)&gsr.gsr_group;
|
||||||
grp->sin_family = AF_INET;
|
grp->sin_family = AF_INET;
|
||||||
grp->sin_addr.s_addr = streamAddr;
|
grp->sin_addr.s_addr = streamAddrM;
|
||||||
grp->sin_port = 0;
|
grp->sin_port = 0;
|
||||||
src = (struct sockaddr_in*)&gsr.gsr_source;
|
src = (struct sockaddr_in*)&gsr.gsr_source;
|
||||||
src->sin_family = AF_INET;
|
src->sin_family = AF_INET;
|
||||||
src->sin_addr.s_addr = sourceAddr;
|
src->sin_addr.s_addr = sourceAddrM;
|
||||||
src->sin_port = 0;
|
src->sin_port = 0;
|
||||||
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_JOIN_SOURCE_GROUP)", return false);
|
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_JOIN_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_JOIN_SOURCE_GROUP)", return false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct ip_mreq mreq;
|
struct ip_mreq mreq;
|
||||||
mreq.imr_multiaddr.s_addr = streamAddr;
|
mreq.imr_multiaddr.s_addr = streamAddrM;
|
||||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
|
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_ADD_MEMBERSHIP)", return false);
|
||||||
}
|
}
|
||||||
// Update multicasting flag
|
// Update multicasting flag
|
||||||
isActive = true;
|
isActiveM = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvUdpSocket::DropMulticast(void)
|
bool cIptvUdpSocket::DropMulticast(void)
|
||||||
{
|
{
|
||||||
debug("cIptvUdpSocket::DropMulticast()\n");
|
debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
// Check if socket exists
|
// Check if socket exists
|
||||||
if (isActive && (socketDesc >= 0)) {
|
if (isActiveM && (socketDescM >= 0)) {
|
||||||
// Drop the existing multicast group
|
// Drop the existing multicast group
|
||||||
if (useIGMPv3) {
|
if (useIGMPv3M) {
|
||||||
// Source-specific multicast (SSM) is used
|
// Source-specific multicast (SSM) is used
|
||||||
struct group_source_req gsr;
|
struct group_source_req gsr;
|
||||||
struct sockaddr_in *grp;
|
struct sockaddr_in *grp;
|
||||||
@ -201,57 +198,57 @@ bool cIptvUdpSocket::DropMulticast(void)
|
|||||||
gsr.gsr_interface = 0; // if_nametoindex("any") ?
|
gsr.gsr_interface = 0; // if_nametoindex("any") ?
|
||||||
grp = (struct sockaddr_in*)&gsr.gsr_group;
|
grp = (struct sockaddr_in*)&gsr.gsr_group;
|
||||||
grp->sin_family = AF_INET;
|
grp->sin_family = AF_INET;
|
||||||
grp->sin_addr.s_addr = streamAddr;
|
grp->sin_addr.s_addr = streamAddrM;
|
||||||
grp->sin_port = 0;
|
grp->sin_port = 0;
|
||||||
src = (struct sockaddr_in*)&gsr.gsr_source;
|
src = (struct sockaddr_in*)&gsr.gsr_source;
|
||||||
src->sin_family = AF_INET;
|
src->sin_family = AF_INET;
|
||||||
src->sin_addr.s_addr = sourceAddr;
|
src->sin_addr.s_addr = sourceAddrM;
|
||||||
src->sin_port = 0;
|
src->sin_port = 0;
|
||||||
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_LEAVE_SOURCE_GROUP)", return false);
|
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, MCAST_LEAVE_SOURCE_GROUP, &gsr, sizeof(gsr)) < 0, "setsockopt(MCAST_LEAVE_SOURCE_GROUP)", return false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
struct ip_mreq mreq;
|
struct ip_mreq mreq;
|
||||||
mreq.imr_multiaddr.s_addr = streamAddr;
|
mreq.imr_multiaddr.s_addr = streamAddrM;
|
||||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
ERROR_IF_RET(setsockopt(socketDesc, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
|
ERROR_IF_RET(setsockopt(socketDescM, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0, "setsockopt(IP_DROP_MEMBERSHIP)", return false);
|
||||||
}
|
}
|
||||||
// Update multicasting flag
|
// Update multicasting flag
|
||||||
isActive = false;
|
isActiveM = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvUdpSocket::Read()\n");
|
//debug("cIptvUdpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in cIptvUdpSocket::%s()\n", __FUNCTION__);
|
error("Invalid socket in cIptvUdpSocket::%s()\n", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
// Read data from socket in a loop
|
// Read data from socket in a loop
|
||||||
do {
|
do {
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
struct msghdr msgh;
|
struct msghdr msgh;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
char cbuf[256];
|
char cbuf[256];
|
||||||
len = 0;
|
len = 0;
|
||||||
// Initialize iov and msgh structures
|
// Initialize iov and msgh structures
|
||||||
memset(&msgh, 0, sizeof(struct msghdr));
|
memset(&msgh, 0, sizeof(struct msghdr));
|
||||||
iov.iov_base = BufferAddr;
|
iov.iov_base = bufferAddrP;
|
||||||
iov.iov_len = BufferLen;
|
iov.iov_len = bufferLenP;
|
||||||
msgh.msg_control = cbuf;
|
msgh.msg_control = cbuf;
|
||||||
msgh.msg_controllen = sizeof(cbuf);
|
msgh.msg_controllen = sizeof(cbuf);
|
||||||
msgh.msg_name = &sockAddr;
|
msgh.msg_name = &sockAddrM;
|
||||||
msgh.msg_namelen = addrlen;
|
msgh.msg_namelen = addrlen;
|
||||||
msgh.msg_iov = &iov;
|
msgh.msg_iov = &iov;
|
||||||
msgh.msg_iovlen = 1;
|
msgh.msg_iovlen = 1;
|
||||||
msgh.msg_flags = 0;
|
msgh.msg_flags = 0;
|
||||||
|
|
||||||
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
|
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
|
||||||
len = (int)recvmsg(socketDesc, &msgh, MSG_DONTWAIT);
|
len = (int)recvmsg(socketDescM, &msgh, MSG_DONTWAIT);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
@ -260,36 +257,36 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
|||||||
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
|
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
|
||||||
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
|
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
|
||||||
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
|
struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
|
||||||
if ((i->ipi_addr.s_addr == streamAddr) || (htonl(INADDR_ANY) == streamAddr)) {
|
if ((i->ipi_addr.s_addr == streamAddrM) || (htonl(INADDR_ANY) == streamAddrM)) {
|
||||||
#endif // __FreeBSD__
|
#endif // __FreeBSD__
|
||||||
if (BufferAddr[0] == TS_SYNC_BYTE)
|
if (bufferAddrP[0] == TS_SYNC_BYTE)
|
||||||
return len;
|
return len;
|
||||||
else if (len > 3) {
|
else if (len > 3) {
|
||||||
// http://tools.ietf.org/html/rfc3550
|
// http://tools.ietf.org/html/rfc3550
|
||||||
// http://tools.ietf.org/html/rfc2250
|
// http://tools.ietf.org/html/rfc2250
|
||||||
// version
|
// version
|
||||||
unsigned int v = (BufferAddr[0] >> 6) & 0x03;
|
unsigned int v = (bufferAddrP[0] >> 6) & 0x03;
|
||||||
// extension bit
|
// extension bit
|
||||||
unsigned int x = (BufferAddr[0] >> 4) & 0x01;
|
unsigned int x = (bufferAddrP[0] >> 4) & 0x01;
|
||||||
// cscr count
|
// cscr count
|
||||||
unsigned int cc = BufferAddr[0] & 0x0F;
|
unsigned int cc = bufferAddrP[0] & 0x0F;
|
||||||
// payload type: MPEG2 TS = 33
|
// payload type: MPEG2 TS = 33
|
||||||
//unsigned int pt = readBuffer[1] & 0x7F;
|
//unsigned int pt = bufferAddrP[1] & 0x7F;
|
||||||
// header lenght
|
// header lenght
|
||||||
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
|
unsigned int headerlen = (3 + cc) * (unsigned int)sizeof(uint32_t);
|
||||||
// check if extension
|
// check if extension
|
||||||
if (x) {
|
if (x) {
|
||||||
// extension header length
|
// extension header length
|
||||||
unsigned int ehl = (((BufferAddr[headerlen + 2] & 0xFF) << 8) |
|
unsigned int ehl = (((bufferAddrP[headerlen + 2] & 0xFF) << 8) |
|
||||||
(BufferAddr[headerlen + 3] & 0xFF));
|
(bufferAddrP[headerlen + 3] & 0xFF));
|
||||||
// update header length
|
// update header length
|
||||||
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
|
headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
// Check that rtp is version 2 and payload contains multiple of TS packet data
|
// Check that rtp is version 2 and payload contains multiple of TS packet data
|
||||||
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
|
if ((v == 2) && (((len - headerlen) % TS_SIZE) == 0) &&
|
||||||
(BufferAddr[headerlen] == TS_SYNC_BYTE)) {
|
(bufferAddrP[headerlen] == TS_SYNC_BYTE)) {
|
||||||
// Set argument point to payload in read buffer
|
// Set argument point to payload in read buffer
|
||||||
memmove(BufferAddr, &BufferAddr[headerlen], (len - headerlen));
|
memmove(bufferAddrP, &bufferAddrP[headerlen], (len - headerlen));
|
||||||
return (len - headerlen);
|
return (len - headerlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,42 +305,42 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
|||||||
// TCP socket class
|
// TCP socket class
|
||||||
cIptvTcpSocket::cIptvTcpSocket()
|
cIptvTcpSocket::cIptvTcpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::cIptvTcpSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvTcpSocket::~cIptvTcpSocket()
|
cIptvTcpSocket::~cIptvTcpSocket()
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::~cIptvTcpSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::OpenSocket(const int Port, const char *StreamAddr)
|
bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP)
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::OpenSocket()\n");
|
debug("cIptvTcpSocket::%s(%s, %s)", __FUNCTION__, portP, streamAddrP);
|
||||||
// Socket must be opened before setting the host address
|
// Socket must be opened before setting the host address
|
||||||
return (cIptvSocket::OpenSocket(Port, false) && CheckAddress(StreamAddr, &sockAddr.sin_addr.s_addr));
|
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.sin_addr.s_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cIptvTcpSocket::CloseSocket(void)
|
void cIptvTcpSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::CloseSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
cIptvSocket::CloseSocket();
|
cIptvSocket::CloseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::ConnectSocket(void)
|
bool cIptvTcpSocket::ConnectSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::ConnectSocket()\n");
|
debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
if (!isActive && (socketDesc >= 0)) {
|
if (!isActiveM && (socketDescM >= 0)) {
|
||||||
int retval = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr));
|
int retval = connect(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM));
|
||||||
// Non-blocking sockets always report in-progress error when connected
|
// Non-blocking sockets always report in-progress error when connected
|
||||||
ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false);
|
ERROR_IF_RET(retval < 0 && errno != EINPROGRESS, "connect()", return false);
|
||||||
// Select with 800ms timeout on the socket completion, check if it is writable
|
// Select with 800ms timeout on the socket completion, check if it is writable
|
||||||
retval = select_single_desc(socketDesc, 800000, true);
|
retval = select_single_desc(socketDescM, 800000, true);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
// Select has returned. Get socket errors if there are any
|
// Select has returned. Get socket errors if there are any
|
||||||
retval = 0;
|
retval = 0;
|
||||||
socklen_t len = sizeof(retval);
|
socklen_t len = sizeof(retval);
|
||||||
getsockopt(socketDesc, SOL_SOCKET, SO_ERROR, &retval, &len);
|
getsockopt(socketDescM, SOL_SOCKET, SO_ERROR, &retval, &len);
|
||||||
// If not any errors, then socket must be ready and connected
|
// If not any errors, then socket must be ready and connected
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
@ -355,41 +352,41 @@ bool cIptvTcpSocket::ConnectSocket(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvTcpSocket::Read()\n");
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int len = 0;
|
int len = 0;
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
// Read data from socket
|
// Read data from socket
|
||||||
if (isActive && socketDesc && BufferAddr && (BufferLen > 0))
|
if (isActiveM && socketDescM && bufferAddrP && (bufferLenP > 0))
|
||||||
len = (int)recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT,
|
len = (int)recvfrom(socketDescM, bufferAddrP, bufferLenP, MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
(struct sockaddr *)&sockAddrM, &addrlen);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::ReadChar(char* BufferAddr, unsigned int TimeoutMs)
|
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
|
||||||
{
|
{
|
||||||
//debug("cIptvTcpSocket::ReadChar()\n");
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
socklen_t addrlen = sizeof(sockAddr);
|
socklen_t addrlen = sizeof(sockAddrM);
|
||||||
// Wait 500ms for data
|
// Wait 500ms for data
|
||||||
int retval = select_single_desc(socketDesc, 1000 * TimeoutMs, false);
|
int retval = select_single_desc(socketDescM, 1000 * timeoutMsP, false);
|
||||||
// Check if error
|
// Check if error
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return false;
|
return false;
|
||||||
// Check if data available
|
// Check if data available
|
||||||
else if (retval) {
|
else if (retval) {
|
||||||
retval = (int)recvfrom(socketDesc, BufferAddr, 1, MSG_DONTWAIT,
|
retval = (int)recvfrom(socketDescM, bufferAddrP, 1, MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
(struct sockaddr *)&sockAddrM, &addrlen);
|
||||||
if (retval <= 0)
|
if (retval <= 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -397,15 +394,15 @@ bool cIptvTcpSocket::ReadChar(char* BufferAddr, unsigned int TimeoutMs)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::Write(const char* BufferAddr, unsigned int BufferLen)
|
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP)
|
||||||
{
|
{
|
||||||
//debug("cIptvTcpSocket::Write()\n");
|
//debug("cIptvTcpSocket::%s()", __FUNCTION__);
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
if (socketDesc <= 0) {
|
if (socketDescM <= 0) {
|
||||||
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
error("Invalid socket in cIptvTcpSocket::%s()\n", __FUNCTION__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ERROR_IF_RET(send(socketDesc, BufferAddr, BufferLen, 0) < 0, "send()", return false);
|
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
30
socket.h
30
socket.h
@ -15,17 +15,17 @@
|
|||||||
|
|
||||||
class cIptvSocket {
|
class cIptvSocket {
|
||||||
private:
|
private:
|
||||||
int socketPort;
|
int socketPortM;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int socketDesc;
|
int socketDescM;
|
||||||
struct sockaddr_in sockAddr;
|
struct sockaddr_in sockAddrM;
|
||||||
bool isActive;
|
bool isActiveM;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool OpenSocket(const int Port, const bool isUdp);
|
bool OpenSocket(const int portP, const bool isUdpP);
|
||||||
void CloseSocket(void);
|
void CloseSocket(void);
|
||||||
bool CheckAddress(const char *Addr, in_addr_t *InAddr);
|
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvSocket();
|
cIptvSocket();
|
||||||
@ -34,16 +34,16 @@ public:
|
|||||||
|
|
||||||
class cIptvUdpSocket : public cIptvSocket {
|
class cIptvUdpSocket : public cIptvSocket {
|
||||||
private:
|
private:
|
||||||
in_addr_t streamAddr;
|
in_addr_t streamAddrM;
|
||||||
in_addr_t sourceAddr;
|
in_addr_t sourceAddrM;
|
||||||
bool useIGMPv3;
|
bool useIGMPv3M;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cIptvUdpSocket();
|
cIptvUdpSocket();
|
||||||
virtual ~cIptvUdpSocket();
|
virtual ~cIptvUdpSocket();
|
||||||
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool OpenSocket(const int Port);
|
bool OpenSocket(const int Port);
|
||||||
bool OpenSocket(const int Port, const char *StreamAddr, const char *SourceAddr, bool UseIGMPv3);
|
bool OpenSocket(const int Port, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P);
|
||||||
void CloseSocket(void);
|
void CloseSocket(void);
|
||||||
bool JoinMulticast(void);
|
bool JoinMulticast(void);
|
||||||
bool DropMulticast(void);
|
bool DropMulticast(void);
|
||||||
@ -53,12 +53,12 @@ class cIptvTcpSocket : public cIptvSocket {
|
|||||||
public:
|
public:
|
||||||
cIptvTcpSocket();
|
cIptvTcpSocket();
|
||||||
virtual ~cIptvTcpSocket();
|
virtual ~cIptvTcpSocket();
|
||||||
virtual int Read(unsigned char* BufferAddr, unsigned int BufferLen);
|
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
||||||
bool OpenSocket(const int Port, const char *StreamAddr);
|
bool OpenSocket(const int portP, const char *streamAddrP);
|
||||||
void CloseSocket(void);
|
void CloseSocket(void);
|
||||||
bool ConnectSocket(void);
|
bool ConnectSocket(void);
|
||||||
bool ReadChar(char* BufferAddr, unsigned int TimeoutMs);
|
bool ReadChar(char* bufferAddrP, unsigned int timeoutMsP);
|
||||||
bool Write(const char* BufferAddr, unsigned int BufferLen);
|
bool Write(const char* bufferAddrP, unsigned int bufferLenP);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __IPTV_SOCKET_H
|
#endif // __IPTV_SOCKET_H
|
||||||
|
14
source.c
14
source.c
@ -16,7 +16,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
|
|||||||
protocolM(eProtocolUDP),
|
protocolM(eProtocolUDP),
|
||||||
parameterM(0)
|
parameterM(0)
|
||||||
{
|
{
|
||||||
debug("cIptvTransponderParameters::cIptvTransponderParameters('%s')\n", parametersP);
|
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, parametersP);
|
||||||
|
|
||||||
memset(&addressM, 0, sizeof(addressM));
|
memset(&addressM, 0, sizeof(addressM));
|
||||||
Parse(parametersP);
|
Parse(parametersP);
|
||||||
@ -24,7 +24,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
|
|||||||
|
|
||||||
cString cIptvTransponderParameters::ToString(char typeP) const
|
cString cIptvTransponderParameters::ToString(char typeP) const
|
||||||
{
|
{
|
||||||
debug("cIptvTransponderParameters::ToString(%c)\n", typeP);
|
debug("cIptvTransponderParameters::%s(%c)", __FUNCTION__, typeP);
|
||||||
|
|
||||||
const char *protocolstr;
|
const char *protocolstr;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ cString cIptvTransponderParameters::ToString(char typeP) const
|
|||||||
|
|
||||||
bool cIptvTransponderParameters::Parse(const char *strP)
|
bool cIptvTransponderParameters::Parse(const char *strP)
|
||||||
{
|
{
|
||||||
debug("cIptvTransponderParameters::Parse('%s'\n", strP);
|
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, strP);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (strP && *strP) {
|
if (strP && *strP) {
|
||||||
@ -138,7 +138,7 @@ cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
|
|||||||
dataM(),
|
dataM(),
|
||||||
itpM()
|
itpM()
|
||||||
{
|
{
|
||||||
debug("cIptvSourceParam::cIptvSourceParam(%c, '%s')\n", sourceP, descriptionP);
|
debug("cIptvSourceParam::%s(%c, %s)", __FUNCTION__, sourceP, descriptionP);
|
||||||
|
|
||||||
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
|
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
|
||||||
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL");
|
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL");
|
||||||
@ -149,7 +149,7 @@ cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
|
|||||||
|
|
||||||
void cIptvSourceParam::SetData(cChannel *channelP)
|
void cIptvSourceParam::SetData(cChannel *channelP)
|
||||||
{
|
{
|
||||||
debug("cIptvSourceParam::SetData('%s')\n", channelP->Parameters());
|
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
|
||||||
dataM = *channelP;
|
dataM = *channelP;
|
||||||
nidM = dataM.Nid();
|
nidM = dataM.Nid();
|
||||||
tidM = dataM.Tid();
|
tidM = dataM.Tid();
|
||||||
@ -160,7 +160,7 @@ void cIptvSourceParam::SetData(cChannel *channelP)
|
|||||||
|
|
||||||
void cIptvSourceParam::GetData(cChannel *channelP)
|
void cIptvSourceParam::GetData(cChannel *channelP)
|
||||||
{
|
{
|
||||||
debug("cIptvSourceParam::GetData('%s')\n", channelP->Parameters());
|
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters());
|
||||||
dataM.SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
|
dataM.SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
|
||||||
dataM.SetId(nidM, tidM, channelP->Sid(), ridM);
|
dataM.SetId(nidM, tidM, channelP->Sid(), ridM);
|
||||||
*channelP = dataM;
|
*channelP = dataM;
|
||||||
@ -168,7 +168,7 @@ void cIptvSourceParam::GetData(cChannel *channelP)
|
|||||||
|
|
||||||
cOsdItem *cIptvSourceParam::GetOsdItem(void)
|
cOsdItem *cIptvSourceParam::GetOsdItem(void)
|
||||||
{
|
{
|
||||||
debug("cIptvSourceParam::GetOsdItem()\n");
|
debug("cIptvSourceParam::%s()", __FUNCTION__);
|
||||||
switch (paramM++) {
|
switch (paramM++) {
|
||||||
case 0: return new cMenuEditIntItem( tr("Nid"), &nidM, 0);
|
case 0: return new cMenuEditIntItem( tr("Nid"), &nidM, 0);
|
||||||
case 1: return new cMenuEditIntItem( tr("Tid"), &tidM, 0);
|
case 1: return new cMenuEditIntItem( tr("Tid"), &tidM, 0);
|
||||||
|
46
statistics.c
46
statistics.c
@ -11,24 +11,24 @@
|
|||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
// Section statistic class
|
// Section statistics class
|
||||||
cIptvSectionStatistics::cIptvSectionStatistics()
|
cIptvSectionStatistics::cIptvSectionStatistics()
|
||||||
: filteredDataM(0),
|
: filteredDataM(0),
|
||||||
numberOfCallsM(0),
|
numberOfCallsM(0),
|
||||||
timerM(),
|
timerM(),
|
||||||
mutexM()
|
mutexM()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::cIptvSectionStatistics()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvSectionStatistics::~cIptvSectionStatistics()
|
cIptvSectionStatistics::~cIptvSectionStatistics()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::~cIptvSectionStatistics()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvSectionStatistics::GetSectionStatistic()
|
cString cIptvSectionStatistics::GetSectionStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::GetStatistic()\n");
|
//debug("cIptvSectionStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timerM.Set();
|
timerM.Set();
|
||||||
@ -44,7 +44,7 @@ cString cIptvSectionStatistics::GetSectionStatistic()
|
|||||||
|
|
||||||
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
|
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
|
||||||
{
|
{
|
||||||
//debug("cIptvSectionStatistics::AddStatistic(%ld, %ld)\n", bytesP, callsP);
|
//debug("cIptvSectionStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, callsP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
filteredDataM += bytesP;
|
filteredDataM += bytesP;
|
||||||
numberOfCallsM += callsP;
|
numberOfCallsM += callsP;
|
||||||
@ -52,23 +52,23 @@ void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
|
|||||||
|
|
||||||
// --- cIptvPidStatistics ----------------------------------------------------
|
// --- cIptvPidStatistics ----------------------------------------------------
|
||||||
|
|
||||||
// Device statistic class
|
// Device statistics class
|
||||||
cIptvPidStatistics::cIptvPidStatistics()
|
cIptvPidStatistics::cIptvPidStatistics()
|
||||||
: timerM(),
|
: timerM(),
|
||||||
mutexM()
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvPidStatistics::cIptvPidStatistics()\n");
|
debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
memset(mostActivePidsM, '\0', sizeof(mostActivePidsM));
|
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvPidStatistics::~cIptvPidStatistics()
|
cIptvPidStatistics::~cIptvPidStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvPidStatistics::~cIptvPidStatistics()\n");
|
debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvPidStatistics::GetPidStatistic()
|
cString cIptvPidStatistics::GetPidStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::GetStatistic()\n");
|
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timerM.Set();
|
timerM.Set();
|
||||||
@ -83,13 +83,13 @@ cString cIptvPidStatistics::GetPidStatistic()
|
|||||||
IptvConfig.GetUseBytes() ? "B" : "bit");
|
IptvConfig.GetUseBytes() ? "B" : "bit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(mostActivePidsM, '\0', sizeof(mostActivePidsM));
|
memset(mostActivePidsM, 0, sizeof(mostActivePidsM));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
|
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::SortPids()\n");
|
//debug("cIptvPidStatistics::%s()", __FUNCTION__);
|
||||||
const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P);
|
const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P);
|
||||||
const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P);
|
const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P);
|
||||||
if (comp1->DataAmount > comp2->DataAmount)
|
if (comp1->DataAmount > comp2->DataAmount)
|
||||||
@ -101,7 +101,7 @@ int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
|
|||||||
|
|
||||||
void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
|
void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
|
||||||
{
|
{
|
||||||
//debug("cIptvPidStatistics::AddStatistic(%ld, %ld)\n", pidP, payloadP);
|
//debug("cIptvPidStatistics::%s(%ld, %ld)", __FUNCTION__, pidP, payloadP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
|
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
|
||||||
// If our statistic already is in the array, update it and quit
|
// If our statistic already is in the array, update it and quit
|
||||||
@ -125,23 +125,23 @@ void cIptvPidStatistics::AddPidStatistic(u_short pidP, long payloadP)
|
|||||||
|
|
||||||
// --- cIptvStreamerStatistics -----------------------------------------------
|
// --- cIptvStreamerStatistics -----------------------------------------------
|
||||||
|
|
||||||
// Streamer statistic class
|
// Streamer statistics class
|
||||||
cIptvStreamerStatistics::cIptvStreamerStatistics()
|
cIptvStreamerStatistics::cIptvStreamerStatistics()
|
||||||
: dataBytesM(0),
|
: dataBytesM(0),
|
||||||
timerM(),
|
timerM(),
|
||||||
mutexM()
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamerStatistics::cIptvStreamerStatistics()\n");
|
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
cIptvStreamerStatistics::~cIptvStreamerStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamerStatistics::~cIptvStreamerStatistics()\n");
|
debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvStreamerStatistics::GetStreamerStatistic()
|
cString cIptvStreamerStatistics::GetStreamerStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::GetStatistic()\n");
|
//debug("cIptvStreamerStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timerM.Set();
|
timerM.Set();
|
||||||
@ -155,13 +155,13 @@ cString cIptvStreamerStatistics::GetStreamerStatistic()
|
|||||||
|
|
||||||
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
|
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamerStatistics::AddStatistic(%ld)\n", bytesP);
|
//debug("cIptvStreamerStatistics::%s(%ld)", __FUNCTION__, bytesP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
dataBytesM += bytesP;
|
dataBytesM += bytesP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Buffer statistic class
|
// Buffer statistics class
|
||||||
cIptvBufferStatistics::cIptvBufferStatistics()
|
cIptvBufferStatistics::cIptvBufferStatistics()
|
||||||
: dataBytesM(0),
|
: dataBytesM(0),
|
||||||
freeSpaceM(0),
|
freeSpaceM(0),
|
||||||
@ -169,17 +169,17 @@ cIptvBufferStatistics::cIptvBufferStatistics()
|
|||||||
timerM(),
|
timerM(),
|
||||||
mutexM()
|
mutexM()
|
||||||
{
|
{
|
||||||
debug("cIptvBufferStatistics::cIptvBufferStatistics()\n");
|
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cIptvBufferStatistics::~cIptvBufferStatistics()
|
cIptvBufferStatistics::~cIptvBufferStatistics()
|
||||||
{
|
{
|
||||||
debug("cIptvBufferStatistics::~cIptvBufferStatistics()\n");
|
debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
cString cIptvBufferStatistics::GetBufferStatistic()
|
cString cIptvBufferStatistics::GetBufferStatistic()
|
||||||
{
|
{
|
||||||
//debug("cIptvBufferStatistics::GetStatistic()\n");
|
//debug("cIptvBufferStatistics::%s()", __FUNCTION__);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
|
||||||
timerM.Set();
|
timerM.Set();
|
||||||
@ -203,7 +203,7 @@ cString cIptvBufferStatistics::GetBufferStatistic()
|
|||||||
|
|
||||||
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
|
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
|
||||||
{
|
{
|
||||||
//debug("cIptvBufferStatistics::AddStatistic(%ld, %ld)\n", bytesP, usedP);
|
//debug("cIptvBufferStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, usedP);
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
dataBytesM += bytesP;
|
dataBytesM += bytesP;
|
||||||
if (usedP > usedSpaceM)
|
if (usedP > usedSpaceM)
|
||||||
|
16
streamer.c
16
streamer.c
@ -17,7 +17,7 @@ cIptvStreamer::cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packet
|
|||||||
packetBufferLenM(packetLenP),
|
packetBufferLenM(packetLenP),
|
||||||
protocolM(NULL)
|
protocolM(NULL)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::cIptvStreamer(%d)\n", packetBufferLenM);
|
debug("cIptvStreamer::%s(%d)", __FUNCTION__, packetBufferLenM);
|
||||||
// Allocate packet buffer
|
// Allocate packet buffer
|
||||||
packetBufferM = MALLOC(unsigned char, packetBufferLenM);
|
packetBufferM = MALLOC(unsigned char, packetBufferLenM);
|
||||||
if (packetBufferM)
|
if (packetBufferM)
|
||||||
@ -28,7 +28,7 @@ cIptvStreamer::cIptvStreamer(cRingBufferLinear* ringBufferP, unsigned int packet
|
|||||||
|
|
||||||
cIptvStreamer::~cIptvStreamer()
|
cIptvStreamer::~cIptvStreamer()
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::~cIptvStreamer()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Close the protocol
|
// Close the protocol
|
||||||
Close();
|
Close();
|
||||||
protocolM = NULL;
|
protocolM = NULL;
|
||||||
@ -39,7 +39,7 @@ cIptvStreamer::~cIptvStreamer()
|
|||||||
|
|
||||||
void cIptvStreamer::Action(void)
|
void cIptvStreamer::Action(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Action(): Entering\n");
|
debug("cIptvStreamer::%s(): entering", __FUNCTION__);
|
||||||
// Increase priority
|
// Increase priority
|
||||||
//SetPriority(-1);
|
//SetPriority(-1);
|
||||||
// Do the thread loop
|
// Do the thread loop
|
||||||
@ -58,12 +58,12 @@ void cIptvStreamer::Action(void)
|
|||||||
else
|
else
|
||||||
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
|
sleepM.Wait(10); // to avoid busy loop and reduce cpu load
|
||||||
}
|
}
|
||||||
debug("cIptvStreamer::Action(): Exiting\n");
|
debug("cIptvStreamer::%s(): exiting", __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvStreamer::Open(void)
|
bool cIptvStreamer::Open(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Open()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Open the protocol
|
// Open the protocol
|
||||||
if (protocolM && !protocolM->Open())
|
if (protocolM && !protocolM->Open())
|
||||||
return false;
|
return false;
|
||||||
@ -74,7 +74,7 @@ bool cIptvStreamer::Open(void)
|
|||||||
|
|
||||||
bool cIptvStreamer::Close(void)
|
bool cIptvStreamer::Close(void)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Close()\n");
|
debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
// Stop thread
|
// Stop thread
|
||||||
sleepM.Signal();
|
sleepM.Signal();
|
||||||
if (Running())
|
if (Running())
|
||||||
@ -87,7 +87,7 @@ bool cIptvStreamer::Close(void)
|
|||||||
|
|
||||||
bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
|
bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
|
||||||
{
|
{
|
||||||
debug("cIptvStreamer::Set('%s', %d, %d)\n", locationP, parameterP, indexP);
|
debug("cIptvStreamer::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP);
|
||||||
if (!isempty(locationP)) {
|
if (!isempty(locationP)) {
|
||||||
// Update protocol and set location and parameter; Close the existing one if changed
|
// Update protocol and set location and parameter; Close the existing one if changed
|
||||||
if (protocolM != protocolP) {
|
if (protocolM != protocolP) {
|
||||||
@ -107,7 +107,7 @@ bool cIptvStreamer::Set(const char* locationP, const int parameterP, const int i
|
|||||||
|
|
||||||
cString cIptvStreamer::GetInformation(void)
|
cString cIptvStreamer::GetInformation(void)
|
||||||
{
|
{
|
||||||
//debug("cIptvStreamer::GetInformation()");
|
//debug("cIptvStreamer::%s()", __FUNCTION__);
|
||||||
cString s;
|
cString s;
|
||||||
if (protocolM)
|
if (protocolM)
|
||||||
s = protocolM->GetInformation();
|
s = protocolM->GetInformation();
|
||||||
|
Loading…
Reference in New Issue
Block a user