diff --git a/sys/v4l2codecs/gstv4l2codech264dec.c b/sys/v4l2codecs/gstv4l2codech264dec.c index 37f7e7838a..db088a92c9 100644 --- a/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/sys/v4l2codecs/gstv4l2codech264dec.c @@ -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); diff --git a/sys/v4l2codecs/gstv4l2decoder.c b/sys/v4l2codecs/gstv4l2decoder.c index d80f7c7d58..beb2e56dbb 100644 --- a/sys/v4l2codecs/gstv4l2decoder.c +++ b/sys/v4l2codecs/gstv4l2decoder.c @@ -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) diff --git a/sys/v4l2codecs/gstv4l2decoder.h b/sys/v4l2codecs/gstv4l2decoder.h index 350d367661..72ecb23d03 100644 --- a/sys/v4l2codecs/gstv4l2decoder.h +++ b/sys/v4l2codecs/gstv4l2decoder.h @@ -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);