From 6d64a8b0a732f05939f00308e14ca77246cc2422 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Sat, 22 Nov 2014 14:56:20 +0200 Subject: [PATCH] Fixed keep-alive and retuning. --- rtp.c | 11 ++++++++--- rtp.h | 2 +- tuner.c | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rtp.c b/rtp.c index 44a85d8..67d3774 100644 --- a/rtp.c +++ b/rtp.c @@ -48,7 +48,7 @@ void cSatipRtp::Close(void) } } -int cSatipRtp::GetHeaderLenght(int lengthP) +int cSatipRtp::GetHeaderLenght(unsigned int lengthP) { //debug("cSatipRtp::%s() [device %d]", __FUNCTION__, tunerM.GetId()); unsigned int headerlen = 0; @@ -91,9 +91,14 @@ int cSatipRtp::GetHeaderLenght(int lengthP) // Update header length headerlen += (ehl + 1) * (unsigned int)sizeof(uint32_t); } + // Check for empty payload + if (lengthP == headerlen) { + debug("cSatipRtp::%s(%d): Received empty RTP packet #%d [device %d]", __FUNCTION__, lengthP, seq, tunerM.GetId()); + headerlen = -1; + } // Check that rtp is version 2 and payload contains multiple of TS packet data - if ((v != 2) || (((lengthP - headerlen) % TS_SIZE) != 0) || (bufferM[headerlen] != TS_SYNC_BYTE)) { - debug("cSatipRtp::%s(%d): Received incorrect RTP packet [device %d]", __FUNCTION__, lengthP, tunerM.GetId()); + else if ((v != 2) || (((lengthP - headerlen) % TS_SIZE) != 0) || (bufferM[headerlen] != TS_SYNC_BYTE)) { + debug("cSatipRtp::%s(%d): Received incorrect RTP packet #%d v=%d len=%d sync=0x%02X [device %d]", __FUNCTION__, lengthP, seq, v, headerlen, bufferM[headerlen], tunerM.GetId()); headerlen = -1; } } diff --git a/rtp.h b/rtp.h index ccc654b..d15308a 100644 --- a/rtp.h +++ b/rtp.h @@ -23,7 +23,7 @@ private: time_t lastErrorReportM; int packetErrorsM; int sequenceNumberM; - int GetHeaderLenght(int lengthP); + int GetHeaderLenght(unsigned int lengthP); public: cSatipRtp(cSatipTunerIf &tunerP, unsigned int bufferLenP); diff --git a/tuner.c b/tuner.c index 26ef9dd..8cd8164 100644 --- a/tuner.c +++ b/tuner.c @@ -207,6 +207,7 @@ bool cSatipTuner::Connect(void) return true; } } + streamIdM = -1; error("Connect failed [device %d]", deviceIdM); } @@ -412,8 +413,8 @@ bool cSatipTuner::KeepAlive(bool forceP) keepAliveM.Set(timeoutM); forceP = true; } - if (forceP && !isempty(*streamAddrM) && (streamIdM > 0)) { - cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM); + if (forceP && !isempty(*streamAddrM)) { + cString uri = cString::sprintf("rtsp://%s/", *streamAddrM); if (!rtspM.Options(*uri)) return false; }