[gstreamermm] Media Player Example: Get and save XID when video area is realized.



commit 381e059db2cfc05c07f3933b97a3271a9b28232a
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Sun Aug 9 14:39:31 2009 -0400

    	Media Player Example: Get and save XID when video area is realized.
    
    	* examples/media_player_gtkmm/player_window.cc:
    	* examples/media_player_gtkmm/player_window.h: Get the video area X
    	Window ID and save it when it is realized for more stability.

 ChangeLog                                    |    8 ++++++++
 examples/media_player_gtkmm/player_window.cc |   20 ++++++++++++++++----
 examples/media_player_gtkmm/player_window.h  |    2 ++
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 88758ef..aecc58b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-09  José Alburquerque  <jaalburqu svn gnome org>
+
+	Media Player Example: Get and save XID when video area is realized.
+
+	* examples/media_player_gtkmm/player_window.cc:
+	* examples/media_player_gtkmm/player_window.h: Get the video area X
+	Window ID and save it when it is realized for more stability.
+
 2009-08-06  José Alburquerque  <jaalburqu svn gnome org>
 
 	Task: Use anonymous namespace around internal structure definition.
diff --git a/examples/media_player_gtkmm/player_window.cc b/examples/media_player_gtkmm/player_window.cc
index 75bf420..027ee23 100644
--- a/examples/media_player_gtkmm/player_window.cc
+++ b/examples/media_player_gtkmm/player_window.cc
@@ -79,6 +79,9 @@ PlayerWindow::PlayerWindow(const Glib::RefPtr<Gst::PlayBin2>& playbin,
   m_open_button.signal_clicked().connect(sigc::mem_fun(*this,
                       &PlayerWindow::on_button_open));
 
+  m_video_area.signal_realize().connect(sigc::mem_fun(*this,
+                      &PlayerWindow::on_video_area_realize));
+
   // Get the bus from the pipeline:
   Glib::RefPtr<Gst::Bus> bus = playbin->get_bus();
 
@@ -109,7 +112,17 @@ PlayerWindow::PlayerWindow(const Glib::RefPtr<Gst::PlayBin2>& playbin,
   m_pause_button.hide();
 }
 
-// This function is used to receive asynchronous messages from mainPipeline's bus
+void PlayerWindow::on_video_area_realize()
+{
+  // When the video area (the drawing area) is realized, Get its X Window
+  // ID and save it for when the Gst::XOverlay is ready to accept an ID in
+  // which to draw the video.
+  x_window_id = GDK_WINDOW_XID(m_video_area.get_window()->gobj());
+}
+
+// This function is used to receive asynchronous messages from mainPipeline's
+// bus specifically to prepare the Gst::XOverlay to draw inside the window
+// in which we want it to draw to.
 void PlayerWindow::on_bus_message_sync(
     const Glib::RefPtr<Gst::Message>& message)
 {
@@ -128,8 +141,7 @@ void PlayerWindow::on_bus_message_sync(
 
   if(xoverlay)
   {
-    const gulong xWindowId = GDK_WINDOW_XID(m_video_area.get_window()->gobj());
-    xoverlay->set_xwindow_id(xWindowId);
+    xoverlay->set_xwindow_id(x_window_id);
   }
 }
 
@@ -362,7 +374,7 @@ void PlayerWindow::on_button_open()
 #ifdef GLIBMM_PROPERTIES_ENABLED
     m_play_bin->property_uri() = chooser.get_uri();
 #else
-    m_play_bin->set_property("property_uri", chooser.get_uri());
+    m_play_bin->set_property("uri", chooser.get_uri());
 #endif
 
     // Resize m_video_area and window to minimum when opening a file
diff --git a/examples/media_player_gtkmm/player_window.h b/examples/media_player_gtkmm/player_window.h
index 6197d01..ba711f0 100644
--- a/examples/media_player_gtkmm/player_window.h
+++ b/examples/media_player_gtkmm/player_window.h
@@ -44,6 +44,7 @@ public:
 protected:
 
   //Signal handlers:
+  void on_video_area_realize();
   void on_bus_message_sync(const Glib::RefPtr<Gst::Message>& message);
   bool on_bus_message(const Glib::RefPtr<Gst::Bus>& bus, const Glib::RefPtr<Gst::Message>& message);
   bool on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad, const Glib::RefPtr<Gst::MiniObject>& buffer);
@@ -77,6 +78,7 @@ protected:
   sigc::connection m_timeout_connection;
   guint m_watch_id;
   gint64 m_duration;
+  gulong x_window_id;
   gulong m_pad_probe_id;
 };
 



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