diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/config.h.in | 8 | ||||
-rw-r--r-- | src/uca-camera.c | 72 | ||||
-rw-r--r-- | src/uca-camera.h | 4 |
4 files changed, 79 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3650f6..6b413dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,6 @@ find_package(ClSerMe4) # --- Miscellanous packages find_package(PkgConfig) -find_package(Threads) pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED) pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED) @@ -34,7 +33,7 @@ set(uca_LIBS ${GOBJECT2_LIBRARIES}) # --- Build options ----------------------------------------------------------- -option(HAVE_DUMMY_CAMERA "Camera: Dummy" OFF) +option(HAVE_MOCK_CAMERA "Camera: Dummy" OFF) # --- Add sources if camera/framegrabber access sources are available --------- @@ -81,18 +80,11 @@ if (IPE_FOUND) endif() endif() -if (HAVE_DUMMY_CAMERA) +if (HAVE_MOCK_CAMERA) set(uca_SRCS ${uca_SRCS} cameras/uca-mock-camera.c) set(uca_HDRS ${uca_HDRS} cameras/uca-mock-camera.h) endif() -if (Threads_FOUND) - set(HAVE_PTHREADS TRUE) - - set(uca_LIBS - ${uca_LIBS} - ${CMAKE_THREAD_LIBS_INIT}) -endif() # --- Configure step configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in diff --git a/src/config.h.in b/src/config.h.in index 40a61f8..6a6b6b4 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,12 +1,6 @@ - -#cmakedefine HAVE_ME4 - #cmakedefine HAVE_PCO_CL #cmakedefine HAVE_PHOTON_FOCUS #cmakedefine HAVE_PHOTRON_FASTCAM #cmakedefine HAVE_IPE_CAMERA -#cmakedefine HAVE_DUMMY_CAMERA -#cmakedefine HAVE_SIMPLE_CAMERA - -#cmakedefine HAVE_PTHREADS +#cmakedefine HAVE_MOCK_CAMERA diff --git a/src/uca-camera.c b/src/uca-camera.c index ac04b86..f7f980a 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -16,14 +16,24 @@ Franklin St, Fifth Floor, Boston, MA 02110, USA */ #include <glib.h> +#include "config.h" #include "uca-camera.h" +#ifdef HAVE_PCO_CL +#include "cameras/uca-pco-camera.h" +#endif + +#ifdef HAVE_MOCK_CAMERA +#include "cameras/uca-mock-camera.h" +#endif + #define UCA_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_CAMERA, UcaCameraPrivate)) G_DEFINE_TYPE(UcaCamera, uca_camera, G_TYPE_OBJECT) /** * UcaCameraError: + * @UCA_CAMERA_ERROR_NOT_FOUND: Camera type is unknown * @UCA_CAMERA_ERROR_RECORDING: Camera is already recording * @UCA_CAMERA_ERROR_NOT_RECORDING: Camera is not recording * @UCA_CAMERA_ERROR_NO_GRAB_FUNC: No grab callback was set @@ -33,6 +43,16 @@ GQuark uca_camera_error_quark() return g_quark_from_static_string("uca-camera-error-quark"); } +static gchar *uca_camera_types[] = { +#ifdef HAVE_PCO_CL + "pco", +#endif +#ifdef HAVE_MOCK_CAMERA + "mock", +#endif + NULL +}; + enum { LAST_SIGNAL }; @@ -222,6 +242,58 @@ static void uca_camera_init(UcaCamera *camera) } /** + * uca_camera_get_types: + * + * Enumerate all camera types that can be instantiated with uca_camera_new(). + * + * Returns: An array of strings with camera types. The list should be freed with + * g_strfreev(). + */ +gchar **uca_camera_get_types() +{ + return g_strdupv(uca_camera_types); +} + +/** + * uca_camera_new: + * @param type: Type name of the camera + * @error: Location to store an error or %NULL + * + * Factory method for instantiating cameras by names listed in + * uca_camera_get_type(). + * + * Returns: A new #UcaCamera of the correct type or %NULL if type was not found + */ +UcaCamera *uca_camera_new(const gchar *type, GError **error) +{ + UcaCamera *camera = NULL; + GError *tmp_error = NULL; + +#ifdef HAVE_MOCK_CAMERA + if (!g_strcmp0(type, "mock")) + camera = UCA_CAMERA(uca_mock_camera_new(&tmp_error)); +#endif + +#ifdef HAVE_PCO_CL + if (!g_strcmp0(type, "pco")) + camera = UCA_CAMERA(uca_pco_camera_new(&tmp_error)); +#endif + + if (tmp_error != NULL) { + g_propagate_error(error, tmp_error); + return NULL; + } + + if ((tmp_error == NULL) && (camera == NULL)) { + g_set_error(error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_FOUND, + "Camera type %s not found", type); + return NULL; + } + + return camera; +} + +/** * uca_camera_start_recording: * @camera: A #UcaCamera object * @error: Location to store a #UcaCameraError error or %NULL diff --git a/src/uca-camera.h b/src/uca-camera.h index 0370466..44770f1 100644 --- a/src/uca-camera.h +++ b/src/uca-camera.h @@ -29,6 +29,7 @@ #define UCA_CAMERA_ERROR uca_camera_error_quark() typedef enum { + UCA_CAMERA_ERROR_NOT_FOUND, UCA_CAMERA_ERROR_RECORDING, UCA_CAMERA_ERROR_NOT_RECORDING, UCA_CAMERA_ERROR_NO_GRAB_FUNC @@ -74,6 +75,9 @@ struct _UcaCameraClass { void (*recording_stopped) (UcaCamera *camera); }; +gchar **uca_camera_get_types(); +UcaCamera *uca_camera_new(const gchar *type, GError **error); + void uca_camera_start_recording(UcaCamera *camera, GError **error); void uca_camera_stop_recording(UcaCamera *camera, GError **error); void uca_camera_grab(UcaCamera *camera, gpointer data, GError **error); |