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 <curl/curl.h>
|
|
|
|
#include <curl/easy.h>
|
|
|
|
|
|
|
|
#ifndef CURLOPT_RTSPHEADER
|
|
|
|
#error "libcurl is missing required RTSP support"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vdr/thread.h>
|
|
|
|
#include <vdr/tools.h>
|
|
|
|
|
|
|
|
#include "deviceif.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"
|
|
|
|
|
|
|
|
class cSatipTuner : public cThread, public cSatipTunerStatistics {
|
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
eConnectTimeoutMs = 1500, // in milliseconds
|
|
|
|
ePidUpdateIntervalMs = 100, // in milliseconds
|
|
|
|
eReConnectTimeoutMs = 5000, // in milliseconds
|
|
|
|
eKeepAliveIntervalMs = 600000 // in milliseconds
|
|
|
|
};
|
|
|
|
|
|
|
|
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
|
|
|
|
|
|
|
cCondWait sleepM;
|
|
|
|
cSatipDeviceIf* deviceM;
|
|
|
|
unsigned char* packetBufferM;
|
|
|
|
unsigned int packetBufferLenM;
|
|
|
|
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;
|
|
|
|
CURL *handleM;
|
|
|
|
struct curl_slist *headerListM;
|
|
|
|
cTimeMs keepAliveM;
|
|
|
|
cTimeMs signalInfoCacheM;
|
|
|
|
cTimeMs pidUpdateCacheM;
|
2014-03-16 18:58:09 +01:00
|
|
|
cString sessionM;
|
2014-03-08 12:07:47 +01:00
|
|
|
int timeoutM;
|
|
|
|
bool openedM;
|
|
|
|
bool tunedM;
|
|
|
|
bool hasLockM;
|
|
|
|
int signalStrengthM;
|
|
|
|
int signalQualityM;
|
|
|
|
int streamIdM;
|
|
|
|
bool pidUpdatedM;
|
|
|
|
cVector<int> pidsM;
|
|
|
|
|
|
|
|
bool Connect(void);
|
|
|
|
bool Disconnect(void);
|
|
|
|
bool ValidateLatestResponse(void);
|
|
|
|
void ParseReceptionParameters(const char *paramP);
|
2014-03-16 18:58:09 +01:00
|
|
|
void SetStreamId(int streamIdP);
|
|
|
|
void SetSessionTimeout(const char *sessionP, int timeoutP);
|
2014-03-08 12:07:47 +01:00
|
|
|
bool KeepAlive(void);
|
|
|
|
bool UpdateSignalInfoCache(void);
|
|
|
|
bool UpdatePids(void);
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __SATIP_TUNER_H
|