v4l2: Add helper to query input status

This is a wrapper around ENUM_INPUT renamed for readability.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/870>
This commit is contained in:
Nicolas Dufresne 2021-02-08 17:24:00 -05:00
parent ba3eddebc8
commit 293abe0675
2 changed files with 16 additions and 1 deletions

View file

@ -327,6 +327,7 @@ gboolean gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id *
gboolean gst_v4l2_set_norm (GstV4l2Object * v4l2object, v4l2_std_id norm);
gboolean gst_v4l2_get_input (GstV4l2Object * v4l2object, guint32 * input);
gboolean gst_v4l2_set_input (GstV4l2Object * v4l2object, guint32 input);
gboolean gst_v4l2_query_input (GstV4l2Object * v4l2object, struct v4l2_input * input);
gboolean gst_v4l2_get_output (GstV4l2Object * v4l2object, guint32 * output);
gboolean gst_v4l2_set_output (GstV4l2Object * v4l2object, guint32 output);
@ -341,7 +342,6 @@ gboolean gst_v4l2_set_attribute (GstV4l2Object * v4l2object, int attribute
gboolean gst_v4l2_set_string_attribute (GstV4l2Object * v4l2object, int attribute_num, const char *value);
gboolean gst_v4l2_set_controls (GstV4l2Object * v4l2object, GstStructure * controls);
/* events */
gboolean gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event);
gboolean gst_v4l2_dequeue_event (GstV4l2Object * v4l2object, struct v4l2_event *event);

View file

@ -1139,6 +1139,21 @@ input_failed:
return FALSE;
}
gboolean
gst_v4l2_query_input (GstV4l2Object * obj, struct v4l2_input * input)
{
gint ret;
ret = obj->ioctl (obj->video_fd, VIDIOC_ENUMINPUT, input);
if (ret < 0) {
GST_WARNING_OBJECT (obj->dbg_obj, "Failed to read input state: %s (%i)",
g_strerror (errno), errno);
return FALSE;
}
return TRUE;
}
gboolean
gst_v4l2_get_output (GstV4l2Object * v4l2object, guint32 * output)
{