diff options
author | Nicolas Dufresne <nicolas@ndufresne.ca> | 2018-09-13 02:35:39 +0000 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-11-07 19:50:42 -0500 |
commit | 6ff07230652b1e181d79bddc71ea72e69e3d4e09 (patch) | |
tree | 1791e13ab84d6ac15270367fbf9bf3428b1a79bb | |
parent | 4de11b56853f17f8f78ba2d613d2e8a39b94e333 (diff) | |
download | gstreamer-plugins-good-6ff07230652b1e181d79bddc71ea72e69e3d4e09.tar.gz |
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.
-rw-r--r-- | sys/v4l2/gstv4l2videodec.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c index 838ebff24..d6159d3fd 100644 --- a/sys/v4l2/gstv4l2videodec.c +++ b/sys/v4l2/gstv4l2videodec.c @@ -129,12 +129,6 @@ gst_v4l2_video_dec_open (GstVideoDecoder * decoder) if (gst_caps_is_empty (self->probed_sinkcaps)) 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; no_encoded_format: @@ -143,13 +137,6 @@ no_encoded_format: self->v4l2output->videodev), (NULL)); 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: if (GST_V4L2_IS_OPEN (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); + 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) self->input_state = gst_video_codec_state_ref (state); else @@ -281,6 +275,12 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder, done: 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 @@ -640,8 +640,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder, gst_structure_remove_field (st, "format"); /* Probe currently available pixel formats */ - available_caps = gst_v4l2_object_probe_caps (self->v4l2capture, NULL); - available_caps = gst_caps_make_writable (available_caps); + available_caps = gst_caps_copy (self->probed_srccaps); GST_DEBUG_OBJECT (self, "Available caps: %" GST_PTR_FORMAT, available_caps); /* Replace coded size with visible size, we want to negotiate visible size |