v4l2codecs: Implement flushing sequence

This simply consit of cycling through STREAMOFF/STREAMON with stateless
decoders.
This commit is contained in:
Nicolas Dufresne 2020-03-20 14:14:46 -04:00
parent f69283819a
commit 09a9ffcda6
3 changed files with 27 additions and 0 deletions

View file

@ -808,6 +808,18 @@ gst_v4l2_codec_h264_dec_decode_slice (GstH264Decoder * decoder,
return TRUE;
}
static gboolean
gst_v4l2_codec_h264_dec_flush (GstVideoDecoder * decoder)
{
GstV4l2CodecH264Dec *self = GST_V4L2_CODEC_H264_DEC (decoder);
GST_DEBUG_OBJECT (self, "Flushing decoder state.");
gst_v4l2_decoder_flush (self->decoder);
return GST_VIDEO_DECODER_CLASS (parent_class)->flush (decoder);
}
static void
gst_v4l2_codec_h264_dec_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@ -896,6 +908,7 @@ gst_v4l2_codec_h264_dec_subclass_init (GstV4l2CodecH264DecClass * klass,
GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_dec_negotiate);
decoder_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_dec_decide_allocation);
decoder_class->flush = GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_dec_flush);
h264decoder_class->new_sequence =
GST_DEBUG_FUNCPTR (gst_v4l2_codec_h264_dec_new_sequence);

View file

@ -199,6 +199,18 @@ gst_v4l2_decoder_streamoff (GstV4l2Decoder * self, GstPadDirection direction)
return TRUE;
}
gboolean
gst_v4l2_decoder_flush (GstV4l2Decoder * self)
{
/* We ignore streamoff failure as it's not relevant, if we manage to
* streamon again, we are good. */
gst_v4l2_decoder_streamoff (self, GST_PAD_SINK);
gst_v4l2_decoder_streamoff (self, GST_PAD_SRC);
return gst_v4l2_decoder_streamon (self, GST_PAD_SINK) &&
gst_v4l2_decoder_streamon (self, GST_PAD_SRC);
}
gboolean
gst_v4l2_decoder_enum_sink_fmt (GstV4l2Decoder * self, gint i,
guint32 * out_fmt)

View file

@ -45,6 +45,8 @@ gboolean gst_v4l2_decoder_streamon (GstV4l2Decoder * self,
gboolean gst_v4l2_decoder_streamoff (GstV4l2Decoder * self,
GstPadDirection direction);
gboolean gst_v4l2_decoder_flush (GstV4l2Decoder * self);
gboolean gst_v4l2_decoder_enum_sink_fmt (GstV4l2Decoder * self,
gint i, guint32 * out_fmt);