gnomemm r1499 - in gstreamermm/trunk: . examples/media_player_gtkmm examples/ogg_player_gtkmm gstreamer/src



Author: murrayc
Date: Sat May 17 13:11:52 2008
New Revision: 1499
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1499&view=rev

Log:
2008-05-17  Murray Cumming  <murrayc murrayc com>

* gstreamer/src/message.ccg:
* gstreamer/src/message.hg: Implement MessageInfo::parse() and add a 
method overload without the debug parameter. 

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/examples/media_player_gtkmm/player_window.cc
   gstreamermm/trunk/examples/media_player_gtkmm/player_window.h
   gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.cc
   gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.h
   gstreamermm/trunk/gstreamer/src/message.ccg
   gstreamermm/trunk/gstreamer/src/message.hg

Modified: gstreamermm/trunk/examples/media_player_gtkmm/player_window.cc
==============================================================================
--- gstreamermm/trunk/examples/media_player_gtkmm/player_window.cc	(original)
+++ gstreamermm/trunk/examples/media_player_gtkmm/player_window.cc	Sat May 17 13:11:52 2008
@@ -209,10 +209,10 @@
   m_play_button.hide();
   m_pause_button.show();
 
-  // Call update_stream_progress function at a 200ms
+  // Call on_timeout function at a 200ms
   // interval to regularly update the position of the stream
   m_timeout_connection = Glib::signal_timeout().connect(
-    sigc::mem_fun(*this, &PlayerWindow::update_stream_progress), 200);
+    sigc::mem_fun(*this, &PlayerWindow::on_timeout), 200);
 
   // set the pipeline to play mode:
   m_play_bin->set_state(Gst::STATE_PLAYING);
@@ -268,7 +268,7 @@
 
 bool PlayerWindow::on_scale_value_changed(Gtk::ScrollType /* type_not_used */, double value)
 {
-  gint64 newPos = gint64(value * m_duration);
+  const gint64 newPos = gint64(value * m_duration);
 
   if(m_play_bin->seek(Gst::FORMAT_TIME, Gst::SEEK_FLAG_FLUSH, newPos))
   {
@@ -377,7 +377,7 @@
   }
 }
 
-bool PlayerWindow::update_stream_progress()
+bool PlayerWindow::on_timeout()
 {
   Gst::Format fmt = Gst::FORMAT_TIME;
   gint64 pos = 0;

Modified: gstreamermm/trunk/examples/media_player_gtkmm/player_window.h
==============================================================================
--- gstreamermm/trunk/examples/media_player_gtkmm/player_window.h	(original)
+++ gstreamermm/trunk/examples/media_player_gtkmm/player_window.h	Sat May 17 13:11:52 2008
@@ -56,9 +56,8 @@
   void on_button_forward();
   void on_button_open();
   bool on_scale_value_changed(Gtk::ScrollType type, double value);
+  bool on_timeout();
 
-
-  bool update_stream_progress();
   void display_label_progress(gint64 pos, gint64 len);
 
 protected:

Modified: gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.cc	(original)
+++ gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.cc	Sat May 17 13:11:52 2008
@@ -106,13 +106,12 @@
       break;
     case Gst::MESSAGE_ERROR:
     {
-      Glib::RefPtr<Gst::MessageError> msgError =
+      Glib::RefPtr<Gst::MessageError> error_message =
         Glib::RefPtr<Gst::MessageError>::cast_dynamic(message);
-      if(msgError)
+      if(error_message)
       {
         Glib::Error err;
-        std::string debug; //TODO: Maybe this should be an optional parameter.
-        msgError->parse(err, debug);
+        error_message->parse(err); //TODO: Make err the return type?
         std::cerr << "Error: " << err.what() << std::endl;
       }
       else
@@ -123,7 +122,7 @@
     }
     default:
     {
-    //std::cout << "debug: on_bus_message: unhandled message=" << G_OBJECT_TYPE_NAME(message->gobj()) << std::endl;
+      //std::cout << "debug: on_bus_message: unhandled message=" << G_OBJECT_TYPE_NAME(message->gobj()) << std::endl;
     }
     break;
   }
@@ -133,21 +132,21 @@
 
 void PlayerWindow::on_button_play()
 {
-  m_progress_scale.set_sensitive(true);
+  m_progress_scale.set_sensitive();
   m_play_button.set_sensitive(false);
-  m_pause_button.set_sensitive(true);
-  m_stop_button.set_sensitive(true);
-  m_rewind_button.set_sensitive(true);
-  m_forward_button.set_sensitive(true);
+  m_pause_button.set_sensitive();
+  m_stop_button.set_sensitive();
+  m_rewind_button.set_sensitive();
+  m_forward_button.set_sensitive();
   m_open_button.set_sensitive(false);
 
   m_play_button.hide();
   m_pause_button.show();
 
-  // Call update_stream_progress function at a 200ms
+  // Call on_timeout function at a 200ms
   // interval to regularly update the position of the stream
   m_progress_connection = Glib::signal_timeout().connect(
-    sigc::mem_fun(*this, &PlayerWindow::update_stream_progress), 200);
+    sigc::mem_fun(*this, &PlayerWindow::on_timeout), 200);
 
   // set Gstmm pipeline to play mode
   m_main_pipeline->set_state(Gst::STATE_PLAYING);
@@ -155,7 +154,7 @@
  
 void PlayerWindow::on_button_pause()
 {
-  m_play_button.set_sensitive(true);
+  m_play_button.set_sensitive();
   m_pause_button.set_sensitive(false);
 
   m_pause_button.hide();
@@ -171,12 +170,12 @@
 void PlayerWindow::on_button_stop()
 {
   m_progress_scale.set_sensitive(false);
-  m_play_button.set_sensitive(true);
+  m_play_button.set_sensitive();
   m_pause_button.set_sensitive(false);
   m_stop_button.set_sensitive(false);
   m_rewind_button.set_sensitive(false);
   m_forward_button.set_sensitive(false);
-  m_open_button.set_sensitive(true);
+  m_open_button.set_sensitive();
 
   m_pause_button.hide();
   m_play_button.show();
@@ -215,7 +214,7 @@
 
   if(m_main_pipeline->query_position(fmt, pos))
   {
-    gint64 newPos = (pos > skipAmount) ? (pos - skipAmount) : 0;
+    const gint64 newPos = (pos > skipAmount) ? (pos - skipAmount) : 0;
 
     if(m_main_pipeline->seek(Gst::FORMAT_TIME, Gst::SEEK_FLAG_FLUSH, newPos))
     {
@@ -229,6 +228,7 @@
 
 void PlayerWindow::on_button_forward()
 {
+  //TODO: Wrap GST_SECOND:
   static const gint64 skipAmount = GST_SECOND * 3;
 
   gint64 pos = 0;
@@ -265,38 +265,38 @@
 
 void PlayerWindow::on_button_open()
 {
-  Glib::ustring workingDir = Glib::get_home_dir();
+  static Glib::ustring working_dir = Glib::get_home_dir();
   
+  //Offer a file chooser dialog to the user:
   Gtk::FileChooserDialog chooser(*this,
-            "Select ogg file", Gtk::FILE_CHOOSER_ACTION_OPEN);
+    "Select ogg file", Gtk::FILE_CHOOSER_ACTION_OPEN);
+  chooser.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+  chooser.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
 
   Gtk::FileFilter filter;
   filter.add_mime_type("application/ogg");
   filter.set_name("Ogg files");
-
   chooser.set_filter(filter);
-
-  chooser.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-  chooser.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
   
-  chooser.set_current_folder(workingDir);
+  chooser.set_current_folder(working_dir);
   
   const int response = chooser.run();
   if(response == Gtk::RESPONSE_OK)
   {
-    workingDir = chooser.get_current_folder();
+    working_dir = chooser.get_current_folder();
 
     // Set filename property on the file source. 
     // TODO: Create a FileSrc class that we can dynamic_cast<> to, so we can use property_location()?
-    m_source_element->set_property("location", chooser.get_filename());
-    set_title( Glib::filename_display_basename(chooser.get_filename()) );
+    const std::string filename = chooser.get_filename(); //TODO: Can this use a URI?
+    m_source_element->set_property("location", filename);
+    set_title( Glib::filename_display_basename(filename) );
 
-    m_play_button.set_sensitive(true);
+    m_play_button.set_sensitive();
     display_label_progress(0, 0);
   }
 }
 
-bool PlayerWindow::update_stream_progress()
+bool PlayerWindow::on_timeout()
 {
   Gst::Format fmt = Gst::FORMAT_TIME;
   gint64 pos = 0;
@@ -308,7 +308,7 @@
     display_label_progress(pos, m_duration);
   }
 
-   return true;
+  return true;
 }
 
 void PlayerWindow::display_label_progress(gint64 pos, gint64 len)

Modified: gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.h
==============================================================================
--- gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.h	(original)
+++ gstreamermm/trunk/examples/ogg_player_gtkmm/player_window.h	Sat May 17 13:11:52 2008
@@ -49,7 +49,7 @@
   void on_button_forward();
   void on_button_open();
 
-  bool update_stream_progress();
+  bool on_timeout();
   void display_label_progress(gint64 pos, gint64 len);
 
   Gtk::VBox m_vbox;

Modified: gstreamermm/trunk/gstreamer/src/message.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.ccg	Sat May 17 13:11:52 2008
@@ -75,8 +75,8 @@
 
 void MessageClockProvide::parse(Glib::RefPtr<Clock>& clock, bool& ready)
 {
-  GstClock* cclock;
-  gboolean ready_;
+  GstClock* cclock = 0;
+  gboolean ready_ = FALSE;
   gst_message_parse_clock_provide(gobj(), &cclock, &ready_);
   clock = Glib::wrap(cclock);
   ready = ready_;
@@ -96,7 +96,7 @@
 
 void MessageClockLost::parse(Glib::RefPtr<Clock>& clock)
 {
-  GstClock* cclock;
+  GstClock* cclock = 0;
   gst_message_parse_clock_lost(gobj(), &cclock);
   clock = Glib::wrap(cclock, false);
 }
@@ -151,7 +151,7 @@
 
 void MessageError::parse(Glib::Error& error, std::string& debug)
 {
-  GError *c_error = 0;
+  GError* c_error = 0;
   gchar* c_debug = 0;
   gst_message_parse_error(gobj(), &c_error, &c_debug);
 
@@ -170,7 +170,7 @@
 
 void MessageError::parse(Glib::Error& error)
 {
-  GError *c_error = 0;
+  GError* c_error = 0;
   gst_message_parse_error(gobj(), &c_error, NULL);
 
   if(c_error)
@@ -193,6 +193,38 @@
 }
 
 
+void MessageInfo::parse(Glib::Error& error, std::string& debug)
+{
+  GError* c_error = 0;
+  gchar* c_debug = 0;
+  gst_message_parse_info(gobj(), &c_error, &c_debug);
+
+  if(c_debug)
+  {
+    debug = c_debug;
+    g_free(c_debug);
+  }
+
+  if(c_error)
+  {
+    error = Glib::Error(c_error); 
+    g_error_free(c_error);
+  }
+}
+
+void MessageInfo::parse(Glib::Error& error)
+{
+  GError* c_error = 0;
+  gst_message_parse_info(gobj(), &c_error, NULL);
+
+  if(c_error)
+  {
+    error = Glib::Error(c_error); 
+    g_error_free(c_error);
+  }
+}
+
+
 MessageNewClock::MessageNewClock(GstMessage* castitem)
 : Message(castitem)
 {

Modified: gstreamermm/trunk/gstreamer/src/message.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.hg	Sat May 17 13:11:52 2008
@@ -144,6 +144,7 @@
 
   static Glib::RefPtr<Message> create(const Glib::RefPtr<Object>& src, Glib::Error& error, const std::string& debug);
   void parse(Glib::Error& error, std::string& debug);
+  void parse(Glib::Error& error);
 };
 
 class MessageNewClock: public Message



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