[pinpoint] [PATCH V2] allow the use of multiple cameras



After applying this patch, the command line switch "--camera" can be specified
multiple times when calling pinpoint.

A slide can access a specific camera with the statement [camera-id=n], where n
is the position in the command line list.

Signed-off-by: Stefan Tomanek <stefan pico ruhr de>
---
 pinpoint.c   |   11 +++++++++--
 pinpoint.h   |    5 ++++-
 pp-clutter.c |   23 +++++++++++++++++++----
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/pinpoint.c b/pinpoint.c
index 3f52f15..ee82b7e 100644
--- a/pinpoint.c
+++ b/pinpoint.c
@@ -86,6 +86,7 @@ static PinPointPoint pin_default_point = {
 
   .camera_framerate = 0,                    /* auto */
   .camera_resolution = {0, 0},              /* auto */
+  .camera_id = -1,                          /* auto */
 
   .data = NULL,
 };
@@ -99,7 +100,7 @@ gboolean  pp_fullscreen      = FALSE;
 gboolean  pp_maximized       = FALSE;
 gboolean  pp_speakermode     = FALSE;
 gboolean  pp_rehearse        = FALSE;
-char     *pp_camera_device   = NULL;
+char    **pp_camera_device   = NULL;
 
 static GOptionEntry entries[] =
 {
@@ -117,7 +118,7 @@ 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,
+    { "camera", 'c', 0, G_OPTION_ARG_FILENAME_ARRAY, &pp_camera_device,
       "Device to use for [camera] background", "DEVICE" },
     { NULL }
 };
@@ -189,6 +190,11 @@ main (int    argc,
       g_print ("option parsing failed: %s\n", error->message);
       return EXIT_FAILURE;
     }
+  if (pp_camera_device && g_strv_length(pp_camera_device) > MAX_CAMERAS)
+    {
+      g_print ("Unable to handle more than %d camera devices, %d specified.\n", MAX_CAMERAS, 
g_strv_length(pp_camera_device));
+      return EXIT_FAILURE;
+    }
 
   pinfile = argv[1];
 
@@ -464,6 +470,7 @@ parse_setting (PinPointPoint *point,
   IF_PREFIX("transition=") point->transition = STRING;
   IF_PREFIX("camera-framerate=")  point->camera_framerate = INT;
   IF_PREFIX("camera-resolution=") RESOLUTION (point->camera_resolution);
+  IF_PREFIX("camera-id=")  point->camera_id = INT;
   IF_EQUAL("fill")         point->bg_scale = PP_BG_FILL;
   IF_EQUAL("fit")          point->bg_scale = PP_BG_FIT;
   IF_EQUAL("stretch")      point->bg_scale = PP_BG_STRETCH;
diff --git a/pinpoint.h b/pinpoint.h
index b242f01..f665dbf 100644
--- a/pinpoint.h
+++ b/pinpoint.h
@@ -50,6 +50,8 @@ typedef enum
   PP_BG_SVG
 } PPBackgroundType;
 
+#define MAX_CAMERAS 8
+
 typedef enum
 {
   PP_BG_UNSCALED,
@@ -112,6 +114,7 @@ struct _PinPointPoint
 
   gint              camera_framerate;
   PPResolution      camera_resolution;
+  gint              camera_id;
 
   void              *data;            /* the renderer can attach data here */
 };
@@ -121,7 +124,7 @@ extern gboolean  pp_fullscreen;
 extern gboolean  pp_maximized;
 extern gboolean  pp_speakermode;
 extern gboolean  pp_rehearse;
-extern char     *pp_camera_device;
+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 e614ad9..753fe08 100644
--- a/pp-clutter.c
+++ b/pp-clutter.c
@@ -1129,8 +1129,20 @@ setup_camera (PinPointRenderer *renderer,
 {
   /* These are static to be able to share the texture and the pipeline between
    * all the slides using the camera */
-  static ClutterActor *texture = NULL;
-  static GstElement   *pipeline = NULL;
+  static ClutterActor *textures[MAX_CAMERAS]  = {NULL};
+  static GstElement   *pipelines[MAX_CAMERAS] = {NULL};
+
+  int cur_cam = point->camera_id;
+  if (!pp_camera_device || cur_cam >= g_strv_length(pp_camera_device)) {
+    g_print ( "camera-id %d not found on command line, reverting to autodetection.\n", cur_cam );
+    cur_cam = -1;
+  }
+  if (cur_cam < 0) {
+    cur_cam = 0;
+  }
+
+  ClutterActor *texture = textures[cur_cam];
+  GstElement   *pipeline = pipelines[cur_cam];
 
   ClutterPointData *data = point->data;
   GstElement       *src;
@@ -1180,7 +1192,10 @@ setup_camera (PinPointRenderer *renderer,
     }
 
   if (pp_camera_device)
-    g_object_set (src, "device", pp_camera_device, NULL);
+    {
+      g_print( "Using camera id %d (%s)\n", cur_cam, pp_camera_device[cur_cam] );
+      g_object_set (src, "device", pp_camera_device[cur_cam], NULL);
+    }
 
 #define W (point->camera_resolution.width)
 #define H (point->camera_resolution.height)
@@ -1606,7 +1621,7 @@ static void leave_slide (ClutterRenderer *renderer,
 #ifdef USE_CLUTTER_GST
       if (point->bg_type == PP_BG_CAMERA)
         {
-          gst_element_set_state (data->pipeline, GST_STATE_PAUSED);
+          gst_element_set_state (data->pipeline, GST_STATE_NULL);
         }
       if (CLUTTER_GST_IS_VIDEO_TEXTURE (data->background))
         {
-- 
1.7.10.4


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