Added support for tracing modes.

This commit is contained in:
Rolf Ahrenberg 2015-03-08 14:33:18 +02:00
parent 63359e4c24
commit bc6da9dd63
21 changed files with 343 additions and 251 deletions

View File

@ -12,16 +12,6 @@
#include <vdr/config.h> #include <vdr/config.h>
#include <vdr/i18n.h> #include <vdr/i18n.h>
#ifdef DEBUG
#define debug(x...) dsyslog("IPTV: " x);
#define info(x...) isyslog("IPTV: " x);
#define error(x...) esyslog("ERROR: " x);
#else
#define debug(x...) ;
#define info(x...) isyslog("IPTV: " x);
#define error(x...) esyslog("ERROR: " x);
#endif
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0])) #define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
#define IPTV_BUFFER_SIZE MEGABYTE(1) #define IPTV_BUFFER_SIZE MEGABYTE(1)
@ -42,15 +32,15 @@
#define SECTION_FILTER_TABLE_SIZE 5 #define SECTION_FILTER_TABLE_SIZE 5
#define ERROR_IF_FUNC(exp, errstr, func, ret) \ #define ERROR_IF_FUNC(exp, errstr, func, ret) \
do { \ do { \
if (exp) { \ if (exp) { \
char tmp[64]; \ char tmp[64]; \
error("[%s,%d]: "errstr": %s", __FILE__, __LINE__, \ esyslog("[%s,%d]: "errstr": %s", __FILE__, __LINE__, \
strerror_r(errno, tmp, sizeof(tmp))); \ strerror_r(errno, tmp, sizeof(tmp))); \
func; \ func; \
ret; \ ret; \
} \ } \
} while (0) } while (0)

View File

@ -5,12 +5,14 @@
* *
*/ */
#include "log.h"
#include "config.h" #include "config.h"
cIptvConfig IptvConfig; cIptvConfig IptvConfig;
cIptvConfig::cIptvConfig(void) cIptvConfig::cIptvConfig(void)
: protocolBasePortM(4321), : traceModeM(eTraceModeNormal),
protocolBasePortM(4321),
useBytesM(1), useBytesM(1),
sectionFilteringM(1) sectionFilteringM(1)
{ {
@ -41,12 +43,12 @@ void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP)
void cIptvConfig::SetConfigDirectory(const char *directoryP) void cIptvConfig::SetConfigDirectory(const char *directoryP)
{ {
debug("cIptvConfig::%s(%s)", __FUNCTION__, directoryP); debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory"); ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
} }
void cIptvConfig::SetResourceDirectory(const char *directoryP) void cIptvConfig::SetResourceDirectory(const char *directoryP)
{ {
debug("cIptvConfig::%s(%s)", __FUNCTION__, directoryP); debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory"); ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory");
} }

View File

@ -14,6 +14,7 @@
class cIptvConfig class cIptvConfig
{ {
private: private:
unsigned int traceModeM;
unsigned int protocolBasePortM; unsigned int protocolBasePortM;
unsigned int useBytesM; unsigned int useBytesM;
unsigned int sectionFilteringM; unsigned int sectionFilteringM;
@ -22,7 +23,29 @@ private:
char resourceDirectoryM[PATH_MAX]; char resourceDirectoryM[PATH_MAX];
public: public:
enum eTraceMode {
eTraceModeNormal = 0x0000,
eTraceModeDebug1 = 0x0001,
eTraceModeDebug2 = 0x0002,
eTraceModeDebug3 = 0x0004,
eTraceModeDebug4 = 0x0008,
eTraceModeDebug5 = 0x0010,
eTraceModeDebug6 = 0x0020,
eTraceModeDebug7 = 0x0040,
eTraceModeDebug8 = 0x0080,
eTraceModeDebug9 = 0x0100,
eTraceModeDebug10 = 0x0200,
eTraceModeDebug11 = 0x0400,
eTraceModeDebug12 = 0x0800,
eTraceModeDebug13 = 0x1000,
eTraceModeDebug14 = 0x2000,
eTraceModeDebug15 = 0x4000,
eTraceModeDebug16 = 0x8000,
eTraceModeMask = 0xFFFF
};
cIptvConfig(); cIptvConfig();
unsigned int GetTraceMode(void) const { return traceModeM; }
bool IsTraceMode(eTraceMode modeP) const { return (traceModeM & modeP); }
unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; } unsigned int GetProtocolBasePort(void) const { return protocolBasePortM; }
unsigned int GetUseBytes(void) const { return useBytesM; } unsigned int GetUseBytes(void) const { return useBytesM; }
unsigned int GetSectionFiltering(void) const { return sectionFilteringM; } unsigned int GetSectionFiltering(void) const { return sectionFilteringM; }
@ -30,6 +53,7 @@ public:
const char *GetResourceDirectory(void) const { return resourceDirectoryM; } const char *GetResourceDirectory(void) const { return resourceDirectoryM; }
unsigned int GetDisabledFiltersCount(void) const; unsigned int GetDisabledFiltersCount(void) const;
int GetDisabledFilters(unsigned int indexP) const; int GetDisabledFilters(unsigned int indexP) const;
void SetTraceMode(unsigned int modeP) { traceModeM = (modeP & eTraceModeMask); }
void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; } void SetProtocolBasePort(unsigned int portNumberP) { protocolBasePortM = portNumberP; }
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; } void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; } void SetSectionFiltering(unsigned int onOffP) { sectionFilteringM = onOffP; }

View File

@ -24,7 +24,7 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
{ {
unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE; unsigned int bufsize = (unsigned int)IPTV_BUFFER_SIZE;
bufsize -= (bufsize % TS_SIZE); bufsize -= (bufsize % TS_SIZE);
isyslog("creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex()); info("Creating IPTV device %d (CardIndex=%d)", deviceIndexM, CardIndex());
tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false, tsBufferM = new cRingBufferLinear(bufsize + 1, TS_SIZE, false,
*cString::sprintf("IPTV TS %d", deviceIndexM)); *cString::sprintf("IPTV TS %d", deviceIndexM));
if (tsBufferM) { if (tsBufferM) {
@ -50,13 +50,13 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
if (S_ISFIFO(sb.st_mode)) { if (S_ISFIFO(sb.st_mode)) {
dvrFdM = open(filename, O_RDWR | O_NONBLOCK); dvrFdM = open(filename, O_RDWR | O_NONBLOCK);
if (dvrFdM >= 0) if (dvrFdM >= 0)
dsyslog("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename); info("IPTV device %d redirecting input stream to '%s'", deviceIndexM, *filename);
} }
} }
cIptvDevice::~cIptvDevice() cIptvDevice::~cIptvDevice()
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop section handler of iptv device // Stop section handler of iptv device
StopSectionHandler(); StopSectionHandler();
DELETE_POINTER(pIptvSectionM); DELETE_POINTER(pIptvSectionM);
@ -79,7 +79,7 @@ cIptvDevice::~cIptvDevice()
bool cIptvDevice::Initialize(unsigned int deviceCountP) bool cIptvDevice::Initialize(unsigned int deviceCountP)
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceCountP); debug1("%s (%u)", __PRETTY_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;
@ -92,7 +92,7 @@ bool cIptvDevice::Initialize(unsigned int deviceCountP)
void cIptvDevice::Shutdown(void) void cIptvDevice::Shutdown(void)
{ {
debug("cIptvDevice::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
for (int i = 0; i < IPTV_MAX_DEVICES; ++i) { for (int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i]) if (IptvDevicesS[i])
IptvDevicesS[i]->CloseDvr(); IptvDevicesS[i]->CloseDvr();
@ -102,7 +102,7 @@ void cIptvDevice::Shutdown(void)
unsigned int cIptvDevice::Count(void) unsigned int cIptvDevice::Count(void)
{ {
unsigned int count = 0; unsigned int count = 0;
debug("cIptvDevice::%s()", __FUNCTION__); debug1("%s", __PRETTY_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++;
@ -112,10 +112,10 @@ unsigned int cIptvDevice::Count(void)
cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP) cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, cardIndexP); debug16("%s (%d)", __PRETTY_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] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) { if (IptvDevicesS[i] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
//debug("cIptvDevice::%s(%d): found!", __FUNCTION__, cardIndexP); debug16("%s (%d) Found", __PRETTY_FUNCTION__, cardIndexP);
return IptvDevicesS[i]; return IptvDevicesS[i];
} }
} }
@ -124,7 +124,7 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
cString cIptvDevice::GetGeneralInformation(void) cString cIptvDevice::GetGeneralInformation(void)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_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() : "",
@ -135,13 +135,13 @@ cString cIptvDevice::GetGeneralInformation(void)
cString cIptvDevice::GetPidsInformation(void) cString cIptvDevice::GetPidsInformation(void)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return GetPidStatistic(); return GetPidStatistic();
} }
cString cIptvDevice::GetFiltersInformation(void) cString cIptvDevice::GetFiltersInformation(void)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return cString::sprintf("Active section filters:\n%s", pIptvSectionM ? *pIptvSectionM->GetInformation() : ""); return cString::sprintf("Active section filters:\n%s", pIptvSectionM ? *pIptvSectionM->GetInformation() : "");
} }
@ -177,37 +177,37 @@ cString cIptvDevice::GetInformation(unsigned int pageP)
cString cIptvDevice::DeviceType(void) const cString cIptvDevice::DeviceType(void) const
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return "IPTV"; return "IPTV";
} }
cString cIptvDevice::DeviceName(void) const cString cIptvDevice::DeviceName(void) const
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_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::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100); return (100);
} }
int cIptvDevice::SignalQuality(void) const int cIptvDevice::SignalQuality(void) const
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (100); return (100);
} }
bool cIptvDevice::ProvidesSource(int sourceP) const bool cIptvDevice::ProvidesSource(int sourceP) const
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_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::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return (ProvidesSource(channelP->Source())); return (ProvidesSource(channelP->Source()));
} }
@ -217,7 +217,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::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (channelP && ProvidesTransponder(channelP)) { if (channelP && ProvidesTransponder(channelP)) {
result = hasPriority; result = hasPriority;
@ -263,7 +263,7 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
cIptvProtocolIf *protocol; cIptvProtocolIf *protocol;
cIptvTransponderParameters itp(channelP->Parameters()); cIptvTransponderParameters itp(channelP->Parameters());
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isempty(itp.Address())) { if (isempty(itp.Address())) {
error("Unrecognized IPTV address: %s", channelP->Parameters()); error("Unrecognized IPTV address: %s", channelP->Parameters());
@ -304,7 +304,7 @@ 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::%s(%d): pid=%d type=%d on=%d", __FUNCTION__, deviceIndexM, handleP ? handleP->pid : -1, typeP, onP); debug1("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, handleP ? handleP->pid : -1, typeP, onP, deviceIndexM);
if (pIptvStreamerM && handleP) if (pIptvStreamerM && handleP)
return pIptvStreamerM->SetPid(handleP->pid, typeP, onP); return pIptvStreamerM->SetPid(handleP->pid, typeP, onP);
return true; return true;
@ -312,7 +312,7 @@ bool cIptvDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP) int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
{ {
//debug("cIptvDevice::%s(%d): pid=%d tid=%d mask=%d", __FUNCTION__, deviceIndexM, pidP, tidP, maskP); debug16("%s (%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
if (pIptvSectionM && IptvConfig.GetSectionFiltering()) { if (pIptvSectionM && IptvConfig.GetSectionFiltering()) {
if (pIptvStreamerM) if (pIptvStreamerM)
pIptvStreamerM->SetPid(pidP, ptOther, true); pIptvStreamerM->SetPid(pidP, ptOther, true);
@ -323,7 +323,7 @@ int cIptvDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
void cIptvDevice::CloseFilter(int handleP) void cIptvDevice::CloseFilter(int handleP)
{ {
//debug("cIptvDevice::%s(%d): handle=%d", __FUNCTION__, deviceIndexM, handleP); debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, handleP, deviceIndexM);
if (pIptvSectionM) { if (pIptvSectionM) {
if (pIptvStreamerM) if (pIptvStreamerM)
pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false); pIptvStreamerM->SetPid(pIptvSectionM->GetPid(handleP), ptOther, false);
@ -333,7 +333,7 @@ void cIptvDevice::CloseFilter(int handleP)
bool cIptvDevice::OpenDvr(void) bool cIptvDevice::OpenDvr(void)
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
isPacketDeliveredM = false; isPacketDeliveredM = false;
tsBufferM->Clear(); tsBufferM->Clear();
if (pIptvStreamerM) if (pIptvStreamerM)
@ -348,7 +348,7 @@ bool cIptvDevice::OpenDvr(void)
void cIptvDevice::CloseDvr(void) void cIptvDevice::CloseDvr(void)
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (pidScanEnabledM && pPidScannerM) if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Close(); pPidScannerM->Close();
if (sidScanEnabledM && pSidScannerM) if (sidScanEnabledM && pSidScannerM)
@ -360,19 +360,19 @@ void cIptvDevice::CloseDvr(void)
bool cIptvDevice::HasLock(int timeoutMsP) const bool cIptvDevice::HasLock(int timeoutMsP) const
{ {
//debug("cIptvDevice::%s(%d): timeoutMs=%d", __FUNCTION__, deviceIndexM, timeoutMsP); debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, timeoutMsP, deviceIndexM);
return (pIptvStreamerM && pIptvStreamerM->Active()); return (pIptvStreamerM && pIptvStreamerM->Active());
} }
bool cIptvDevice::HasInternalCam(void) bool cIptvDevice::HasInternalCam(void)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
return false; return false;
} }
void cIptvDevice::WriteData(uchar *bufferP, int lengthP) void cIptvDevice::WriteData(uchar *bufferP, int lengthP)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
int len; int len;
// Send data to dvr fifo // Send data to dvr fifo
if (dvrFdM >= 0) if (dvrFdM >= 0)
@ -390,7 +390,7 @@ void cIptvDevice::WriteData(uchar *bufferP, int lengthP)
unsigned int cIptvDevice::CheckData(void) unsigned int cIptvDevice::CheckData(void)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (tsBufferM) if (tsBufferM)
return (unsigned int)tsBufferM->Free(); return (unsigned int)tsBufferM->Free();
return 0; return 0;
@ -398,7 +398,7 @@ unsigned int cIptvDevice::CheckData(void)
uchar *cIptvDevice::GetData(int *availableP) uchar *cIptvDevice::GetData(int *availableP)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (isOpenDvrM && tsBufferM) { if (isOpenDvrM && tsBufferM) {
int count = 0; int count = 0;
if (isPacketDeliveredM) if (isPacketDeliveredM)
@ -429,7 +429,7 @@ uchar *cIptvDevice::GetData(int *availableP)
void cIptvDevice::SkipData(int countP) void cIptvDevice::SkipData(int countP)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s (%d) [device %d]]", __PRETTY_FUNCTION__, countP, deviceIndexM);
tsBufferM->Del(countP); tsBufferM->Del(countP);
isPacketDeliveredM = false; isPacketDeliveredM = false;
// Update buffer statistics // Update buffer statistics
@ -438,7 +438,7 @@ void cIptvDevice::SkipData(int countP)
bool cIptvDevice::GetTSPacket(uchar *&dataP) bool cIptvDevice::GetTSPacket(uchar *&dataP)
{ {
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
if (tsBufferM) { if (tsBufferM) {
if (cCamSlot *cs = CamSlot()) { if (cCamSlot *cs = CamSlot()) {
if (cs->WantsTsData()) { if (cs->WantsTsData()) {

55
iptv.c
View File

@ -54,7 +54,7 @@ public:
cPluginIptv::cPluginIptv(void) cPluginIptv::cPluginIptv(void)
: deviceCountM(1) : deviceCountM(1)
{ {
//debug("cPluginIptv::%s()", __FUNCTION__); debug16("%s", __PRETTY_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,23 +62,25 @@ cPluginIptv::cPluginIptv(void)
cPluginIptv::~cPluginIptv() cPluginIptv::~cPluginIptv()
{ {
//debug("cPluginIptv::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
// Clean up after yourself! // Clean up after yourself!
} }
const char *cPluginIptv::CommandLineHelp(void) const char *cPluginIptv::CommandLineHelp(void)
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_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"
" -t <mode>, --trace=<mode> set the tracing mode\n";
} }
bool cPluginIptv::ProcessArgs(int argc, char *argv[]) bool cPluginIptv::ProcessArgs(int argc, char *argv[])
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_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' },
{ "trace", required_argument, NULL, 't' },
{ NULL, no_argument, NULL, 0 } { NULL, no_argument, NULL, 0 }
}; };
@ -88,6 +90,9 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
case 'd': case 'd':
deviceCountM = atoi(optarg); deviceCountM = atoi(optarg);
break; break;
case 't':
IptvConfig.SetTraceMode(strtol(optarg, NULL, 0));
break;
default: default:
return false; return false;
} }
@ -97,7 +102,7 @@ bool cPluginIptv::ProcessArgs(int argc, char *argv[])
bool cPluginIptv::Initialize(void) bool cPluginIptv::Initialize(void)
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Initialize any background activities the plugin shall perform. // Initialize any background activities the plugin shall perform.
IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N));
IptvConfig.SetResourceDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N)); IptvConfig.SetResourceDirectory(cPlugin::ResourceDirectory(PLUGIN_NAME_I18N));
@ -106,7 +111,7 @@ bool cPluginIptv::Initialize(void)
bool cPluginIptv::Start(void) bool cPluginIptv::Start(void)
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_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);
@ -124,7 +129,7 @@ bool cPluginIptv::Start(void)
void cPluginIptv::Stop(void) void cPluginIptv::Stop(void)
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Stop any background activities the plugin is performing. // Stop any background activities the plugin is performing.
cIptvDevice::Shutdown(); cIptvDevice::Shutdown();
curl_global_cleanup(); curl_global_cleanup();
@ -132,54 +137,54 @@ void cPluginIptv::Stop(void)
void cPluginIptv::Housekeeping(void) void cPluginIptv::Housekeeping(void)
{ {
//debug("cPluginIptv::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s()", __FUNCTION__); debug1("%s", __PRETTY_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::%s(%s)", __FUNCTION__, valueP); debug1("%s (%s, )", __PRETTY_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::%s(): filters[%d]=%d", __FUNCTION__, n, i); debug16("%s (%s, ) filters[%d]=%d", __PRETTY_FUNCTION__, valueP, n, i);
if (i >= 0) if (i >= 0)
filtersP[n++] = i; filtersP[n++] = i;
if ((valueP = strchr(valueP, ' ')) != NULL) if ((valueP = strchr(valueP, ' ')) != NULL)
@ -190,7 +195,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::%s()", __FUNCTION__); debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, valueP);
// Parse your own setup parameters and store their values. // Parse your own setup parameters and store their values.
if (!strcasecmp(nameP, "ExtProtocolBasePort")) if (!strcasecmp(nameP, "ExtProtocolBasePort"))
IptvConfig.SetProtocolBasePort(atoi(valueP)); IptvConfig.SetProtocolBasePort(atoi(valueP));
@ -211,8 +216,8 @@ 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::%s()", __FUNCTION__); debug1("%s (%s, )", __PRETTY_FUNCTION__, idP);
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);
cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex); cIptvDevice *dev = cIptvDevice::GetIptvDevice(data->cardIndex);
@ -228,7 +233,7 @@ bool cPluginIptv::Service(const char *idP, void *dataP)
const char **cPluginIptv::SVDRPHelpPages(void) const char **cPluginIptv::SVDRPHelpPages(void)
{ {
debug("cPluginIptv::%s()", __FUNCTION__); debug1("%s", __PRETTY_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"
@ -236,6 +241,8 @@ const char **cPluginIptv::SVDRPHelpPages(void)
" option: 1=general 2=pids 3=section filters.\n", " option: 1=general 2=pids 3=section filters.\n",
"MODE\n" "MODE\n"
" Toggles between bit or byte information mode.\n", " Toggles between bit or byte information mode.\n",
"TRAC [ <mode> ]\n"
" Gets and/or sets used tracing mode.\n",
NULL NULL
}; };
return HelpPages; return HelpPages;
@ -243,7 +250,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::%s(%s, %s)", __FUNCTION__, commandP, optionP); debug1("%s (%s, %s, )", __PRETTY_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) {
@ -265,6 +272,12 @@ cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int
IptvConfig.SetUseBytes(mode); IptvConfig.SetUseBytes(mode);
return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits"); return cString::sprintf("IPTV information mode is: %s\n", mode ? "bytes" : "bits");
} }
else if (strcasecmp(commandP, "TRAC") == 0) {
if (optionP && *optionP)
IptvConfig.SetTraceMode(strtol(optionP, NULL, 0));
return cString::sprintf("IPTV tracing mode: 0x%04X\n", IptvConfig.GetTraceMode());
}
return NULL; return NULL;
} }

48
log.h Normal file
View File

@ -0,0 +1,48 @@
/*
* log.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_LOG_H
#define __IPTV_LOG_H
#include "config.h"
#define error(x...) esyslog("IPTV-ERROR: " x)
#define info(x...) isyslog("IPTV: " x)
// 0x0001: Generic call stack
#define debug1(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug1) ? dsyslog("IPTV1: " x) : void() )
// 0x0002: TBD
#define debug2(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug2) ? dsyslog("IPTV2: " x) : void() )
// 0x0004: TBD
#define debug3(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug3) ? dsyslog("IPTV3: " x) : void() )
// 0x0008: TBD
#define debug4(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug4) ? dsyslog("IPTV4: " x) : void() )
// 0x0010: TBD
#define debug5(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug5) ? dsyslog("IPTV5: " x) : void() )
// 0x0020: TBD
#define debug6(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug6) ? dsyslog("IPTV6: " x) : void() )
// 0x0040: TBD
#define debug7(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug7) ? dsyslog("IPTV7: " x) : void() )
// 0x0080: TBD
#define debug8(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug8) ? dsyslog("IPTV8: " x) : void() )
// 0x0100: TBD
#define debug9(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug9) ? dsyslog("IPTV9: " x) : void() )
// 0x0200: TBD
#define debug10(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug10) ? dsyslog("IPTV10: " x) : void() )
// 0x0400: TBD
#define debug11(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug11) ? dsyslog("IPTV11: " x) : void() )
// 0x0800: TBD
#define debug12(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug12) ? dsyslog("IPTV12: " x) : void() )
// 0x1000: TBD
#define debug13(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug13) ? dsyslog("IPTV13: " x) : void() )
// 0x2000: TBD
#define debug14(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug14) ? dsyslog("IPTV14: " x) : void() )
// 0x4000: TBD
#define debug15(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug15) ? dsyslog("IPTV15: " x) : void() )
// 0x8000; Extra call stack
#define debug16(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug16) ? dsyslog("IPTV16: " x) : void() )
#endif // __IPTV_LOG_H

View File

@ -22,17 +22,17 @@ cPidScanner::cPidScanner(void)
numVpidsM(0), numVpidsM(0),
numApidsM(0) numApidsM(0)
{ {
debug("cPidScanner::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cPidScanner::~cPidScanner() cPidScanner::~cPidScanner()
{ {
debug("cPidScanner::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
void cPidScanner::SetChannel(const tChannelID &channelIdP) void cPidScanner::SetChannel(const tChannelID &channelIdP)
{ {
debug("cPidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString()); debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString());
channelIdM = channelIdP; channelIdM = channelIdP;
vPidM = 0xFFFF; vPidM = 0xFFFF;
numVpidsM = 0; numVpidsM = 0;
@ -43,13 +43,13 @@ void cPidScanner::SetChannel(const tChannelID &channelIdP)
void cPidScanner::Process(const uint8_t* bufP) void cPidScanner::Process(const uint8_t* bufP)
{ {
//debug("cPidScanner::%s()", __FUNCTION__); debug16("%s", __PRETTY_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::%s(): timed out determining pids", __FUNCTION__); debug1("%s Timed out determining pids", __PRETTY_FUNCTION__);
processM = false; processM = false;
} }
@ -84,24 +84,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::%s(): found lower Apid: 0x%X instead of 0x%X", __FUNCTION__, pid, aPidM); debug1("%s Found lower Apid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, aPidM);
aPidM = pid; aPidM = pid;
numApidsM = 1; numApidsM = 1;
} }
else if (pid == aPidM) { else if (pid == aPidM) {
++numApidsM; ++numApidsM;
debug("cPidScanner::%s(): incrementing Apids, now at %d", __FUNCTION__, numApidsM); debug1("%s Incrementing Apids, now at %d", __PRETTY_FUNCTION__, numApidsM);
} }
} }
else if ((sid >= 0xE0) && (sid <= 0xEF)) { else if ((sid >= 0xE0) && (sid <= 0xEF)) {
if (pid < vPidM) { if (pid < vPidM) {
debug("cPidScanner::%s(): found lower Vpid: 0x%X instead of 0x%X", __FUNCTION__, pid, vPidM); debug1("%s Found lower Vpid: 0x%X instead of 0x%X", __PRETTY_FUNCTION__, pid, vPidM);
vPidM = pid; vPidM = pid;
numVpidsM = 1; numVpidsM = 1;
} }
else if (pid == vPidM) { else if (pid == vPidM) {
++numVpidsM; ++numVpidsM;
debug("cPidScanner::%s(): incrementing Vpids, now at %d", __FUNCTION__, numVpidsM); debug1("%s Incrementing Vpids, now at %d", __PRETTY_FUNCTION__, numVpidsM);
} }
} }
} }
@ -146,7 +146,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::%s(): vpid=0x%04X, apid=0x%04X", __FUNCTION__, vPidM, aPidM); debug1("%s vpid=0x%04X, apid=0x%04X", __PRETTY_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();

View File

@ -11,6 +11,8 @@
#include <vdr/tools.h> #include <vdr/tools.h>
#include <vdr/channels.h> #include <vdr/channels.h>
#include "log.h"
class cPidScanner { class cPidScanner {
private: private:
enum { enum {
@ -32,8 +34,8 @@ public:
~cPidScanner(); ~cPidScanner();
void SetChannel(const tChannelID &channelIdP); void SetChannel(const tChannelID &channelIdP);
void Process(const uint8_t* bufP); void Process(const uint8_t* bufP);
void Open() { debug("cPidScanner::%s()", __FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); } void Open() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); }
void Close() { debug("cPidScanner::%s()", __FUNCTION__); timeoutM.Set(0); } void Close() { debug1("%s", __PRETTY_FUNCTION__); timeoutM.Set(0); }
}; };
#endif // __PIDSCANNER_H #endif // __PIDSCANNER_H

View File

@ -7,6 +7,7 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolcurl.h" #include "protocolcurl.h"
#ifdef CURLOPT_RTSPHEADER #ifdef CURLOPT_RTSPHEADER
@ -38,7 +39,7 @@ cIptvProtocolCurl::cIptvProtocolCurl()
connectedM(false), connectedM(false),
pausedM(false) pausedM(false)
{ {
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (ringBufferM) { if (ringBufferM) {
ringBufferM->SetTimeouts(100, 0); ringBufferM->SetTimeouts(100, 0);
ringBufferM->SetIoThrottle(); ringBufferM->SetIoThrottle();
@ -48,7 +49,7 @@ cIptvProtocolCurl::cIptvProtocolCurl()
cIptvProtocolCurl::~cIptvProtocolCurl() cIptvProtocolCurl::~cIptvProtocolCurl()
{ {
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
Disconnect(); Disconnect();
// Free allocated memory // Free allocated memory
DELETE_POINTER(ringBufferM); DELETE_POINTER(ringBufferM);
@ -58,7 +59,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::%s(%zu)", __FUNCTION__, len); debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, 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;
@ -71,7 +72,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::%s(%zu)", __FUNCTION__, len); debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, 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)) {
@ -113,7 +114,7 @@ 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::%s(%zu)", __FUNCTION__, len); debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, len);
bool found = false; bool found = false;
cString control = ""; cString control = "";
@ -121,7 +122,7 @@ size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmem
char *r = strtok(p, "\r\n"); char *r = strtok(p, "\r\n");
while (r) { while (r) {
//debug("cIptvProtocolCurl::%s(%zu): %s", __FUNCTION__, len, r); debug16("%s (, %zu, %zu, ) len=%zu r=%s", __PRETTY_FUNCTION__, sizeP, nmembP, len, r);
// Look for a media name: "video" // Look for a media name: "video"
if (strstr(r, "m=video")) { if (strstr(r, "m=video")) {
found = true; found = true;
@ -147,13 +148,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::%s(%zu)", __FUNCTION__, len); debug16("%s (, %zu, %zu, ) len=%zu", __PRETTY_FUNCTION__, sizeP, nmembP, 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::%s(%zu): %s", __FUNCTION__, len, r); debug16("%s (, %zu, %zu, ) len=%zu r=%s", __PRETTY_FUNCTION__, sizeP, nmembP, len, r);
r = strtok(NULL, "\r\n"); r = strtok(NULL, "\r\n");
} }
@ -163,7 +164,7 @@ 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::%s(%s)", __FUNCTION__, controlP); debug16("%s (%s)", __PRETTY_FUNCTION__, controlP);
cString protocol = ChangeCase(controlP, false).Truncate(7); cString protocol = ChangeCase(controlP, false).Truncate(7);
if (startswith(*protocol, "rtsp://")) { if (startswith(*protocol, "rtsp://")) {
streamUrlM = controlP; streamUrlM = controlP;
@ -176,13 +177,13 @@ void cIptvProtocolCurl::SetRtspControl(const char *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::%s(%d)", __FUNCTION__, lenP); debug16("%s (, %d)", __PRETTY_FUNCTION__, lenP);
if (pausedM) if (pausedM)
return false; return false;
if (ringBufferM && (lenP >= 0)) { if (ringBufferM && (lenP >= 0)) {
// Should we pause the transfer ? // Should we pause the transfer ?
if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) { if (ringBufferM->Free() < (2 * CURL_MAX_WRITE_SIZE)) {
debug("cIptvProtocolCurl::%s(pause): free=%d available=%d len=%d", __FUNCTION__, debug1("%s Pause free=%d available=%d len=%d", __PRETTY_FUNCTION__,
ringBufferM->Free(), ringBufferM->Available(), lenP); ringBufferM->Free(), ringBufferM->Available(), lenP);
pausedM = true; pausedM = true;
return false; return false;
@ -198,14 +199,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::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM && (lenP >= 0)) if (ringBufferM && (lenP >= 0))
ringBufferM->Del(lenP); ringBufferM->Del(lenP);
} }
void cIptvProtocolCurl::ClearData() void cIptvProtocolCurl::ClearData()
{ {
//debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
if (ringBufferM) if (ringBufferM)
ringBufferM->Clear(); ringBufferM->Clear();
} }
@ -213,7 +214,7 @@ void cIptvProtocolCurl::ClearData()
unsigned char *cIptvProtocolCurl::GetData(int &lenP) unsigned char *cIptvProtocolCurl::GetData(int &lenP)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
//debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
unsigned char *p = NULL; unsigned char *p = NULL;
lenP = 0; lenP = 0;
if (ringBufferM) { if (ringBufferM) {
@ -245,7 +246,7 @@ unsigned char *cIptvProtocolCurl::GetData(int &lenP)
bool cIptvProtocolCurl::Connect() bool cIptvProtocolCurl::Connect()
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (connectedM) if (connectedM)
return true; return true;
@ -408,7 +409,7 @@ bool cIptvProtocolCurl::Connect()
bool cIptvProtocolCurl::Disconnect() bool cIptvProtocolCurl::Disconnect()
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (!connectedM) if (!connectedM)
return true; return true;
@ -463,20 +464,20 @@ bool cIptvProtocolCurl::Disconnect()
bool cIptvProtocolCurl::Open(void) bool cIptvProtocolCurl::Open(void)
{ {
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
return Connect(); return Connect();
} }
bool cIptvProtocolCurl::Close(void) bool cIptvProtocolCurl::Close(void)
{ {
debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug1("%s", __PRETTY_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::%s()", __FUNCTION__); debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
int len = 0; int len = 0;
if (ringBufferM) { if (ringBufferM) {
// Fill up the buffer // Fill up the buffer
@ -490,7 +491,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
// Remember the heart beat // Remember the heart beat
if (timeoutM.TimedOut()) { if (timeoutM.TimedOut()) {
debug("cIptvProtocolCurl::%s(): KeepAlive", __FUNCTION__); debug1("%s KeepAlive", __PRETTY_FUNCTION__);
cString uri = cString::sprintf("%s", *streamUrlM); cString uri = cString::sprintf("%s", *streamUrlM);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri); iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS); iptv_curl_easy_setopt(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
@ -523,8 +524,8 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
// Use 20% threshold before continuing to filling up the buffer. // Use 20% threshold before continuing to filling up the buffer.
mutexM.Lock(); mutexM.Lock();
if (pausedM && (ringBufferM->Available() < (IPTV_BUFFER_SIZE / 5))) { if (pausedM && (ringBufferM->Available() < (IPTV_BUFFER_SIZE / 5))) {
debug("cIptvProtocolCurl::%s(continue): free=%d available=%d", __FUNCTION__, debug1("%s Continue free=%d available=%d", __PRETTY_FUNCTION__,
ringBufferM->Free(), ringBufferM->Available()); ringBufferM->Free(), ringBufferM->Available());
pausedM = false; pausedM = false;
curl_easy_pause(handleM, CURLPAUSE_CONT); curl_easy_pause(handleM, CURLPAUSE_CONT);
} }
@ -537,8 +538,8 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
CURLMsg *msg = curl_multi_info_read(multiM, &msgcount); CURLMsg *msg = curl_multi_info_read(multiM, &msgcount);
mutexM.Unlock(); mutexM.Unlock();
if (msg && (msg->msg == CURLMSG_DONE)) { if (msg && (msg->msg == CURLMSG_DONE)) {
debug("cIptvProtocolCurl::%s(done): %s (%d)", __FUNCTION__, debug1("%s Done %s (%d)", __PRETTY_FUNCTION__,
curl_easy_strerror(msg->data.result), msg->data.result); curl_easy_strerror(msg->data.result), msg->data.result);
Disconnect(); Disconnect();
Connect(); Connect();
} }
@ -558,7 +559,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
len = min(len, (int)bufferLenP); len = min(len, (int)bufferLenP);
memcpy(bufferAddrP, p, len); memcpy(bufferAddrP, p, len);
DelData(len); DelData(len);
//debug("cIptvProtocolCurl::%s(): get %d bytes", __FUNCTION__, len); debug16("%s Get %d bytes", __PRETTY_FUNCTION__, len);
} }
} }
@ -567,7 +568,7 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, const int indexP)
{ {
debug("cIptvProtocolCurl::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) { if (!isempty(locationP)) {
// Disconnect // Disconnect
Disconnect(); Disconnect();
@ -584,7 +585,7 @@ bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, c
modeM = eModeFile; modeM = eModeFile;
else else
modeM = eModeUnknown; modeM = eModeUnknown;
debug("cIptvProtocolCurl::%s(): %s (%d)", __FUNCTION__, *protocol, modeM); debug1("%s (%s, %d, %d) protocol=%s mode=%d", __PRETTY_FUNCTION__, locationP, parameterP, indexP, *protocol, modeM);
// Update stream parameter - force UDP mode for RTSP // Update stream parameter - force UDP mode for RTSP
streamParamM = (modeM == eModeRtsp) ? 0 : parameterP; streamParamM = (modeM == eModeRtsp) ? 0 : parameterP;
// Update listen port // Update listen port
@ -597,12 +598,12 @@ bool cIptvProtocolCurl::SetSource(const char* locationP, const int parameterP, c
bool cIptvProtocolCurl::SetPid(int pidP, int typeP, bool onP) bool cIptvProtocolCurl::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cIptvProtocolCurl::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true; return true;
} }
cString cIptvProtocolCurl::GetInformation(void) cString cIptvProtocolCurl::GetInformation(void)
{ {
//debug("cIptvProtocolCurl::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("%s [%d]", *streamUrlM, streamParamM); return cString::sprintf("%s [%d]", *streamUrlM, streamParamM);
} }

View File

@ -17,6 +17,7 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolext.h" #include "protocolext.h"
#ifndef EXTSHELL #ifndef EXTSHELL
@ -29,19 +30,19 @@ cIptvProtocolExt::cIptvProtocolExt()
scriptParameterM(0), scriptParameterM(0),
streamPortM(0) streamPortM(0)
{ {
debug("cIptvProtocolExt::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvProtocolExt::~cIptvProtocolExt() cIptvProtocolExt::~cIptvProtocolExt()
{ {
debug("cIptvProtocolExt::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Drop the socket connection // Drop the socket connection
cIptvProtocolExt::Close(); cIptvProtocolExt::Close();
} }
void cIptvProtocolExt::ExecuteScript(void) void cIptvProtocolExt::ExecuteScript(void)
{ {
debug("cIptvProtocolExt::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Check if already executing // Check if already executing
if (isActiveM || isempty(scriptFileM)) if (isActiveM || isempty(scriptFileM))
return; return;
@ -59,7 +60,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::%s(child): %s", __FUNCTION__, *cmd); debug1("%s Child %s", __PRETTY_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,13 +70,13 @@ void cIptvProtocolExt::ExecuteScript(void)
_exit(0); _exit(0);
} }
else { else {
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM); debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM);
} }
} }
void cIptvProtocolExt::TerminateScript(void) void cIptvProtocolExt::TerminateScript(void)
{ {
debug("cIptvProtocolExt::%s(): pid=%d", __FUNCTION__, pidM); debug1("%s pid=%d", __PRETTY_FUNCTION__, pidM);
if (!isActiveM || isempty(scriptFileM)) if (!isActiveM || isempty(scriptFileM))
return; return;
if (pidM > 0) { if (pidM > 0) {
@ -111,7 +112,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("cIptvProtocolExt::%s(): child (%d) exited as expected", __FUNCTION__, pidM); debug1("%s Child (%d) exited as expected", __PRETTY_FUNCTION__, pidM);
waitOver = true; waitOver = true;
} }
// Unsuccessful wait, avoid busy looping // Unsuccessful wait, avoid busy looping
@ -124,7 +125,7 @@ void cIptvProtocolExt::TerminateScript(void)
bool cIptvProtocolExt::Open(void) bool cIptvProtocolExt::Open(void)
{ {
debug("cIptvProtocolExt::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Reject empty script files // Reject empty script files
if (!strlen(*scriptFileM)) if (!strlen(*scriptFileM))
return false; return false;
@ -138,7 +139,7 @@ bool cIptvProtocolExt::Open(void)
bool cIptvProtocolExt::Close(void) bool cIptvProtocolExt::Close(void)
{ {
debug("cIptvProtocolExt::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Terminate the external script // Terminate the external script
TerminateScript(); TerminateScript();
isActiveM = false; isActiveM = false;
@ -154,7 +155,7 @@ int cIptvProtocolExt::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, const int indexP)
{ {
debug("cIptvProtocolExt::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d)", __PRETTY_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,12 +173,12 @@ bool cIptvProtocolExt::SetSource(const char* locationP, const int parameterP, co
bool cIptvProtocolExt::SetPid(int pidP, int typeP, bool onP) bool cIptvProtocolExt::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cIptvProtocolExt::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true; return true;
} }
cString cIptvProtocolExt::GetInformation(void) cString cIptvProtocolExt::GetInformation(void)
{ {
//debug("cIptvProtocolExt::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM); return cString::sprintf("ext://%s:%d", *scriptFileM, scriptParameterM);
} }

View File

@ -12,6 +12,7 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolfile.h" #include "protocolfile.h"
cIptvProtocolFile::cIptvProtocolFile() cIptvProtocolFile::cIptvProtocolFile()
@ -20,12 +21,12 @@ cIptvProtocolFile::cIptvProtocolFile()
fileStreamM(NULL), fileStreamM(NULL),
isActiveM(false) isActiveM(false)
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvProtocolFile::~cIptvProtocolFile() cIptvProtocolFile::~cIptvProtocolFile()
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Drop open handles // Drop open handles
cIptvProtocolFile::Close(); cIptvProtocolFile::Close();
// Free allocated memory // Free allocated memory
@ -34,7 +35,7 @@ cIptvProtocolFile::~cIptvProtocolFile()
bool cIptvProtocolFile::OpenFile(void) bool cIptvProtocolFile::OpenFile(void)
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_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 +48,7 @@ bool cIptvProtocolFile::OpenFile(void)
void cIptvProtocolFile::CloseFile(void) void cIptvProtocolFile::CloseFile(void)
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_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 +59,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::%s()", __FUNCTION__); debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
// Check errors // Check errors
if (!fileStreamM || ferror(fileStreamM)) { if (!fileStreamM || ferror(fileStreamM)) {
debug("cIptvProtocolFile::%s(): stream error", __FUNCTION__); debug1("%s (, %d) Stream error", __PRETTY_FUNCTION__, bufferLenP);
return -1; return -1;
} }
// Rewind if EOF // Rewind if EOF
@ -81,7 +82,7 @@ int cIptvProtocolFile::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolFile::Open(void) bool cIptvProtocolFile::Open(void)
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Open the file stream // Open the file stream
OpenFile(); OpenFile();
return true; return true;
@ -89,7 +90,7 @@ bool cIptvProtocolFile::Open(void)
bool cIptvProtocolFile::Close(void) bool cIptvProtocolFile::Close(void)
{ {
debug("cIptvProtocolFile::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Close the file stream // Close the file stream
CloseFile(); CloseFile();
return true; return true;
@ -97,7 +98,7 @@ bool cIptvProtocolFile::Close(void)
bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, const int indexP)
{ {
debug("cIptvProtocolFile::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) { if (!isempty(locationP)) {
// Close the file stream // Close the file stream
CloseFile(); CloseFile();
@ -112,12 +113,12 @@ bool cIptvProtocolFile::SetSource(const char* locationP, const int parameterP, c
bool cIptvProtocolFile::SetPid(int pidP, int typeP, bool onP) bool cIptvProtocolFile::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cIptvProtocolFile::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true; return true;
} }
cString cIptvProtocolFile::GetInformation(void) cString cIptvProtocolFile::GetInformation(void)
{ {
//debug("cIptvProtocolFile::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM); return cString::sprintf("file://%s:%d", fileLocationM, fileDelayM);
} }

View File

@ -16,6 +16,7 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "protocolhttp.h" #include "protocolhttp.h"
cIptvProtocolHttp::cIptvProtocolHttp() cIptvProtocolHttp::cIptvProtocolHttp()
@ -23,12 +24,12 @@ cIptvProtocolHttp::cIptvProtocolHttp()
streamPathM(strdup("/")), streamPathM(strdup("/")),
streamPortM(0) streamPortM(0)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvProtocolHttp::~cIptvProtocolHttp() cIptvProtocolHttp::~cIptvProtocolHttp()
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Close the socket // Close the socket
cIptvProtocolHttp::Close(); cIptvProtocolHttp::Close();
// Free allocated memory // Free allocated memory
@ -38,7 +39,7 @@ cIptvProtocolHttp::~cIptvProtocolHttp()
bool cIptvProtocolHttp::Connect(void) bool cIptvProtocolHttp::Connect(void)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Check that stream address is valid // Check that stream address is valid
if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) { if (!isActiveM && !isempty(streamAddrM) && !isempty(streamPathM)) {
// Ensure that socket is valid and connect // Ensure that socket is valid and connect
@ -56,7 +57,7 @@ bool cIptvProtocolHttp::Connect(void)
"\r\n", streamPathM, streamAddrM, "\r\n", streamPathM, streamAddrM,
PLUGIN_NAME_I18N, VERSION); PLUGIN_NAME_I18N, VERSION);
unsigned int len = strlen(*buffer); unsigned int len = strlen(*buffer);
debug("cIptvProtocolHttp::%s(): requesting %d: %s", __FUNCTION__, len, *buffer); debug1("%s Requesting %d: %s", __PRETTY_FUNCTION__, len, *buffer);
if (!Write(*buffer, len)) { if (!Write(*buffer, len)) {
CloseSocket(); CloseSocket();
return false; return false;
@ -74,7 +75,7 @@ bool cIptvProtocolHttp::Connect(void)
bool cIptvProtocolHttp::Disconnect(void) bool cIptvProtocolHttp::Disconnect(void)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (isActiveM) { if (isActiveM) {
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
@ -87,7 +88,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::%s()", __FUNCTION__); debug1("%s (, %u, )", __PRETTY_FUNCTION__, destLenP);
bool linefeed = false; bool linefeed = false;
bool newline = false; bool newline = false;
char *bufptr = destP; char *bufptr = destP;
@ -128,7 +129,7 @@ bool cIptvProtocolHttp::GetHeaderLine(char* destP, unsigned int destLenP,
bool cIptvProtocolHttp::ProcessHeaders(void) bool cIptvProtocolHttp::ProcessHeaders(void)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_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;
@ -159,14 +160,14 @@ bool cIptvProtocolHttp::ProcessHeaders(void)
bool cIptvProtocolHttp::Open(void) bool cIptvProtocolHttp::Open(void)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Connect the socket // Connect the socket
return Connect(); return Connect();
} }
bool cIptvProtocolHttp::Close(void) bool cIptvProtocolHttp::Close(void)
{ {
debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Disconnect the current stream // Disconnect the current stream
Disconnect(); Disconnect();
return true; return true;
@ -179,7 +180,7 @@ int cIptvProtocolHttp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, const int indexP)
{ {
debug("cIptvProtocolHttp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d)", __PRETTY_FUNCTION__, locationP, parameterP, indexP);
if (!isempty(locationP)) { if (!isempty(locationP)) {
// Disconnect the current socket // Disconnect the current socket
Disconnect(); Disconnect();
@ -201,12 +202,12 @@ bool cIptvProtocolHttp::SetSource(const char* locationP, const int parameterP, c
bool cIptvProtocolHttp::SetPid(int pidP, int typeP, bool onP) bool cIptvProtocolHttp::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cIptvProtocolHttp::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true; return true;
} }
cString cIptvProtocolHttp::GetInformation(void) cString cIptvProtocolHttp::GetInformation(void)
{ {
//debug("cIptvProtocolHttp::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM); return cString::sprintf("http://%s:%d%s", streamAddrM, streamPortM, streamPathM);
} }

View File

@ -15,8 +15,9 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "protocoludp.h" #include "log.h"
#include "socket.h" #include "socket.h"
#include "protocoludp.h"
cIptvProtocolUdp::cIptvProtocolUdp() cIptvProtocolUdp::cIptvProtocolUdp()
: isIGMPv3M(false), : isIGMPv3M(false),
@ -24,12 +25,12 @@ cIptvProtocolUdp::cIptvProtocolUdp()
streamAddrM(strdup("")), streamAddrM(strdup("")),
streamPortM(0) streamPortM(0)
{ {
debug("cIptvProtocolUdp::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvProtocolUdp::~cIptvProtocolUdp() cIptvProtocolUdp::~cIptvProtocolUdp()
{ {
debug("cIptvProtocolUdp::%s()", __FUNCTION__); debug1("%s", __PRETTY_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 +40,7 @@ cIptvProtocolUdp::~cIptvProtocolUdp()
bool cIptvProtocolUdp::Open(void) bool cIptvProtocolUdp::Open(void)
{ {
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM); debug1("%s streamAddr='%s'", __PRETTY_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 +51,7 @@ bool cIptvProtocolUdp::Open(void)
bool cIptvProtocolUdp::Close(void) bool cIptvProtocolUdp::Close(void)
{ {
debug("cIptvProtocolUdp::%s(%s)", __FUNCTION__, streamAddrM); debug1("%s streamAddr='%s'", __PRETTY_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 +73,7 @@ int cIptvProtocolUdp::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, const int indexP) bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, const int indexP)
{ {
debug("cIptvProtocolUdp::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d)", __PRETTY_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,13 +106,13 @@ bool cIptvProtocolUdp::SetSource(const char* locationP, const int parameterP, co
bool cIptvProtocolUdp::SetPid(int pidP, int typeP, bool onP) bool cIptvProtocolUdp::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cIptvProtocolUdp::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug16("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
return true; return true;
} }
cString cIptvProtocolUdp::GetInformation(void) cString cIptvProtocolUdp::GetInformation(void)
{ {
//debug("cIptvProtocolUdp::%s()", __FUNCTION__); debug16("%s", __PRETTY_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);

View File

@ -6,6 +6,7 @@
*/ */
#include "config.h" #include "config.h"
#include "log.h"
#include "sectionfilter.h" #include "sectionfilter.h"
cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP) cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t tidP, uint8_t maskP)
@ -20,7 +21,7 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)), ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount * eDmxMaxSectionSize)),
deviceIndexM(deviceIndexP) deviceIndexM(deviceIndexP)
{ {
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, deviceIndexM, pidM); debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int i; int i;
memset(secBufBaseM, 0, sizeof(secBufBaseM)); memset(secBufBaseM, 0, sizeof(secBufBaseM));
@ -61,7 +62,7 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
cIptvSectionFilter::~cIptvSectionFilter() cIptvSectionFilter::~cIptvSectionFilter()
{ {
//debug("cIptvSectionFilter::%s(%d, %d)", __FUNCTION__, deviceIndexM, pidM); debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
int tmp = socketM[1]; int tmp = socketM[1];
socketM[1] = -1; socketM[1] = -1;
if (tmp >= 0) if (tmp >= 0)
@ -236,7 +237,7 @@ cIptvSectionFilterHandler::cIptvSectionFilterHandler(int deviceIndexP, unsigned
mutexM(), mutexM(),
deviceIndexM(deviceIndexP) deviceIndexM(deviceIndexP)
{ {
debug("cIptvSectionFilterHandler::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s (%d, %d) [device %d]", __PRETTY_FUNCTION__, deviceIndexP, bufferLenP, deviceIndexM);
// Initialize filter pointers // Initialize filter pointers
memset(filtersM, 0, sizeof(filtersM)); memset(filtersM, 0, sizeof(filtersM));
@ -254,7 +255,7 @@ cIptvSectionFilterHandler::cIptvSectionFilterHandler(int deviceIndexP, unsigned
cIptvSectionFilterHandler::~cIptvSectionFilterHandler() cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
{ {
debug("cIptvSectionFilterHandler::%s(%d)", __FUNCTION__, deviceIndexM); debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// Stop thread // Stop thread
if (Running()) if (Running())
Cancel(3); Cancel(3);
@ -268,7 +269,7 @@ cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
void cIptvSectionFilterHandler::Action(void) void cIptvSectionFilterHandler::Action(void)
{ {
debug("cIptvSectionFilterHandler::%s(%d): entering", __FUNCTION__, deviceIndexM); debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
bool processed = false; bool processed = false;
// Do the thread loop // Do the thread loop
while (Running()) { while (Running()) {
@ -299,7 +300,7 @@ void cIptvSectionFilterHandler::Action(void)
} }
} }
ringBufferM->Del(len); ringBufferM->Del(len);
debug("cIptvSectionFilterHandler::%s(%d): Skipped %d bytes to sync on TS packet", __FUNCTION__, deviceIndexM, len); debug1("%s Skipped %d bytes to sync on TS packet [device %d]]", __PRETTY_FUNCTION__, len, deviceIndexM);
continue; continue;
} }
// Process TS packet through all filters // Process TS packet through all filters
@ -315,12 +316,12 @@ void cIptvSectionFilterHandler::Action(void)
} }
cCondWait::SleepMs(10); // to avoid busy loop and reduce cpu load cCondWait::SleepMs(10); // to avoid busy loop and reduce cpu load
} }
debug("cIptvSectionFilterHandler::%s(%d): exiting", __FUNCTION__, deviceIndexM); debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
} }
cString cIptvSectionFilterHandler::GetInformation(void) cString cIptvSectionFilterHandler::GetInformation(void)
{ {
//debug("cIptvSectionFilterHandler::%s(%d)", __FUNCTION__, deviceIndexM); debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
// loop through active section filters // loop through active section filters
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
cString s = ""; cString s = "";
@ -339,9 +340,9 @@ cString cIptvSectionFilterHandler::GetInformation(void)
bool cIptvSectionFilterHandler::Delete(unsigned int indexP) bool cIptvSectionFilterHandler::Delete(unsigned int indexP)
{ {
//debug("cIptvSectionFilterHandler::%s(%d): index=%d", __FUNCTION__, deviceIndexM, indexP); debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
if ((indexP < eMaxSecFilterCount) && filtersM[indexP]) { if ((indexP < eMaxSecFilterCount) && filtersM[indexP]) {
//debug("cIptvSectionFilterHandler::%s(%d): found %d", __FUNCTION__, deviceIndexM, indexP); debug16("%s (%d) Found [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
cIptvSectionFilter *tmp = filtersM[indexP]; cIptvSectionFilter *tmp = filtersM[indexP];
filtersM[indexP] = NULL; filtersM[indexP] = NULL;
delete tmp; delete tmp;
@ -352,7 +353,7 @@ bool cIptvSectionFilterHandler::Delete(unsigned int indexP)
bool cIptvSectionFilterHandler::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const bool cIptvSectionFilterHandler::IsBlackListed(u_short pidP, u_char tidP, u_char maskP) const
{ {
//debug("cIptvSectionFilterHandler::%s(%d): pid=%d tid=%02X mask=%02X", __FUNCTION__, deviceIndexM, pidP, tidP, maskP); debug16("%s (%d, %02X, %02X) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
// 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);
@ -360,7 +361,7 @@ bool cIptvSectionFilterHandler::IsBlackListed(u_short pidP, u_char tidP, u_char
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("cIptvSectionFilterHandler::%s(%d): found %s", __FUNCTION__, deviceIndexM, section_filter_table[index].description); debug16("%s (%d, %02X, %02X) Found %s [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, section_filter_table[index].description, deviceIndexM);
return true; return true;
} }
} }
@ -378,7 +379,7 @@ int cIptvSectionFilterHandler::Open(u_short pidP, u_char tidP, u_char maskP)
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (!filtersM[i]) { if (!filtersM[i]) {
filtersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP); filtersM[i] = new cIptvSectionFilter(deviceIndexM, pidP, tidP, maskP);
//debug("cIptvSectionFilterHandler::%s(%d): pid=%d tid=%02X mask=%02X handle=%d index=%u", __FUNCTION__, deviceIndexM, pidP, tidP, maskP, filtersM[i]->GetFd(), i); debug16("%s (%d, %02X, %02X) handle=%d index=%u [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetFd(); return filtersM[i]->GetFd();
} }
} }
@ -393,7 +394,7 @@ void cIptvSectionFilterHandler::Close(int handleP)
// Search the filter for deletion // Search the filter for deletion
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) { if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug("cIptvSectionFilterHandler::%s(%d): pid=%d handle=%d index=%d", __FUNCTION__, deviceIndexM, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i); debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
Delete(i); Delete(i);
break; break;
} }
@ -407,7 +408,7 @@ int cIptvSectionFilterHandler::GetPid(int handleP)
// Search the filter for data // Search the filter for data
for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) { for (unsigned int i = 0; i < eMaxSecFilterCount; ++i) {
if (filtersM[i] && (handleP == filtersM[i]->GetFd())) { if (filtersM[i] && (handleP == filtersM[i]->GetFd())) {
debug("cIptvSectionFilterHandler::%s(%d): pid=%d handle=%d index=%d", __FUNCTION__, deviceIndexM, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i); debug1("%s (%d) pid=%d handle=%d index=%d [device %d]", __PRETTY_FUNCTION__, handleP, filtersM[i]->GetPid(), filtersM[i]->GetFd(), i, deviceIndexM);
return filtersM[i]->GetPid(); return filtersM[i]->GetPid();
} }
} }
@ -416,7 +417,7 @@ int cIptvSectionFilterHandler::GetPid(int handleP)
void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP) void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP)
{ {
//debug("cIptvSectionFilterHandler::%s(%d): length=%d", __FUNCTION__, deviceIndexM, lengthP); debug16("%s (, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIndexM);
// Fill up the buffer // Fill up the buffer
if (ringBufferM) { if (ringBufferM) {
int len = ringBufferM->Put(bufferP, lengthP); int len = ringBufferM->Put(bufferP, lengthP);

View File

@ -112,7 +112,7 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys keyP)
cIptvPluginSetup::cIptvPluginSetup() cIptvPluginSetup::cIptvPluginSetup()
{ {
debug("cIptvPluginSetup::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
protocolBasePortM = IptvConfig.GetProtocolBasePort(); protocolBasePortM = IptvConfig.GetProtocolBasePort();
sectionFilteringM = IptvConfig.GetSectionFiltering(); sectionFilteringM = IptvConfig.GetSectionFiltering();
numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount(); numDisabledFiltersM = IptvConfig.GetDisabledFiltersCount();
@ -156,7 +156,7 @@ void cIptvPluginSetup::Setup(void)
eOSState cIptvPluginSetup::ShowInfo(void) eOSState cIptvPluginSetup::ShowInfo(void)
{ {
debug("cIptvPluginSetup::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (HasSubMenu()) if (HasSubMenu())
return osContinue; return osContinue;
return AddSubMenu(new cIptvMenuInfo()); return AddSubMenu(new cIptvMenuInfo());
@ -201,7 +201,7 @@ void cIptvPluginSetup::StoreFilters(const char *nameP, int *valuesP)
q += strlen(s); q += strlen(s);
} }
*q = 0; *q = 0;
debug("cIptvPluginSetup::%s(%s, %s)", __FUNCTION__, nameP, buffer); debug1("%s (%s, %s)", __PRETTY_FUNCTION__, nameP, buffer);
SetupStore(nameP, buffer); SetupStore(nameP, buffer);
} }

View File

@ -17,19 +17,19 @@ cSidScanner::cSidScanner(void)
tidFoundM(false), tidFoundM(false),
isActiveM(false) isActiveM(false)
{ {
debug("cSidScanner::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
Set(0x00, 0x00); // PAT Set(0x00, 0x00); // PAT
Set(0x10, 0x40); // NIT Set(0x10, 0x40); // NIT
} }
cSidScanner::~cSidScanner() cSidScanner::~cSidScanner()
{ {
debug("cSidScanner::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
void cSidScanner::SetChannel(const tChannelID &channelIdP) void cSidScanner::SetChannel(const tChannelID &channelIdP)
{ {
debug("cSidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString()); debug1("%s (%s)", __PRETTY_FUNCTION__, *channelIdP.ToString());
channelIdM = channelIdP; channelIdM = channelIdP;
sidFoundM = false; sidFoundM = false;
nidFoundM = false; nidFoundM = false;
@ -40,12 +40,12 @@ 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::%s()", __FUNCTION__); debug16("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
if (!isActiveM) if (!isActiveM)
return; return;
if (channelIdM.Valid()) { if (channelIdM.Valid()) {
if ((pidP == 0x00) && (tidP == 0x00)) { if ((pidP == 0x00) && (tidP == 0x00)) {
//debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP); debug16("%s (%d, %02X, , %d) pat", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
SI::PAT pat(dataP, false); SI::PAT pat(dataP, false);
if (!pat.CheckCRCAndParse()) if (!pat.CheckCRCAndParse())
return; return;
@ -53,7 +53,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::%s(): sid=%d", __FUNCTION__, assoc.getServiceId()); debug1("%s (%d, %02X, , %d) sid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, assoc.getServiceId());
newSid = assoc.getServiceId(); newSid = assoc.getServiceId();
} }
sidFoundM = true; sidFoundM = true;
@ -62,19 +62,19 @@ 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::%s(%d, %02X)", __FUNCTION__, pidP, tidP); debug1("%s (%d, %02X, , %d)", __PRETTY_FUNCTION__, pidP, tidP, lengthP);
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::%s(): tsid=%d", __FUNCTION__, ts.getTransportStreamId()); debug1("%s (%d, %02X, , %d) tsid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getTransportStreamId());
newTid = ts.getTransportStreamId(); newTid = ts.getTransportStreamId();
tidFoundM = true; tidFoundM = true;
} }
if (ts.getOriginalNetworkId() != channelIdM.Nid()) { if (ts.getOriginalNetworkId() != channelIdM.Nid()) {
debug("cSidScanner::%s(): onid=%d", __FUNCTION__, ts.getOriginalNetworkId()); debug1("%s (%d, %02X, , %d) onid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, ts.getOriginalNetworkId());
newNid = ts.getOriginalNetworkId(); newNid = ts.getOriginalNetworkId();
nidFoundM = true; nidFoundM = true;
} }
@ -82,7 +82,7 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le
} }
// fallback for network id if not found already // fallback for network id if not found already
if (!nidFoundM && (nit.getNetworkId() != channelIdM.Nid())) { if (!nidFoundM && (nit.getNetworkId() != channelIdM.Nid())) {
debug("cSidScanner::%s(): nid=%d", __FUNCTION__, nit.getNetworkId()); debug1("%s (%d, %02X, , %d) nid=%d", __PRETTY_FUNCTION__, pidP, tidP, lengthP, nit.getNetworkId());
newNid = nit.getNetworkId(); newNid = nit.getNetworkId();
nidFoundM = true; nidFoundM = true;
} }

View File

@ -11,6 +11,8 @@
#include <vdr/channels.h> #include <vdr/channels.h>
#include <vdr/filter.h> #include <vdr/filter.h>
#include "log.h"
class cSidScanner : public cFilter { class cSidScanner : public cFilter {
private: private:
tChannelID channelIdM; tChannelID channelIdM;
@ -26,8 +28,8 @@ public:
cSidScanner(void); cSidScanner(void);
~cSidScanner(); ~cSidScanner();
void SetChannel(const tChannelID &channelIdP); void SetChannel(const tChannelID &channelIdP);
void Open() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = true; } void Open() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = true; }
void Close() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = false; } void Close() { debug1("%s", __PRETTY_FUNCTION__); isActiveM = false; }
}; };
#endif // __SIDSCANNER_H #endif // __SIDSCANNER_H

View File

@ -16,6 +16,7 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "socket.h" #include "socket.h"
cIptvSocket::cIptvSocket() cIptvSocket::cIptvSocket()
@ -26,24 +27,24 @@ cIptvSocket::cIptvSocket()
sequenceNumberM(-1), sequenceNumberM(-1),
isActiveM(false) isActiveM(false)
{ {
debug("cIptvSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddrM, 0, sizeof(sockAddrM));
} }
cIptvSocket::~cIptvSocket() cIptvSocket::~cIptvSocket()
{ {
debug("cIptvSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Close the socket // Close the socket
CloseSocket(); CloseSocket();
} }
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP) bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
{ {
debug("cIptvSocket::%s(%d, %d)", __FUNCTION__, portP, isUdpP); debug1("%s (%d, %d)", __PRETTY_FUNCTION__, portP, isUdpP);
// 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 (portP != socketPortM) { if (portP != socketPortM) {
debug("cIptvSocket::%s(): socket tear-down", __FUNCTION__); debug1("%s (%d, %d) Socket tear-down", __PRETTY_FUNCTION__, portP, isUdpP);
CloseSocket(); CloseSocket();
} }
// Bind to the socket if it is not active already // Bind to the socket if it is not active already
@ -82,7 +83,7 @@ bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP)
void cIptvSocket::CloseSocket(void) void cIptvSocket::CloseSocket(void)
{ {
debug("cIptvSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists // Check if socket exists
if (socketDescM >= 0) { if (socketDescM >= 0) {
close(socketDescM); close(socketDescM);
@ -91,7 +92,7 @@ void cIptvSocket::CloseSocket(void)
memset(&sockAddrM, 0, sizeof(sockAddrM)); memset(&sockAddrM, 0, sizeof(sockAddrM));
} }
if (packetErrorsM) { if (packetErrorsM) {
info("detected %d RTP packet errors", packetErrorsM); info("Detected %d RTP packet errors", packetErrorsM);
packetErrorsM = 0; packetErrorsM = 0;
lastErrorReportM = time(NULL); lastErrorReportM = time(NULL);
} }
@ -103,7 +104,7 @@ bool cIptvSocket::CheckAddress(const char *addrP, in_addr_t *inAddrP)
// First try only the IP address // First try only the IP address
*inAddrP = inet_addr(addrP); *inAddrP = inet_addr(addrP);
if (*inAddrP == htonl(INADDR_NONE)) { if (*inAddrP == htonl(INADDR_NONE)) {
debug("cIptvSocket::%s(%s): cannot convert to address", __FUNCTION__, addrP); debug1("%s (%s, ) Cannot convert to address", __PRETTY_FUNCTION__, addrP);
// It may be a host name, get the name // It may be a host name, get the name
struct hostent *host = gethostbyname(addrP); struct hostent *host = gethostbyname(addrP);
if (!host) { if (!host) {
@ -125,17 +126,17 @@ cIptvUdpSocket::cIptvUdpSocket()
sourceAddrM(htonl(INADDR_ANY)), sourceAddrM(htonl(INADDR_ANY)),
useIGMPv3M(false) useIGMPv3M(false)
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvUdpSocket::~cIptvUdpSocket() cIptvUdpSocket::~cIptvUdpSocket()
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
bool cIptvUdpSocket::OpenSocket(const int portP) bool cIptvUdpSocket::OpenSocket(const int portP)
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s (%d)", __PRETTY_FUNCTION__, portP);
streamAddrM = htonl(INADDR_ANY); streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY); sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false; useIGMPv3M = false;
@ -144,7 +145,7 @@ bool cIptvUdpSocket::OpenSocket(const int portP)
bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P) bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P)
{ {
debug("cIptvUdpSocket::%s(%d, %s, %s, %d)", __FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P); debug1("%s (%d, %s, %s, %d)", __PRETTY_FUNCTION__, portP, streamAddrP, sourceAddrP, useIGMPv3P);
CheckAddress(streamAddrP, &streamAddrM); CheckAddress(streamAddrP, &streamAddrM);
CheckAddress(sourceAddrP, &sourceAddrM); CheckAddress(sourceAddrP, &sourceAddrM);
useIGMPv3M = useIGMPv3P; useIGMPv3M = useIGMPv3P;
@ -153,7 +154,7 @@ bool cIptvUdpSocket::OpenSocket(const int portP, const char *streamAddrP, const
void cIptvUdpSocket::CloseSocket(void) void cIptvUdpSocket::CloseSocket(void)
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
streamAddrM = htonl(INADDR_ANY); streamAddrM = htonl(INADDR_ANY);
sourceAddrM = htonl(INADDR_ANY); sourceAddrM = htonl(INADDR_ANY);
useIGMPv3M = false; useIGMPv3M = false;
@ -162,7 +163,7 @@ void cIptvUdpSocket::CloseSocket(void)
bool cIptvUdpSocket::JoinMulticast(void) bool cIptvUdpSocket::JoinMulticast(void)
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists // Check if socket exists
if (!isActiveM && (socketDescM >= 0)) { if (!isActiveM && (socketDescM >= 0)) {
// Join a new multicast group // Join a new multicast group
@ -196,7 +197,7 @@ bool cIptvUdpSocket::JoinMulticast(void)
bool cIptvUdpSocket::DropMulticast(void) bool cIptvUdpSocket::DropMulticast(void)
{ {
debug("cIptvUdpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Check if socket exists // Check if socket exists
if (isActiveM && (socketDescM >= 0)) { if (isActiveM && (socketDescM >= 0)) {
// Drop the existing multicast group // Drop the existing multicast group
@ -231,10 +232,10 @@ bool cIptvUdpSocket::DropMulticast(void)
int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{ {
//debug("cIptvUdpSocket::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDescM <= 0) {
error("Invalid socket in cIptvUdpSocket::%s()", __FUNCTION__); error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1; return -1;
} }
int len = 0; int len = 0;
@ -289,7 +290,7 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) { else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1) % 0xFFFF) != seq)) {
packetErrorsM++; packetErrorsM++;
if (time(NULL) - lastErrorReportM > eReportIntervalS) { if (time(NULL) - lastErrorReportM > eReportIntervalS) {
info("detected %d RTP packet errors", packetErrorsM); info("Detected %d RTP packet errors", packetErrorsM);
packetErrorsM = 0; packetErrorsM = 0;
lastErrorReportM = time(NULL); lastErrorReportM = time(NULL);
} }
@ -330,30 +331,30 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
// TCP socket class // TCP socket class
cIptvTcpSocket::cIptvTcpSocket() cIptvTcpSocket::cIptvTcpSocket()
{ {
debug("cIptvTcpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvTcpSocket::~cIptvTcpSocket() cIptvTcpSocket::~cIptvTcpSocket()
{ {
debug("cIptvTcpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP) bool cIptvTcpSocket::OpenSocket(const int portP, const char *streamAddrP)
{ {
debug("cIptvTcpSocket::%s(%d, %s)", __FUNCTION__, portP, streamAddrP); debug1("%s (%d, %s)", __PRETTY_FUNCTION__, portP, streamAddrP);
// Socket must be opened before setting the host address // Socket must be opened before setting the host address
return (cIptvSocket::OpenSocket(portP, false) && CheckAddress(streamAddrP, &sockAddrM.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::%s()", __FUNCTION__); debug1("%s()", __PRETTY_FUNCTION__);
cIptvSocket::CloseSocket(); cIptvSocket::CloseSocket();
} }
bool cIptvTcpSocket::ConnectSocket(void) bool cIptvTcpSocket::ConnectSocket(void)
{ {
debug("cIptvTcpSocket::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
if (!isActiveM && (socketDescM >= 0)) { if (!isActiveM && (socketDescM >= 0)) {
int retval = connect(socketDescM, (struct sockaddr *)&sockAddrM, sizeof(sockAddrM)); 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
@ -379,10 +380,10 @@ bool cIptvTcpSocket::ConnectSocket(void)
int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
{ {
//debug("cIptvTcpSocket::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDescM <= 0) {
error("Invalid socket in cIptvTcpSocket::%s()", __FUNCTION__); error("%s Invalid socket", __PRETTY_FUNCTION__);
return -1; return -1;
} }
int len = 0; int len = 0;
@ -396,10 +397,10 @@ int cIptvTcpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP)
bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP) bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
{ {
//debug("cIptvTcpSocket::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDescM <= 0) {
error("Invalid socket in cIptvTcpSocket::%s()", __FUNCTION__); error("%s Invalid socket", __PRETTY_FUNCTION__);
return false; return false;
} }
socklen_t addrlen = sizeof(sockAddrM); socklen_t addrlen = sizeof(sockAddrM);
@ -421,10 +422,10 @@ bool cIptvTcpSocket::ReadChar(char *bufferAddrP, unsigned int timeoutMsP)
bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP) bool cIptvTcpSocket::Write(const char *bufferAddrP, unsigned int bufferLenP)
{ {
//debug("cIptvTcpSocket::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
// Error out if socket not initialized // Error out if socket not initialized
if (socketDescM <= 0) { if (socketDescM <= 0) {
error("cIptvTcpSocket::%s(): Invalid socket", __FUNCTION__); error("%s Invalid socket", __PRETTY_FUNCTION__);
return false; return false;
} }
ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false); ERROR_IF_RET(send(socketDescM, bufferAddrP, bufferLenP, 0) < 0, "send()", return false);

View File

@ -6,7 +6,9 @@
*/ */
#include <ctype.h> #include <ctype.h>
#include "common.h" #include "common.h"
#include "log.h"
#include "source.h" #include "source.h"
// --- cIptvTransponderParameters -------------------------------------------- // --- cIptvTransponderParameters --------------------------------------------
@ -17,7 +19,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
protocolM(eProtocolUDP), protocolM(eProtocolUDP),
parameterM(0) parameterM(0)
{ {
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, parametersP); debug1("%s (%s)", __PRETTY_FUNCTION__, parametersP);
memset(&addressM, 0, sizeof(addressM)); memset(&addressM, 0, sizeof(addressM));
Parse(parametersP); Parse(parametersP);
@ -25,7 +27,7 @@ cIptvTransponderParameters::cIptvTransponderParameters(const char *parametersP)
cString cIptvTransponderParameters::ToString(char typeP) const cString cIptvTransponderParameters::ToString(char typeP) const
{ {
debug("cIptvTransponderParameters::%s(%c)", __FUNCTION__, typeP); debug1("%s (%c)", __PRETTY_FUNCTION__, typeP);
const char *protocolstr; const char *protocolstr;
@ -52,7 +54,7 @@ cString cIptvTransponderParameters::ToString(char typeP) const
bool cIptvTransponderParameters::Parse(const char *strP) bool cIptvTransponderParameters::Parse(const char *strP)
{ {
debug("cIptvTransponderParameters::%s(%s)", __FUNCTION__, strP); debug1("%s (%s)", __PRETTY_FUNCTION__, strP);
bool result = false; bool result = false;
if (strP && *strP) { if (strP && *strP) {
@ -140,7 +142,7 @@ cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
dataM(), dataM(),
itpM() itpM()
{ {
debug("cIptvSourceParam::%s(%c, %s)", __FUNCTION__, sourceP, descriptionP); debug1("%s (%c, %s)", __PRETTY_FUNCTION__, sourceP, descriptionP);
protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP"); protocolsM[cIptvTransponderParameters::eProtocolUDP] = tr("UDP");
protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL"); protocolsM[cIptvTransponderParameters::eProtocolCURL] = tr("CURL");
@ -151,7 +153,7 @@ cIptvSourceParam::cIptvSourceParam(char sourceP, const char *descriptionP)
void cIptvSourceParam::SetData(cChannel *channelP) void cIptvSourceParam::SetData(cChannel *channelP)
{ {
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters()); debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
dataM = *channelP; dataM = *channelP;
ridM = dataM.Rid(); ridM = dataM.Rid();
itpM.Parse(dataM.Parameters()); itpM.Parse(dataM.Parameters());
@ -160,14 +162,14 @@ void cIptvSourceParam::SetData(cChannel *channelP)
void cIptvSourceParam::GetData(cChannel *channelP) void cIptvSourceParam::GetData(cChannel *channelP)
{ {
debug("cIptvSourceParam::%s(%s)", __FUNCTION__, channelP->Parameters()); debug1("%s (%s)", __PRETTY_FUNCTION__, channelP->Parameters());
channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true); channelP->SetTransponderData(channelP->Source(), channelP->Frequency(), dataM.Srate(), itpM.ToString(Source()), true);
channelP->SetId(channelP->Nid(), channelP->Tid(), channelP->Sid(), ridM); channelP->SetId(channelP->Nid(), channelP->Tid(), channelP->Sid(), ridM);
} }
cOsdItem *cIptvSourceParam::GetOsdItem(void) cOsdItem *cIptvSourceParam::GetOsdItem(void)
{ {
debug("cIptvSourceParam::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
switch (paramM++) { switch (paramM++) {
case 0: return new cMenuEditIntItem( tr("Rid"), &ridM, 0); case 0: return new cMenuEditIntItem( tr("Rid"), &ridM, 0);
case 1: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM); case 1: return new cMenuEditBoolItem(tr("Scan section ids"), &itpM.sidScanM);

View File

@ -8,8 +8,9 @@
#include <limits.h> #include <limits.h>
#include "common.h" #include "common.h"
#include "statistics.h"
#include "config.h" #include "config.h"
#include "log.h"
#include "statistics.h"
// Section statistics class // Section statistics class
cIptvSectionStatistics::cIptvSectionStatistics() cIptvSectionStatistics::cIptvSectionStatistics()
@ -18,17 +19,17 @@ cIptvSectionStatistics::cIptvSectionStatistics()
timerM(), timerM(),
mutexM() mutexM()
{ {
//debug("cIptvSectionStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
} }
cIptvSectionStatistics::~cIptvSectionStatistics() cIptvSectionStatistics::~cIptvSectionStatistics()
{ {
//debug("cIptvSectionStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
} }
cString cIptvSectionStatistics::GetSectionStatistic() cString cIptvSectionStatistics::GetSectionStatistic()
{ {
//debug("cIptvSectionStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_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 +45,7 @@ cString cIptvSectionStatistics::GetSectionStatistic()
void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP) void cIptvSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
{ {
//debug("cIptvSectionStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, callsP); debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, callsP);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
filteredDataM += bytesP; filteredDataM += bytesP;
numberOfCallsM += callsP; numberOfCallsM += callsP;
@ -57,7 +58,7 @@ cIptvPidStatistics::cIptvPidStatistics()
: timerM(), : timerM(),
mutexM() mutexM()
{ {
debug("cIptvPidStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct); const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
for (int i = 0; i < numberOfElements; ++i) { for (int i = 0; i < numberOfElements; ++i) {
mostActivePidsM[i].pid = -1; mostActivePidsM[i].pid = -1;
@ -67,12 +68,12 @@ cIptvPidStatistics::cIptvPidStatistics()
cIptvPidStatistics::~cIptvPidStatistics() cIptvPidStatistics::~cIptvPidStatistics()
{ {
debug("cIptvPidStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cString cIptvPidStatistics::GetPidStatistic() cString cIptvPidStatistics::GetPidStatistic()
{ {
//debug("cIptvPidStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct); const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */ uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
@ -97,7 +98,7 @@ cString cIptvPidStatistics::GetPidStatistic()
int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P) int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
{ {
//debug("cIptvPidStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_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)
@ -109,7 +110,7 @@ int cIptvPidStatistics::SortPids(const void* data1P, const void* data2P)
void cIptvPidStatistics::AddPidStatistic(int pidP, long payloadP) void cIptvPidStatistics::AddPidStatistic(int pidP, long payloadP)
{ {
//debug("cIptvPidStatistics::%s(%ld, %ld)", __FUNCTION__, pidP, payloadP); debug16("%s (%d, %ld)", __PRETTY_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
@ -139,17 +140,17 @@ cIptvStreamerStatistics::cIptvStreamerStatistics()
timerM(), timerM(),
mutexM() mutexM()
{ {
debug("cIptvStreamerStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvStreamerStatistics::~cIptvStreamerStatistics() cIptvStreamerStatistics::~cIptvStreamerStatistics()
{ {
debug("cIptvStreamerStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cString cIptvStreamerStatistics::GetStreamerStatistic() cString cIptvStreamerStatistics::GetStreamerStatistic()
{ {
//debug("cIptvStreamerStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_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();
@ -163,7 +164,7 @@ cString cIptvStreamerStatistics::GetStreamerStatistic()
void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP) void cIptvStreamerStatistics::AddStreamerStatistic(long bytesP)
{ {
//debug("cIptvStreamerStatistics::%s(%ld)", __FUNCTION__, bytesP); debug16("%s (%ld)", __PRETTY_FUNCTION__, bytesP);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
dataBytesM += bytesP; dataBytesM += bytesP;
} }
@ -177,17 +178,17 @@ cIptvBufferStatistics::cIptvBufferStatistics()
timerM(), timerM(),
mutexM() mutexM()
{ {
debug("cIptvBufferStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cIptvBufferStatistics::~cIptvBufferStatistics() cIptvBufferStatistics::~cIptvBufferStatistics()
{ {
debug("cIptvBufferStatistics::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
} }
cString cIptvBufferStatistics::GetBufferStatistic() cString cIptvBufferStatistics::GetBufferStatistic()
{ {
//debug("cIptvBufferStatistics::%s()", __FUNCTION__); debug16("%s", __PRETTY_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();
@ -211,7 +212,7 @@ cString cIptvBufferStatistics::GetBufferStatistic()
void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP) void cIptvBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
{ {
//debug("cIptvBufferStatistics::%s(%ld, %ld)", __FUNCTION__, bytesP, usedP); debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, usedP);
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
dataBytesM += bytesP; dataBytesM += bytesP;
if (usedP > usedSpaceM) if (usedP > usedSpaceM)

View File

@ -6,6 +6,7 @@
*/ */
#include "common.h" #include "common.h"
#include "log.h"
#include "streamer.h" #include "streamer.h"
cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP) cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP)
@ -15,7 +16,7 @@ cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP)
packetBufferLenM(packetLenP), packetBufferLenM(packetLenP),
protocolM(NULL) protocolM(NULL)
{ {
debug("cIptvStreamer::%s(%d)", __FUNCTION__, packetBufferLenM); debug1("%s (, %d)", __PRETTY_FUNCTION__, packetBufferLenM);
// Allocate packet buffer // Allocate packet buffer
packetBufferM = MALLOC(unsigned char, packetBufferLenM); packetBufferM = MALLOC(unsigned char, packetBufferLenM);
if (packetBufferM) if (packetBufferM)
@ -26,7 +27,7 @@ cIptvStreamer::cIptvStreamer(cIptvDeviceIf &deviceP, unsigned int packetLenP)
cIptvStreamer::~cIptvStreamer() cIptvStreamer::~cIptvStreamer()
{ {
debug("cIptvStreamer::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Close the protocol // Close the protocol
Close(); Close();
protocolM = NULL; protocolM = NULL;
@ -36,7 +37,7 @@ cIptvStreamer::~cIptvStreamer()
void cIptvStreamer::Action(void) void cIptvStreamer::Action(void)
{ {
debug("cIptvStreamer::%s(): entering", __FUNCTION__); debug1("%s() Entering", __PRETTY_FUNCTION__);
// Increase priority // Increase priority
//SetPriority(-1); //SetPriority(-1);
// Do the thread loop // Do the thread loop
@ -52,12 +53,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::%s(): exiting", __FUNCTION__); debug1("%s Exiting", __PRETTY_FUNCTION__);
} }
bool cIptvStreamer::Open(void) bool cIptvStreamer::Open(void)
{ {
debug("cIptvStreamer::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Open the protocol // Open the protocol
if (protocolM && !protocolM->Open()) if (protocolM && !protocolM->Open())
return false; return false;
@ -68,7 +69,7 @@ bool cIptvStreamer::Open(void)
bool cIptvStreamer::Close(void) bool cIptvStreamer::Close(void)
{ {
debug("cIptvStreamer::%s()", __FUNCTION__); debug1("%s", __PRETTY_FUNCTION__);
// Stop thread // Stop thread
sleepM.Signal(); sleepM.Signal();
if (Running()) if (Running())
@ -81,7 +82,7 @@ bool cIptvStreamer::Close(void)
bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP) bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const int indexP, cIptvProtocolIf* protocolP)
{ {
debug("cIptvStreamer::%s(%s, %d, %d)", __FUNCTION__, locationP, parameterP, indexP); debug1("%s (%s, %d, %d, )", __PRETTY_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) {
@ -101,7 +102,7 @@ bool cIptvStreamer::SetSource(const char* locationP, const int parameterP, const
bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP) bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP)
{ {
debug("cIptvStreamer::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); debug1("%s (%d, %d, %d)", __PRETTY_FUNCTION__, pidP, typeP, onP);
if (protocolM) if (protocolM)
return protocolM->SetPid(pidP, typeP, onP); return protocolM->SetPid(pidP, typeP, onP);
return true; return true;
@ -109,7 +110,7 @@ bool cIptvStreamer::SetPid(int pidP, int typeP, bool onP)
cString cIptvStreamer::GetInformation(void) cString cIptvStreamer::GetInformation(void)
{ {
//debug("cIptvStreamer::%s()", __FUNCTION__); debug16("%s", __PRETTY_FUNCTION__);
cString s; cString s;
if (protocolM) if (protocolM)
s = protocolM->GetInformation(); s = protocolM->GetInformation();