[pinpoint] Add an option to set the camera device



commit 1867411ab984091767331e53f72e25eb4454d334
Author: Neil Roberts <neil linux intel com>
Date:   Tue Aug 2 14:28:03 2011 +0100

    Add an option to set the camera device
    
    This adds a --camera=DEVICE option to specify the device used when the
    background is [camera]. This is useful to select between an internal
    and external camera.

 pinpoint.c   |    3 +++
 pinpoint.h   |    1 +
 pp-clutter.c |   14 +++++++++++++-
 3 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/pinpoint.c b/pinpoint.c
index 36dd52c..9ab36aa 100644
--- a/pinpoint.c
+++ b/pinpoint.c
@@ -90,6 +90,7 @@ gboolean  pp_fullscreen      = FALSE;
 gboolean  pp_maximized       = FALSE;
 gboolean  pp_speakermode     = FALSE;
 gboolean  pp_rehearse        = FALSE;
+char     *pp_camera_device   = NULL;
 
 static GOptionEntry entries[] =
 {
@@ -107,6 +108,8 @@ static GOptionEntry entries[] =
     { "output", 'o', 0, G_OPTION_ARG_STRING, &pp_output_filename,
       "Output presentation to FILE\n"
 "                                         (formats supported: pdf)", "FILE" },
+    { "camera", 'c', 0, G_OPTION_ARG_STRING, &pp_camera_device,
+      "Device to use for [camera] background", "DEVICE" },
     { NULL }
 };
 
diff --git a/pinpoint.h b/pinpoint.h
index 2e7ecae..fcd48de 100644
--- a/pinpoint.h
+++ b/pinpoint.h
@@ -120,6 +120,7 @@ extern gboolean  pp_fullscreen;
 extern gboolean  pp_maximized;
 extern gboolean  pp_speakermode;
 extern gboolean  pp_rehearse;
+extern char     *pp_camera_device;
 
 extern GList         *pp_slides;  /* list of slide text */
 extern GList         *pp_slidep;  /* current slide */
diff --git a/pp-clutter.c b/pp-clutter.c
index 0517814..6e9d3ed 100644
--- a/pp-clutter.c
+++ b/pp-clutter.c
@@ -959,6 +959,7 @@ setup_camera (PinPointRenderer *renderer,
   GstElement       *sink;
   GstCaps          *caps;
   gboolean          result;
+  GError           *error = NULL;
 
   if (texture)
     {
@@ -977,7 +978,15 @@ setup_camera (PinPointRenderer *renderer,
   /* Set up pipeline */
   pipeline = gst_pipeline_new (NULL);
 
-  src = gst_element_factory_make ("v4l2src", NULL);
+  src = gst_element_factory_make ("v4l2src", &error);
+  if (src == NULL)
+    {
+      g_critical ("Failed to create v4l2src element: %s", error->message);
+      g_clear_error (&error);
+      g_object_unref (pipeline);
+      return;
+    }
+
   capsfilter = gst_element_factory_make ("capsfilter", NULL);
   sink = clutter_gst_video_sink_new (CLUTTER_TEXTURE (texture));
 
@@ -992,6 +1001,9 @@ setup_camera (PinPointRenderer *renderer,
                            NULL);
     }
 
+  if (pp_camera_device)
+    g_object_set (src, "device", pp_camera_device, NULL);
+
 #define W (point->camera_resolution.width)
 #define H (point->camera_resolution.height)
   if (W != 0 && H != 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]