Commit 9f0825c3 authored by Alberto Fanjul's avatar Alberto Fanjul Committed by David King

Allow device parameter to understand api.v4l2.path

!37
#4
parent c5cf9af9
Pipeline #217201 passed with stage
in 6 minutes and 16 seconds
......@@ -87,6 +87,7 @@ enum
{
PROP_0,
PROP_NAME,
PROP_PATH,
PROP_DEVICE,
PROP_LAST
};
......@@ -99,6 +100,7 @@ typedef struct
gchar *name;
GstCaps *caps;
GList *formats; /* list members are CheeseVideoFormatFull structs. */
gchar *path;
GError *construct_error;
} CheeseCameraDevicePrivate;
......@@ -602,6 +604,9 @@ cheese_camera_device_get_property (GObject *object, guint prop_id, GValue *value
case PROP_DEVICE:
g_value_set_object (value, priv->device);
break;
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -626,6 +631,12 @@ cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue
priv->device = g_value_dup_object (value);
g_free (priv->name);
priv->name = gst_device_get_display_name (priv->device);
g_free (priv->path);
priv->path = g_value_dup_string (gst_structure_get_value (gst_device_get_properties (priv->device), "api.v4l2.path"));
break;
case PROP_PATH:
g_free (priv->path);
priv->path = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......@@ -641,6 +652,7 @@ cheese_camera_device_finalize (GObject *object)
g_object_unref (priv->device);
g_free (priv->name);
g_free (priv->path);
gst_caps_unref (priv->caps);
free_format_list (device);
......@@ -678,6 +690,18 @@ cheese_camera_device_class_init (CheeseCameraDeviceClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
* CheeseCameraDevice:path:
*
* Path of the video capture device.
*/
properties[PROP_PATH] = g_param_spec_string ("path",
"Device path",
"Path of the video capture device",
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
* CheeseCameraDevice:device:
*
......@@ -781,6 +805,25 @@ cheese_camera_device_get_format_list (CheeseCameraDevice *device)
return g_list_copy (priv->formats);
}
/**
* cheese_camera_device_get_path:
* @device: a #CheeseCameraDevice
*
* Get path for the device, as reported by udev.
*
* Returns: (transfer none): the path of the video capture device
*/
const gchar *
cheese_camera_device_get_path (CheeseCameraDevice *device)
{
CheeseCameraDevicePrivate *priv;
g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL);
priv = cheese_camera_device_get_instance_private (device);
return priv->path;
}
/**
* cheese_camera_device_get_name:
* @device: a #CheeseCameraDevice
......
......@@ -73,6 +73,7 @@ CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *dev
GList * cheese_camera_device_get_format_list (CheeseCameraDevice *device);
const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device);
const gchar *cheese_camera_device_get_path (CheeseCameraDevice *device);
GstElement * cheese_camera_device_get_src (CheeseCameraDevice *device);
GstCaps * cheese_camera_device_supported_format_caps (void);
......
......@@ -1594,8 +1594,8 @@ cheese_camera_setup (CheeseCamera *camera, CheeseCameraDevice *device, GError **
{
device = g_ptr_array_index (priv->camera_devices, i);
if (g_strcmp0 (cheese_camera_device_get_name (device),
priv->initial_name) == 0)
if (g_strcmp0 (cheese_camera_device_get_name (device), priv->initial_name) == 0
|| g_strcmp0 (cheese_camera_device_get_path (device), priv->initial_name) == 0)
{
cheese_camera_set_device (camera, device);
break;
......
......@@ -78,11 +78,14 @@ namespace Cheese
public Gst.Caps get_caps_for_format (Cheese.VideoFormat format);
public GLib.List<unowned Cheese.VideoFormat> get_format_list ();
public unowned string get_name ();
public unowned string get_path ();
public Gst.Element get_src ();
[NoAccessorMethod]
public Gst.Device device {get; construct;}
[NoAccessorMethod]
public string name {get;}
[NoAccessorMethod]
public string path {get;}
}
[CCode (cheader_filename = "cheese-camera-device-monitor.h")]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment