Added better logging for channel changes.

This commit is contained in:
Rolf Ahrenberg 2014-12-14 01:56:21 +02:00
parent 7c1aa732b4
commit fecbd3cbd4
3 changed files with 35 additions and 16 deletions

View File

@ -217,7 +217,7 @@ int cSatipDevice::SignalQuality(void) const
bool cSatipDevice::ProvidesSource(int sourceP) const
{
debug8("%s (%c) [device %u]", __PRETTY_FUNCTION__, cSource::ToChar(sourceP), deviceIndexM);
debug9("%s (%c) [device %u]", __PRETTY_FUNCTION__, cSource::ToChar(sourceP), deviceIndexM);
if (!SatipConfig.IsOperatingModeOff() && !!cSatipDiscover::GetInstance()->GetServer(sourceP)) {
int numDisabledSourcesM = SatipConfig.GetDisabledSourcesCount();
for (int i = 0; i < numDisabledSourcesM; ++i) {
@ -231,7 +231,7 @@ bool cSatipDevice::ProvidesSource(int sourceP) const
bool cSatipDevice::ProvidesTransponder(const cChannel *channelP) const
{
debug1("%s (%d) transponder=%d source=%c [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, channelP ? channelP->Transponder() : -1, channelP ? cSource::ToChar(channelP->Source()) : '?', deviceIndexM);
debug9("%s (%d) transponder=%d source=%c [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, channelP ? channelP->Transponder() : -1, channelP ? cSource::ToChar(channelP->Source()) : '?', deviceIndexM);
if (!ProvidesSource(channelP->Source()))
return false;
return DeviceHooksProvidesTransponder(channelP);
@ -243,7 +243,7 @@ bool cSatipDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool
bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority());
bool needsDetachReceivers = false;
debug1("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, priorityP, !!needsDetachReceiversP, deviceIndexM);
debug9("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, priorityP, !!needsDetachReceiversP, deviceIndexM);
if (channelP && ProvidesTransponder(channelP)) {
result = hasPriority;
@ -315,11 +315,12 @@ bool cSatipDevice::MaySwitchTransponder(const cChannel *channelP) const
bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
{
debug9("%s (%d, %d) [device %u]", __PRETTY_FUNCTION__, channelP ? channelP->Number() : -1, liveViewP, deviceIndexM);
if (channelP) {
cDvbTransponderParameters dtp(channelP->Parameters());
cString params = GetTransponderUrlParameters(channelP);
if (isempty(params)) {
error("Unrecognized SATIP channel parameters: %s", channelP->Parameters());
error("Unrecognized SATIP channel parameters: %s [device %u]", channelP->Parameters(), deviceIndexM);
return false;
}
cString address;
@ -344,7 +345,7 @@ bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP)
bool cSatipDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
{
debug8("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, handleP->pid, typeP, onP, deviceIndexM);
debug9("%s (%d, %d, %d) [device %u]", __PRETTY_FUNCTION__, handleP->pid, typeP, onP, deviceIndexM);
if (pTunerM && handleP && handleP->pid >= 0) {
if (onP)
return pTunerM->SetPid(handleP->pid, typeP, true);
@ -356,7 +357,7 @@ bool cSatipDevice::SetPid(cPidHandle *handleP, int typeP, bool onP)
int cSatipDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
{
debug8("%s (%d, %02X, %02X) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
debug9("%s (%d, %02X, %02X) [device %d]", __PRETTY_FUNCTION__, pidP, tidP, maskP, deviceIndexM);
if (pSectionFilterHandlerM) {
int handle = pSectionFilterHandlerM->Open(pidP, tidP, maskP);
if (pTunerM && (handle >= 0))
@ -368,17 +369,18 @@ int cSatipDevice::OpenFilter(u_short pidP, u_char tidP, u_char maskP)
void cSatipDevice::CloseFilter(int handleP)
{
debug8("%s (%d) [device %u]", __PRETTY_FUNCTION__, handleP, deviceIndexM);
if (pSectionFilterHandlerM) {
int pid = pSectionFilterHandlerM->GetPid(handleP);
debug9("%s (%d) [device %u]", __PRETTY_FUNCTION__, pid, deviceIndexM);
if (pTunerM)
pTunerM->SetPid(pSectionFilterHandlerM->GetPid(handleP), ptOther, false);
pTunerM->SetPid(pid, ptOther, false);
pSectionFilterHandlerM->Close(handleP);
}
}
bool cSatipDevice::OpenDvr(void)
{
debug1("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
debug9("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
isPacketDeliveredM = false;
tsBufferM->Clear();
if (pTunerM)
@ -389,7 +391,7 @@ bool cSatipDevice::OpenDvr(void)
void cSatipDevice::CloseDvr(void)
{
debug1("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
debug9("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
if (pTunerM)
pTunerM->Close();
isOpenDvrM = false;
@ -423,7 +425,6 @@ void cSatipDevice::WriteData(uchar *bufferP, int lengthP)
int cSatipDevice::GetId(void)
{
debug8("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
return deviceIndexM;
}

16
tuner.c
View File

@ -374,6 +374,13 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
delPidsM.AddPid(pidP);
addPidsM.RemovePid(pidP);
}
if (pidsM.Size()) {
cString s = "";
for (int i = 0; i < pidsM.Size(); ++i)
s = cString::sprintf("%s%d,", *s, pidsM[i]);
s = s.Truncate(-1);
debug9("%s (%d, %d, %d) pids=%s [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, *s, deviceIdM);
}
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
sleepM.Signal();
@ -391,7 +398,8 @@ bool cSatipTuner::UpdatePids(bool forceP)
if (pidsM.Size()) {
uri = cString::sprintf("%s?pids=", *uri);
for (int i = 0; i < pidsM.Size(); ++i)
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
uri = cString::sprintf("%s%d,", *uri, pidsM[i]);
uri = uri.Truncate(-1);
}
if (usedummy && (pidsM.Size() == 1) && (pidsM[0] < 0x20))
uri = cString::sprintf("%s,%d", *uri, eDummyPid);
@ -400,12 +408,14 @@ bool cSatipTuner::UpdatePids(bool forceP)
if (addPidsM.Size()) {
uri = cString::sprintf("%s?addpids=", *uri);
for (int i = 0; i < addPidsM.Size(); ++i)
uri = cString::sprintf("%s%d%s", *uri, addPidsM[i], (i == (addPidsM.Size() - 1)) ? "" : ",");
uri = cString::sprintf("%s%d,", *uri, addPidsM[i]);
uri = uri.Truncate(-1);
}
if (delPidsM.Size()) {
uri = cString::sprintf("%s%sdelpids=", *uri, addPidsM.Size() ? "&" : "?");
for (int i = 0; i < delPidsM.Size(); ++i)
uri = cString::sprintf("%s%d%s", *uri, delPidsM[i], (i == (delPidsM.Size() - 1)) ? "" : ",");
uri = cString::sprintf("%s%d,", *uri, delPidsM[i]);
uri = uri.Truncate(-1);
}
}
if (!rtspM.Play(*uri))

12
tuner.h
View File

@ -28,19 +28,27 @@ private:
}
return -1;
}
static int PidCompare(const void *aPidP, const void *bPidP)
{
return (*(int*)aPidP - *(int*)bPidP);
}
public:
void RemovePid(const int &pidP)
{
int i = PidIndex(pidP);
if (i >= 0)
if (i >= 0) {
Remove(i);
Sort(PidCompare);
}
}
void AddPid(int pidP)
{
if (PidIndex(pidP) < 0)
if (PidIndex(pidP) < 0) {
Append(pidP);
Sort(PidCompare);
}
}
};