[pinpoint] [PATCH] 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 |   18 +++++++++++++-----
 3 files changed, 26 insertions(+), 8 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 d033f3e..5157ebf 100644
--- a/pp-clutter.c
+++ b/pp-clutter.c
@@ -1129,8 +1129,13 @@ 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 >= 0 && point->camera_id < MAX_CAMERAS) ? point->camera_id : 0;
+
+  ClutterActor *texture = textures[cur_cam];
+  GstElement   *pipeline = pipelines[cur_cam];
 
   ClutterPointData *data = point->data;
   GstElement       *src;
@@ -1179,8 +1184,11 @@ setup_camera (PinPointRenderer *renderer,
                            NULL);
     }
 
-  if (pp_camera_device)
-    g_object_set (src, "device", pp_camera_device, NULL);
+  if (pp_camera_device && pp_camera_device[point->camera_id])
+    {
+      g_print( "Using camera id %d (%s)\n", point->camera_id, pp_camera_device[point->camera_id] );
+      g_object_set (src, "device", pp_camera_device[point->camera_id], NULL);
+    }
 
 #define W (point->camera_resolution.width)
 #define H (point->camera_resolution.height)
@@ -1606,7 +1614,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]