diff options
author | Xℹ Ruoyao <xry111@mengyan1223.wang> | 2020-01-06 20:16:37 +0800 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2020-09-21 10:02:02 +0100 |
commit | 5587daca748e9010f59250c5dcb8e8ea42266685 (patch) | |
tree | 6ef493dcc77985400693fe088b29cda9e0ba6bcd | |
parent | 1c1e7fa0c4608331fd89683ccb342ed3518acccc (diff) | |
download | cheese-5587daca748e9010f59250c5dcb8e8ea42266685.tar.gz |
Enable cameras with only MJPEG output
This enables cameras like Sunplus Technology 1.3M Camera with vendor ID
04fc and device ID 2802, which only outputs through image/jpeg and
doesn't support raw output.
-rw-r--r-- | libcheese/cheese-camera-device-monitor.c | 2 | ||||
-rw-r--r-- | libcheese/cheese-camera-device.c | 39 | ||||
-rw-r--r-- | libcheese/cheese-camera-device.h | 2 |
3 files changed, 31 insertions, 12 deletions
diff --git a/libcheese/cheese-camera-device-monitor.c b/libcheese/cheese-camera-device-monitor.c index 19f4ff0b..87c48ccb 100644 --- a/libcheese/cheese-camera-device-monitor.c +++ b/libcheese/cheese-camera-device-monitor.c @@ -296,7 +296,7 @@ initable_init (GInitable *initable, gst_bus_add_watch (bus, cheese_camera_device_monitor_bus_func, monitor); gst_object_unref (bus); - caps = gst_caps_new_empty_simple ("video/x-raw"); + caps = cheese_camera_device_supported_format_caps (); gst_device_monitor_add_filter (priv->monitor, "Video/Source", caps); gst_caps_unref (caps); diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c index efcb0459..c6cc39ef 100644 --- a/libcheese/cheese-camera-device.c +++ b/libcheese/cheese-camera-device.c @@ -163,6 +163,27 @@ compare_formats (gconstpointer a, gconstpointer b) return (d->width * d->height - c->width * c->height); } +static GstCaps * +format_caps (const gchar * const formats[]) +{ + GstCaps *filter; + gsize i; + + filter = gst_caps_new_empty (); + + for (i = 0; formats[i] != NULL; i++) + { + gst_caps_append (filter, + gst_caps_new_simple (formats[i], + "framerate", + GST_TYPE_FRACTION_RANGE, + 0, 1, CHEESE_MAXIMUM_RATE, 1, + NULL)); + } + + return filter; +} + /* * cheese_camera_device_filter_caps: * @device: the #CheeseCameraDevice @@ -182,18 +203,8 @@ cheese_camera_device_filter_caps (CheeseCameraDevice *device, { GstCaps *filter; GstCaps *allowed; - gsize i; - - filter = gst_caps_new_empty (); - for (i = 0; formats[i] != NULL; i++) - { - gst_caps_append (filter, - gst_caps_new_simple (formats[i], - "framerate", GST_TYPE_FRACTION_RANGE, - 0, 1, CHEESE_MAXIMUM_RATE, 1, - NULL)); - } + filter = format_caps (formats); allowed = gst_caps_intersect (caps, filter); @@ -935,3 +946,9 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device, return result_caps; } + +GstCaps * +cheese_camera_device_supported_format_caps (void) +{ + return format_caps (supported_formats); +} diff --git a/libcheese/cheese-camera-device.h b/libcheese/cheese-camera-device.h index 4f5d819f..5e6b3ca5 100644 --- a/libcheese/cheese-camera-device.h +++ b/libcheese/cheese-camera-device.h @@ -75,6 +75,8 @@ GList * cheese_camera_device_get_format_list (CheeseCameraDevice *dev const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device); GstElement * cheese_camera_device_get_src (CheeseCameraDevice *device); +GstCaps * cheese_camera_device_supported_format_caps (void); + G_END_DECLS #endif /* CHEESE_CAMERA_DEVICE_H_ */ |