[GnomeMeeting-devel-list] [PATCH] vfakeio modification



Hi,

the following patch makes gnomemeeting's wonderful deeply embedded video
input device work with its full set of incredible features again ;-)

Seriously, I mean:
* the moving logo is still there;
* the static picture works again (the chosen picture is centered, with a
black background).

Known problems:
1) in the static image case, the background is black: perhaps it would
be nice to have the same color as the image's background...
2) there also seem to be a little problem with image changing: when a
static picture is displayed, and another image choice is made, you have
to wait quite long before the new setting gets into effect... I don't
think it is a problem in the plugin, but more in the way gnomemeeting
manages the setting.

Snark
diff -ur gnomemeeting-cvs-20040208.CVS/src/vfakeio.cpp gnomemeeting-cvs-20040208.CVS.patched/src/vfakeio.cpp
--- gnomemeeting-cvs-20040208.CVS/src/vfakeio.cpp	2004-01-20 12:00:52.000000000 +0100
+++ gnomemeeting-cvs-20040208.CVS.patched/src/vfakeio.cpp	2004-02-08 15:18:17.000000000 +0100
@@ -50,25 +50,13 @@
 
 GMH323FakeVideoInputDevice::GMH323FakeVideoInputDevice ()
 {
-  data_pix = NULL;
-  logo_pix = NULL;
-
-  //  if (image)
-  //video_image = g_strdup (image);
-  //else
-  video_image = NULL;
-
+  orig_pix = NULL;
+  cached_pix = NULL;
+	
   pos = 0;
   increment = 1;
 
-  picture = false;
-  
-  gnomemeeting_threads_enter ();
-
-  logo_pix = 
-    gdk_pixbuf_new_from_xpm_data ((const char **) text_logo_xpm);
-
-  gnomemeeting_threads_leave ();
+  moving = false;
 }
 
 
@@ -76,37 +64,62 @@
 {
   gnomemeeting_threads_enter ();
 
-  if (data_pix)
-    g_object_unref (G_OBJECT (data_pix));
-
-  if (logo_pix)
-    g_object_unref (G_OBJECT (logo_pix));
+  if (orig_pix)
+    g_object_unref (G_OBJECT (orig_pix));
+  if (cached_pix)
+    g_object_unref (G_OBJECT (cached_pix));
 
   gnomemeeting_threads_leave ();
 
-  g_free (video_image);
 }
 
 
 
 BOOL
-GMH323FakeVideoInputDevice::Open (const PString &,
+GMH323FakeVideoInputDevice::Open (const PString &name,
 				  BOOL start_immediate)
 {
-  return TRUE;
+
+  if (name == "MovingLogo") {
+    moving = true;
+    orig_pix = gdk_pixbuf_new_from_xpm_data ((const char **)text_logo_xpm);
+    return TRUE;
+  }
+
+  /* from there on, we're in the static picture case! */
+  moving = false;
+  
+  GConfClient *client = gconf_client_get_default ();
+  gchar *image_name = gconf_client_get_string (GCONF_CLIENT (client), VIDEO_DEVICES_KEY "image", NULL);
+  orig_pix =  gdk_pixbuf_new_from_file (image_name, NULL);
+  g_free (image_name);
+
+  if (orig_pix != NULL) 
+    return TRUE;
+
+  return FALSE;
 }
 
 
 BOOL
 GMH323FakeVideoInputDevice::IsOpen ()
 {
-  return TRUE;
+  if (orig_pix != NULL) return TRUE;
+  return FALSE;
 }
 
 
 BOOL
 GMH323FakeVideoInputDevice::Close ()
 {
+  if (orig_pix != NULL)
+    g_object_unref (G_OBJECT (orig_pix));
+  if (cached_pix != NULL)
+    g_object_unref (G_OBJECT (cached_pix));
+  
+  orig_pix = NULL;
+  cached_pix = NULL;
+  
   return TRUE;
 }
 
@@ -184,62 +197,46 @@
 
 BOOL GMH323FakeVideoInputDevice::GetFrameDataNoDelay (BYTE *frame, PINDEX *i)
 {
-  GdkPixbuf *data_pix_tmp = NULL;
-
   guchar *data = NULL;
 
   unsigned width = 0;
   unsigned height = 0;
-
   GetFrameSize (width, height);
 
   gnomemeeting_threads_enter ();
-  if ((video_image)&&(!data_pix)) {
-
-    data_pix_tmp =  gdk_pixbuf_new_from_file (video_image, NULL);
-
-    if (data_pix_tmp) {
-
-      data_pix = gdk_pixbuf_scale_simple (data_pix_tmp, 
-					  width, height, 
-					  GDK_INTERP_NEAREST);
-
-      g_object_unref (data_pix_tmp);
+  if (cached_pix == NULL) {
+    cached_pix = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+			       width, height);
+    gdk_pixbuf_fill (cached_pix, 0x000000FF); /* Opaque black */
 
-      if (data_pix)
-	picture = true;
+    if (!moving) { // create the ever-displayed picture
+      int orig_width = gdk_pixbuf_get_width (orig_pix);
+      int orig_height = gdk_pixbuf_get_height (orig_pix);
+      gdk_pixbuf_copy_area (orig_pix, 0, 0, orig_width, orig_height,
+			    cached_pix, (width - orig_width) / 2, (height - orig_height) / 2);
     }
   }
-  
-  if (!data_pix) {
-
-    data_pix = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 
-			       width, height);
-    picture = false;
-  }
-  
-  if (!picture) {
-
-    gdk_pixbuf_fill (data_pix, 0x000000FF); /* Opaque black */
-    gdk_pixbuf_copy_area (logo_pix, 0, 0, 176, 60, 
-			  data_pix, (width - 176) / 2, pos);
+   
+  if (moving) {  // recompute the cache pix
+    int orig_width = gdk_pixbuf_get_width (orig_pix);
+    int orig_height = gdk_pixbuf_get_height (orig_pix);
+
+    gdk_pixbuf_fill (cached_pix, 0x000000FF); /* Opaque black */
+    gdk_pixbuf_copy_area (orig_pix, 0, 0, orig_width, orig_height, 
+			  cached_pix, (width - orig_width) / 2, pos);
 
     pos = pos + increment;
 
-    if ((int) pos > (int) height - 60 - 10) increment = -1;
+    if ((int) pos > (int) height - orig_height - 10) increment = -1;
     if (pos < 10) increment = +1;
   }
-  
-  data = gdk_pixbuf_get_pixels (data_pix);
-  rgb_increment = gdk_pixbuf_get_n_channels (data_pix);
+
+  data = gdk_pixbuf_get_pixels (cached_pix);
+  rgb_increment = gdk_pixbuf_get_n_channels (cached_pix);
 
   if (converter)
     converter->Convert (data, frame);
 
-  //  RGBtoYUV420PSameSize (data, frame, rgb_increment, FALSE, 
-  //		width, height);
-  
-
   gnomemeeting_threads_leave ();
 
 
diff -ur gnomemeeting-cvs-20040208.CVS/src/vfakeio.h gnomemeeting-cvs-20040208.CVS.patched/src/vfakeio.h
--- gnomemeeting-cvs-20040208.CVS/src/vfakeio.h	2004-01-20 12:00:52.000000000 +0100
+++ gnomemeeting-cvs-20040208.CVS.patched/src/vfakeio.h	2004-02-08 14:49:20.000000000 +0100
@@ -182,10 +182,9 @@
   
   
   PBYTEArray data;
-  GdkPixbuf *data_pix;
-  GdkPixbuf *logo_pix;
-  gchar *video_image;
-  bool picture;
+  GdkPixbuf *orig_pix;
+  GdkPixbuf *cached_pix;
+  bool moving;
   int rgb_increment;
   int pos;
   int increment;


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