mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-17 04:45:47 +00:00
rtsp-stream: add getter for payload type
* gst/rtsp-server/rtsp-stream.c: add new method gst_rtsp_stream_get_pt. * gst/rtsp-server/rtsp-media.c (pad_added_cb): find real payloader element and create the stream with this one instead of the dynpay%d element. https://bugzilla.gnome.org/show_bug.cgi?id=712396
This commit is contained in:
parent
08160e0913
commit
e5332535a7
3 changed files with 54 additions and 2 deletions
|
@ -67,6 +67,8 @@
|
||||||
#include <gst/app/gstappsrc.h>
|
#include <gst/app/gstappsrc.h>
|
||||||
#include <gst/app/gstappsink.h>
|
#include <gst/app/gstappsink.h>
|
||||||
|
|
||||||
|
#include <gst/rtp/gstrtpbasepayload.h>
|
||||||
|
|
||||||
#include "rtsp-media.h"
|
#include "rtsp-media.h"
|
||||||
|
|
||||||
#define GST_RTSP_MEDIA_GET_PRIVATE(obj) \
|
#define GST_RTSP_MEDIA_GET_PRIVATE(obj) \
|
||||||
|
@ -1529,15 +1531,41 @@ watch_destroyed (GstRTSPMedia * media)
|
||||||
g_object_unref (media);
|
g_object_unref (media);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
find_payload_element (GstElement * payloader)
|
||||||
|
{
|
||||||
|
GValue item = { 0 };
|
||||||
|
GstIterator *iter;
|
||||||
|
GstElement *element;
|
||||||
|
GstElement *pay = NULL;
|
||||||
|
|
||||||
|
iter = gst_bin_iterate_recurse (GST_BIN (payloader));
|
||||||
|
while (gst_iterator_next (iter, &item) == GST_ITERATOR_OK) {
|
||||||
|
element = (GstElement *) g_value_get_object (&item);
|
||||||
|
if (GST_IS_RTP_BASE_PAYLOAD (element)) {
|
||||||
|
pay = gst_object_ref (element);
|
||||||
|
g_value_unset (&item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_value_unset (&item);
|
||||||
|
}
|
||||||
|
gst_iterator_free (iter);
|
||||||
|
|
||||||
|
return pay;
|
||||||
|
}
|
||||||
|
|
||||||
/* called from streaming threads */
|
/* called from streaming threads */
|
||||||
static void
|
static void
|
||||||
pad_added_cb (GstElement * element, GstPad * pad, GstRTSPMedia * media)
|
pad_added_cb (GstElement * element, GstPad * pad, GstRTSPMedia * media)
|
||||||
{
|
{
|
||||||
GstRTSPMediaPrivate *priv = media->priv;
|
GstRTSPMediaPrivate *priv = media->priv;
|
||||||
GstRTSPStream *stream;
|
GstRTSPStream *stream;
|
||||||
|
GstElement *pay;
|
||||||
|
|
||||||
/* FIXME, element is likely not a payloader, find the payloader here */
|
/* find the real payload element */
|
||||||
stream = gst_rtsp_media_create_stream (media, element, pad);
|
pay = find_payload_element (element);
|
||||||
|
stream = gst_rtsp_media_create_stream (media, pay, pad);
|
||||||
|
gst_object_unref (pay);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (pad), "gst-rtsp-dynpad-stream", stream);
|
g_object_set_data (G_OBJECT (pad), "gst-rtsp-dynpad-stream", stream);
|
||||||
|
|
||||||
|
|
|
@ -306,6 +306,29 @@ gst_rtsp_stream_get_index (GstRTSPStream * stream)
|
||||||
return stream->priv->idx;
|
return stream->priv->idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtsp_stream_get_pt:
|
||||||
|
* @stream: a #GstRTSPStream
|
||||||
|
*
|
||||||
|
* Get the stream payload type.
|
||||||
|
*
|
||||||
|
* Return: the stream payload type.
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gst_rtsp_stream_get_pt (GstRTSPStream * stream)
|
||||||
|
{
|
||||||
|
GstRTSPStreamPrivate *priv;
|
||||||
|
guint pt;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), -1);
|
||||||
|
|
||||||
|
priv = stream->priv;
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (priv->payloader), "pt", &pt, NULL);
|
||||||
|
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_rtsp_stream_get_srcpad:
|
* gst_rtsp_stream_get_srcpad:
|
||||||
* @stream: a #GstRTSPStream
|
* @stream: a #GstRTSPStream
|
||||||
|
|
|
@ -66,6 +66,7 @@ GType gst_rtsp_stream_get_type (void);
|
||||||
GstRTSPStream * gst_rtsp_stream_new (guint idx, GstElement *payloader,
|
GstRTSPStream * gst_rtsp_stream_new (guint idx, GstElement *payloader,
|
||||||
GstPad *srcpad);
|
GstPad *srcpad);
|
||||||
guint gst_rtsp_stream_get_index (GstRTSPStream *stream);
|
guint gst_rtsp_stream_get_index (GstRTSPStream *stream);
|
||||||
|
guint gst_rtsp_stream_get_pt (GstRTSPStream *stream);
|
||||||
GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream);
|
GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream);
|
||||||
|
|
||||||
void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control);
|
void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control);
|
||||||
|
|
Loading…
Reference in a new issue