2013-02-23 01:03:27 +01:00
|
|
|
/*
|
|
|
|
* protocolcurl.h: IPTV plugin for the Video Disk Recorder
|
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IPTV_PROTOCOLCURL_H
|
|
|
|
#define __IPTV_PROTOCOLCURL_H
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <curl/easy.h>
|
|
|
|
|
|
|
|
#include <vdr/ringbuffer.h>
|
|
|
|
#include <vdr/thread.h>
|
|
|
|
#include <vdr/tools.h>
|
|
|
|
|
|
|
|
#include "protocolif.h"
|
2014-02-19 20:38:11 +01:00
|
|
|
#include "socket.h"
|
2013-02-23 01:03:27 +01:00
|
|
|
|
2014-02-19 20:38:11 +01:00
|
|
|
class cIptvProtocolCurl : public cIptvUdpSocket, public cIptvProtocolIf {
|
2013-02-23 01:03:27 +01:00
|
|
|
private:
|
|
|
|
enum eModeType {
|
|
|
|
eModeUnknown = 0,
|
|
|
|
eModeHttp,
|
|
|
|
eModeHttps,
|
|
|
|
eModeRtsp,
|
|
|
|
eModeFile,
|
|
|
|
eModeCount
|
|
|
|
};
|
|
|
|
enum {
|
2014-02-19 20:38:11 +01:00
|
|
|
eConnectTimeoutS = 5, // in seconds
|
2015-02-24 19:28:32 +01:00
|
|
|
eLowSpeedTimeoutS = 3, // in seconds
|
|
|
|
eLowSpeedLimitBytes = 100, // in bytes per second
|
2014-02-19 20:38:11 +01:00
|
|
|
eMaxDownloadSpeedMBits = 20, // in megabits per second
|
|
|
|
eKeepAliveIntervalMs = 300000 // in milliseconds
|
2013-02-23 01:03:27 +01:00
|
|
|
};
|
|
|
|
|
2015-03-08 14:47:12 +01:00
|
|
|
static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP);
|
2013-02-23 01:03:27 +01:00
|
|
|
static size_t WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
|
|
|
static size_t WriteRtspCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
|
|
|
static size_t DescribeCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
|
|
|
static size_t HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);
|
|
|
|
|
|
|
|
cString streamUrlM;
|
|
|
|
int streamParamM;
|
2014-02-19 20:38:11 +01:00
|
|
|
int streamPortM;
|
2013-02-23 01:03:27 +01:00
|
|
|
cMutex mutexM;
|
|
|
|
CURL *handleM;
|
|
|
|
CURLM *multiM;
|
|
|
|
struct curl_slist *headerListM;
|
|
|
|
cRingBufferLinear *ringBufferM;
|
|
|
|
cString rtspControlM;
|
|
|
|
eModeType modeM;
|
2014-02-19 20:38:11 +01:00
|
|
|
cTimeMs timeoutM;
|
2013-02-23 01:03:27 +01:00
|
|
|
bool connectedM;
|
|
|
|
bool pausedM;
|
|
|
|
|
|
|
|
bool Connect(void);
|
|
|
|
bool Disconnect(void);
|
|
|
|
bool PutData(unsigned char *dataP, int lenP);
|
|
|
|
void DelData(int lenP);
|
|
|
|
void ClearData(void);
|
2013-03-02 00:26:04 +01:00
|
|
|
unsigned char *GetData(int &lenP);
|
2013-02-23 01:03:27 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
cIptvProtocolCurl();
|
|
|
|
virtual ~cIptvProtocolCurl();
|
2013-02-23 14:31:11 +01:00
|
|
|
int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
|
2014-02-09 18:22:02 +01:00
|
|
|
bool SetSource(const char* locationP, const int parameterP, const int indexP);
|
|
|
|
bool SetPid(int pidP, int typeP, bool onP);
|
2013-02-23 01:03:27 +01:00
|
|
|
bool Open(void);
|
|
|
|
bool Close(void);
|
|
|
|
cString GetInformation(void);
|
|
|
|
void SetRtspControl(const char *controlP);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __IPTV_PROTOCOLCURL_H
|
|
|
|
|