mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
rtpmux: Re-push sticky events on input pad change
This commit is contained in:
parent
21831b430f
commit
0c54079af5
2 changed files with 36 additions and 33 deletions
|
@ -171,8 +171,11 @@ gst_rtp_mux_class_init (GstRTPMuxClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_rtp_mux_dispose (GObject * object)
|
gst_rtp_mux_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
|
GstRTPMux *rtp_mux = GST_RTP_MUX (object);
|
||||||
GList *item;
|
GList *item;
|
||||||
|
|
||||||
|
g_clear_object (&rtp_mux->last_pad);
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
for (item = GST_ELEMENT_PADS (object); item; item = g_list_next (item)) {
|
for (item = GST_ELEMENT_PADS (object); item; item = g_list_next (item)) {
|
||||||
GstPad *pad = GST_PAD (item->data);
|
GstPad *pad = GST_PAD (item->data);
|
||||||
|
@ -238,7 +241,6 @@ static void
|
||||||
gst_rtp_mux_init (GstRTPMux * rtp_mux)
|
gst_rtp_mux_init (GstRTPMux * rtp_mux)
|
||||||
{
|
{
|
||||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (rtp_mux);
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (rtp_mux);
|
||||||
GstSegment segment;
|
|
||||||
|
|
||||||
rtp_mux->srcpad =
|
rtp_mux->srcpad =
|
||||||
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
|
||||||
|
@ -247,9 +249,6 @@ gst_rtp_mux_init (GstRTPMux * rtp_mux)
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_mux_src_event));
|
GST_DEBUG_FUNCPTR (gst_rtp_mux_src_event));
|
||||||
gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad);
|
gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad);
|
||||||
|
|
||||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
||||||
gst_pad_push_event (rtp_mux->srcpad, gst_event_new_segment (&segment));
|
|
||||||
|
|
||||||
rtp_mux->ssrc = DEFAULT_SSRC;
|
rtp_mux->ssrc = DEFAULT_SSRC;
|
||||||
rtp_mux->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
|
rtp_mux->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
|
||||||
rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
|
rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
|
||||||
|
@ -272,7 +271,7 @@ gst_rtp_mux_setup_sinkpad (GstRTPMux * rtp_mux, GstPad * sinkpad)
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_mux_sink_query));
|
GST_DEBUG_FUNCPTR (gst_rtp_mux_sink_query));
|
||||||
|
|
||||||
|
|
||||||
gst_segment_init (&padpriv->segment, GST_FORMAT_TIME);
|
gst_segment_init (&padpriv->segment, GST_FORMAT_UNDEFINED);
|
||||||
|
|
||||||
gst_pad_set_element_private (sinkpad, padpriv);
|
gst_pad_set_element_private (sinkpad, padpriv);
|
||||||
|
|
||||||
|
@ -319,7 +318,6 @@ gst_rtp_mux_release_pad (GstElement * element, GstPad * pad)
|
||||||
gst_element_remove_pad (element, pad);
|
gst_element_remove_pad (element, pad);
|
||||||
|
|
||||||
if (padpriv) {
|
if (padpriv) {
|
||||||
gst_caps_replace (&padpriv->out_caps, NULL);
|
|
||||||
g_slice_free (GstRTPMuxPadPrivate, padpriv);
|
g_slice_free (GstRTPMuxPadPrivate, padpriv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,14 +446,24 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
resend_events (GstPad * pad, GstEvent ** event, gpointer user_data)
|
||||||
|
{
|
||||||
|
GstRTPMux *rtp_mux = user_data;
|
||||||
|
|
||||||
|
gst_pad_push_event (rtp_mux->srcpad, gst_event_ref (*event));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
gst_rtp_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstRTPMux *rtp_mux;
|
GstRTPMux *rtp_mux;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstRTPMuxPadPrivate *padpriv;
|
GstRTPMuxPadPrivate *padpriv;
|
||||||
GstEvent *newseg_event = NULL;
|
|
||||||
gboolean drop;
|
gboolean drop;
|
||||||
|
gboolean changed = FALSE;
|
||||||
GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
|
GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
|
||||||
|
|
||||||
rtp_mux = GST_RTP_MUX (GST_OBJECT_PARENT (pad));
|
rtp_mux = GST_RTP_MUX (GST_OBJECT_PARENT (pad));
|
||||||
|
@ -484,6 +492,12 @@ gst_rtp_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
gst_rtp_buffer_unmap (&rtpbuffer);
|
gst_rtp_buffer_unmap (&rtpbuffer);
|
||||||
|
|
||||||
if (!drop) {
|
if (!drop) {
|
||||||
|
if (pad != rtp_mux->last_pad) {
|
||||||
|
changed = TRUE;
|
||||||
|
g_clear_object (&rtp_mux->last_pad);
|
||||||
|
rtp_mux->last_pad = g_object_ref (pad);
|
||||||
|
}
|
||||||
|
|
||||||
if (GST_BUFFER_DURATION_IS_VALID (buffer) &&
|
if (GST_BUFFER_DURATION_IS_VALID (buffer) &&
|
||||||
GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
|
GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
|
||||||
rtp_mux->last_stop = GST_BUFFER_TIMESTAMP (buffer) +
|
rtp_mux->last_stop = GST_BUFFER_TIMESTAMP (buffer) +
|
||||||
|
@ -494,8 +508,8 @@ gst_rtp_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (rtp_mux);
|
GST_OBJECT_UNLOCK (rtp_mux);
|
||||||
|
|
||||||
if (newseg_event)
|
if (changed)
|
||||||
gst_pad_push_event (rtp_mux->srcpad, newseg_event);
|
gst_pad_sticky_events_foreach (pad, resend_events, rtp_mux);
|
||||||
|
|
||||||
if (drop) {
|
if (drop) {
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
@ -544,13 +558,6 @@ gst_rtp_mux_setcaps (GstPad * pad, GstRTPMux * rtp_mux, GstCaps * caps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
GST_OBJECT_LOCK (rtp_mux);
|
|
||||||
padpriv = gst_pad_get_element_private (pad);
|
|
||||||
if (padpriv)
|
|
||||||
gst_caps_replace (&padpriv->out_caps, caps);
|
|
||||||
GST_OBJECT_UNLOCK (rtp_mux);
|
|
||||||
}
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -744,12 +751,8 @@ gst_rtp_mux_set_property (GObject * object,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
gst_rtp_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
{
|
{
|
||||||
|
GstRTPMux *mux = GST_RTP_MUX (parent);
|
||||||
GstRTPMux *mux;
|
gboolean is_pad;
|
||||||
gboolean ret = FALSE;
|
|
||||||
gboolean forward = TRUE;
|
|
||||||
|
|
||||||
mux = GST_RTP_MUX (parent);
|
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_CAPS:
|
case GST_EVENT_CAPS:
|
||||||
|
@ -757,9 +760,7 @@ gst_rtp_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
gst_event_parse_caps (event, &caps);
|
gst_event_parse_caps (event, &caps);
|
||||||
ret = gst_rtp_mux_setcaps (pad, mux, caps);
|
return gst_rtp_mux_setcaps (pad, mux, caps);
|
||||||
forward = FALSE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
{
|
{
|
||||||
|
@ -780,18 +781,20 @@ gst_rtp_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (mux);
|
GST_OBJECT_UNLOCK (mux);
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
forward = FALSE;
|
|
||||||
ret = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forward)
|
GST_OBJECT_LOCK (mux);
|
||||||
ret = gst_pad_push_event (mux->srcpad, event);
|
is_pad = (pad == mux->last_pad);
|
||||||
|
GST_OBJECT_UNLOCK (mux);
|
||||||
|
|
||||||
return ret;
|
if (is_pad)
|
||||||
|
return gst_pad_push_event (mux->srcpad, event);
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -800,6 +803,8 @@ gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (rtp_mux);
|
GST_OBJECT_LOCK (rtp_mux);
|
||||||
|
|
||||||
|
g_clear_object (&rtp_mux->last_pad);
|
||||||
|
|
||||||
if (rtp_mux->ssrc == -1)
|
if (rtp_mux->ssrc == -1)
|
||||||
rtp_mux->current_ssrc = g_random_int ();
|
rtp_mux->current_ssrc = g_random_int ();
|
||||||
else
|
else
|
||||||
|
|
|
@ -45,8 +45,6 @@ typedef struct
|
||||||
gboolean have_clock_base;
|
gboolean have_clock_base;
|
||||||
guint clock_base;
|
guint clock_base;
|
||||||
|
|
||||||
GstCaps *out_caps;
|
|
||||||
|
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
|
|
||||||
gboolean priority;
|
gboolean priority;
|
||||||
|
@ -74,7 +72,7 @@ struct _GstRTPMux
|
||||||
guint ssrc;
|
guint ssrc;
|
||||||
guint current_ssrc;
|
guint current_ssrc;
|
||||||
|
|
||||||
gboolean segment_pending;
|
GstPad *last_pad; /* protected by object lock */
|
||||||
|
|
||||||
GstClockTime last_stop;
|
GstClockTime last_stop;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue