basevideodecoder: invoke subclass start method at state change and use set_format

While this changes API slightly (e.g. actually uses set_format now), which is OK
for unstable API, it has following merits:
* symmetric w.r.t. stop at state change
* in line with other base class practice
* otherwise no subclass method at state change (global activation time)
Moreover, subclassese are either unaffected or trivially adjusted accordingly.
This commit is contained in:
Mark Nauwelaerts 2011-03-29 10:41:54 +02:00
parent 04a34b4ab7
commit f591361d2f
3 changed files with 22 additions and 13 deletions

View file

@ -98,6 +98,8 @@ static void gst_vp8_dec_get_property (GObject * object, guint prop_id,
static gboolean gst_vp8_dec_start (GstBaseVideoDecoder * decoder);
static gboolean gst_vp8_dec_stop (GstBaseVideoDecoder * decoder);
static gboolean gst_vp8_dec_set_format (GstBaseVideoDecoder * decoder,
GstVideoState * state);
static gboolean gst_vp8_dec_reset (GstBaseVideoDecoder * decoder);
static GstFlowReturn gst_vp8_dec_parse_data (GstBaseVideoDecoder * decoder,
gboolean at_eos);
@ -175,6 +177,7 @@ gst_vp8_dec_class_init (GstVP8DecClass * klass)
base_video_decoder_class->start = gst_vp8_dec_start;
base_video_decoder_class->stop = gst_vp8_dec_stop;
base_video_decoder_class->reset = gst_vp8_dec_reset;
base_video_decoder_class->set_format = gst_vp8_dec_set_format;
base_video_decoder_class->parse_data = gst_vp8_dec_parse_data;
base_video_decoder_class->handle_frame = gst_vp8_dec_handle_frame;
@ -274,6 +277,17 @@ gst_vp8_dec_stop (GstBaseVideoDecoder * base_video_decoder)
return TRUE;
}
static gboolean
gst_vp8_dec_set_format (GstBaseVideoDecoder * decoder, GstVideoState * state)
{
GstVP8Dec *gst_vp8_dec = GST_VP8_DEC (decoder);
GST_DEBUG_OBJECT (gst_vp8_dec, "set_format");
gst_vp8_dec->decoder_inited = FALSE;
return TRUE;
}
static gboolean
gst_vp8_dec_reset (GstBaseVideoDecoder * base_video_decoder)
{

View file

@ -161,8 +161,9 @@ gst_base_video_decoder_sink_setcaps (GstPad * pad, GstCaps * caps)
state->codec_data = gst_value_get_buffer (codec_data);
}
if (base_video_decoder_class->start) {
ret = base_video_decoder_class->start (base_video_decoder);
if (base_video_decoder_class->set_format) {
ret = base_video_decoder_class->set_format (base_video_decoder,
&GST_BASE_VIDEO_CODEC (base_video_decoder)->state);
}
g_object_unref (base_video_decoder);
@ -728,8 +729,6 @@ gst_base_video_decoder_reset (GstBaseVideoDecoder * base_video_decoder)
GST_DEBUG_OBJECT (base_video_decoder, "reset");
base_video_decoder->started = FALSE;
base_video_decoder->discont = TRUE;
base_video_decoder->have_sync = FALSE;
@ -818,11 +817,6 @@ gst_base_video_decoder_chain (GstPad * pad, GstBuffer * buf)
gst_base_video_decoder_reset (base_video_decoder);
}
if (!base_video_decoder->started) {
klass->start (base_video_decoder);
base_video_decoder->started = TRUE;
}
if (base_video_decoder->current_frame == NULL) {
base_video_decoder->current_frame =
gst_base_video_decoder_new_frame (base_video_decoder);
@ -917,6 +911,10 @@ gst_base_video_decoder_change_state (GstElement * element,
base_video_decoder_class = GST_BASE_VIDEO_DECODER_GET_CLASS (element);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (base_video_decoder_class->start) {
base_video_decoder_class->start (base_video_decoder);
}
default:
break;
}

View file

@ -75,7 +75,6 @@ struct _GstBaseVideoDecoder
gboolean have_sync;
gboolean discont;
gboolean started;
gboolean sink_clipping;
gboolean do_byte_time;
@ -117,9 +116,7 @@ struct _GstBaseVideoDecoderClass
{
GstBaseVideoCodecClass base_video_codec_class;
gboolean (*set_format) (GstBaseVideoDecoder *coder, GstVideoFormat,
int width, int height, int fps_n, int fps_d,
int par_n, int par_d);
gboolean (*set_format) (GstBaseVideoDecoder *coder, GstVideoState * state);
gboolean (*start) (GstBaseVideoDecoder *coder);
gboolean (*stop) (GstBaseVideoDecoder *coder);
gboolean (*reset) (GstBaseVideoDecoder *coder);