summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-05-02 09:42:39 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-05-22 14:33:25 +0200
commit2b34e3355c8943f41c84f39ad9a838f6edb80429 (patch)
tree4af47148a982b0ca7ac38986f657ed19f89d6731
parent80cc653364fe330dfa4bf310f98d98d4cef0698b (diff)
Gstreamer: Pass GstUDPSrc's caps via "udpsrc.caps=" url's query item
Sometimes it is needed to configure udpsrc element to play a stream, means to set some caps to GstUDPSrc element. But currently there are no any ways to pass such caps. Added parsing of the requested url to find "udpsrc.caps" query item and to use it as the caps for udpsrc source element. It allows to show streams by passing caps within url. E.g. if the stream is created using $ gst-launch-1.0 v4l2src ! videoconvert ! video/x-raw,format=I420,width=800,height=600 ! \ jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=5001 it could be shown via QMediaPlayer like: MediaPlayer { source: "udp://127.0.0.1:5001/?udpsrc.caps=application/x-rtp,media=video,clock-rate=90000,encoding=JPEG,payload=26" } Change-Id: I6f9c20c6004a34bce5fd1d0073311b7c62a8010f Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r--src/gsttools/qgstreamerplayersession.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gsttools/qgstreamerplayersession.cpp b/src/gsttools/qgstreamerplayersession.cpp
index 56f78cb9f..5ede8a1c9 100644
--- a/src/gsttools/qgstreamerplayersession.cpp
+++ b/src/gsttools/qgstreamerplayersession.cpp
@@ -61,6 +61,7 @@
#include <QtCore/qdir.h>
#include <QtCore/qstandardpaths.h>
#include <qvideorenderercontrol.h>
+#include <QUrlQuery>
//#define DEBUG_PLAYBIN
@@ -1658,6 +1659,14 @@ void QGstreamerPlayerSession::playbinNotifySource(GObject *o, GParamSpec *p, gpo
self->m_sourceType = UDPSrc;
//The udpsrc is always a live source.
self->m_isLiveSource = true;
+
+ QUrlQuery query(self->m_request.url());
+ const QString var = QLatin1String("udpsrc.caps");
+ if (query.hasQueryItem(var)) {
+ GstCaps *caps = gst_caps_from_string(query.queryItemValue(var).toLatin1().constData());
+ g_object_set(G_OBJECT(source), "caps", caps, NULL);
+ gst_caps_unref(caps);
+ }
} else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstSoupHTTPSrc") == 0) {
//souphttpsrc timeout unit = second
g_object_set(G_OBJECT(source), "timeout", guint(timeout), NULL);