1
0
mirror of https://github.com/rofafor/vdr-plugin-satip.git synced 2023-10-10 13:37:42 +02:00

Improved debug messages.

This commit is contained in:
Rolf Ahrenberg 2014-04-12 16:57:28 +03:00
parent 5ff54d27a3
commit 1a304e9dc2

50
tuner.c
View File

@ -37,20 +37,20 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
pidUpdatedM(false), pidUpdatedM(false),
pidsM() pidsM()
{ {
debug("cSatipTuner::%s(%d)", __FUNCTION__, packetBufferLenM); debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
// Allocate packet buffer // Allocate packet buffer
packetBufferM = MALLOC(unsigned char, packetBufferLenM); packetBufferM = MALLOC(unsigned char, packetBufferLenM);
if (packetBufferM) if (packetBufferM)
memset(packetBufferM, 0, packetBufferLenM); memset(packetBufferM, 0, packetBufferLenM);
else else
error("MALLOC() failed for packet buffer"); error("MALLOC() failed for packet buffer [device %d]", deviceM->GetId());
// Start thread // Start thread
Start(); Start();
} }
cSatipTuner::~cSatipTuner() cSatipTuner::~cSatipTuner()
{ {
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
// Stop thread // Stop thread
sleepM.Signal(); sleepM.Signal();
if (Running()) if (Running())
@ -96,7 +96,7 @@ size_t cSatipTuner::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void
void cSatipTuner::Action(void) void cSatipTuner::Action(void)
{ {
debug("cSatipTuner::%s(): entering", __FUNCTION__); debug("cSatipTuner::%s(): entering [device %d]", __FUNCTION__, deviceM->GetId());
cTimeMs timeout(eReConnectTimeoutMs); cTimeMs timeout(eReConnectTimeoutMs);
// Increase priority // Increase priority
SetPriority(-1); SetPriority(-1);
@ -137,12 +137,12 @@ void cSatipTuner::Action(void)
sleepM.Wait(10); // to avoid busy loop and reduce cpu load sleepM.Wait(10); // to avoid busy loop and reduce cpu load
} }
} }
debug("cSatipTuner::%s(): exiting", __FUNCTION__); debug("cSatipTuner::%s(): exiting [device %d]", __FUNCTION__, deviceM->GetId());
} }
bool cSatipTuner::Open(void) bool cSatipTuner::Open(void)
{ {
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
if (Connect()) { if (Connect()) {
openedM = true; openedM = true;
return true; return true;
@ -152,7 +152,7 @@ bool cSatipTuner::Open(void)
bool cSatipTuner::Close(void) bool cSatipTuner::Close(void)
{ {
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
openedM = false; openedM = false;
Disconnect(); Disconnect();
return true; return true;
@ -161,7 +161,7 @@ bool cSatipTuner::Close(void)
bool cSatipTuner::Connect(void) bool cSatipTuner::Connect(void)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
// Initialize the curl session // Initialize the curl session
if (!handleM) if (!handleM)
@ -173,7 +173,7 @@ bool cSatipTuner::Connect(void)
// Just retune // Just retune
if (tunedM && (streamIdM >= 0)) { if (tunedM && (streamIdM >= 0)) {
debug("cSatipTuner::%s(): retune", __FUNCTION__); debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM); uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri); SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY); SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
@ -218,7 +218,7 @@ bool cSatipTuner::Connect(void)
rtcpSocketM->Close(); rtcpSocketM->Close();
} }
if ((rtpSocketM->Port() <= 0) || (rtcpSocketM->Port() <= 0)) { if ((rtpSocketM->Port() <= 0) || (rtcpSocketM->Port() <= 0)) {
error("Cannot open required ports!"); error("Cannot open required RTP/RTCP ports [device %d]", deviceM->GetId());
return false; return false;
} }
@ -274,7 +274,7 @@ bool cSatipTuner::Connect(void)
bool cSatipTuner::Disconnect(void) bool cSatipTuner::Disconnect(void)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
// Terminate curl session // Terminate curl session
if (handleM) { if (handleM) {
@ -318,7 +318,7 @@ bool cSatipTuner::Disconnect(void)
bool cSatipTuner::ValidateLatestResponse(void) bool cSatipTuner::ValidateLatestResponse(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
if (handleM) { if (handleM) {
long rc = 0; long rc = 0;
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
@ -326,7 +326,7 @@ bool cSatipTuner::ValidateLatestResponse(void)
if (rc == 200) if (rc == 200)
return true; return true;
else if (rc != 0) else if (rc != 0)
error("Tuner detected invalid status code: %ld", rc); error("Tuner detected invalid status code %ld [device %d]", rc, deviceM->GetId());
} }
return false; return false;
@ -334,7 +334,7 @@ bool cSatipTuner::ValidateLatestResponse(void)
void cSatipTuner::ParseReceptionParameters(const char *paramP) void cSatipTuner::ParseReceptionParameters(const char *paramP)
{ {
//debug("cSatipTuner::%s(%s)", __FUNCTION__, paramP); //debug("cSatipTuner::%s(%s) [device %d]", __FUNCTION__, paramP, deviceM->GetId());
// DVB-S2: // DVB-S2:
// ver=<major>.<minor>;src=<srcID>;tuner=<feID>,<level>,<lock>,<quality>,<frequency>,<polarisation>,<system>,<type>,<pilots>,<roll_off>,<symbol_rate>,<fec_inner>;pids=<pid0>,...,<pidn> // ver=<major>.<minor>;src=<srcID>;tuner=<feID>,<level>,<lock>,<quality>,<frequency>,<polarisation>,<system>,<type>,<pilots>,<roll_off>,<symbol_rate>,<fec_inner>;pids=<pid0>,...,<pidn>
// DVB-T2: // DVB-T2:
@ -381,21 +381,21 @@ void cSatipTuner::ParseReceptionParameters(const char *paramP)
void cSatipTuner::SetStreamId(int streamIdP) void cSatipTuner::SetStreamId(int streamIdP)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cSatipTuner::%s(%d)", __FUNCTION__, streamIdP); debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, streamIdP, deviceM->GetId());
streamIdM = streamIdP; streamIdM = streamIdP;
} }
void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP) void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
debug("cSatipTuner::%s(%s, %d)", __FUNCTION__, sessionP, timeoutP); debug("cSatipTuner::%s(%s, %d) [device %d]", __FUNCTION__, sessionP, timeoutP, deviceM->GetId());
sessionM = sessionP; sessionM = sessionP;
timeoutM = (timeoutP > eMinKeepAliveIntervalMs) ? timeoutP : eMinKeepAliveIntervalMs; timeoutM = (timeoutP > eMinKeepAliveIntervalMs) ? timeoutP : eMinKeepAliveIntervalMs;
} }
bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP) bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP)
{ {
debug("cSatipTuner::%s(%s, %d)", __FUNCTION__, parameterP, indexP); debug("cSatipTuner::%s(%s, %d) [device %d]", __FUNCTION__, parameterP, indexP, deviceM->GetId());
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP); nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP);
if (nextServerM && !isempty(nextServerM->Address()) && !isempty(parameterP)) { if (nextServerM && !isempty(nextServerM->Address()) && !isempty(parameterP)) {
@ -410,7 +410,7 @@ bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const
bool cSatipTuner::SetPid(int pidP, int typeP, bool onP) bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cSatipTuner::%s(%d, %d, %d)", __FUNCTION__, pidP, typeP, onP); //debug("cSatipTuner::%s(%d, %d, %d) [device %d]", __FUNCTION__, pidP, typeP, onP, deviceM->GetId());
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
bool found = false; bool found = false;
for (int i = 0; i < pidsM.Size(); ++i) { for (int i = 0; i < pidsM.Size(); ++i) {
@ -435,7 +435,7 @@ bool cSatipTuner::UpdatePids(void)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
if (pidUpdateCacheM.TimedOut() && pidUpdatedM && pidsM.Size() && tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) { if (pidUpdateCacheM.TimedOut() && pidUpdatedM && pidsM.Size() && tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
//cString uri = cString::sprintf("rtsp://%s/stream=%d?%spids=%d", *streamAddrM, streamIdM, onP ? "add" : "del", pidP); //cString uri = cString::sprintf("rtsp://%s/stream=%d?%spids=%d", *streamAddrM, streamIdM, onP ? "add" : "del", pidP);
cString uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM); cString uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM);
@ -461,7 +461,7 @@ bool cSatipTuner::KeepAlive(void)
{ {
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
if (tunedM && handleM && keepAliveM.TimedOut()) { if (tunedM && handleM && keepAliveM.TimedOut()) {
debug("cSatipTuner::%s()", __FUNCTION__); debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM); cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
@ -481,30 +481,30 @@ bool cSatipTuner::KeepAlive(void)
int cSatipTuner::SignalStrength(void) int cSatipTuner::SignalStrength(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
return signalStrengthM; return signalStrengthM;
} }
int cSatipTuner::SignalQuality(void) int cSatipTuner::SignalQuality(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
return signalQualityM; return signalQualityM;
} }
bool cSatipTuner::HasLock(void) bool cSatipTuner::HasLock(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
return tunedM && hasLockM; return tunedM && hasLockM;
} }
cString cSatipTuner::GetSignalStatus(void) cString cSatipTuner::GetSignalStatus(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
return cString::sprintf("lock=%d strength=%d quality=%d", HasLock(), SignalStrength(), SignalQuality()); return cString::sprintf("lock=%d strength=%d quality=%d", HasLock(), SignalStrength(), SignalQuality());
} }
cString cSatipTuner::GetInformation(void) cString cSatipTuner::GetInformation(void)
{ {
//debug("cSatipTuner::%s()", __FUNCTION__); //debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
return tunedM ? cString::sprintf("rtsp://%s/?%s [stream=%d]", *streamAddrM, *streamParamM, streamIdM) : "connection failed"; return tunedM ? cString::sprintf("rtsp://%s/?%s [stream=%d]", *streamAddrM, *streamParamM, streamIdM) : "connection failed";
} }