streamsplitter: Drop duplicated force-key-unit events

Forward force-key-unit event only once for the corresponding sequence number.
This commit is contained in:
Seungha Yang 2018-04-15 19:19:34 +09:00
parent 9af8516873
commit 41bad88d6d
2 changed files with 27 additions and 0 deletions

View file

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <gst/video/video.h>
#include "gststreamsplitter.h"
static GstStaticPadTemplate src_template =
@ -464,6 +465,29 @@ beach:
return res;
}
static gboolean
gst_stream_splitter_src_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{
GstStreamSplitter *stream_splitter = (GstStreamSplitter *) parent;
if (gst_video_event_is_force_key_unit (event)) {
guint32 seqnum = gst_event_get_seqnum (event);
STREAMS_LOCK (stream_splitter);
if (seqnum == stream_splitter->keyunit_seqnum) {
STREAMS_UNLOCK (stream_splitter);
GST_TRACE_OBJECT (pad,
"Drop duplicated force-key-unit event %" G_GUINT32_FORMAT, seqnum);
gst_event_unref (event);
return TRUE;
}
stream_splitter->keyunit_seqnum = seqnum;
STREAMS_UNLOCK (stream_splitter);
}
return gst_pad_event_default (pad, parent, event);
}
static void
gst_stream_splitter_init (GstStreamSplitter * stream_splitter)
{
@ -494,6 +518,7 @@ gst_stream_splitter_request_new_pad (GstElement * element,
gst_pad_set_active (srcpad, TRUE);
gst_element_add_pad (element, srcpad);
stream_splitter->cookie++;
gst_pad_set_event_function (srcpad, gst_stream_splitter_src_event);
STREAMS_UNLOCK (stream_splitter);
return srcpad;

View file

@ -49,6 +49,8 @@ struct _GstStreamSplitter {
/* List of pending in-band events */
GList *pending_events;
guint32 keyunit_seqnum;
};
struct _GstStreamSplitterClass {