From 159093cd6a4cd4d2d6faad392c8bf7a81bb5c552 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 20 Jul 2011 09:09:25 +0200 Subject: [PATCH] basevideoencoder: Add ::reset vfunc and handle ::reset/::finish the same way as in the decoder --- omx/gstbasevideoencoder.c | 19 ++++++++++++++++--- omx/gstbasevideoencoder.h | 9 ++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/omx/gstbasevideoencoder.c b/omx/gstbasevideoencoder.c index f2e7584..75e7a99 100644 --- a/omx/gstbasevideoencoder.c +++ b/omx/gstbasevideoencoder.c @@ -239,9 +239,9 @@ gst_base_video_encoder_drain (GstBaseVideoEncoder * enc) return TRUE; } - if (enc_class->finish) { + if (enc_class->reset) { GST_DEBUG_OBJECT (enc, "requesting subclass to finish"); - ret = enc_class->finish (enc); + ret = enc_class->reset (enc); } /* everything should be away now */ if (codec->frames) { @@ -366,13 +366,26 @@ static gboolean gst_base_video_encoder_sink_eventfunc (GstBaseVideoEncoder * base_video_encoder, GstEvent * event) { + GstBaseVideoEncoderClass *base_video_encoder_class; gboolean ret = FALSE; + base_video_encoder_class = + GST_BASE_VIDEO_ENCODER_GET_CLASS (base_video_encoder); + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: { + GstFlowReturn flow_ret; + base_video_encoder->a.at_eos = TRUE; - gst_base_video_encoder_drain (base_video_encoder); + + if (base_video_encoder_class->finish) { + flow_ret = base_video_encoder_class->finish (base_video_encoder); + } else { + flow_ret = GST_FLOW_OK; + } + + ret = (flow_ret == GST_BASE_VIDEO_ENCODER_FLOW_DROPPED); break; } case GST_EVENT_NEWSEGMENT: diff --git a/omx/gstbasevideoencoder.h b/omx/gstbasevideoencoder.h index 17df4a6..5eeb2e3 100644 --- a/omx/gstbasevideoencoder.h +++ b/omx/gstbasevideoencoder.h @@ -58,6 +58,12 @@ G_BEGIN_DECLS */ #define GST_BASE_VIDEO_ENCODER_SRC_NAME "src" +/** + * GST_BASE_VIDEO_ENCODER_FLOW_DROPPED: + * + * Returned when the event/buffer should be dropped. + */ +#define GST_BASE_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1 typedef struct _GstBaseVideoEncoder GstBaseVideoEncoder; typedef struct _GstBaseVideoEncoderClass GstBaseVideoEncoderClass; @@ -148,7 +154,8 @@ struct _GstBaseVideoEncoderClass GstFlowReturn (*handle_frame) (GstBaseVideoEncoder *coder, GstVideoFrame *frame); - gboolean (*finish) (GstBaseVideoEncoder *coder); + gboolean (*reset) (GstBaseVideoEncoder *coder); + GstFlowReturn (*finish) (GstBaseVideoEncoder *coder); GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder, GstVideoFrame *frame); -- 2.7.4