v4l2videodec: Move capture probe after input format is set

This is to support Amlogic CODEC driver which does not provide a full
list of formats when the driver is initially opened. GStreamer does
not strictly need this full list initially, but only later, in order
to negotiate with downstream if multiple format can be selected.

With this change, we will no longer probe twice the device, since the
probed list can be directly used for negotation.
This commit is contained in:
Nicolas Dufresne 2018-09-13 02:35:39 +00:00 committed by Nicolas Dufresne
parent 7f42b12e8c
commit 2510b5937d

View file

@ -129,12 +129,6 @@ gst_v4l2_video_dec_open (GstVideoDecoder * decoder)
if (gst_caps_is_empty (self->probed_sinkcaps)) if (gst_caps_is_empty (self->probed_sinkcaps))
goto no_encoded_format; goto no_encoded_format;
self->probed_srccaps = gst_v4l2_object_probe_caps (self->v4l2capture,
gst_v4l2_object_get_raw_caps ());
if (gst_caps_is_empty (self->probed_srccaps))
goto no_raw_format;
return TRUE; return TRUE;
no_encoded_format: no_encoded_format:
@ -143,13 +137,6 @@ no_encoded_format:
self->v4l2output->videodev), (NULL)); self->v4l2output->videodev), (NULL));
goto failure; goto failure;
no_raw_format:
GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
(_("Decoder on device %s has no supported output format"),
self->v4l2output->videodev), (NULL));
goto failure;
failure: failure:
if (GST_V4L2_IS_OPEN (self->v4l2output)) if (GST_V4L2_IS_OPEN (self->v4l2output))
gst_v4l2_object_close (self->v4l2output); gst_v4l2_object_close (self->v4l2output);
@ -274,6 +261,13 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder,
ret = gst_v4l2_object_set_format (self->v4l2output, state->caps, &error); ret = gst_v4l2_object_set_format (self->v4l2output, state->caps, &error);
gst_caps_replace (&self->probed_srccaps, NULL);
self->probed_srccaps = gst_v4l2_object_probe_caps (self->v4l2capture,
gst_v4l2_object_get_raw_caps ());
if (gst_caps_is_empty (self->probed_srccaps))
goto no_raw_format;
if (ret) if (ret)
self->input_state = gst_video_codec_state_ref (state); self->input_state = gst_video_codec_state_ref (state);
else else
@ -281,6 +275,12 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder,
done: done:
return ret; return ret;
no_raw_format:
GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
(_("Decoder on device %s has no supported output format"),
self->v4l2output->videodev), (NULL));
return GST_FLOW_ERROR;
} }
static gboolean static gboolean
@ -641,8 +641,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
gst_structure_remove_field (st, "format"); gst_structure_remove_field (st, "format");
/* Probe currently available pixel formats */ /* Probe currently available pixel formats */
available_caps = gst_v4l2_object_probe_caps (self->v4l2capture, NULL); available_caps = gst_caps_copy (self->probed_srccaps);
available_caps = gst_caps_make_writable (available_caps);
GST_DEBUG_OBJECT (self, "Available caps: %" GST_PTR_FORMAT, available_caps); GST_DEBUG_OBJECT (self, "Available caps: %" GST_PTR_FORMAT, available_caps);
/* Replace coded size with visible size, we want to negotiate visible size /* Replace coded size with visible size, we want to negotiate visible size