#include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h>
+#include <gst/rtp/gstrtpbasepayload.h>
+
#include "rtsp-media.h"
#define GST_RTSP_MEDIA_GET_PRIVATE(obj) \
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 */
static void
pad_added_cb (GstElement * element, GstPad * pad, GstRTSPMedia * media)
{
GstRTSPMediaPrivate *priv = media->priv;
GstRTSPStream *stream;
+ GstElement *pay;
- /* FIXME, element is likely not a payloader, find the payloader here */
- stream = gst_rtsp_media_create_stream (media, element, pad);
+ /* find the real payload element */
+ 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);
}
/**
+ * 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:
* @stream: a #GstRTSPStream
*
GstRTSPStream * gst_rtsp_stream_new (guint idx, GstElement *payloader,
GstPad *srcpad);
guint gst_rtsp_stream_get_index (GstRTSPStream *stream);
+guint gst_rtsp_stream_get_pt (GstRTSPStream *stream);
GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream);
void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control);