From 76f489c5959b9b5b695baad7dac70d9b1e4230ba Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 5 Oct 2009 16:16:34 -0700 Subject: [PATCH] basevideo: Revert "Call GstBaseVideoEncoder::start/stop during pad [de]activation." This reverts commit 4c087bcb072dcc9847b11c00123cf93c5e541dcb. The reverted commit changes the order that set_format() and start() are called, which is incorrect. The correct order is set_format(), start(), handle_frame()..., stop() --- gst-libs/gst/video/gstbasevideoencoder.c | 55 +++--------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/gst-libs/gst/video/gstbasevideoencoder.c b/gst-libs/gst/video/gstbasevideoencoder.c index f22928220b..991981424c 100644 --- a/gst-libs/gst/video/gstbasevideoencoder.c +++ b/gst-libs/gst/video/gstbasevideoencoder.c @@ -27,8 +27,6 @@ GST_DEBUG_CATEGORY_EXTERN (basevideo_debug); #define GST_CAT_DEFAULT basevideo_debug -static gboolean gst_base_video_encoder_sink_activate (GstBaseVideoEncoder * - base_video_encoder, gboolean active); static void gst_base_video_encoder_finalize (GObject * object); static gboolean gst_base_video_encoder_sink_setcaps (GstPad * pad, @@ -43,8 +41,6 @@ static const GstQueryType *gst_base_video_encoder_get_query_types (GstPad * pad); static gboolean gst_base_video_encoder_src_query (GstPad * pad, GstQuery * query); -static gboolean gst_base_video_encoder_sink_activate_push (GstPad * pad, - gboolean active); static void _do_init (GType object_type) @@ -94,8 +90,6 @@ gst_base_video_encoder_init (GstBaseVideoEncoder * base_video_encoder, pad = GST_BASE_VIDEO_CODEC_SINK_PAD (base_video_encoder); - gst_pad_set_activatepush_function (pad, - gst_base_video_encoder_sink_activate_push); gst_pad_set_chain_function (pad, gst_base_video_encoder_chain); gst_pad_set_event_function (pad, gst_base_video_encoder_sink_event); gst_pad_set_setcaps_function (pad, gst_base_video_encoder_sink_setcaps); @@ -106,50 +100,6 @@ gst_base_video_encoder_init (GstBaseVideoEncoder * base_video_encoder, gst_pad_set_query_function (pad, gst_base_video_encoder_src_query); } -static gboolean -gst_base_video_encoder_sink_activate (GstBaseVideoEncoder * encoder, - gboolean active) -{ - GstBaseVideoEncoderClass *klass; - gboolean result = FALSE; - - GST_DEBUG_OBJECT (encoder, "activate"); - - klass = GST_BASE_VIDEO_ENCODER_GET_CLASS (encoder); - - if (active) { - if (klass->start) - result = klass->start (encoder); - } else { - /* We must make sure streaming has finished before resetting things - * and calling the ::stop vfunc */ - GST_PAD_STREAM_LOCK (GST_BASE_VIDEO_CODEC_SINK_PAD (encoder)); - GST_PAD_STREAM_UNLOCK (GST_BASE_VIDEO_CODEC_SINK_PAD (encoder)); - - if (klass->stop) - result = klass->stop (encoder); - } - - GST_DEBUG_OBJECT (encoder, "activate: %d", result); - - return result; -} - -static gboolean -gst_base_video_encoder_sink_activate_push (GstPad * pad, gboolean active) -{ - gboolean result = TRUE; - GstBaseVideoEncoder *base_video_encoder; - - base_video_encoder = GST_BASE_VIDEO_ENCODER (gst_pad_get_parent (pad)); - - result = gst_base_video_encoder_sink_activate (base_video_encoder, active); - - gst_object_unref (base_video_encoder); - - return result; -} - static gboolean gst_base_video_encoder_sink_setcaps (GstPad * pad, GstCaps * caps) { @@ -168,6 +118,8 @@ gst_base_video_encoder_sink_setcaps (GstPad * pad, GstCaps * caps) res = base_video_encoder_class->set_format (base_video_encoder, &base_video_encoder->state); + base_video_encoder_class->start (base_video_encoder); + g_object_unref (base_video_encoder); return res; @@ -419,6 +371,9 @@ gst_base_video_encoder_change_state (GstElement * element, switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: + if (base_video_encoder_class->stop) { + base_video_encoder_class->stop (base_video_encoder); + } break; default: break;