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 ...@@ -87,6 +87,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_NAME, PROP_NAME,
PROP_PATH,
PROP_DEVICE, PROP_DEVICE,
PROP_LAST PROP_LAST
}; };
...@@ -99,6 +100,7 @@ typedef struct ...@@ -99,6 +100,7 @@ typedef struct
gchar *name; gchar *name;
GstCaps *caps; GstCaps *caps;
GList *formats; /* list members are CheeseVideoFormatFull structs. */ GList *formats; /* list members are CheeseVideoFormatFull structs. */
gchar *path;
GError *construct_error; GError *construct_error;
} CheeseCameraDevicePrivate; } CheeseCameraDevicePrivate;
...@@ -602,6 +604,9 @@ cheese_camera_device_get_property (GObject *object, guint prop_id, GValue *value ...@@ -602,6 +604,9 @@ cheese_camera_device_get_property (GObject *object, guint prop_id, GValue *value
case PROP_DEVICE: case PROP_DEVICE:
g_value_set_object (value, priv->device); g_value_set_object (value, priv->device);
break; break;
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -626,6 +631,12 @@ cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue ...@@ -626,6 +631,12 @@ cheese_camera_device_set_property (GObject *object, guint prop_id, const GValue
priv->device = g_value_dup_object (value); priv->device = g_value_dup_object (value);
g_free (priv->name); g_free (priv->name);
priv->name = gst_device_get_display_name (priv->device); 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; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -641,6 +652,7 @@ cheese_camera_device_finalize (GObject *object) ...@@ -641,6 +652,7 @@ cheese_camera_device_finalize (GObject *object)
g_object_unref (priv->device); g_object_unref (priv->device);
g_free (priv->name); g_free (priv->name);
g_free (priv->path);
gst_caps_unref (priv->caps); gst_caps_unref (priv->caps);
free_format_list (device); free_format_list (device);
...@@ -678,6 +690,18 @@ cheese_camera_device_class_init (CheeseCameraDeviceClass *klass) ...@@ -678,6 +690,18 @@ cheese_camera_device_class_init (CheeseCameraDeviceClass *klass)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS); 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: * CheeseCameraDevice:device:
* *
...@@ -781,6 +805,25 @@ cheese_camera_device_get_format_list (CheeseCameraDevice *device) ...@@ -781,6 +805,25 @@ cheese_camera_device_get_format_list (CheeseCameraDevice *device)
return g_list_copy (priv->formats); 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: * cheese_camera_device_get_name:
* @device: a #CheeseCameraDevice * @device: a #CheeseCameraDevice
......
...@@ -73,6 +73,7 @@ CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *dev ...@@ -73,6 +73,7 @@ CheeseVideoFormat *cheese_camera_device_get_best_format (CheeseCameraDevice *dev
GList * cheese_camera_device_get_format_list (CheeseCameraDevice *device); GList * cheese_camera_device_get_format_list (CheeseCameraDevice *device);
const gchar *cheese_camera_device_get_name (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); GstElement * cheese_camera_device_get_src (CheeseCameraDevice *device);
GstCaps * cheese_camera_device_supported_format_caps (void); GstCaps * cheese_camera_device_supported_format_caps (void);
......
...@@ -1594,8 +1594,8 @@ cheese_camera_setup (CheeseCamera *camera, CheeseCameraDevice *device, GError ** ...@@ -1594,8 +1594,8 @@ cheese_camera_setup (CheeseCamera *camera, CheeseCameraDevice *device, GError **
{ {
device = g_ptr_array_index (priv->camera_devices, i); device = g_ptr_array_index (priv->camera_devices, i);
if (g_strcmp0 (cheese_camera_device_get_name (device), if (g_strcmp0 (cheese_camera_device_get_name (device), priv->initial_name) == 0
priv->initial_name) == 0) || g_strcmp0 (cheese_camera_device_get_path (device), priv->initial_name) == 0)
{ {
cheese_camera_set_device (camera, device); cheese_camera_set_device (camera, device);
break; break;
......
...@@ -78,11 +78,14 @@ namespace Cheese ...@@ -78,11 +78,14 @@ namespace Cheese
public Gst.Caps get_caps_for_format (Cheese.VideoFormat format); public Gst.Caps get_caps_for_format (Cheese.VideoFormat format);
public GLib.List<unowned Cheese.VideoFormat> get_format_list (); public GLib.List<unowned Cheese.VideoFormat> get_format_list ();
public unowned string get_name (); public unowned string get_name ();
public unowned string get_path ();
public Gst.Element get_src (); public Gst.Element get_src ();
[NoAccessorMethod] [NoAccessorMethod]
public Gst.Device device {get; construct;} public Gst.Device device {get; construct;}
[NoAccessorMethod] [NoAccessorMethod]
public string name {get;} public string name {get;}
[NoAccessorMethod]
public string path {get;}
} }
[CCode (cheader_filename = "cheese-camera-device-monitor.h")] [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