From 27c35a8ff39078de7694a9aabfd2a69f10add58c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 30 Oct 2014 00:45:18 +0000 Subject: [PATCH] rpicamsrc: deviceprovider: check if camera is detected and supported --- sys/rpicamsrc/RaspiCamControl.c | 2 +- sys/rpicamsrc/RaspiCamControl.h | 1 + sys/rpicamsrc/gstrpicamsrcdeviceprovider.c | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sys/rpicamsrc/RaspiCamControl.c b/sys/rpicamsrc/RaspiCamControl.c index a93fdc4..d03cb4e 100644 --- a/sys/rpicamsrc/RaspiCamControl.c +++ b/sys/rpicamsrc/RaspiCamControl.c @@ -1094,7 +1094,7 @@ static int raspicamcontrol_get_mem_gpu(void) * @param supported None-zero if software supports the camera * @param detected None-zero if a camera has been detected */ -static void raspicamcontrol_get_camera(int *supported, int *detected) +void raspicamcontrol_get_camera(int *supported, int *detected) { char response[80] = ""; if (vc_gencmd(response, sizeof response, "get_camera") == 0) diff --git a/sys/rpicamsrc/RaspiCamControl.h b/sys/rpicamsrc/RaspiCamControl.h index 847b447..aac3e19 100644 --- a/sys/rpicamsrc/RaspiCamControl.h +++ b/sys/rpicamsrc/RaspiCamControl.h @@ -147,6 +147,7 @@ void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params); void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params); void raspicamcontrol_check_configuration(int min_gpu_mem); +void raspicamcontrol_get_camera(int *supported, int *detected); // Individual setting functions int raspicamcontrol_set_saturation(MMAL_COMPONENT_T *camera, int saturation); diff --git a/sys/rpicamsrc/gstrpicamsrcdeviceprovider.c b/sys/rpicamsrc/gstrpicamsrcdeviceprovider.c index 1a8b822..387ee61 100644 --- a/sys/rpicamsrc/gstrpicamsrcdeviceprovider.c +++ b/sys/rpicamsrc/gstrpicamsrcdeviceprovider.c @@ -27,6 +27,8 @@ #if GST_CHECK_VERSION (1,4,0) +#include "RaspiCapture.h" + /* FIXME: translations */ #define _(s) s @@ -54,15 +56,27 @@ gst_rpi_cam_src_device_provider_class_init (GstRpiCamSrcDeviceProviderClass * kl static void gst_rpi_cam_src_device_provider_init (GstRpiCamSrcDeviceProvider * provider) { - /* nothing to do here yet */ + raspicapture_init (); } static GList * gst_rpi_cam_src_device_provider_probe (GstDeviceProvider * provider) { GstRpiCamSrcDevice *device; + int supported = 0, detected = 0; + + raspicamcontrol_get_camera (&supported, &detected); + + if (!detected) { + GST_INFO ("No Raspberry Pi camera module detected."); + return NULL; + } else if (!supported) { + GST_WARNING ("Raspberry Pi camera module not supported, make sure to enable it."); + return NULL; + } + + GST_INFO ("Raspberry Pi camera module detected and supported."); - /* FIXME: check if camera module is usable and supported */ device = gst_rpi_cam_src_device_new (); return g_list_append (NULL, device); -- 2.7.4