2014-03-08 12:07:47 +01:00
|
|
|
/*
|
|
|
|
* tuner.h: SAT>IP plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SATIP_TUNER_H
|
|
|
|
#define __SATIP_TUNER_H
|
|
|
|
|
|
|
|
#include <vdr/thread.h>
|
|
|
|
#include <vdr/tools.h>
|
|
|
|
|
|
|
|
#include "deviceif.h"
|
2014-11-09 11:51:52 +01:00
|
|
|
#include "rtsp.h"
|
2014-03-13 17:23:55 +01:00
|
|
|
#include "server.h"
|
2014-03-08 12:07:47 +01:00
|
|
|
#include "statistics.h"
|
|
|
|
#include "socket.h"
|
|
|
|
|
2014-11-09 01:32:50 +01:00
|
|
|
class cSatipPid : public cVector<int> {
|
|
|
|
private:
|
|
|
|
int PidIndex(const int &pidP)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < this->Size(); ++i) {
|
|
|
|
if (pidP == this->At(i))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void RemovePid(const int &pidP)
|
|
|
|
{
|
|
|
|
int i = PidIndex(pidP);
|
|
|
|
if (i >= 0)
|
|
|
|
this->Remove(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddPid(int pidP)
|
|
|
|
{
|
|
|
|
if (PidIndex(pidP) < 0)
|
|
|
|
this->Append(pidP);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-11-09 11:51:52 +01:00
|
|
|
class cSatipTuner : public cThread, public cSatipTunerStatistics, public cSatipTunerIf {
|
2014-03-08 12:07:47 +01:00
|
|
|
private:
|
|
|
|
enum {
|
2014-11-09 19:32:08 +01:00
|
|
|
eMaxFileDescriptors = 2, // RTP + RTCP
|
2014-11-03 20:54:19 +01:00
|
|
|
eDummyPid = 100,
|
|
|
|
eDefaultSignalStrength = 15,
|
|
|
|
eDefaultSignalQuality = 224,
|
2014-11-09 19:32:08 +01:00
|
|
|
eReadTimeoutMs = 500, // in milliseconds
|
2014-11-05 20:55:40 +01:00
|
|
|
eStatusUpdateTimeoutMs = 1000, // in milliseconds
|
2014-04-02 20:06:37 +02:00
|
|
|
eConnectTimeoutMs = 1500, // in milliseconds
|
2014-04-15 19:04:01 +02:00
|
|
|
ePidUpdateIntervalMs = 250, // in milliseconds
|
2014-04-02 20:06:37 +02:00
|
|
|
eReConnectTimeoutMs = 5000, // in milliseconds
|
|
|
|
eMinKeepAliveIntervalMs = 30000 // in milliseconds
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cCondWait sleepM;
|
|
|
|
cSatipDeviceIf* deviceM;
|
2014-11-09 11:51:52 +01:00
|
|
|
int deviceIdM;
|
2014-03-08 12:07:47 +01:00
|
|
|
unsigned char* packetBufferM;
|
|
|
|
unsigned int packetBufferLenM;
|
2014-11-09 11:51:52 +01:00
|
|
|
cSatipRtsp *rtspM;
|
2014-03-08 12:07:47 +01:00
|
|
|
cSatipSocket *rtpSocketM;
|
|
|
|
cSatipSocket *rtcpSocketM;
|
|
|
|
cString streamAddrM;
|
|
|
|
cString streamParamM;
|
2014-03-13 17:23:55 +01:00
|
|
|
cSatipServer *currentServerM;
|
|
|
|
cSatipServer *nextServerM;
|
2014-03-08 12:07:47 +01:00
|
|
|
cMutex mutexM;
|
|
|
|
cTimeMs keepAliveM;
|
2014-11-05 20:55:40 +01:00
|
|
|
cTimeMs statusUpdateM;
|
2014-03-08 12:07:47 +01:00
|
|
|
cTimeMs signalInfoCacheM;
|
|
|
|
cTimeMs pidUpdateCacheM;
|
2014-03-16 18:58:09 +01:00
|
|
|
cString sessionM;
|
2014-11-09 19:32:08 +01:00
|
|
|
int fdM;
|
2014-03-08 12:07:47 +01:00
|
|
|
int timeoutM;
|
|
|
|
bool openedM;
|
|
|
|
bool tunedM;
|
|
|
|
bool hasLockM;
|
|
|
|
int signalStrengthM;
|
|
|
|
int signalQualityM;
|
|
|
|
int streamIdM;
|
2014-11-09 01:32:50 +01:00
|
|
|
cSatipPid addPidsM;
|
|
|
|
cSatipPid delPidsM;
|
|
|
|
cSatipPid pidsM;
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
bool Connect(void);
|
|
|
|
bool Disconnect(void);
|
|
|
|
bool KeepAlive(void);
|
2014-11-05 20:55:40 +01:00
|
|
|
bool ReadReceptionStatus(void);
|
2014-03-08 12:07:47 +01:00
|
|
|
bool UpdateSignalInfoCache(void);
|
2014-04-19 16:27:47 +02:00
|
|
|
bool UpdatePids(bool forceP = false);
|
2014-03-08 12:07:47 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void Action(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP);
|
|
|
|
virtual ~cSatipTuner();
|
|
|
|
bool IsTuned(void) const { return tunedM; }
|
2014-03-13 17:23:55 +01:00
|
|
|
bool SetSource(cSatipServer *serverP, const char *parameterP, const int indexP);
|
2014-03-08 12:07:47 +01:00
|
|
|
bool SetPid(int pidP, int typeP, bool onP);
|
|
|
|
bool Open(void);
|
|
|
|
bool Close(void);
|
|
|
|
int SignalStrength(void);
|
|
|
|
int SignalQuality(void);
|
|
|
|
bool HasLock(void);
|
|
|
|
cString GetSignalStatus(void);
|
|
|
|
cString GetInformation(void);
|
2014-11-09 11:51:52 +01:00
|
|
|
|
|
|
|
// for internal tuner interface
|
|
|
|
public:
|
|
|
|
virtual void ParseReceptionParameters(const char *paramP);
|
|
|
|
virtual void SetStreamId(int streamIdP);
|
|
|
|
virtual void SetSessionTimeout(const char *sessionP, int timeoutP);
|
|
|
|
virtual int GetId(void);
|
2014-03-08 12:07:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_TUNER_H
|