[gstreamermm: 121/167] fixed and restor examples, minor changes in caps, pad



commit 9bb313caf5d02c3ccb34bde568811cb562361ae7
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date:   Fri Aug 2 11:08:30 2013 +0200

    fixed and restor examples, minor changes in caps, pad

 configure.ac                                 |    1 +
 examples/Makefile.am                         |    1 +
 examples/media_player_gtkmm/main.cc          |    4 +-
 examples/media_player_gtkmm/player_window.cc |   61 ++++++++++++--------------
 examples/media_player_gtkmm/player_window.h  |    8 ++--
 examples/ogg_player_gtkmm/player_window.cc   |    6 +-
 gstreamer/gstreamermm.h                      |    1 +
 gstreamer/src/caps.ccg                       |    5 ++
 gstreamer/src/caps.hg                        |    2 +-
 gstreamer/src/filelist.am                    |    1 +
 gstreamer/src/pad.hg                         |    3 +
 11 files changed, 50 insertions(+), 43 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 14026a3..5a36ff1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,6 +141,7 @@ theoradec|theoradec|TheoraDec \
 theoraenc|theoraenc|TheoraEnc \
 theoraparse|theoraparse|TheoraParse \
 timeoverlay|timeoverlay|TimeOverlay \
+typefindelement|typefind|TypeFindElement \
 uridecodebin|uridecodebin|UriDecodeBin \
 valve|valve|Valve \
 videoconvert|videoconvert|VideoConvert \
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 40fa86d..bd9e04d 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -28,6 +28,7 @@ noinst_PROGRAMS =                     \
        hello_world/example             \
        ogg_player/example              \
        ogg_rewriter/example    \
+       typefind/example        \
        optiongroup/example     \
        $(optional_examples)
 
diff --git a/examples/media_player_gtkmm/main.cc b/examples/media_player_gtkmm/main.cc
index 4df0f8d..a836259 100644
--- a/examples/media_player_gtkmm/main.cc
+++ b/examples/media_player_gtkmm/main.cc
@@ -21,7 +21,7 @@
 #include <gstreamermm/element.h>
 
 // Plug-ins:
-#include <gstreamermm/playbin2.h>
+#include <gstreamermm/playbin.h>
 
 #include <iostream>
 #include "player_window.h"
@@ -35,7 +35,7 @@ int main(int argc, char** argv)
 
   // playbin2 plays any media type, choosing an appropriate set of elements
   // and linking them together.
-  Glib::RefPtr<Gst::PlayBin2> playbin = Gst::PlayBin2::create("playbin");
+  Glib::RefPtr<Gst::PlayBin> playbin = Gst::PlayBin::create("playbin");
 
   if(!playbin)
   {
diff --git a/examples/media_player_gtkmm/player_window.cc b/examples/media_player_gtkmm/player_window.cc
index 6e1428b..824d2c5 100644
--- a/examples/media_player_gtkmm/player_window.cc
+++ b/examples/media_player_gtkmm/player_window.cc
@@ -33,8 +33,7 @@
 #include <gstreamermm/event.h>
 #include <gstreamermm/message.h>
 #include <gstreamermm/query.h>
-#include <gstreamermm/interface.h>
-#include <gstreamermm/xoverlay.h>
+#include <gstreamermm/videooverlay.h>
 #include <glibmm/main.h>
 #include <glibmm/miscutils.h>
 #include <glibmm/convert.h>
@@ -43,7 +42,7 @@
 #include <iomanip>
 #include "player_window.h"
 
-PlayerWindow::PlayerWindow(const Glib::RefPtr<Gst::PlayBin2>& playbin)
+PlayerWindow::PlayerWindow(const Glib::RefPtr<Gst::PlayBin>& playbin)
 : m_vbox(false, 6),
   m_progress_label("000:00:00.000000000 / 000:00:00.000000000"),
   m_play_button(Gtk::Stock::MEDIA_PLAY),
@@ -152,12 +151,11 @@ void PlayerWindow::on_bus_message_sync(
   Glib::RefPtr<Gst::Element> element =
       Glib::RefPtr<Gst::Element>::cast_dynamic(message->get_source());
 
-  Glib::RefPtr< Gst::ElementInterfaced<Gst::XOverlay> > xoverlay =
-      Gst::Interface::cast <Gst::XOverlay>(element);
+  Glib::RefPtr< Gst::VideoOverlay > videooverlay = Glib::RefPtr<Gst::VideoOverlay>::cast_dynamic(element);
 
-  if(xoverlay)
+  if(videooverlay)
   {
-    xoverlay->set_xwindow_id(m_x_window_id);
+      videooverlay->set_window_handle(m_x_window_id);
   }
 }
 
@@ -174,7 +172,7 @@ bool PlayerWindow::on_bus_message(const Glib::RefPtr<Gst::Bus>& /* bus */,
     }
     case Gst::MESSAGE_ERROR:
     {
-      Glib::RefPtr<Gst::MessageError> msgError = Glib::RefPtr<Gst::MessageError>::cast_dynamic(message);
+      Glib::RefPtr<Gst::MessageError> msgError = Glib::RefPtr<Gst::MessageError>::cast_static(message);
       if(msgError)
       {
         Glib::Error err;
@@ -204,42 +202,39 @@ void PlayerWindow::on_video_changed()
     // Add a buffer probe to the video sink pad which will be removed after
     // the first buffer is received in the on_video_pad_got_buffer method.
     // When the first buffer arrives, the video size can be extracted.
-    m_pad_probe_id = pad->add_buffer_probe(
+    m_pad_probe_id = pad->add_probe(Gst::PAD_PROBE_TYPE_BUFFER,
       sigc::mem_fun(*this, &PlayerWindow::on_video_pad_got_buffer));
   }
 }
 
-bool PlayerWindow::on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad,
-    const Glib::RefPtr<Gst::MiniObject>& data)
+Gst::PadProbeReturn PlayerWindow::on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad,
+        const Gst::PadProbeInfo& data)
 {
-  Glib::RefPtr<Gst::Buffer> buffer = Glib::RefPtr<Gst::Buffer>::cast_dynamic(data);
+  int width_value;
+  int height_value;
 
-  if(buffer)
-  {
-    int width_value;
-    int height_value;
+  Glib::RefPtr<Gst::Caps> caps = pad->query_caps(Glib::RefPtr<Gst::Caps>());
 
-    Glib::RefPtr<Gst::Caps> caps = buffer->get_caps();
+  caps = caps->create_writable();
 
-    const Gst::Structure structure = caps->get_structure(0);
-    if(structure)
-    {
-      structure.get_field("width", width_value);
-      structure.get_field("height", height_value);
-    }
+  const Gst::Structure structure = caps->get_structure(0);
+  if(structure)
+  {
+    structure.get_field("width", width_value);
+    structure.get_field("height", height_value);
+  }
 
-    m_video_area.set_size_request(width_value, height_value);
+  m_video_area.set_size_request(width_value, height_value);
 
-    // Resize to minimum when first playing by making size 
-    // smallest then resizing according to video new size:
-    resize(1, 1);
-    check_resize();
-  }
+  // Resize to minimum when first playing by making size
+  // smallest then resizing according to video new size:
+  resize(1, 1);
+  check_resize();
 
-  pad->remove_buffer_probe(m_pad_probe_id);
+  pad->remove_probe(m_pad_probe_id);
   m_pad_probe_id = 0; // Clear probe id to indicate that it has been removed
 
-  return true; // Keep buffer in pipeline (do not throw away)
+  return Gst::PAD_PROBE_OK;
 }
 
 void PlayerWindow::on_button_play()
@@ -352,7 +347,7 @@ void PlayerWindow::on_button_forward()
   if(m_playbin->query(query))
   {
     Glib::RefPtr<Gst::QueryPosition> posQuery =
-      Glib::RefPtr<Gst::QueryPosition>::cast_dynamic(query);
+      Glib::RefPtr<Gst::QueryPosition>::cast_static(query);
 
     gint64 pos = posQuery->parse();
 
@@ -364,7 +359,7 @@ void PlayerWindow::on_button_forward()
         Gst::SEEK_TYPE_NONE, -1);
 
     Glib::RefPtr<Gst::EventSeek> seekEvent =
-      Glib::RefPtr<Gst::EventSeek>::cast_dynamic(event);
+      Glib::RefPtr<Gst::EventSeek>::cast_static(event);
 
     if(Glib::RefPtr<Gst::Element>::cast_static(m_playbin)->send_event(event))
     {
diff --git a/examples/media_player_gtkmm/player_window.h b/examples/media_player_gtkmm/player_window.h
index b93e16a..6d5cf83 100644
--- a/examples/media_player_gtkmm/player_window.h
+++ b/examples/media_player_gtkmm/player_window.h
@@ -28,7 +28,7 @@
 #include <gstreamermm/element.h>
 #include <gstreamermm/pipeline.h>
 #include <gstreamermm/bus.h>
-#include <gstreamermm/playbin2.h>
+#include <gstreamermm/playbin.h>
 
 class PlayerWindow : public Gtk::Window
 {
@@ -36,7 +36,7 @@ public:
   /**
    * @param playbin The pipeline that can play media files.
    */
-  PlayerWindow(const Glib::RefPtr<Gst::PlayBin2>& playbin);
+  PlayerWindow(const Glib::RefPtr<Gst::PlayBin>& playbin);
   virtual ~PlayerWindow();
 
 protected:
@@ -46,7 +46,7 @@ protected:
   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);
   void on_video_changed();
-  bool on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad, const Glib::RefPtr<Gst::MiniObject>& 
buffer);
+  Gst::PadProbeReturn on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad, const Gst::PadProbeInfo& 
data);
 
   void on_button_play();
   void on_button_pause();
@@ -72,7 +72,7 @@ protected:
   Gtk::Button m_forward_button;
   Gtk::Button m_open_button;
 
-  Glib::RefPtr<Gst::PlayBin2> m_playbin;
+  Glib::RefPtr<Gst::PlayBin> m_playbin;
   sigc::connection m_timeout_connection;
   guint m_watch_id;
   gint64 m_duration;
diff --git a/examples/ogg_player_gtkmm/player_window.cc b/examples/ogg_player_gtkmm/player_window.cc
index 97fb163..d413042 100644
--- a/examples/ogg_player_gtkmm/player_window.cc
+++ b/examples/ogg_player_gtkmm/player_window.cc
@@ -111,7 +111,7 @@ bool PlayerWindow::on_bus_message(const Glib::RefPtr<Gst::Bus>& /* bus */, const
       //There was an error, so stop playing, 
       //and output some information to stdout:
       Glib::RefPtr<Gst::MessageError> error_message =
-        Glib::RefPtr<Gst::MessageError>::cast_dynamic(message);
+        Glib::RefPtr<Gst::MessageError>::cast_static(message);
       if(error_message)
       {
         Glib::Error err;
@@ -241,7 +241,7 @@ void PlayerWindow::on_button_forward()
   if(m_main_pipeline->query(query))
   {
     Glib::RefPtr<Gst::QueryPosition> posQuery =
-      Glib::RefPtr<Gst::QueryPosition>::cast_dynamic(query);
+      Glib::RefPtr<Gst::QueryPosition>::cast_static(query);
 
     gint64 pos = posQuery->parse();
 
@@ -253,7 +253,7 @@ void PlayerWindow::on_button_forward()
       Gst::SEEK_TYPE_NONE, -1);
 
     Glib::RefPtr<Gst::EventSeek> seekEvent =
-      Glib::RefPtr<Gst::EventSeek>::cast_dynamic(event);
+      Glib::RefPtr<Gst::EventSeek>::cast_static(event);
 
     if(m_main_pipeline->send_event(seekEvent))
     {
diff --git a/gstreamer/gstreamermm.h b/gstreamer/gstreamermm.h
index 025ac49..733cd47 100644
--- a/gstreamer/gstreamermm.h
+++ b/gstreamer/gstreamermm.h
@@ -157,6 +157,7 @@
 #include <gstreamermm/oggdemux.h>
 #include <gstreamermm/oggmux.h>
 #include <gstreamermm/subtitleoverlay.h>
+#include <gstreamermm/typefindelement.h>
 #include <gstreamermm/videooverlay.h>
 
 
diff --git a/gstreamer/src/caps.ccg b/gstreamer/src/caps.ccg
index 50efaef..abc9f71 100644
--- a/gstreamer/src/caps.ccg
+++ b/gstreamer/src/caps.ccg
@@ -47,6 +47,11 @@ Glib::RefPtr<Gst::Caps> Caps::create_simple(const Glib::ustring& media_type)
   return result;
 }
 
+Glib::RefPtr<Gst::Caps> Caps::create_writable()
+{
+    return Glib::RefPtr<Gst::Caps>(Glib::wrap(gst_caps_make_writable(gobj())));
+}
+
 Glib::RefPtr<Gst::Caps> Caps::create(const Structure& structure)
 {
   //We take a copy because gst_caps_append_structure() wants to take ownership:
diff --git a/gstreamer/src/caps.hg b/gstreamer/src/caps.hg
index eb58c11..4904402 100644
--- a/gstreamer/src/caps.hg
+++ b/gstreamer/src/caps.hg
@@ -198,7 +198,7 @@ public:
   //This is const (returns a non const) because it always creates a new instance:
   _WRAP_METHOD(Glib::RefPtr<Gst::Caps> get_difference(const Glib::RefPtr<const Gst::Caps>& subtrahend_caps) 
const, gst_caps_subtract)
 
-  _WRAP_METHOD(Glib::RefPtr<Gst::Caps> create_writable(), gst_caps_make_writable)
+  Glib::RefPtr<Gst::Caps> create_writable();
   _WRAP_METHOD(void truncate(), gst_caps_truncate)
 };
 
diff --git a/gstreamer/src/filelist.am b/gstreamer/src/filelist.am
index 1f82d5f..daec533 100644
--- a/gstreamer/src/filelist.am
+++ b/gstreamer/src/filelist.am
@@ -65,6 +65,7 @@ plugins_hg =                    \
         theoraenc.hg            \
         theoraparse.hg          \
         timeoverlay.hg          \
+        typefindelement.hg      \
         uridecodebin.hg         \
         valve.hg                \
         videoconvert.hg         \
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index 40c6d30..03a0b85 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -156,6 +156,9 @@ public:
    */
   _WRAP_CREATE(const Glib::RefPtr<const Gst::PadTemplate>& pad_template, const Glib::ustring& name)
 
+  _WRAP_METHOD(Glib::RefPtr<Gst::Caps> query_caps(Glib::RefPtr<Gst::Caps> caps), gst_pad_query_caps)
+  _WRAP_METHOD(Glib::RefPtr<const Gst::Caps> query_caps(Glib::RefPtr<Gst::Caps> caps) const, 
gst_pad_query_caps, constversion)
+
   _WRAP_METHOD(PadDirection get_direction() const, gst_pad_get_direction)
   _WRAP_METHOD(Glib::RefPtr<Gst::Element> get_parent_element(), gst_pad_get_parent_element)
   _WRAP_METHOD(Glib::RefPtr<const Gst::Element> get_parent_element() const, gst_pad_get_parent_element, 
constversion)


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