Commit 5587daca authored by Xi Ruoyao's avatar Xi Ruoyao 😿 Committed by David King

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.
parent 1c1e7fa0
...@@ -296,7 +296,7 @@ initable_init (GInitable *initable, ...@@ -296,7 +296,7 @@ initable_init (GInitable *initable,
gst_bus_add_watch (bus, cheese_camera_device_monitor_bus_func, monitor); gst_bus_add_watch (bus, cheese_camera_device_monitor_bus_func, monitor);
gst_object_unref (bus); 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_device_monitor_add_filter (priv->monitor, "Video/Source", caps);
gst_caps_unref (caps); gst_caps_unref (caps);
......
...@@ -163,6 +163,27 @@ compare_formats (gconstpointer a, gconstpointer b) ...@@ -163,6 +163,27 @@ compare_formats (gconstpointer a, gconstpointer b)
return (d->width * d->height - c->width * c->height); 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: * cheese_camera_device_filter_caps:
* @device: the #CheeseCameraDevice * @device: the #CheeseCameraDevice
...@@ -182,18 +203,8 @@ cheese_camera_device_filter_caps (CheeseCameraDevice *device, ...@@ -182,18 +203,8 @@ cheese_camera_device_filter_caps (CheeseCameraDevice *device,
{ {
GstCaps *filter; GstCaps *filter;
GstCaps *allowed; GstCaps *allowed;
gsize i;
filter = gst_caps_new_empty ();
for (i = 0; formats[i] != NULL; i++) filter = format_caps (formats);
{
gst_caps_append (filter,
gst_caps_new_simple (formats[i],
"framerate", GST_TYPE_FRACTION_RANGE,
0, 1, CHEESE_MAXIMUM_RATE, 1,
NULL));
}
allowed = gst_caps_intersect (caps, filter); allowed = gst_caps_intersect (caps, filter);
...@@ -935,3 +946,9 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device, ...@@ -935,3 +946,9 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device,
return result_caps; return result_caps;
} }
GstCaps *
cheese_camera_device_supported_format_caps (void)
{
return format_caps (supported_formats);
}
...@@ -75,6 +75,8 @@ GList * cheese_camera_device_get_format_list (CheeseCameraDevice *dev ...@@ -75,6 +75,8 @@ GList * cheese_camera_device_get_format_list (CheeseCameraDevice *dev
const gchar *cheese_camera_device_get_name (CheeseCameraDevice *device); const gchar *cheese_camera_device_get_name (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);
G_END_DECLS G_END_DECLS
#endif /* CHEESE_CAMERA_DEVICE_H_ */ #endif /* CHEESE_CAMERA_DEVICE_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