summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames DeLisle <james.delisle@qt.io>2022-02-18 16:10:35 -0500
committerJames DeLisle <james.delisle@qt.io>2023-01-24 09:51:53 -0500
commit42449760305548b6c6b2d4d70ebc0e6ec89a877e (patch)
tree9820b29c478498d78d4d9e6b50cb965b81e21479
parent54830b12f0b2ccba5054564f60340271d3110f77 (diff)
Add internal ability to adjust RTSP latency
When using the gstreamer backend, the RTSP latency is set to 2000ms by default. This latency creates issues for cases where near realtime camera feedback is critical for directing the user. This change adds the ability to turn 3 knobs in the RTSP jitter buffer pipeline using the following environment variables: 1. QT_MEDIA_RTSP_LATENCY An unsigned integer value expressed in ms. This dictates the high water mark of the latency buffer. Default: 2000 ms 2. QT_MEDIA_RTSP_DROP_ON_LATENCY May be set to 1 for on or 0 for off When turned on, the jitter buffer will drop packets that arrive after the high water mark of the buffer has been filled. No new packets will be accepted until the high water mark recedes sufficiently to allow new packets to be stored in the buffer. Default: off 3. QT_MEDIA_RTSP_DO_RETRANSMISSION May be set to 1 for on or 0 for off When set to true, the jitter buffer will request a re-send of dropped packets. Default: off This change is strictly for a customer project, but may be helpful in understanding what additions to the public API would be helpful in the future. Change-Id: Icede93161d72936970f4835c6443e369789b4c38 Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 2fcf1212ff78f02e7c7d408c2719a0369eab5bad) Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamermediaplayer.cpp34
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamermediaplayer_p.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer.cpp b/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer.cpp
index fbdafe860..cfdc3d5e9 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer.cpp
@@ -635,6 +635,39 @@ void QGstreamerMediaPlayer::uridecodebinElementAddedCallback(GstElement */*uride
}
}
+void QGstreamerMediaPlayer::sourceSetupCallback(GstElement *uridecodebin, GstElement *source, QGstreamerMediaPlayer *that)
+{
+ Q_UNUSED(uridecodebin)
+ Q_UNUSED(that)
+
+ qCDebug(qLcMediaPlayer) << "Setting up source:" << g_type_name_from_instance((GTypeInstance*)source);
+
+ if (QLatin1String("GstRTSPSrc") == QString::fromUtf8(g_type_name_from_instance((GTypeInstance*)source))) {
+ QGstElement s(source);
+ int latency{40};
+ bool ok{false};
+ int v = QString::fromLocal8Bit(qgetenv("QT_MEDIA_RTSP_LATENCY")).toUInt(&ok);
+ if (ok)
+ latency = v;
+ qCDebug(qLcMediaPlayer) << " -> setting source latency to:" << latency << "ms";
+ s.set("latency", latency);
+
+ bool drop{true};
+ v = QString::fromLocal8Bit(qgetenv("QT_MEDIA_RTSP_DROP_ON_LATENCY")).toUInt(&ok);
+ if (ok && v == 0)
+ drop = false;
+ qCDebug(qLcMediaPlayer) << " -> setting drop-on-latency to:" << drop;
+ s.set("drop-on-latency", drop);
+
+ bool retrans{false};
+ v = QString::fromLocal8Bit(qgetenv("QT_MEDIA_RTSP_DO_RETRANSMISSION")).toUInt(&ok);
+ if (ok && v not_eq 0)
+ retrans = true;
+ qCDebug(qLcMediaPlayer) << " -> setting do-retransmission to:" << retrans;
+ s.set("do-retransmission", retrans);
+ }
+}
+
void QGstreamerMediaPlayer::setMedia(const QUrl &content, QIODevice *stream)
{
qCDebug(qLcMediaPlayer) << Q_FUNC_INFO << "setting location to" << content;
@@ -691,6 +724,7 @@ void QGstreamerMediaPlayer::setMedia(const QUrl &content, QIODevice *stream)
playerPipeline.add(decoder);
// can't set post-stream-topology to true, as uridecodebin doesn't have the property. Use a hack
decoder.connect("element-added", GCallback(QGstreamerMediaPlayer::uridecodebinElementAddedCallback), this);
+ decoder.connect("source-setup", GCallback(QGstreamerMediaPlayer::sourceSetupCallback), this);
decoder.set("uri", content.toEncoded().constData());
if (m_bufferProgress != 0) {
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer_p.h b/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer_p.h
index bd0381108..c047a9edd 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgstreamermediaplayer_p.h
@@ -143,6 +143,7 @@ private:
void decoderPadAdded(const QGstElement &src, const QGstPad &pad);
void decoderPadRemoved(const QGstElement &src, const QGstPad &pad);
static void uridecodebinElementAddedCallback(GstElement *uridecodebin, GstElement *child, QGstreamerMediaPlayer *that);
+ static void sourceSetupCallback(GstElement *uridecodebin, GstElement *source, QGstreamerMediaPlayer *that);
void parseStreamsAndMetadata();
void connectOutput(TrackSelector &ts);
void removeOutput(TrackSelector &ts);