mirror of
				https://github.com/rofafor/vdr-plugin-satip.git
				synced 2023-10-10 11:37:42 +00:00 
			
		
		
		
	Added new debugging modes.
This commit is contained in:
		
							
								
								
									
										68
									
								
								tuner.c
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								tuner.c
									
									
									
									
									
								
							| @@ -42,7 +42,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP) | ||||
|   delPidsM(), | ||||
|   pidsM() | ||||
| { | ||||
|   debug("%s(, %d) [device %d]", __PRETTY_FUNCTION__, packetLenP, deviceIdM); | ||||
|   debug1("%s(, %d) [device %d]", __PRETTY_FUNCTION__, packetLenP, deviceIdM); | ||||
|  | ||||
|   // Open sockets | ||||
|   int i = 100; | ||||
| @@ -65,7 +65,7 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP) | ||||
|  | ||||
| cSatipTuner::~cSatipTuner() | ||||
| { | ||||
|   debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|  | ||||
|   // Stop thread | ||||
|   sleepM.Signal(); | ||||
| @@ -85,22 +85,22 @@ cSatipTuner::~cSatipTuner() | ||||
|  | ||||
| void cSatipTuner::Action(void) | ||||
| { | ||||
|   debug("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   reConnectM.Set(eConnectTimeoutMs); | ||||
|   // Do the thread loop | ||||
|   while (Running()) { | ||||
|         UpdateCurrentState(); | ||||
|         switch (currentStateM) { | ||||
|           case tsIdle: | ||||
|                //debug("%s: tsIdle [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                debug4("%s: tsIdle [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                break; | ||||
|           case tsRelease: | ||||
|                //debug("%s: tsRelease [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                debug4("%s: tsRelease [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                Disconnect(); | ||||
|                RequestState(tsIdle, smInternal); | ||||
|                break; | ||||
|           case tsSet: | ||||
|                //debug("%s: tsSet [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                debug4("%s: tsSet [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                reConnectM.Set(eConnectTimeoutMs); | ||||
|                if (Connect()) { | ||||
|                   RequestState(tsTuned, smInternal); | ||||
| @@ -112,7 +112,7 @@ void cSatipTuner::Action(void) | ||||
|                   } | ||||
|                break; | ||||
|           case tsTuned: | ||||
|                //debug("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                reConnectM.Set(eConnectTimeoutMs); | ||||
|                // Read reception statistics via DESCRIBE and RTCP | ||||
|                if (hasLockM || ReadReceptionStatus()) { | ||||
| @@ -127,7 +127,7 @@ void cSatipTuner::Action(void) | ||||
|                   } | ||||
|                break; | ||||
|           case tsLocked: | ||||
|                //debug("%s: tsLocked [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                debug4("%s: tsLocked [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|                if (!UpdatePids()) { | ||||
|                   error("Pid update failed - retuning [device %d]", deviceIdM); | ||||
|                   RequestState(tsSet, smInternal); | ||||
| @@ -151,13 +151,13 @@ void cSatipTuner::Action(void) | ||||
|         if (!StateRequested()) | ||||
|            sleepM.Wait(eSleepTimeoutMs); // to avoid busy loop and reduce cpu load | ||||
|         } | ||||
|   debug("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
| } | ||||
|  | ||||
| bool cSatipTuner::Open(void) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|  | ||||
|   RequestState(tsSet, smExternal); | ||||
|  | ||||
| @@ -168,7 +168,7 @@ bool cSatipTuner::Open(void) | ||||
| bool cSatipTuner::Close(void) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|  | ||||
|   RequestState(tsRelease, smExternal); | ||||
|  | ||||
| @@ -179,14 +179,14 @@ bool cSatipTuner::Close(void) | ||||
| bool cSatipTuner::Connect(void) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|  | ||||
|   if (!isempty(*streamAddrM)) { | ||||
|      cString connectionUri = cString::sprintf("rtsp://%s/", *streamAddrM); | ||||
|      // Just retune | ||||
|      if (streamIdM >= 0) { | ||||
|         cString uri = cString::sprintf("%sstream=%d?%s", *connectionUri, streamIdM, *streamParamM); | ||||
|         debug("%s Retuning [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|         debug1("%s Retuning [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|         if (rtspM.Play(*uri)) { | ||||
|            keepAliveM.Set(timeoutM); | ||||
|            return true; | ||||
| @@ -219,7 +219,7 @@ bool cSatipTuner::Connect(void) | ||||
| bool cSatipTuner::Disconnect(void) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug1("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|  | ||||
|   if (!isempty(*streamAddrM) && (streamIdM >= 0)) { | ||||
|      cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM); | ||||
| @@ -245,7 +245,7 @@ bool cSatipTuner::Disconnect(void) | ||||
|  | ||||
| void cSatipTuner::ProcessVideoData(u_char *bufferP, int lengthP) | ||||
| { | ||||
|   //debug("%s(, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIdM); | ||||
|   debug8("%s(, %d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIdM); | ||||
|   if (lengthP > 0) { | ||||
|      AddTunerStatistic(lengthP); | ||||
|      deviceM->WriteData(bufferP, lengthP); | ||||
| @@ -255,7 +255,7 @@ void cSatipTuner::ProcessVideoData(u_char *bufferP, int lengthP) | ||||
|  | ||||
| void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) | ||||
| { | ||||
|   //debug("%s(%d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIdM); | ||||
|   debug8("%s(%d) [device %d]", __PRETTY_FUNCTION__, lengthP, deviceIdM); | ||||
|   // 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> | ||||
|   // DVB-T2: | ||||
| @@ -265,7 +265,7 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) | ||||
|   if (lengthP > 0) { | ||||
|      char s[lengthP]; | ||||
|      memcpy(s, (char *)bufferP, lengthP); | ||||
|      //debug("%s(%s) [device %d]", __PRETTY_FUNCTION__, s, deviceIdM); | ||||
|      debug8("%s(%s) [device %d]", __PRETTY_FUNCTION__, s, deviceIdM); | ||||
|      char *c = strstr(s, ";tuner="); | ||||
|      if (c)  { | ||||
|         int value; | ||||
| @@ -306,27 +306,27 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) | ||||
| void cSatipTuner::SetStreamId(int streamIdP) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s(%d) [device %d]", __PRETTY_FUNCTION__, streamIdP, deviceIdM); | ||||
|   debug1("%s(%d) [device %d]", __PRETTY_FUNCTION__, streamIdP, deviceIdM); | ||||
|   streamIdM = streamIdP; | ||||
| } | ||||
|  | ||||
| void cSatipTuner::SetSessionTimeout(const char *sessionP, int timeoutP) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s(%s, %d) [device %d]", __PRETTY_FUNCTION__, sessionP, timeoutP, deviceIdM); | ||||
|   debug1("%s(%s, %d) [device %d]", __PRETTY_FUNCTION__, sessionP, timeoutP, deviceIdM); | ||||
|   sessionM = sessionP; | ||||
|   timeoutM = (timeoutP > eMinKeepAliveIntervalMs) ? timeoutP : eMinKeepAliveIntervalMs; | ||||
| } | ||||
|  | ||||
| int cSatipTuner::GetId(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return deviceIdM; | ||||
| } | ||||
|  | ||||
| bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const int indexP) | ||||
| { | ||||
|   debug("%s(%s, %d) [device %d]", __PRETTY_FUNCTION__, parameterP, indexP, deviceIdM); | ||||
|   debug1("%s(%s, %d) [device %d]", __PRETTY_FUNCTION__, parameterP, indexP, deviceIdM); | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   if (serverP) { | ||||
|      nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP); | ||||
| @@ -348,7 +348,7 @@ bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const | ||||
|  | ||||
| bool cSatipTuner::SetPid(int pidP, int typeP, bool onP) | ||||
| { | ||||
|   //debug("%s(%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, deviceIdM); | ||||
|   debug8("%s(%d, %d, %d) [device %d]", __PRETTY_FUNCTION__, pidP, typeP, onP, deviceIdM); | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   if (onP) { | ||||
|      pidsM.AddPid(pidP); | ||||
| @@ -368,7 +368,7 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP) | ||||
|  | ||||
| bool cSatipTuner::UpdatePids(bool forceP) | ||||
| { | ||||
|   //debug("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   debug8("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) && | ||||
|       !isempty(*streamAddrM) && (streamIdM > 0)) { | ||||
|      cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM); | ||||
| @@ -405,7 +405,7 @@ bool cSatipTuner::UpdatePids(bool forceP) | ||||
|  | ||||
| bool cSatipTuner::KeepAlive(bool forceP) | ||||
| { | ||||
|   //debug("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   debug8("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   if (keepAliveM.TimedOut()) { | ||||
|      keepAliveM.Set(timeoutM); | ||||
| @@ -422,7 +422,7 @@ bool cSatipTuner::KeepAlive(bool forceP) | ||||
|  | ||||
| bool cSatipTuner::ReadReceptionStatus(bool forceP) | ||||
| { | ||||
|   //debug("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   debug8("%s(%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   if (statusUpdateM.TimedOut()) { | ||||
|      statusUpdateM.Set(eStatusUpdateTimeoutMs); | ||||
| @@ -439,7 +439,7 @@ bool cSatipTuner::ReadReceptionStatus(bool forceP) | ||||
|  | ||||
| void cSatipTuner::UpdateCurrentState(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   eTunerState state = currentStateM; | ||||
|  | ||||
| @@ -453,7 +453,7 @@ void cSatipTuner::UpdateCurrentState(void) | ||||
|      } | ||||
|  | ||||
|   if (currentStateM != state) { | ||||
|      debug("%s: switching from %s to %s [device %d]", __PRETTY_FUNCTION__, TunerStateString(currentStateM), TunerStateString(state), deviceIdM); | ||||
|      debug1("%s: switching from %s to %s [device %d]", __PRETTY_FUNCTION__, TunerStateString(currentStateM), TunerStateString(state), deviceIdM); | ||||
|      currentStateM = state; | ||||
|      } | ||||
| } | ||||
| @@ -461,7 +461,7 @@ void cSatipTuner::UpdateCurrentState(void) | ||||
| bool cSatipTuner::StateRequested(void) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   //debug("%s current=%s internal=%d external=%d [device %d]", __PRETTY_FUNCTION__, TunerStateString(currentStateM), internalStateM.Size(), externalStateM.Size(), deviceIdM); | ||||
|   debug8("%s current=%s internal=%d external=%d [device %d]", __PRETTY_FUNCTION__, TunerStateString(currentStateM), internalStateM.Size(), externalStateM.Size(), deviceIdM); | ||||
|  | ||||
|   return (internalStateM.Size() || externalStateM.Size()); | ||||
| } | ||||
| @@ -469,7 +469,7 @@ bool cSatipTuner::StateRequested(void) | ||||
| bool cSatipTuner::RequestState(eTunerState stateP, eStateMode modeP) | ||||
| { | ||||
|   cMutexLock MutexLock(&mutexM); | ||||
|   debug("%s(%s, %s) current=%s internal=%d external=%d [device %d]", __PRETTY_FUNCTION__, TunerStateString(stateP), StateModeString(modeP), TunerStateString(currentStateM), internalStateM.Size(), externalStateM.Size(), deviceIdM); | ||||
|   debug1("%s(%s, %s) current=%s internal=%d external=%d [device %d]", __PRETTY_FUNCTION__, TunerStateString(stateP), StateModeString(modeP), TunerStateString(currentStateM), internalStateM.Size(), externalStateM.Size(), deviceIdM); | ||||
|  | ||||
|   if (modeP == smExternal) | ||||
|      externalStateM.Append(stateP); | ||||
| @@ -533,30 +533,30 @@ const char *cSatipTuner::TunerStateString(eTunerState stateP) | ||||
|  | ||||
| int cSatipTuner::SignalStrength(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return signalStrengthM; | ||||
| } | ||||
|  | ||||
| int cSatipTuner::SignalQuality(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return signalQualityM; | ||||
| } | ||||
|  | ||||
| bool cSatipTuner::HasLock(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return (currentStateM >= tsTuned) && hasLockM; | ||||
| } | ||||
|  | ||||
| cString cSatipTuner::GetSignalStatus(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return cString::sprintf("lock=%d strength=%d quality=%d", HasLock(), SignalStrength(), SignalQuality()); | ||||
| } | ||||
|  | ||||
| cString cSatipTuner::GetInformation(void) | ||||
| { | ||||
|   //debug("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   debug8("%s [device %d]", __PRETTY_FUNCTION__, deviceIdM); | ||||
|   return (currentStateM >= tsTuned) ? cString::sprintf("rtsp://%s/?%s [stream=%d]", *streamAddrM, *streamParamM, streamIdM) : "connection failed"; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user