[ekiga/ds-clutter] Video: Implemented extended video output with GmVideoWidget.



commit aee7e018f67097a1c08abbab1519907bab2b8d2e
Author: Damien Sandras <dsandras beip be>
Date:   Sun Jan 5 18:11:40 2014 +0100

    Video: Implemented extended video output with GmVideoWidget.
    
    This is now a GmWindow.

 lib/Makefile.am                             |    2 -
 lib/engine/gui/gtk-frontend/call-window.cpp |   58 +++++++++++++--------
 lib/engine/gui/gtk-frontend/ext-window.cpp  |   73 +++++++++++++++-----------
 lib/engine/gui/gtk-frontend/ext-window.h    |    4 ++
 org.gnome.ekiga.gschema.xml.in.in           |   13 +++++
 5 files changed, 95 insertions(+), 55 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1a4d072..cc64ba3 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -388,8 +388,6 @@ libekiga_la_SOURCES += \
        engine/gui/gtk-frontend/book-view-gtk.cpp \
        engine/gui/gtk-frontend/call-window.h \
        engine/gui/gtk-frontend/call-window.cpp \
-       engine/gui/gtk-frontend/ext-window.h \
-       engine/gui/gtk-frontend/ext-window.cpp \
        engine/gui/gtk-frontend/roster-view-gtk.h \
        engine/gui/gtk-frontend/roster-view-gtk.cpp \
        engine/gui/gtk-frontend/call-history-view-gtk.h \
diff --git a/lib/engine/gui/gtk-frontend/call-window.cpp b/lib/engine/gui/gtk-frontend/call-window.cpp
index 5f3e7da..8b3cb38 100644
--- a/lib/engine/gui/gtk-frontend/call-window.cpp
+++ b/lib/engine/gui/gtk-frontend/call-window.cpp
@@ -113,6 +113,7 @@ struct _EkigaCallWindowPrivate
   GtkWidget *info_text;
 
   GtkWidget *video_widget;
+  GtkWidget *extended_video_widget;
   bool fullscreen;
 
   GtkWidget *call_frame;
@@ -466,10 +467,6 @@ hang_up_call_cb (GtkWidget * /*widget*/,
 
   if (cw->priv->current_call)
     cw->priv->current_call->hang_up ();
-
-  if (cw->priv->ext_video_win) {
-    ekiga_ext_window_destroy (EKIGA_EXT_WINDOW (cw->priv->ext_video_win));
-  }
 }
 
 
@@ -574,22 +571,33 @@ on_videooutput_device_opened_cb (Ekiga::VideoOutputManager & /* manager */,
                                  unsigned width,
                                  unsigned height,
                                  bool both_streams,
-                                 bool ext_stream,
+                                 G_GNUC_UNUSED bool ext_stream,
                                  gpointer self)
 {
   g_return_if_fail (EKIGA_IS_CALL_WINDOW (self));
 
   EkigaCallWindow *cw = EKIGA_CALL_WINDOW (self);
-  GM_STREAM_TYPE t =
-    (type == Ekiga::VideoOutputManager::REMOTE) ? PRIMARY_STREAM : SECONDARY_STREAM;
 
-  gtk_widget_show (GTK_WIDGET (cw));
-  gm_video_widget_set_stream_natural_size (GM_VIDEO_WIDGET (cw->priv->video_widget),
-                                           t, width, height);
-  gm_video_widget_set_stream_state (GM_VIDEO_WIDGET (cw->priv->video_widget),
-                                    t, STREAM_STATE_PLAYING);
+  if (type == Ekiga::VideoOutputManager::EXTENDED) {
+
+    gtk_widget_show (GTK_WIDGET (cw->priv->ext_video_win));
+    gm_video_widget_set_stream_natural_size (GM_VIDEO_WIDGET (cw->priv->extended_video_widget),
+                                             PRIMARY_STREAM, width, height);
+    gm_video_widget_set_stream_state (GM_VIDEO_WIDGET (cw->priv->extended_video_widget),
+                                      PRIMARY_STREAM, STREAM_STATE_PLAYING);
+  }
+  else {
+    GM_STREAM_TYPE t =
+      (type == Ekiga::VideoOutputManager::REMOTE) ? PRIMARY_STREAM : SECONDARY_STREAM;
 
-  gtk_menu_section_set_sensitive (cw->priv->main_menu, "pip", both_streams);
+    gtk_widget_show (GTK_WIDGET (cw));
+    gm_video_widget_set_stream_natural_size (GM_VIDEO_WIDGET (cw->priv->video_widget),
+                                             t, width, height);
+    gm_video_widget_set_stream_state (GM_VIDEO_WIDGET (cw->priv->video_widget),
+                                      t, STREAM_STATE_PLAYING);
+
+    gtk_menu_section_set_sensitive (cw->priv->main_menu, "pip", both_streams);
+  }
 }
 
 static void
@@ -604,6 +612,9 @@ on_videooutput_device_closed_cb (Ekiga::VideoOutputManager & /* manager */,
     gm_video_widget_set_stream_state (GM_VIDEO_WIDGET (cw->priv->video_widget),
                                       type, STREAM_STATE_STOPPED);
   }
+  gtk_widget_hide (cw->priv->ext_video_win);
+
+  gtk_menu_section_set_sensitive (cw->priv->main_menu, "pip", FALSE);
 }
 
 static void
@@ -972,10 +983,6 @@ on_cleared_call_cb (G_GNUC_UNUSED boost::shared_ptr<Ekiga::CallManager> manager,
   ekiga_call_window_set_bandwidth (cw, 0.0, 0.0, 0.0, 0.0);
   ekiga_call_window_clear_stats (cw);
 
-  if (cw->priv->ext_video_win) {
-    ekiga_ext_window_destroy (EKIGA_EXT_WINDOW (cw->priv->ext_video_win));
-  }
-
   if (cw->priv->current_call) {
     cw->priv->current_call = boost::shared_ptr<Ekiga::Call>();
     g_source_remove (cw->priv->timeout_id);
@@ -1843,15 +1850,25 @@ ekiga_call_window_init_clutter (EkigaCallWindow *cw)
   gchar *filename = NULL;
 
   cw->priv->video_widget = gm_video_widget_new ();
-  gtk_widget_set_size_request (GTK_WIDGET (cw->priv->video_widget), STAGE_WIDTH, STAGE_HEIGHT);
+  gtk_widget_set_size_request (GTK_WIDGET (cw->priv->video_widget),
+                               STAGE_WIDTH, STAGE_HEIGHT);
   gtk_container_add (GTK_CONTAINER (cw->priv->event_box), cw->priv->video_widget);
 
+  cw->priv->extended_video_widget = gm_video_widget_new ();
+  gtk_widget_set_size_request (GTK_WIDGET (cw->priv->extended_video_widget),
+                               STAGE_WIDTH, STAGE_HEIGHT);
+  gtk_widget_show (cw->priv->extended_video_widget);
+  gtk_container_add (GTK_CONTAINER (cw->priv->ext_video_win),
+                     cw->priv->extended_video_widget);
+
   filename = g_build_filename (DATA_DIR, "pixmaps", PACKAGE_NAME,
                                PACKAGE_NAME "-full-icon.png", NULL);
   gm_video_widget_set_logo (GM_VIDEO_WIDGET (cw->priv->video_widget), filename);
   g_free (filename);
 
   cw->priv->videooutput_core->set_display_info (gm_video_widget_get_stream (GM_VIDEO_WIDGET 
(cw->priv->video_widget), SECONDARY_STREAM), gm_video_widget_get_stream (GM_VIDEO_WIDGET 
(cw->priv->video_widget), PRIMARY_STREAM));
+
+  cw->priv->videooutput_core->set_ext_display_info (gm_video_widget_get_stream (GM_VIDEO_WIDGET 
(cw->priv->extended_video_widget), PRIMARY_STREAM));
 }
 
 static void
@@ -2060,10 +2077,7 @@ ekiga_call_window_init_gui (EkigaCallWindow *cw)
   cw->priv->video_settings_window = gm_cw_video_settings_window_new (cw);
 
   /* The extended video stream window */
-//  cw->priv->ext_video_win = ext_window_new (cw->priv->videooutput_core);
- // cw->priv->video_stream[Ekiga::VideoOutputManager::EXTENDED] = 
-   // ekiga_ext_window_get_video_stream (EKIGA_EXT_WINDOW (cw->priv->ext_video_win));
-//  gtk_widget_show_all (cw->priv->ext_video_win);
+  cw->priv->ext_video_win = gm_window_new_with_key (USER_INTERFACE ".video-settings-window");
 
   /* The main table */
   event_box = gtk_event_box_new ();
diff --git a/lib/engine/gui/gtk-frontend/ext-window.cpp b/lib/engine/gui/gtk-frontend/ext-window.cpp
index c33db07..514a105 100644
--- a/lib/engine/gui/gtk-frontend/ext-window.cpp
+++ b/lib/engine/gui/gtk-frontend/ext-window.cpp
@@ -36,6 +36,9 @@
 #include <gdk/gdkwin32.h>
 #endif
 
+#define STAGE_WIDTH 640
+#define STAGE_HEIGHT 480
+
 G_DEFINE_TYPE (EkigaExtWindow, ekiga_ext_window, GTK_TYPE_WINDOW);
 
 struct _EkigaExtWindowPrivate {
@@ -43,6 +46,8 @@ struct _EkigaExtWindowPrivate {
   GC gc;
 #endif
   GtkWidget *video, *zin, *zout, *event_box;
+  ClutterActor *stage;
+  ClutterActor *video_stream;
   boost::shared_ptr<Ekiga::VideoOutputCore> vocore;
   boost::shared_ptr<Ekiga::Settings> video_display_settings;
 };
@@ -97,37 +102,25 @@ stay_on_top_changed_cb (GSettings *settings,
 }
 
 static void
-gui_layout (EkigaExtWindow *ew)
+ekiga_extended_video_window_init_clutter (EkigaExtWindow *ew)
 {
-  GtkWidget *zin, *zout, *vbox, *hbox;
-
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  gtk_container_add (GTK_CONTAINER (ew), vbox);
-
-  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-
-  zin = gtk_button_new_from_stock (GTK_STOCK_ZOOM_IN);
-  gtk_box_pack_start (GTK_BOX (hbox), zin, FALSE, FALSE, 0);
-
-  zout = gtk_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
-  gtk_box_pack_start (GTK_BOX (hbox), zout, FALSE, FALSE, 0);
-
-  ew->priv->event_box = gtk_event_box_new ();
-  ew->priv->video = gtk_image_new ();
-  gtk_container_add (GTK_CONTAINER (ew->priv->event_box), ew->priv->video);
-  gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (ew->priv->event_box), FALSE, FALSE, 0);
-
-  ew->priv->zin = zin;
-  ew->priv->zout = zout;
-
-  g_signal_connect (zin, "clicked", G_CALLBACK (zoom_in), ew);
-  g_signal_connect (zout, "clicked", G_CALLBACK (zoom_out), ew);
-
-  gtk_widget_show_all (vbox);
-  gtk_widget_realize (vbox);
-
-  gtk_window_set_resizable (GTK_WINDOW (ew), FALSE);
+  GtkWidget *clutter_widget = NULL;
+
+  clutter_widget = gtk_clutter_embed_new ();
+  gtk_widget_set_size_request (GTK_WIDGET (clutter_widget), STAGE_WIDTH, STAGE_HEIGHT);
+  gtk_container_add (GTK_CONTAINER (ew), clutter_widget);
+
+  ew->priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter_widget));
+  clutter_actor_set_background_color (CLUTTER_ACTOR (ew->priv->stage), CLUTTER_COLOR_Black);
+  clutter_stage_set_user_resizable (CLUTTER_STAGE (ew->priv->stage), TRUE);
+
+  ew->priv->video_stream =
+    CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL));
+  clutter_actor_add_child (CLUTTER_ACTOR (ew->priv->stage), CLUTTER_ACTOR (ew->priv->video_stream));
+  clutter_actor_add_constraint (ew->priv->video_stream,
+                                clutter_align_constraint_new (ew->priv->stage,
+                                                              CLUTTER_ALIGN_BOTH,
+                                                              0.5));
 }
 
 static inline void
@@ -162,7 +155,7 @@ constructor (GType type, guint n_properties, GObjectConstructParam *params)
                                                                         n_properties,
                                                                         params);
 
-  gui_layout (EKIGA_EXT_WINDOW (object));
+  ekiga_extended_video_window_init_clutter (EKIGA_EXT_WINDOW (object));
 
   return object;
 }
@@ -285,9 +278,27 @@ ext_window_new (boost::shared_ptr<Ekiga::VideoOutputCore> &vocore)
                     "changed::stay-on-top",
                     G_CALLBACK (stay_on_top_changed_cb), ew);
 
+  ew->priv->vocore->set_ext_display_info (ew->priv->video_stream);
+
   return GTK_WIDGET (ew);
 }
 
+ClutterActor *
+ekiga_ext_window_get_stage (EkigaExtWindow *ew)
+{
+  g_return_val_if_fail (EKIGA_IS_EXT_WINDOW (ew), NULL);
+
+  return ew->priv->stage;
+}
+
+ClutterActor *
+ekiga_ext_window_get_video_stream (EkigaExtWindow *ew)
+{
+  g_return_val_if_fail (EKIGA_IS_EXT_WINDOW (ew), NULL);
+
+  return ew->priv->video_stream;
+}
+
 void
 ekiga_ext_window_set_size (EkigaExtWindow *ew, int width, int height)
 {
diff --git a/lib/engine/gui/gtk-frontend/ext-window.h b/lib/engine/gui/gtk-frontend/ext-window.h
index f4f97b7..bd58d12 100644
--- a/lib/engine/gui/gtk-frontend/ext-window.h
+++ b/lib/engine/gui/gtk-frontend/ext-window.h
@@ -32,6 +32,8 @@
 #include "gmwindow.h"
 #include "videooutput-core.h"
 
+#include <clutter-gtk/clutter-gtk.h>
+
 G_BEGIN_DECLS
 
 #define EKIGA_TYPE_EXT_WINDOW                  \
@@ -60,6 +62,8 @@ struct _EkigaExtWindowClass {
 
 GType ekiga_ext_window_get_type ();
 GtkWidget *ext_window_new (boost::shared_ptr<Ekiga::VideoOutputCore> &vocore);
+ClutterActor *ekiga_ext_window_get_stage (EkigaExtWindow *cw);
+ClutterActor *ekiga_ext_window_get_video_stream (EkigaExtWindow *cw);
 void ekiga_ext_window_set_size (EkigaExtWindow *cw, int width, int height);
 void ekiga_ext_window_destroy (EkigaExtWindow *ew);
 
diff --git a/org.gnome.ekiga.gschema.xml.in.in b/org.gnome.ekiga.gschema.xml.in.in
index e790d47..00658f5 100644
--- a/org.gnome.ekiga.gschema.xml.in.in
+++ b/org.gnome.ekiga.gschema.xml.in.in
@@ -190,6 +190,7 @@
   </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org gnome  PACKAGE_NAME@.general.user-interface" 
path="/org/gnome/@PACKAGE_NAME@/general/user-interface/">
     <child name="call-window" schema="org gnome  PACKAGE_NAME@.general.user-interface.call-window"/>
+    <child name="extended-video-window" schema="org gnome  
PACKAGE_NAME@.general.user-interface.extended-video-window"/>
     <child name="main-window" schema="org gnome  PACKAGE_NAME@.general.user-interface.main-window"/>
     <child name="chat-window" schema="org gnome  PACKAGE_NAME@.general.user-interface.chat-window"/>
     <child name="addressbook-window" schema="org gnome  
PACKAGE_NAME@.general.user-interface.addressbook-window"/>
@@ -210,6 +211,18 @@
       <_description>Size of the call window</_description>
     </key>
   </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org gnome  
PACKAGE_NAME@.general.user-interface.extended-video-window" 
path="/org/gnome/@PACKAGE_NAME@/general/user-interface/extended-video-window/">
+    <key name="position" type="s">
+      <default>'0,0'</default>
+      <_summary>Position on the screen of the extended video window</_summary>
+      <_description>Position on the screen of the extended video window</_description>
+    </key>
+    <key name="size" type="s">
+      <default>'270,250'</default>
+      <_summary>Size of the extended video window</_summary>
+      <_description>Size of the extended video window</_description>
+    </key>
+  </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org gnome  
PACKAGE_NAME@.general.user-interface.main-window" 
path="/org/gnome/@PACKAGE_NAME@/general/user-interface/main-window/">
     <key name="size" type="s">
       <default>'275,475'</default>


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