GstV4l2CodecPool *src_pool;
gint min_pool_size;
gboolean has_videometa;
- gboolean need_negotiation;
+ gboolean streaming;
gboolean interlaced;
gboolean need_sequence;
gboolean copy_frames;
}
static void
+gst_v4l2_codec_h264_dec_streamoff (GstV4l2CodecH264Dec * self)
+{
+ if (self->streaming) {
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
+ self->streaming = FALSE;
+ }
+}
+
+static void
gst_v4l2_codec_h264_dec_reset_allocation (GstV4l2CodecH264Dec * self)
{
if (self->sink_allocator) {
{
GstV4l2CodecH264Dec *self = GST_V4L2_CODEC_H264_DEC (decoder);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
+ gst_v4l2_codec_h264_dec_streamoff (self);
gst_v4l2_codec_h264_dec_reset_allocation (self);
if (self->output_state)
GstCaps *filter, *caps;
/* Ignore downstream renegotiation request. */
- if (!self->need_negotiation)
- return TRUE;
- self->need_negotiation = FALSE;
+ if (self->streaming)
+ goto done;
GST_DEBUG_OBJECT (self, "Negotiate");
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
gst_v4l2_codec_h264_dec_reset_allocation (self);
if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_H264_SLICE,
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
+done:
self->output_state =
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (self),
self->vinfo.finfo->format, self->display_width,
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
+ if (self->streaming)
+ return TRUE;
+
if (!gst_v4l2_decoder_streamon (self->decoder, GST_PAD_SINK)) {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Could not enable the decoder driver."),
return FALSE;
}
+ self->streaming = TRUE;
+
return TRUE;
}
GstV4l2CodecH264Dec *self = GST_V4L2_CODEC_H264_DEC (decoder);
guint min = 0, num_bitstream;
+ /* If we are streaming here, then it means there is nothing allocation
+ * related in the new state and allocation can be ignored */
+ if (self->streaming)
+ return TRUE;
+
self->has_videometa = gst_query_find_allocation_meta (query,
GST_VIDEO_META_API_TYPE, NULL);
self->need_sequence = TRUE;
if (negotiation_needed) {
- self->need_negotiation = TRUE;
+ gst_v4l2_codec_h264_dec_streamoff (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
return GST_FLOW_NOT_NEGOTIATED;
GstV4l2Request *request = gst_h264_picture_get_user_data (picture);
gint ret;
+ if (picture->discont_state) {
+ if (!gst_video_decoder_negotiate (vdec)) {
+ GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
+ return FALSE;
+ }
+ }
+
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
ret = gst_v4l2_request_set_done (request);
GstV4l2CodecPool *src_pool;
gint min_pool_size;
gboolean has_videometa;
- gboolean need_negotiation;
+ gboolean streaming;
gboolean copy_frames;
gboolean need_sequence;
}
static void
+gst_v4l2_codec_h265_dec_streamoff (GstV4l2CodecH265Dec * self)
+{
+ if (self->streaming) {
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
+ self->streaming = FALSE;
+ }
+}
+
+static void
gst_v4l2_codec_h265_dec_reset_allocation (GstV4l2CodecH265Dec * self)
{
if (self->sink_allocator) {
{
GstV4l2CodecH265Dec *self = GST_V4L2_CODEC_H265_DEC (decoder);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
+ gst_v4l2_codec_h265_dec_streamoff (self);
gst_v4l2_codec_h265_dec_reset_allocation (self);
if (self->output_state)
GstCaps *filter, *caps;
/* Ignore downstream renegotiation request. */
- if (!self->need_negotiation)
- return TRUE;
- self->need_negotiation = FALSE;
+ if (self->streaming)
+ goto done;
GST_DEBUG_OBJECT (self, "Negotiate");
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
gst_v4l2_codec_h265_dec_reset_allocation (self);
if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_HEVC_SLICE,
}
gst_caps_unref (caps);
+done:
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
+ if (self->streaming)
+ return TRUE;
+
if (!gst_v4l2_decoder_streamon (self->decoder, GST_PAD_SINK)) {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Could not enable the decoder driver."),
return FALSE;
}
+ self->streaming = TRUE;
+
return TRUE;
}
GstV4l2CodecH265Dec *self = GST_V4L2_CODEC_H265_DEC (decoder);
guint min = 0;
+ if (self->streaming)
+ return TRUE;
+
self->has_videometa = gst_query_find_allocation_meta (query,
GST_VIDEO_META_API_TYPE, NULL);
gst_v4l2_codec_h265_dec_fill_sequence (self, sps);
if (negotiation_needed) {
- self->need_negotiation = TRUE;
+ gst_v4l2_codec_h265_dec_streamoff (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
return GST_FLOW_NOT_NEGOTIATED;
GstVideoCodecFrame * frame, GstH265Picture * picture)
{
GstV4l2CodecH265Dec *self = GST_V4L2_CODEC_H265_DEC (decoder);
+ GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
GstV4l2Request *request = gst_h265_picture_get_user_data (picture);
gint ret;
+ if (picture->discont_state) {
+ if (!gst_video_decoder_negotiate (vdec)) {
+ GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
+ return FALSE;
+ }
+ }
+
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
ret = gst_v4l2_request_set_done (request);
gst_h265_picture_unref (picture);
- return gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame);
+ return gst_video_decoder_finish_frame (vdec, frame);
error:
- gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame);
+ gst_video_decoder_drop_frame (vdec, frame);
gst_h265_picture_unref (picture);
return GST_FLOW_ERROR;
GstV4l2CodecPool *src_pool;
gint min_pool_size;
gboolean has_videometa;
- gboolean need_negotiation;
+ gboolean streaming;
GstMemory *bitstream;
GstMapInfo bitstream_map;
}
static void
+gst_v4l2_codec_mpeg2_dec_streamoff (GstV4l2CodecMpeg2Dec * self)
+{
+ if (self->streaming) {
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
+ self->streaming = FALSE;
+ }
+}
+
+static void
gst_v4l2_codec_mpeg2_dec_reset_allocation (GstV4l2CodecMpeg2Dec * self)
{
if (self->sink_allocator) {
{
GstV4l2CodecMpeg2Dec *self = GST_V4L2_CODEC_MPEG2_DEC (decoder);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
+ gst_v4l2_codec_mpeg2_dec_streamoff (self);
gst_v4l2_codec_mpeg2_dec_reset_allocation (self);
if (self->output_state)
GstCaps *filter, *caps;
/* Ignore downstream renegotiation request. */
- if (!self->need_negotiation)
- return TRUE;
- self->need_negotiation = FALSE;
+ if (self->streaming)
+ goto done;
GST_DEBUG_OBJECT (self, "Negotiate");
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
gst_v4l2_codec_mpeg2_dec_reset_allocation (self);
if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_MPEG2_SLICE,
}
gst_caps_unref (caps);
+done:
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
+ if (self->streaming)
+ return TRUE;
+
if (!gst_v4l2_decoder_streamon (self->decoder, GST_PAD_SINK)) {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Could not enable the decoder driver."),
return FALSE;
}
+ self->streaming = TRUE;
+
return TRUE;
}
GST_INFO_OBJECT (self, "Profile change %d -> %d",
self->profile, mpeg_profile);
self->profile = mpeg_profile;
- self->need_negotiation = TRUE;
+ self->streaming = TRUE;
}
if (self->vinfo.finfo->format == GST_VIDEO_FORMAT_UNKNOWN)
/* *INDENT-ON* */
if (negotiation_needed) {
- self->need_negotiation = TRUE;
+ gst_v4l2_codec_mpeg2_dec_streamoff (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
return GST_FLOW_ERROR;
GstV4l2Request *request = gst_mpeg2_picture_get_user_data (picture);
gint ret;
+ if (picture->discont_state) {
+ if (!gst_video_decoder_negotiate (vdec)) {
+ GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
+ return FALSE;
+ }
+ }
+
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
ret = gst_v4l2_request_set_done (request);
GstV4l2CodecPool *src_pool;
gint min_pool_size;
gboolean has_videometa;
- gboolean need_negotiation;
+ gboolean streaming;
gboolean copy_frames;
struct v4l2_ctrl_vp8_frame frame_header;
}
static void
+gst_v4l2_codec_vp8_dec_streamoff (GstV4l2CodecVp8Dec * self)
+{
+ if (self->streaming) {
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
+ self->streaming = FALSE;
+ }
+}
+
+static void
gst_v4l2_codec_vp8_dec_reset_allocation (GstV4l2CodecVp8Dec * self)
{
if (self->sink_allocator) {
{
GstV4l2CodecVp8Dec *self = GST_V4L2_CODEC_VP8_DEC (decoder);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
+ gst_v4l2_codec_vp8_dec_streamoff (self);
gst_v4l2_codec_vp8_dec_reset_allocation (self);
if (self->output_state)
GstCaps *filter, *caps;
/* Ignore downstream renegotiation request. */
- if (!self->need_negotiation)
- return TRUE;
- self->need_negotiation = FALSE;
+ if (self->streaming)
+ goto done;
GST_DEBUG_OBJECT (self, "Negotiate");
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
gst_v4l2_codec_vp8_dec_reset_allocation (self);
if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_VP8_FRAME,
}
gst_caps_unref (caps);
+done:
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
+ if (self->streaming)
+ return TRUE;
+
if (!gst_v4l2_decoder_streamon (self->decoder, GST_PAD_SINK)) {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Could not enable the decoder driver."),
return FALSE;
}
+ self->streaming = TRUE;
+
return TRUE;
}
guint min = 0;
guint num_bitstream;
+ if (self->streaming)
+ return TRUE;
+
self->has_videometa = gst_query_find_allocation_meta (query,
GST_VIDEO_META_API_TYPE, NULL);
gst_v4l2_codec_vp8_dec_fill_frame_header (self, frame_hdr);
if (negotiation_needed) {
- self->need_negotiation = TRUE;
+ gst_v4l2_codec_vp8_dec_streamoff (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
return GST_FLOW_NOT_NEGOTIATED;
GstV4l2Request *request = gst_vp8_picture_get_user_data (picture);
gint ret;
+ if (picture->discont_state) {
+ if (!gst_video_decoder_negotiate (vdec)) {
+ GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
+ return FALSE;
+ }
+ }
+
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
ret = gst_v4l2_request_set_done (request);
GstV4l2CodecAllocator *src_allocator;
GstV4l2CodecPool *src_pool;
gboolean has_videometa;
- gboolean need_negotiation;
+ gboolean streaming;
gboolean copy_frames;
struct v4l2_ctrl_vp9_frame v4l2_vp9_frame;
}
static void
+gst_v4l2_codec_vp9_dec_streamoff (GstV4l2CodecVp9Dec * self)
+{
+ if (self->streaming) {
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
+ gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
+ self->streaming = FALSE;
+ }
+}
+
+static void
gst_v4l2_codec_vp9_dec_reset_allocation (GstV4l2CodecVp9Dec * self)
{
if (self->sink_allocator) {
GstCaps *filter, *caps;
/* Ignore downstream renegotiation request. */
- if (!self->need_negotiation)
- return TRUE;
- self->need_negotiation = FALSE;
+ if (self->streaming)
+ goto done;
GST_DEBUG_OBJECT (self, "Negotiate");
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
- gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
-
gst_v4l2_codec_vp9_dec_reset_allocation (self);
if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_VP9_FRAME,
}
gst_caps_unref (caps);
+done:
if (self->output_state)
gst_video_codec_state_unref (self->output_state);
self->output_state->caps = gst_video_info_to_caps (&self->output_state->info);
if (GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder)) {
+ if (self->streaming)
+ return TRUE;
+
if (!gst_v4l2_decoder_streamon (self->decoder, GST_PAD_SINK)) {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Could not enable the decoder driver."),
return FALSE;
}
+ self->streaming = TRUE;
+
return TRUE;
}
gst_v4l2_codec_vp9_dec_fill_prob_updates (self, frame_hdr);
if (negotiation_needed) {
- self->need_negotiation = TRUE;
+ gst_v4l2_codec_vp9_dec_streamoff (self);
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (self))) {
GST_ERROR_OBJECT (self, "Failed to negotiate with downstream");
return GST_FLOW_ERROR;
GstV4l2Request *request = NULL;
gint ret;
+ if (picture->discont_state) {
+ if (!gst_video_decoder_negotiate (vdec)) {
+ GST_ERROR_OBJECT (vdec, "Could not re-negotiate with updated state");
+ return FALSE;
+ }
+ }
+
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
if (!GST_MINI_OBJECT_FLAG_IS_SET (picture, FLAG_PICTURE_HOLDS_BUFFER))