mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-08 13:18:52 +00:00
basevideoencoder: add event virtual method to allow subclass event handling
This commit is contained in:
parent
16c6a49bd4
commit
294cecbc69
2 changed files with 38 additions and 35 deletions
|
@ -176,19 +176,15 @@ gst_base_video_encoder_finalize (GObject * object)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_base_video_encoder_sink_event (GstPad * pad, GstEvent * event)
|
gst_base_video_encoder_sink_eventfunc (GstBaseVideoEncoder * base_video_encoder,
|
||||||
|
GstEvent * event)
|
||||||
{
|
{
|
||||||
GstBaseVideoEncoder *base_video_encoder;
|
|
||||||
GstBaseVideoEncoderClass *base_video_encoder_class;
|
GstBaseVideoEncoderClass *base_video_encoder_class;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
base_video_encoder = GST_BASE_VIDEO_ENCODER (gst_pad_get_parent (pad));
|
|
||||||
base_video_encoder_class =
|
base_video_encoder_class =
|
||||||
GST_BASE_VIDEO_ENCODER_GET_CLASS (base_video_encoder);
|
GST_BASE_VIDEO_ENCODER_GET_CLASS (base_video_encoder);
|
||||||
|
|
||||||
GST_LOG_OBJECT (base_video_encoder, "handling event: %" GST_PTR_FORMAT,
|
|
||||||
event);
|
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
{
|
{
|
||||||
|
@ -196,12 +192,8 @@ gst_base_video_encoder_sink_event (GstPad * pad, GstEvent * event)
|
||||||
if (base_video_encoder_class->finish) {
|
if (base_video_encoder_class->finish) {
|
||||||
base_video_encoder_class->finish (base_video_encoder);
|
base_video_encoder_class->finish (base_video_encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret =
|
|
||||||
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder),
|
|
||||||
event);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GST_EVENT_NEWSEGMENT:
|
case GST_EVENT_NEWSEGMENT:
|
||||||
{
|
{
|
||||||
gboolean update;
|
gboolean update;
|
||||||
|
@ -221,20 +213,18 @@ gst_base_video_encoder_sink_event (GstPad * pad, GstEvent * event)
|
||||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
|
GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
|
||||||
GST_TIME_ARGS (position));
|
GST_TIME_ARGS (position));
|
||||||
|
|
||||||
if (format != GST_FORMAT_TIME)
|
if (format != GST_FORMAT_TIME) {
|
||||||
goto newseg_wrong_format;
|
GST_DEBUG_OBJECT (base_video_encoder, "received non TIME newsegment");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
base_video_encoder->a.at_eos = FALSE;
|
base_video_encoder->a.at_eos = FALSE;
|
||||||
|
|
||||||
gst_segment_set_newsegment_full (&GST_BASE_VIDEO_CODEC
|
gst_segment_set_newsegment_full (&GST_BASE_VIDEO_CODEC
|
||||||
(base_video_encoder)->segment, update, rate, applied_rate, format,
|
(base_video_encoder)->segment, update, rate, applied_rate, format,
|
||||||
start, stop, position);
|
start, stop, position);
|
||||||
|
|
||||||
ret =
|
|
||||||
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder),
|
|
||||||
event);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GST_EVENT_CUSTOM_DOWNSTREAM:
|
case GST_EVENT_CUSTOM_DOWNSTREAM:
|
||||||
{
|
{
|
||||||
const GstStructure *s;
|
const GstStructure *s;
|
||||||
|
@ -249,32 +239,44 @@ gst_base_video_encoder_sink_event (GstPad * pad, GstEvent * event)
|
||||||
base_video_encoder->force_keyunit_event = gst_event_copy (event);
|
base_video_encoder->force_keyunit_event = gst_event_copy (event);
|
||||||
GST_OBJECT_UNLOCK (base_video_encoder);
|
GST_OBJECT_UNLOCK (base_video_encoder);
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
ret = GST_FLOW_OK;
|
ret = TRUE;
|
||||||
} else {
|
|
||||||
ret =
|
|
||||||
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD
|
|
||||||
(base_video_encoder), event);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
/* FIXME this changes the order of events */
|
|
||||||
ret =
|
|
||||||
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_encoder),
|
|
||||||
event);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
|
||||||
gst_object_unref (base_video_encoder);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
newseg_wrong_format:
|
static gboolean
|
||||||
{
|
gst_base_video_encoder_sink_event (GstPad * pad, GstEvent * event)
|
||||||
GST_DEBUG_OBJECT (base_video_encoder, "received non TIME newsegment");
|
{
|
||||||
gst_event_unref (event);
|
GstBaseVideoEncoder *enc;
|
||||||
goto done;
|
GstBaseVideoEncoderClass *klass;
|
||||||
}
|
gboolean handled = FALSE;
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
|
enc = GST_BASE_VIDEO_ENCODER (gst_pad_get_parent (pad));
|
||||||
|
klass = GST_BASE_VIDEO_ENCODER_GET_CLASS (enc);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (enc, "received event %d, %s", GST_EVENT_TYPE (event),
|
||||||
|
GST_EVENT_TYPE_NAME (event));
|
||||||
|
|
||||||
|
if (klass->event)
|
||||||
|
handled = klass->event (enc, event);
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
handled = gst_base_video_encoder_sink_eventfunc (enc, event);
|
||||||
|
|
||||||
|
if (!handled)
|
||||||
|
ret = gst_pad_event_default (pad, event);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (enc, "event handled");
|
||||||
|
|
||||||
|
gst_object_unref (enc);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -96,6 +96,7 @@ struct _GstBaseVideoEncoderClass
|
||||||
gboolean (*finish) (GstBaseVideoEncoder *coder);
|
gboolean (*finish) (GstBaseVideoEncoder *coder);
|
||||||
gboolean (*handle_frame) (GstBaseVideoEncoder *coder, GstVideoFrame *frame);
|
gboolean (*handle_frame) (GstBaseVideoEncoder *coder, GstVideoFrame *frame);
|
||||||
GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder, GstVideoFrame *frame);
|
GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder, GstVideoFrame *frame);
|
||||||
|
gboolean (*event) (GstBaseVideoEncoder *coder, GstEvent *event);
|
||||||
GstCaps *(*get_caps) (GstBaseVideoEncoder *coder);
|
GstCaps *(*get_caps) (GstBaseVideoEncoder *coder);
|
||||||
|
|
||||||
/* FIXME before moving to base */
|
/* FIXME before moving to base */
|
||||||
|
|
Loading…
Reference in a new issue