mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
matroskamux: use GstCollectPads2 event callback
... in stead of local HACK.
This commit is contained in:
parent
97391f1402
commit
f6b38f2c39
2 changed files with 14 additions and 24 deletions
|
@ -224,6 +224,8 @@ static void gst_matroska_mux_finalize (GObject * object);
|
||||||
/* Pads collected callback */
|
/* Pads collected callback */
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_matroska_mux_collected (GstCollectPads2 * pads, gpointer user_data);
|
gst_matroska_mux_collected (GstCollectPads2 * pads, gpointer user_data);
|
||||||
|
static gboolean gst_matroska_mux_handle_sink_event (GstCollectPads2 * pads,
|
||||||
|
GstCollectData2 * data, GstEvent * event, gpointer user_data);
|
||||||
|
|
||||||
/* pad functions */
|
/* pad functions */
|
||||||
static gboolean gst_matroska_mux_handle_src_event (GstPad * pad,
|
static gboolean gst_matroska_mux_handle_src_event (GstPad * pad,
|
||||||
|
@ -454,6 +456,9 @@ gst_matroska_mux_init (GstMatroskaMux * mux, GstMatroskaMuxClass * g_class)
|
||||||
gst_collect_pads2_set_function (mux->collect,
|
gst_collect_pads2_set_function (mux->collect,
|
||||||
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_matroska_mux_collected),
|
(GstCollectPads2Function) GST_DEBUG_FUNCPTR (gst_matroska_mux_collected),
|
||||||
mux);
|
mux);
|
||||||
|
gst_collect_pads2_set_event_function (mux->collect,
|
||||||
|
(GstCollectPads2EventFunction) GST_DEBUG_FUNCPTR
|
||||||
|
(gst_matroska_mux_handle_sink_event), mux);
|
||||||
|
|
||||||
mux->ebml_write = gst_ebml_write_new (mux->srcpad);
|
mux->ebml_write = gst_ebml_write_new (mux->srcpad);
|
||||||
mux->doctype = GST_MATROSKA_DOCTYPE_MATROSKA;
|
mux->doctype = GST_MATROSKA_DOCTYPE_MATROSKA;
|
||||||
|
@ -709,15 +714,18 @@ gst_matroska_mux_handle_src_event (GstPad * pad, GstEvent * event)
|
||||||
* Returns: #TRUE on success.
|
* Returns: #TRUE on success.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
|
gst_matroska_mux_handle_sink_event (GstCollectPads2 * pads,
|
||||||
|
GstCollectData2 * data, GstEvent * event, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstMatroskaTrackContext *context;
|
GstMatroskaTrackContext *context;
|
||||||
GstMatroskaPad *collect_pad;
|
GstMatroskaPad *collect_pad;
|
||||||
GstMatroskaMux *mux;
|
GstMatroskaMux *mux;
|
||||||
|
GstPad *pad;
|
||||||
GstTagList *list;
|
GstTagList *list;
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
mux = GST_MATROSKA_MUX (gst_pad_get_parent (pad));
|
mux = GST_MATROSKA_MUX (user_data);
|
||||||
|
collect_pad = (GstMatroskaPad *) data;
|
||||||
|
pad = data->pad;
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_TAG:{
|
case GST_EVENT_TAG:{
|
||||||
|
@ -726,8 +734,6 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||||
GST_DEBUG_OBJECT (mux, "received tag event");
|
GST_DEBUG_OBJECT (mux, "received tag event");
|
||||||
gst_event_parse_tag (event, &list);
|
gst_event_parse_tag (event, &list);
|
||||||
|
|
||||||
collect_pad = (GstMatroskaPad *) gst_pad_get_element_private (pad);
|
|
||||||
g_assert (collect_pad);
|
|
||||||
context = collect_pad->track;
|
context = collect_pad->track;
|
||||||
g_assert (context);
|
g_assert (context);
|
||||||
|
|
||||||
|
@ -760,7 +766,6 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||||
gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
|
gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (format != GST_FORMAT_TIME) {
|
if (format != GST_FORMAT_TIME) {
|
||||||
ret = FALSE;
|
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
event = NULL;
|
event = NULL;
|
||||||
}
|
}
|
||||||
|
@ -783,11 +788,9 @@ gst_matroska_mux_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||||
|
|
||||||
/* now GstCollectPads2 can take care of the rest, e.g. EOS */
|
/* now GstCollectPads2 can take care of the rest, e.g. EOS */
|
||||||
if (event)
|
if (event)
|
||||||
ret = mux->collect_event (pad, event);
|
return FALSE;
|
||||||
|
else
|
||||||
gst_object_unref (mux);
|
return TRUE;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2015,18 +2018,6 @@ gst_matroska_mux_request_new_pad (GstElement * element,
|
||||||
collect_pad->track = context;
|
collect_pad->track = context;
|
||||||
gst_matroska_pad_reset (collect_pad, FALSE);
|
gst_matroska_pad_reset (collect_pad, FALSE);
|
||||||
|
|
||||||
/* FIXME: hacked way to override/extend the event function of
|
|
||||||
* GstCollectPads2; because it sets its own event function giving the
|
|
||||||
* element no access to events.
|
|
||||||
* TODO GstCollectPads2 should really give its 'users' a clean chance to
|
|
||||||
* properly handle events that are not meant for collectpads itself.
|
|
||||||
* Perhaps a callback or so, though rejected (?) in #340060.
|
|
||||||
* This would allow (clean) transcoding of info from demuxer/streams
|
|
||||||
* to another muxer */
|
|
||||||
mux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
|
|
||||||
gst_pad_set_event_function (GST_PAD (newpad),
|
|
||||||
GST_DEBUG_FUNCPTR (gst_matroska_mux_handle_sink_event));
|
|
||||||
|
|
||||||
gst_pad_set_setcaps_function (GST_PAD (newpad), setcapsfunc);
|
gst_pad_set_setcaps_function (GST_PAD (newpad), setcapsfunc);
|
||||||
gst_pad_set_active (GST_PAD (newpad), TRUE);
|
gst_pad_set_active (GST_PAD (newpad), TRUE);
|
||||||
if (!gst_element_add_pad (element, GST_PAD (newpad)))
|
if (!gst_element_add_pad (element, GST_PAD (newpad)))
|
||||||
|
|
|
@ -77,7 +77,6 @@ typedef struct _GstMatroskaMux {
|
||||||
/* pads */
|
/* pads */
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
GstCollectPads2 *collect;
|
GstCollectPads2 *collect;
|
||||||
GstPadEventFunction collect_event;
|
|
||||||
GstEbmlWrite *ebml_write;
|
GstEbmlWrite *ebml_write;
|
||||||
|
|
||||||
guint num_streams,
|
guint num_streams,
|
||||||
|
|
Loading…
Reference in a new issue