1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00
vdr-plugin-iptv/protocolcurl.h

80 lines
2.2 KiB
C
Raw Normal View History

/*
* 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"
2014-02-19 20:38:11 +01:00
class cIptvProtocolCurl : public cIptvUdpSocket, public cIptvProtocolIf {
private:
enum eModeType {
eModeUnknown = 0,
eModeHttp,
eModeHttps,
eModeRtsp,
eModeFile,
eModeCount
};
enum {
2014-02-19 20:38:11 +01:00
eConnectTimeoutS = 5, // in seconds
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
};
2015-03-08 14:47:12 +01:00
static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP);
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;
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;
bool connectedM;
bool pausedM;
bool Connect(void);
bool Disconnect(void);
bool PutData(unsigned char *dataP, int lenP);
void DelData(int lenP);
void ClearData(void);
unsigned char *GetData(int &lenP);
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);
bool Open(void);
bool Close(void);
cString GetInformation(void);
void SetRtspControl(const char *controlP);
};
#endif // __IPTV_PROTOCOLCURL_H