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

Fixed tuner reconnection issues.

This commit is contained in:
Rolf Ahrenberg 2014-11-16 15:38:23 +02:00
parent 02bf42b006
commit 5c051d919b
8 changed files with 39 additions and 21 deletions

2
rtcp.c
View File

@ -82,7 +82,7 @@ void cSatipRtcp::Action(int fdP)
if (length > 0) {
int offset = GetApplicationOffset(&length);
if (offset >= 0)
tunerM->ParseReceptionParameters(bufferM + offset, length);
tunerM->ProcessApplicationData(bufferM + offset, length);
}
}
}

4
rtcp.h
View File

@ -8,13 +8,11 @@
#ifndef __SATIP_RTCP_H_
#define __SATIP_RTCP_H_
#include "common.h"
#include "socket.h"
#include "tunerif.h"
#include "pollerif.h"
class cSatipRtcp : public cSatipSocket, public cSatipPollerIf
{
class cSatipRtcp : public cSatipSocket, public cSatipPollerIf {
private:
cSatipTunerIf *tunerM;
unsigned int bufferLenM;

8
rtp.c
View File

@ -8,8 +8,8 @@
#include "common.h"
#include "rtp.h"
cSatipRtp::cSatipRtp(cSatipDeviceIf &deviceP, unsigned int bufferLenP)
: deviceM(&deviceP),
cSatipRtp::cSatipRtp(cSatipTunerIf &tunerP, unsigned int bufferLenP)
: tunerM(&tunerP),
bufferLenM(bufferLenP),
bufferM(MALLOC(unsigned char, bufferLenM)),
lastErrorReportM(0),
@ -104,11 +104,11 @@ void cSatipRtp::Action(int fdP)
{
//debug("cSatipRtp::%s(%d)", __FUNCTION__, fdP);
if (bufferM) {
int length = Read(bufferM, min(deviceM->CheckData(), bufferLenM));
int length = Read(bufferM, min(tunerM->GetVideoDataSize(), bufferLenM));
if (length > 0) {
int headerlen = GetHeaderLenght(length);
if ((headerlen >= 0) && (headerlen < length))
deviceM->WriteData(bufferM + headerlen, length - headerlen);
tunerM->ProcessVideoData(bufferM + headerlen, length - headerlen);
}
}
}

7
rtp.h
View File

@ -9,16 +9,15 @@
#define __SATIP_RTP_H_
#include "socket.h"
#include "deviceif.h"
#include "tunerif.h"
#include "pollerif.h"
#include "statistics.h"
class cSatipRtp : public cSatipSocket, public cSatipPollerIf {
private:
enum {
eReportIntervalS = 300 // in seconds
};
cSatipDeviceIf *deviceM;
cSatipTunerIf *tunerM;
unsigned int bufferLenM;
unsigned char *bufferM;
time_t lastErrorReportM;
@ -31,7 +30,7 @@ protected:
virtual void Action(int fdP);
public:
cSatipRtp(cSatipDeviceIf &deviceP, unsigned int bufferLenP);
cSatipRtp(cSatipTunerIf &tunerP, unsigned int bufferLenP);
virtual ~cSatipRtp();
virtual void Close(void);
};

2
rtsp.c
View File

@ -89,7 +89,7 @@ size_t cSatipRtsp::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *
//debug("cSatipRtsp::%s(%zu)", __FUNCTION__, len);
if (obj && obj->tunerM && (len > 0))
obj->tunerM->ParseReceptionParameters((u_char*)ptrP, len);
obj->tunerM->ProcessApplicationData((u_char*)ptrP, len);
return len;
}

28
tuner.c
View File

@ -17,13 +17,14 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
deviceM(&deviceP),
deviceIdM(deviceP.GetId()),
rtspM(new cSatipRtsp(*this)),
rtpM(new cSatipRtp(deviceP, packetLenP)),
rtpM(new cSatipRtp(*this, packetLenP)),
rtcpM(new cSatipRtcp(*this, 1500)),
streamAddrM(""),
streamParamM(""),
currentServerM(NULL),
nextServerM(NULL),
mutexM(),
reConnectM(),
keepAliveM(),
statusUpdateM(),
pidUpdateCacheM(),
@ -86,7 +87,7 @@ cSatipTuner::~cSatipTuner()
void cSatipTuner::Action(void)
{
debug("cSatipTuner::%s(): entering [device %d]", __FUNCTION__, deviceIdM);
cTimeMs reconnection(eConnectTimeoutMs);
reConnectM.Set(eConnectTimeoutMs);
// Do the thread loop
while (Running()) {
switch (tunerStatusM) {
@ -100,7 +101,7 @@ void cSatipTuner::Action(void)
break;
case tsSet:
//debug("cSatipTuner::%s(): tsSet [device %d]", __FUNCTION__, deviceIdM);
reconnection.Set(eConnectTimeoutMs);
reConnectM.Set(eConnectTimeoutMs);
Disconnect();
if (Connect()) {
tunerStatusM = tsTuned;
@ -113,7 +114,7 @@ void cSatipTuner::Action(void)
break;
case tsTuned:
//debug("cSatipTuner::%s(): tsTuned [device %d]", __FUNCTION__, deviceIdM);
reconnection.Set(eConnectTimeoutMs);
reConnectM.Set(eConnectTimeoutMs);
// Read reception statistics via DESCRIBE and RTCP
if (hasLockM || ReadReceptionStatus()) {
// Quirk for devices without valid reception data
@ -139,7 +140,7 @@ void cSatipTuner::Action(void)
tunerStatusM = tsSet;
break;
}
if (reconnection.TimedOut()) {
if (reConnectM.TimedOut()) {
error("Connection timeout - re-tuning [device %d]", deviceIdM);
tunerStatusM = tsSet;
break;
@ -232,7 +233,22 @@ bool cSatipTuner::Disconnect(void)
return true;
}
void cSatipTuner::ParseReceptionParameters(u_char *bufferP, int lengthP)
unsigned int cSatipTuner::GetVideoDataSize(void)
{
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceIdM);
return deviceM->CheckData();
}
void cSatipTuner::ProcessVideoData(u_char *bufferP, int lengthP)
{
//debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, lengthP, deviceIdM);
if (lengthP > 0)
deviceM->WriteData(bufferP, lengthP);
cMutexLock MutexLock(&mutexM);
reConnectM.Set(eConnectTimeoutMs);
}
void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP)
{
//debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, lengthP, deviceIdM);
// DVB-S2:

View File

@ -70,6 +70,7 @@ private:
cSatipServer *currentServerM;
cSatipServer *nextServerM;
cMutex mutexM;
cTimeMs reConnectM;
cTimeMs keepAliveM;
cTimeMs statusUpdateM;
cTimeMs pidUpdateCacheM;
@ -110,7 +111,9 @@ public:
// for internal tuner interface
public:
virtual void ParseReceptionParameters(u_char *bufferP, int lengthP);
virtual unsigned int GetVideoDataSize(void);
virtual void ProcessVideoData(u_char *bufferP, int lengthP);
virtual void ProcessApplicationData(u_char *bufferP, int lengthP);
virtual void SetStreamId(int streamIdP);
virtual void SetSessionTimeout(const char *sessionP, int timeoutP);
virtual int GetId(void);

View File

@ -12,7 +12,9 @@ class cSatipTunerIf {
public:
cSatipTunerIf() {}
virtual ~cSatipTunerIf() {}
virtual void ParseReceptionParameters(u_char *bufferP, int lenghtP) = 0;
virtual unsigned int GetVideoDataSize(void) = 0;
virtual void ProcessVideoData(u_char *bufferP, int lenghtP) = 0;
virtual void ProcessApplicationData(u_char *bufferP, int lenghtP) = 0;
virtual void SetStreamId(int streamIdP) = 0;
virtual void SetSessionTimeout(const char *sessionP, int timeoutP) = 0;
virtual int GetId(void) = 0;