From 98ecd22a2717a03d16433958e81be079c4fac7d8 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Sun, 21 Oct 2018 20:21:33 +0300 Subject: [PATCH] Fix RTP over TCP with a nasty hack. --- rtsp.c | 22 ++++++++++++++++++++++ rtsp.h | 1 + tuner.c | 14 ++++++++++++++ tuner.h | 1 + 4 files changed, 38 insertions(+) diff --git a/rtsp.c b/rtsp.c index f78b9a3..63e6dfa 100644 --- a/rtsp.c +++ b/rtsp.c @@ -206,6 +206,28 @@ bool cSatipRtsp::SetInterface(const char *bindAddrP) return result; } +bool cSatipRtsp::Receive(const char *uriP) +{ + debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, uriP, tunerM.GetId()); + bool result = false; + + if (handleM && !isempty(uriP) && modeM == cSatipConfig::eTransportModeRtpOverTcp) { + long rc = 0; + cTimeMs processing(0); + CURLcode res = CURLE_OK; + + SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_URL, uriP); + SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_STREAM_URI, uriP); + SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS); // FIXME: this really should be CURL_RTSPREQ_RECEIVE, but getting timeout errors + SATIP_CURL_EASY_PERFORM(handleM); + + result = ValidateLatestResponse(&rc); + debug5("%s (%s) Response %ld in %" PRIu64 " ms [device %d]", __PRETTY_FUNCTION__, uriP, rc, processing.Elapsed(), tunerM.GetId()); + } + + return result; +} + bool cSatipRtsp::Options(const char *uriP) { debug1("%s (%s) [device %d]", __PRETTY_FUNCTION__, uriP, tunerM.GetId()); diff --git a/rtsp.h b/rtsp.h index e751599..d16b23f 100644 --- a/rtsp.h +++ b/rtsp.h @@ -59,6 +59,7 @@ public: cString RtspUnescapeString(const char *strP); void Reset(void); bool SetInterface(const char *bindAddrP); + bool Receive(const char *uriP); bool Options(const char *uriP); bool Setup(const char *uriP, int rtpPortP, int rtcpPortP, bool useTcpP); bool SetSession(const char *sessionP); diff --git a/tuner.c b/tuner.c index 698f0a0..befd78a 100644 --- a/tuner.c +++ b/tuner.c @@ -175,6 +175,7 @@ void cSatipTuner::Action(void) idleCheck.Set(eIdleCheckTimeoutMs); break; } + Receive(); break; default: error("Unknown tuner status %d [device %d]", currentStateM, deviceIdM); @@ -544,6 +545,19 @@ bool cSatipTuner::UpdatePids(bool forceP) return true; } +bool cSatipTuner::Receive(void) +{ + debug16("%s tunerState=%s [device %d]", __PRETTY_FUNCTION__, TunerStateString(currentStateM), deviceIdM); + cMutexLock MutexLock(&mutexM); + if (!isempty(*streamAddrM)) { + cString uri = GetBaseUrl(*streamAddrM, streamPortM); + if (!rtspM.Receive(*uri)) + return false; + } + + return true; +} + bool cSatipTuner::KeepAlive(bool forceP) { debug16("%s (%d) tunerState=%s [device %d]", __PRETTY_FUNCTION__, forceP, TunerStateString(currentStateM), deviceIdM); diff --git a/tuner.h b/tuner.h index 37cd40b..58e363b 100644 --- a/tuner.h +++ b/tuner.h @@ -128,6 +128,7 @@ private: bool Connect(void); bool Disconnect(void); + bool Receive(void); bool KeepAlive(bool forceP = false); bool ReadReceptionStatus(bool forceP = false); bool UpdatePids(bool forceP = false);