dtlssrtpdec: Don't merge RTP and RTCP streams that were just split by srtpdec

The funnel has some overhead, and later rtpbin will have to split both streams
again anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=748723
This commit is contained in:
Sebastian Dröge 2015-05-07 21:04:30 +02:00
parent 541c3049dc
commit c534c8899c
2 changed files with 31 additions and 72 deletions

View file

@ -37,10 +37,17 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate rtp_src_template =
GST_STATIC_PAD_TEMPLATE ("rtp_src",
GST_STATIC_PAD_TEMPLATE ("rtp_src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp;application/x-rtcp")
GST_STATIC_CAPS ("application/x-rtp")
);
static GstStaticPadTemplate rtcp_src_template =
GST_STATIC_PAD_TEMPLATE ("rtcp_src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtcp")
);
static GstStaticPadTemplate data_src_template =
@ -86,9 +93,6 @@ static void gst_dtls_srtp_dec_remove_dtls_element (GstDtlsSrtpBin *);
static GstPadProbeReturn remove_dtls_decoder_probe_callback (GstPad *,
GstPadProbeInfo *, GstElement *);
static GstPadProbeReturn drop_funnel_rtcp_caps (GstPad *, GstPadProbeInfo *,
gpointer);
static void
gst_dtls_srtp_dec_class_init (GstDtlsSrtpDecClass * klass)
{
@ -129,6 +133,8 @@ gst_dtls_srtp_dec_class_init (GstDtlsSrtpDecClass * klass)
gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtp_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtcp_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&data_src_template));
@ -144,19 +150,19 @@ gst_dtls_srtp_dec_init (GstDtlsSrtpDec * self)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (GST_ELEMENT (self));
GstPadTemplate *templ;
GstPad *target_pad, *ghost_pad, *pad;
GstPad *target_pad, *ghost_pad;
gboolean ret;
/*
+--------------------+
+--------------+ .-o| dtlsdec |o-R----------data
| dtls|o-' +--------------------+
+-----------+
+--------------+ .-o| dtlsdec |o-R----data
| dtls|o-' +-----------+
sink---o| dtlsdemux |
| srt(c)p|o-. +-----------+ +-----------+
+--------------+ '-o|srtp rtp|o---o|rtp |
| srtpdec | | funnel |o---rt(c)p
o|srtcp rtcp|o---o|rtcp |
+-----------+ +-----------+
| srt(c)p|o-. +-----------+
+--------------+ '-o|srtp rtp|o------rtp
| srtpdec |
o|srtcp rtcp|o------rtcp
+-----------+
*/
self->srtp_dec = gst_element_factory_make ("srtpdec", "srtp-decoder");
@ -176,15 +182,9 @@ gst_dtls_srtp_dec_init (GstDtlsSrtpDec * self)
GST_ERROR_OBJECT (self, "failed to create dtls_dec");
return;
}
self->funnel = gst_element_factory_make ("funnel", "funnel");
if (!self->funnel) {
GST_ERROR_OBJECT (self, "failed to create funnel");
return;
}
gst_bin_add_many (GST_BIN (self),
self->dtls_srtp_demux,
self->bin.dtls_element, self->srtp_dec, self->funnel, NULL);
self->dtls_srtp_demux, self->bin.dtls_element, self->srtp_dec, NULL);
ret =
gst_element_link_pads (self->dtls_srtp_demux, "dtls_src",
@ -194,21 +194,9 @@ gst_dtls_srtp_dec_init (GstDtlsSrtpDec * self)
gst_element_link_pads (self->dtls_srtp_demux, "rtp_src", self->srtp_dec,
"rtp_sink");
g_return_if_fail (ret);
ret =
gst_element_link_pads (self->srtp_dec, "rtp_src", self->funnel, "sink_0");
g_return_if_fail (ret);
ret =
gst_element_link_pads (self->srtp_dec, "rtcp_src", self->funnel,
"sink_1");
g_return_if_fail (ret);
pad = gst_element_get_static_pad (self->funnel, "sink_1");
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
drop_funnel_rtcp_caps, NULL, NULL);
gst_object_unref (pad);
templ = gst_element_class_get_pad_template (klass, "rtp_src");
target_pad = gst_element_get_static_pad (self->funnel, "src");
target_pad = gst_element_get_static_pad (self->srtp_dec, "rtp_src");
ghost_pad = gst_ghost_pad_new_from_template ("rtp_src", target_pad, templ);
gst_object_unref (target_pad);
g_return_if_fail (ghost_pad);
@ -216,6 +204,15 @@ gst_dtls_srtp_dec_init (GstDtlsSrtpDec * self)
ret = gst_element_add_pad (GST_ELEMENT (self), ghost_pad);
g_return_if_fail (ret);
templ = gst_element_class_get_pad_template (klass, "rtcp_src");
target_pad = gst_element_get_static_pad (self->srtp_dec, "rtcp_src");
ghost_pad = gst_ghost_pad_new_from_template ("rtcp_src", target_pad, templ);
gst_object_unref (target_pad);
g_return_if_fail (ghost_pad);
ret = gst_element_add_pad (GST_ELEMENT (self), ghost_pad);
g_return_if_fail (ret);
templ = gst_element_class_get_pad_template (klass, "sink");
target_pad = gst_element_get_static_pad (self->dtls_srtp_demux, "sink");
ghost_pad = gst_ghost_pad_new_from_template ("sink", target_pad, templ);
@ -437,40 +434,3 @@ remove_dtls_decoder_probe_callback (GstPad * pad,
return GST_PAD_PROBE_OK;
}
static GstPadProbeReturn
drop_funnel_rtcp_caps (GstPad * pad, GstPadProbeInfo * info, gpointer data)
{
/* FIXME: This is needed for setting the proper caps until
* GStreamer supports MIXED caps or another mechanism to
* prevent renegotiation all the time when two different caps
* are going over the same pad
*/
if (GST_EVENT_TYPE (info->data) == GST_EVENT_CAPS) {
GstCaps *caps, *peercaps;
GstStructure *s;
gst_event_parse_caps (GST_EVENT (info->data), &caps);
s = gst_caps_get_structure (caps, 0);
if (gst_structure_has_name (s, "application/x-rtcp")) {
peercaps = gst_pad_query_caps (pad, NULL);
/* If the peer does not accept RTCP, we are linked to
* the RTP sinkpad of rtpbin. In that case we have to
* drop the RTCP caps and assume that we sent RTP caps
* before here, which is very likely but not guaranteed
* if for some reason we receive RTCP before any RTP.
* In that unlikely case we will get event misordering
* warnings later, instead of getting them always as
* happens now.
*/
if (peercaps && !gst_caps_is_subset (caps, peercaps)) {
gst_caps_unref (peercaps);
return GST_PAD_PROBE_DROP;
}
gst_caps_replace (&peercaps, NULL);
}
}
return GST_PAD_PROBE_OK;
}

View file

@ -46,7 +46,6 @@ struct _GstDtlsSrtpDec {
GstElement *dtls_srtp_demux;
GstElement *srtp_dec;
GstElement *funnel;
};
struct _GstDtlsSrtpDecClass {