summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2017-06-01 02:03:27 +0200
committerMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2017-06-07 23:30:05 +0200
commitf6283b082e93b99c0c61c5109e19ef053b5efa82 (patch)
treebef668de1f79030233313896235361aa0022d1a7
parentd3cbea0919a7e5355ce45eaabacb4eca02f1cd49 (diff)
rtspsrc: uniquify stream idsHEADmaster
https://bugzilla.gnome.org/show_bug.cgi?id=783307
-rw-r--r--gst/rtsp/gstrtspsrc.c50
-rw-r--r--gst/rtsp/gstrtspsrc.h3
2 files changed, 53 insertions, 0 deletions
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index effe52676..a8892d3d8 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -1503,6 +1503,17 @@ gst_rtspsrc_collect_connections (GstRTSPSrc * src, const GstSDPMessage * sdp,
}
}
+static gchar *
+make_stream_id (GstRTSPStream * stream, const GstSDPMedia * media)
+{
+ gchar *stream_id = g_strdup_printf ("%s%d%d%s%d", media->media, media->port,
+ media->num_ports, media->proto, stream->default_pt);
+ gchar *res = g_compute_checksum_for_string (G_CHECKSUM_MD5, stream_id, -1);
+
+ g_free (stream_id);
+ return res;
+}
+
/* m=<media> <UDP port> RTP/AVP <payload>
*/
static void
@@ -1583,6 +1594,8 @@ gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp,
g_array_append_val (stream->ptmap, item);
}
+ stream->stream_id = make_stream_id (stream, media);
+
gst_caps_unref (global_caps);
return;
@@ -1652,6 +1665,7 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx,
stream->profile = GST_RTSP_PROFILE_AVP;
stream->ptmap = g_array_new (FALSE, FALSE, sizeof (PtMapItem));
stream->mikey = NULL;
+ stream->stream_id = NULL;
g_array_set_clear_func (stream->ptmap, (GDestroyNotify) clear_ptmap_item);
/* collect bandwidth information for this steam. FIXME, configure in the RTP
@@ -1734,6 +1748,7 @@ gst_rtspsrc_stream_free (GstRTSPSrc * src, GstRTSPStream * stream)
g_free (stream->destination);
g_free (stream->control_url);
g_free (stream->conninfo.location);
+ g_free (stream->stream_id);
for (i = 0; i < 2; i++) {
if (stream->udpsrc[i]) {
@@ -2298,6 +2313,33 @@ gst_rtspsrc_handle_src_event (GstPad * pad, GstObject * parent,
return res;
}
+static gboolean
+gst_rtspsrc_handle_src_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
+{
+ GstRTSPStream *stream;
+
+ stream = gst_pad_get_element_private (pad);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_STREAM_START:{
+ const gchar *upstream_id;
+ gchar *stream_id;
+
+ gst_event_parse_stream_start (event, &upstream_id);
+ stream_id = g_strdup_printf ("%s/%s", upstream_id, stream->stream_id);
+
+ gst_event_unref (event);
+ event = gst_event_new_stream_start (stream_id);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return gst_pad_push_event (stream->srcpad, event);
+}
+
/* this is the final event function we receive on the internal source pad when
* we deal with TCP connections */
static gboolean
@@ -2544,6 +2586,7 @@ new_manager_pad (GstElement * manager, GstPad * pad, GstRTSPSrc * src)
GList *ostreams;
GstRTSPStream *stream;
gboolean all_added;
+ GstPad *internal_src;
GST_DEBUG_OBJECT (src, "got new manager pad %" GST_PTR_FORMAT, pad);
@@ -2588,6 +2631,13 @@ new_manager_pad (GstElement * manager, GstPad * pad, GstRTSPSrc * src)
gst_object_unref (template);
g_free (name);
+ /* We intercept and modify the stream start event */
+ internal_src =
+ GST_PAD (gst_proxy_pad_get_internal (GST_PROXY_PAD (stream->srcpad)));
+ gst_pad_set_element_private (internal_src, stream);
+ gst_pad_set_event_function (internal_src, gst_rtspsrc_handle_src_sink_event);
+ gst_object_unref (internal_src);
+
gst_pad_set_event_function (stream->srcpad, gst_rtspsrc_handle_src_event);
gst_pad_set_query_function (stream->srcpad, gst_rtspsrc_handle_src_query);
gst_pad_set_active (stream->srcpad, TRUE);
diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h
index 88bf305e8..cb7134278 100644
--- a/gst/rtsp/gstrtspsrc.h
+++ b/gst/rtsp/gstrtspsrc.h
@@ -158,6 +158,9 @@ struct _GstRTSPStream {
gboolean is_multicast;
guint ttl;
+ /* A unique and stable id we will use for the stream start event */
+ gchar *stream_id;
+
GstStructure *rtx_pt_map;
};