mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Fixed reconnection.
This commit is contained in:
parent
8ea561a021
commit
01d2afcfc2
82
rtsp.c
82
rtsp.c
@ -15,45 +15,17 @@
|
||||
|
||||
cSatipRtsp::cSatipRtsp(cSatipTunerIf &tunerP)
|
||||
: tunerM(tunerP),
|
||||
handleM(curl_easy_init()),
|
||||
handleM(NULL),
|
||||
headerListM(NULL)
|
||||
{
|
||||
debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
|
||||
|
||||
if (handleM) {
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
// Verbose output
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_VERBOSE, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGFUNCTION, cSatipRtsp::DebugCallback);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGDATA, this);
|
||||
|
||||
// No progress meter and no signaling
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_NOPROGRESS, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_NOSIGNAL, 1L);
|
||||
|
||||
// Set timeouts
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_TIMEOUT_MS, (long)eConnectTimeoutMs);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_CONNECTTIMEOUT_MS, (long)eConnectTimeoutMs);
|
||||
|
||||
// Set user-agent
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s (device %d)", PLUGIN_NAME_I18N, VERSION, tunerM.GetId()));
|
||||
}
|
||||
Create();
|
||||
}
|
||||
|
||||
cSatipRtsp::~cSatipRtsp()
|
||||
{
|
||||
debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
|
||||
|
||||
if (handleM) {
|
||||
// Cleanup curl stuff
|
||||
if (headerListM) {
|
||||
curl_slist_free_all(headerListM);
|
||||
headerListM = NULL;
|
||||
}
|
||||
curl_easy_cleanup(handleM);
|
||||
handleM = NULL;
|
||||
}
|
||||
Destroy();
|
||||
}
|
||||
|
||||
size_t cSatipRtsp::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
|
||||
@ -143,6 +115,54 @@ cString cSatipRtsp::RtspUnescapeString(const char *strP)
|
||||
return cString(strP);
|
||||
}
|
||||
|
||||
void cSatipRtsp::Create(void)
|
||||
{
|
||||
debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
|
||||
if (!handleM)
|
||||
handleM = curl_easy_init();
|
||||
|
||||
if (handleM) {
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
// Verbose output
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_VERBOSE, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGFUNCTION, cSatipRtsp::DebugCallback);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGDATA, this);
|
||||
|
||||
// No progress meter and no signaling
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_NOPROGRESS, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_NOSIGNAL, 1L);
|
||||
|
||||
// Set timeouts
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_TIMEOUT_MS, (long)eConnectTimeoutMs);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_CONNECTTIMEOUT_MS, (long)eConnectTimeoutMs);
|
||||
|
||||
// Set user-agent
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_USERAGENT, *cString::sprintf("vdr-%s/%s (device %d)", PLUGIN_NAME_I18N, VERSION, tunerM.GetId()));
|
||||
}
|
||||
}
|
||||
|
||||
void cSatipRtsp::Destroy(void)
|
||||
{
|
||||
debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
|
||||
if (handleM) {
|
||||
// Cleanup curl stuff
|
||||
if (headerListM) {
|
||||
curl_slist_free_all(headerListM);
|
||||
headerListM = NULL;
|
||||
}
|
||||
curl_easy_cleanup(handleM);
|
||||
handleM = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cSatipRtsp::Reset(void)
|
||||
{
|
||||
debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
|
||||
Destroy();
|
||||
Create();
|
||||
}
|
||||
|
||||
bool cSatipRtsp::Options(const char *uriP)
|
||||
{
|
||||
debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, uriP, tunerM.GetId());
|
||||
|
3
rtsp.h
3
rtsp.h
@ -31,6 +31,8 @@ private:
|
||||
CURL *handleM;
|
||||
struct curl_slist *headerListM;
|
||||
|
||||
void Create(void);
|
||||
void Destroy(void);
|
||||
bool ValidateLatestResponse(long *rcP);
|
||||
|
||||
// to prevent copy constructor and assignment
|
||||
@ -42,6 +44,7 @@ public:
|
||||
virtual ~cSatipRtsp();
|
||||
|
||||
cString RtspUnescapeString(const char *strP);
|
||||
void Reset(void);
|
||||
bool Options(const char *uriP);
|
||||
bool Setup(const char *uriP, int rtpPortP, int rtcpPortP);
|
||||
bool SetSession(const char *sessionP);
|
||||
|
7
tuner.c
7
tuner.c
@ -104,15 +104,12 @@ void cSatipTuner::Action(void)
|
||||
break;
|
||||
case tsSet:
|
||||
debug4("%s: tsSet [device %d]", __PRETTY_FUNCTION__, deviceIdM);
|
||||
reConnectM.Set(eConnectTimeoutMs);
|
||||
if (Connect()) {
|
||||
RequestState(tsTuned, smInternal);
|
||||
UpdatePids(true);
|
||||
}
|
||||
else {
|
||||
error("Tuning failed - retuning [device %d]", deviceIdM);
|
||||
else
|
||||
Disconnect();
|
||||
}
|
||||
break;
|
||||
case tsTuned:
|
||||
debug4("%s: tsTuned [device %d]", __PRETTY_FUNCTION__, deviceIdM);
|
||||
@ -212,6 +209,8 @@ bool cSatipTuner::Connect(void)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
rtspM.Reset();
|
||||
streamIdM = -1;
|
||||
error("Connect failed [device %d]", deviceIdM);
|
||||
}
|
||||
|
2
tuner.h
2
tuner.h
@ -68,7 +68,7 @@ private:
|
||||
eDummyPid = 100,
|
||||
eDefaultSignalStrength = 15,
|
||||
eDefaultSignalQuality = 224,
|
||||
eSleepTimeoutMs = 500, // in milliseconds
|
||||
eSleepTimeoutMs = 1000, // in milliseconds
|
||||
eStatusUpdateTimeoutMs = 1000, // in milliseconds
|
||||
ePidUpdateIntervalMs = 250, // in milliseconds
|
||||
eConnectTimeoutMs = 5000, // in milliseconds
|
||||
|
Loading…
Reference in New Issue
Block a user