mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Tweaked the pid update mechanism.
This commit is contained in:
parent
6e72eba09c
commit
78ef582bea
2
HISTORY
2
HISTORY
@ -49,4 +49,4 @@ VDR Plugin 'satip' Revision History
|
|||||||
|
|
||||||
2014-04-20: Version 0.3.0
|
2014-04-20: Version 0.3.0
|
||||||
|
|
||||||
- Increased the pid update interval to 250ms.
|
- Tweaked the pid update mechanism.
|
||||||
|
107
tuner.c
107
tuner.c
@ -34,7 +34,8 @@ cSatipTuner::cSatipTuner(cSatipDeviceIf &deviceP, unsigned int packetLenP)
|
|||||||
signalStrengthM(-1),
|
signalStrengthM(-1),
|
||||||
signalQualityM(-1),
|
signalQualityM(-1),
|
||||||
streamIdM(-1),
|
streamIdM(-1),
|
||||||
pidUpdatedM(false),
|
addPidsM(),
|
||||||
|
delPidsM(),
|
||||||
pidsM()
|
pidsM()
|
||||||
{
|
{
|
||||||
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
|
debug("cSatipTuner::%s(%d) [device %d]", __FUNCTION__, packetBufferLenM, deviceM->GetId());
|
||||||
@ -174,12 +175,8 @@ bool cSatipTuner::Connect(void)
|
|||||||
// Just retune
|
// Just retune
|
||||||
if (tunedM && (streamIdM >= 0)) {
|
if (tunedM && (streamIdM >= 0)) {
|
||||||
debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
|
debug("cSatipTuner::%s(): retune [device %d]", __FUNCTION__, deviceM->GetId());
|
||||||
uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
keepAliveM.Set(0);
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
KeepAlive();
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
|
||||||
if (!ValidateLatestResponse())
|
|
||||||
return false;
|
|
||||||
// Flush any old content
|
// Flush any old content
|
||||||
if (rtpSocketM)
|
if (rtpSocketM)
|
||||||
rtpSocketM->Flush();
|
rtpSocketM->Flush();
|
||||||
@ -248,18 +245,8 @@ bool cSatipTuner::Connect(void)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Start playing
|
// Start playing
|
||||||
if (pidsM.Size()) {
|
|
||||||
uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM);
|
|
||||||
for (int i = 0; i < pidsM.Size(); ++i)
|
|
||||||
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
|
||||||
if (!ValidateLatestResponse())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tunedM = true;
|
tunedM = true;
|
||||||
|
UpdatePids(true);
|
||||||
if (nextServerM) {
|
if (nextServerM) {
|
||||||
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
cSatipDiscover::GetInstance()->UseServer(nextServerM, true);
|
||||||
currentServerM = nextServerM;
|
currentServerM = nextServerM;
|
||||||
@ -311,7 +298,8 @@ bool cSatipTuner::Disconnect(void)
|
|||||||
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
cSatipDiscover::GetInstance()->UseServer(currentServerM, false);
|
||||||
tunedM = false;
|
tunedM = false;
|
||||||
timeoutM = eMinKeepAliveIntervalMs;
|
timeoutM = eMinKeepAliveIntervalMs;
|
||||||
pidUpdatedM = false;
|
addPidsM.Clear();
|
||||||
|
delPidsM.Clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -416,38 +404,85 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
|
|||||||
for (int i = 0; i < pidsM.Size(); ++i) {
|
for (int i = 0; i < pidsM.Size(); ++i) {
|
||||||
if (pidsM[i] == pidP) {
|
if (pidsM[i] == pidP) {
|
||||||
found = true;
|
found = true;
|
||||||
if (!onP) {
|
if (!onP)
|
||||||
pidsM.Remove(i);
|
pidsM.Remove(i);
|
||||||
pidUpdatedM = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (onP && !found) {
|
if (onP && !found)
|
||||||
pidsM.Append(pidP);
|
pidsM.Append(pidP);
|
||||||
pidUpdatedM = true;
|
// Generate deltas
|
||||||
}
|
found = false;
|
||||||
|
if (onP) {
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i) {
|
||||||
|
if (addPidsM[i] == pidP) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
addPidsM.Append(pidP);
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i) {
|
||||||
|
if (delPidsM[i] == pidP) {
|
||||||
|
delPidsM.Remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i) {
|
||||||
|
if (delPidsM[i] == pidP) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
delPidsM.Append(pidP);
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i) {
|
||||||
|
if (addPidsM[i] == pidP) {
|
||||||
|
addPidsM.Remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
|
pidUpdateCacheM.Set(ePidUpdateIntervalMs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cSatipTuner::UpdatePids(void)
|
bool cSatipTuner::UpdatePids(bool forceP)
|
||||||
{
|
{
|
||||||
cMutexLock MutexLock(&mutexM);
|
cMutexLock MutexLock(&mutexM);
|
||||||
if (pidUpdateCacheM.TimedOut() && pidUpdatedM && pidsM.Size() && tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
if (((forceP && pidsM.Size()) || (pidUpdateCacheM.TimedOut() && (addPidsM.Size() || delPidsM.Size()))) &&
|
||||||
//debug("cSatipTuner::%s() [device %d]", __FUNCTION__, deviceM->GetId());
|
tunedM && handleM && !isempty(*streamAddrM) && (streamIdM > 0)) {
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
//cString uri = cString::sprintf("rtsp://%s/stream=%d?%spids=%d", *streamAddrM, streamIdM, onP ? "add" : "del", pidP);
|
cString uri = cString::sprintf("rtsp://%s/stream=%d", *streamAddrM, streamIdM);
|
||||||
cString uri = cString::sprintf("rtsp://%s/stream=%d?pids=", *streamAddrM, streamIdM);
|
if (forceP) {
|
||||||
|
if (pidsM.Size()) {
|
||||||
for (int i = 0; i < pidsM.Size(); ++i)
|
uri = cString::sprintf("%s?pids=", *uri);
|
||||||
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
for (int i = 0; i < pidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (addPidsM.Size()) {
|
||||||
|
uri = cString::sprintf("%s?addpids=", *uri);
|
||||||
|
for (int i = 0; i < addPidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, addPidsM[i], (i == (addPidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
if (delPidsM.Size()) {
|
||||||
|
uri = cString::sprintf("%s%sdelpids=", *uri, addPidsM.Size() ? "&" : "?");
|
||||||
|
for (int i = 0; i < delPidsM.Size(); ++i)
|
||||||
|
uri = cString::sprintf("%s%d%s", *uri, delPidsM[i], (i == (delPidsM.Size() - 1)) ? "" : ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//debug("cSatipTuner::%s(): %s [device %d]", __FUNCTION__, *uri, deviceM->GetId());
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, *uri);
|
||||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
|
||||||
SATIP_CURL_EASY_PERFORM(handleM);
|
SATIP_CURL_EASY_PERFORM(handleM);
|
||||||
if (ValidateLatestResponse())
|
if (ValidateLatestResponse()) {
|
||||||
pidUpdatedM = false;
|
addPidsM.Clear();
|
||||||
|
delPidsM.Clear();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
||||||
|
5
tuner.h
5
tuner.h
@ -58,7 +58,8 @@ private:
|
|||||||
int signalStrengthM;
|
int signalStrengthM;
|
||||||
int signalQualityM;
|
int signalQualityM;
|
||||||
int streamIdM;
|
int streamIdM;
|
||||||
bool pidUpdatedM;
|
cVector<int> addPidsM;
|
||||||
|
cVector<int> delPidsM;
|
||||||
cVector<int> pidsM;
|
cVector<int> pidsM;
|
||||||
|
|
||||||
bool Connect(void);
|
bool Connect(void);
|
||||||
@ -69,7 +70,7 @@ private:
|
|||||||
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
void SetSessionTimeout(const char *sessionP, int timeoutP = 0);
|
||||||
bool KeepAlive(void);
|
bool KeepAlive(void);
|
||||||
bool UpdateSignalInfoCache(void);
|
bool UpdateSignalInfoCache(void);
|
||||||
bool UpdatePids(void);
|
bool UpdatePids(bool forceP = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Action(void);
|
virtual void Action(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user