#include <gst/gst.h>
-GValue *
-gst_v4l2_codec_probe_profiles (const GstV4l2Codec * codec, gint video_fd)
+gboolean
+gst_v4l2_codec_probe_profiles (const GstV4l2Codec * codec, gint video_fd,
+ GValue * profiles)
{
- GValue *controls = NULL;
struct v4l2_queryctrl query_ctrl;
+ gboolean ret = FALSE;
memset (&query_ctrl, 0, sizeof (query_ctrl));
query_ctrl.id = codec->profile_cid;
if (ioctl (video_fd, VIDIOC_QUERYCTRL, &query_ctrl) == 0) {
- if (query_ctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
- return NULL;
- }
+ if (query_ctrl.flags & V4L2_CTRL_FLAG_DISABLED)
+ return FALSE;
if (query_ctrl.type == V4L2_CTRL_TYPE_MENU) {
struct v4l2_querymenu query_menu;
memset (&query_menu, 0, sizeof (query_menu));
query_menu.id = query_ctrl.id;
- controls = g_new0 (GValue, 1);
- g_value_init (controls, GST_TYPE_LIST);
+ g_value_init (profiles, GST_TYPE_LIST);
for (query_menu.index = query_ctrl.minimum;
query_menu.index <= query_ctrl.maximum; query_menu.index++) {
if (ioctl (video_fd, VIDIOC_QUERYMENU, &query_menu) >= 0) {
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value,
codec->profile_to_string (query_menu.index));
- gst_value_list_append_and_take_value (controls, &value);
+ gst_value_list_append_and_take_value (profiles, &value);
+ ret = TRUE;
}
}
- if (gst_value_list_get_size (controls) == 0) {
- g_value_unset (controls);
- controls = NULL;
+
+ if (gst_value_list_get_size (profiles) == 0) {
+ g_value_unset (profiles);
+ ret = FALSE;
}
}
}
- return controls;
+ return ret;
}
-GValue *
-gst_v4l2_codec_probe_levels (const GstV4l2Codec * codec, gint video_fd)
+gboolean
+gst_v4l2_codec_probe_levels (const GstV4l2Codec * codec, gint video_fd,
+ GValue * levels)
{
- GValue *controls = NULL;
struct v4l2_queryctrl query_ctrl;
+ gboolean ret = FALSE;
memset (&query_ctrl, 0, sizeof (query_ctrl));
query_ctrl.id = codec->level_cid;
if (ioctl (video_fd, VIDIOC_QUERYCTRL, &query_ctrl) == 0) {
- if (query_ctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
- return NULL;
- }
+ if (query_ctrl.flags & V4L2_CTRL_FLAG_DISABLED)
+ return FALSE;
if (query_ctrl.type == V4L2_CTRL_TYPE_MENU) {
struct v4l2_querymenu query_menu;
if (ioctl (video_fd, VIDIOC_QUERYMENU, &query_menu) >= 0) {
gint32 i;
- controls = g_new0 (GValue, 1);
- g_value_init (controls, GST_TYPE_LIST);
+ g_value_init (levels, GST_TYPE_LIST);
/* Assume that all levels below the highest one reported by the driver are supported. */
for (i = query_ctrl.minimum; i <= query_ctrl.maximum; i++) {
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, codec->level_to_string (i));
- gst_value_list_append_and_take_value (controls, &value);
+ gst_value_list_append_and_take_value (levels, &value);
+ ret = TRUE;
+ }
+
+ if (gst_value_list_get_size (levels) == 0) {
+ g_value_unset (levels);
+ ret = FALSE;
}
}
}
}
- return controls;
+ return ret;
}
}
if (cdata->codec != NULL) {
- GValue *value = gst_v4l2_codec_probe_levels (cdata->codec, video_fd);
- if (value != NULL) {
- gst_caps_set_value (cdata->sink_caps, "level", value);
- g_value_unset (value);
+ GValue value = G_VALUE_INIT;
+
+ if (gst_v4l2_codec_probe_levels (cdata->codec, video_fd, &value)) {
+ gst_caps_set_value (cdata->sink_caps, "level", &value);
+ g_value_unset (&value);
}
- value = gst_v4l2_codec_probe_profiles (cdata->codec, video_fd);
- if (value != NULL) {
- gst_caps_set_value (cdata->sink_caps, "profile", value);
- g_value_unset (value);
+ if (gst_v4l2_codec_probe_profiles (cdata->codec, video_fd, &value)) {
+ gst_caps_set_value (cdata->sink_caps, "profile", &value);
+ g_value_unset (&value);
}
}
GType subtype;
gchar *type_name;
GstV4l2VideoEncCData *cdata;
+ GValue value = G_VALUE_INIT;
if (codec != NULL && video_fd != -1) {
- GValue *value = gst_v4l2_codec_probe_levels (codec, video_fd);
- if (value != NULL) {
- gst_caps_set_value (src_caps, "level", value);
- g_value_unset (value);
+ if (gst_v4l2_codec_probe_levels (codec, video_fd, &value)) {
+ gst_caps_set_value (src_caps, "level", &value);
+ g_value_unset (&value);
}
- value = gst_v4l2_codec_probe_profiles (codec, video_fd);
- if (value != NULL) {
- gst_caps_set_value (src_caps, "profile", value);
- g_value_unset (value);
+ if (gst_v4l2_codec_probe_profiles (codec, video_fd, &value)) {
+ gst_caps_set_value (src_caps, "profile", &value);
+ g_value_unset (&value);
}
}