From 2b34e3355c8943f41c84f39ad9a838f6edb80429 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Thu, 2 May 2019 09:42:39 +0200 Subject: Gstreamer: Pass GstUDPSrc's caps via "udpsrc.caps=" url's query item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gsttools/qgstreamerplayersession.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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 #include #include +#include //#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); -- cgit v1.2.3