[gstreamermm: 15/167] fixed bufferlist



commit 50b741709b8fc76490d10324b5a6346e87b52498
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date:   Wed Jul 24 14:04:09 2013 +0200

    fixed bufferlist

 gstreamer/src/bufferlist.ccg |   74 +-------------------------
 gstreamer/src/bufferlist.hg  |  116 ++---------------------------------------
 2 files changed, 9 insertions(+), 181 deletions(-)
---
diff --git a/gstreamer/src/bufferlist.ccg b/gstreamer/src/bufferlist.ccg
index 64f0f07..c9acfdc 100644
--- a/gstreamer/src/bufferlist.ccg
+++ b/gstreamer/src/bufferlist.ccg
@@ -23,7 +23,7 @@ _PINCLUDE(gstreamermm/private/miniobject_p.h)
 extern "C"
 {
 
-static GstBufferListItem BufferList_Foreach_gstreamermm_callback(GstBuffer** buffer, guint group, guint idx, 
void* data)
+static bool BufferList_Foreach_gstreamermm_callback(GstBuffer** buffer, tguint idx, void* data)
 {
   Gst::BufferList::SlotForeach* the_slot =
     static_cast<Gst::BufferList::SlotForeach*>(data);
@@ -35,8 +35,8 @@ static GstBufferListItem BufferList_Foreach_gstreamermm_callback(GstBuffer** buf
 
     // Call the slot which can modify the buffer (ie. set it to a new one or
     // clear it altogether).
-    GstBufferListItem const result =
-      static_cast<GstBufferListItem>((*the_slot)(temp, group, idx));
+    bool result =
+      static_cast<bool>((*the_slot)(temp, group, idx));
 
     // Set the reference to the buffer according to how the temp buffer has
     // been altered.
@@ -64,28 +64,6 @@ static GstBufferListItem BufferList_Foreach_gstreamermm_callback(GstBuffer** buf
   return GST_BUFFER_LIST_CONTINUE;
 }
 
-static GstBuffer* BufferListIterator_Process_gstreamermm_callback(GstBuffer* buffer, void* data)
-{
-  Gst::BufferListIterator::SlotProcess* the_slot =
-    static_cast<Gst::BufferListIterator::SlotProcess*>(data);
-
-  try
-  {
-    Glib::RefPtr<Gst::Buffer> result = (*the_slot)(Gst::wrap(buffer, true));
-
-    if(result)
-      return result->gobj_copy();
-    else
-      return 0;
-  }
-  catch(...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return 0;
-}
-
 } // extern "C"
 
 
@@ -102,56 +80,10 @@ Glib::RefPtr<BufferList> BufferList::create_writable()
   return Gst::wrap(gst_buffer_list_make_writable(gobj()));
 }
 
-guint BufferList::n_groups() const
-{
-  return gst_buffer_list_n_groups(const_cast<GstBufferList*>(gobj()));
-}
-
 void BufferList::foreach(const SlotForeach& slot)
 {
   gst_buffer_list_foreach(gobj(), &BufferList_Foreach_gstreamermm_callback,
     const_cast<SlotForeach*>(&slot));
 }
 
-void BufferList::iterate(BufferListIterator& result)
-{
-  result.set_gobject(gst_buffer_list_iterate(gobj()));
-}
-
-BufferListIterator::BufferListIterator()
-: gobject_(0),
-  take_ownership(false)
-{
-}
-
-BufferListIterator::BufferListIterator(GstBufferListIterator* castitem,
-  bool take_ownership)
-: gobject_(castitem),
-  take_ownership(take_ownership)
-{
-}
-
-void BufferListIterator::set_gobject(GstBufferListIterator* castitem,
-  bool take_ownership)
-{
-  if(gobject_ && take_ownership)
-    gst_buffer_list_iterator_free(gobject_);
-
-  gobject_ = castitem;
-  this->take_ownership = take_ownership;
-}
-
-BufferListIterator::~BufferListIterator()
-{
-  if(take_ownership && gobject_)
-    gst_buffer_list_iterator_free(gobject_);
-}
-
-Glib::RefPtr<Gst::Buffer> BufferListIterator::process(const SlotProcess& slot)
-{
-  return Gst::wrap(gst_buffer_list_iterator_do(gobj(),
-    &BufferListIterator_Process_gstreamermm_callback,
-    const_cast<SlotProcess*>(&slot)));
-}
-
 } //namespace Gst
diff --git a/gstreamer/src/bufferlist.hg b/gstreamer/src/bufferlist.hg
index 6e43bb7..bbc4a48 100644
--- a/gstreamer/src/bufferlist.hg
+++ b/gstreamer/src/bufferlist.hg
@@ -25,10 +25,7 @@ _DEFS(gstreamermm,gst)
 namespace Gst
 {
 
-_WRAP_ENUM(BufferListItem, GstBufferListItem, NO_GTYPE)
-
 class Buffer;
-class BufferListIterator;
 
 /** A grouped scatter data buffer type for data-passing.
  * Buffer lists are units of grouped scatter/gather data transfer in GStreamer.
@@ -68,12 +65,15 @@ public:
    * When the buffer has been made writable, the new buffer reference can be
    * assigned to the buffer.
    */
-  typedef sigc::slot< Gst::BufferListItem, Glib::RefPtr<Gst::Buffer>&, guint,
-    guint> SlotForeach;
+  typedef sigc::slot< bool, Glib::RefPtr<Gst::Buffer>&, guint> SlotForeach;
 
 public:
-  _WRAP_METHOD(static Glib::RefPtr<BufferList> create(), gst_buffer_list_new)
 
+_WRAP_METHOD(void remove(guint idx, guint length), gst_buffer_list_remove)
+
+_WRAP_METHOD(Glib::RefPtr<Gst::Buffer> remove(guint idx), gst_buffer_list_get)
+
+_WRAP_METHOD(void add(gint idx, const Glib::RefPtr<Gst::Buffer>& buffer), gst_buffer_list_insert)
   /** Tests if you can safely add buffers and groups into a buffer list.
    * @return <tt>true</tt> if the buffer list is writable, <tt>false</tt>
    * otherwise.
@@ -91,16 +91,6 @@ public:
    */
   Glib::RefPtr<BufferList> create_writable();
 
-  //TODO: h2def.py does not recognize the C function declaration in the
-  //header.
-  /** Returns the number of groups in list.
-   *
-   * @return The number of groups in the buffer list.
-   *
-   * Since 0.10.24
-   */
-  guint n_groups() const;
-
   /** Call @a slot for each buffer in @a list.
    *
    * @a slot can modify the passed buffer pointer or its contents. The return
@@ -116,100 +106,6 @@ public:
   _WRAP_METHOD(Glib::RefPtr<Gst::Buffer> get(guint idx), gst_buffer_list_get)
   _WRAP_METHOD(Glib::RefPtr<const Gst::Buffer> get(guint idx) const, gst_buffer_list_get, constversion)
 
-  /** Iterate the buffers in the buffer list.
-   * @param result A place in which to store the iterator.
-   * Sine 0.10.24.
-   */
-  void iterate(BufferListIterator& result);
-};
-
-/** An opaque iterator for a Gst::BufferList.
- */
-class BufferListIterator
-{
-  _CLASS_GENERIC(BufferListIterator, GstBufferListIterator)
-
-public:
-  /// Default constructor.
-  BufferListIterator();
-
-  /** C object constructor.
-   * @param castitem The C object.
-   * @param take_ownership Whether to destroy the C object with the wrapper or
-   * not.
-   */
-  explicit BufferListIterator(GstBufferListIterator* castitem,
-    bool take_ownership = true);
-
-  /// Destructor.
-  virtual ~BufferListIterator();
-
-  /// Provides access to the underlying C object.
-  GstBufferListIterator* gobj()
-    { return reinterpret_cast<GstBufferListIterator*>(gobject_); }
-
-  /// Provides access to the underlying C object.
-  const GstBufferListIterator* gobj() const
-    { return reinterpret_cast<GstBufferListIterator*>(gobject_); }
-
-private:
-// noncopyable
-  BufferListIterator(const BufferListIterator& other);
-  BufferListIterator& operator=(const BufferListIterator& other);
-
-  friend class BufferList;
-
-public:
-  /** For example,
-   * Glib::RefPtr<Gst::Buffer> on_process(const Glib::RefPtr<Gst::Buffer>&
-   * buffer);.
-   * A slot for processing the last buffer returned by
-   * Gst::BufferListIterator::next(). The slot can leave the buffer in the
-   * list, replace the buffer in the list or remove the buffer from the list,
-   * depending on the return value. If the slot returns 0, the buffer will be
-   * removed from the list, otherwise the buffer will be replaced with the
-   * returned buffer.
-   *
-   * The last buffer returned by Gst::BufferListIterator::next() will be
-   * replaced with the buffer returned from the function. If 0 is returned, the
-   * buffer will be removed from the list. The list must be writable.
-   */
-  typedef sigc::slot< Glib::RefPtr<Gst::Buffer>, const
-    Glib::RefPtr<Gst::Buffer>& > SlotProcess;
-
-  _WRAP_METHOD(guint n_buffers() const, gst_buffer_list_iterator_n_buffers)
-  _WRAP_METHOD(void add(const Glib::RefPtr<Gst::Buffer>& buffer), gst_buffer_list_iterator_add)
-  _WRAP_METHOD(void add_group(), gst_buffer_list_iterator_add_group)
-
-  _WRAP_METHOD(Glib::RefPtr<Gst::Buffer> next(), gst_buffer_list_iterator_next)
-  _WRAP_METHOD(Glib::RefPtr<const Gst::Buffer> next() const, gst_buffer_list_iterator_next, constversion)
-
-  _WRAP_METHOD(bool next_group(), gst_buffer_list_iterator_next_group)
-  _WRAP_METHOD(void remove(), gst_buffer_list_iterator_remove)
-
-  _WRAP_METHOD(Glib::RefPtr<Gst::Buffer> steal(), gst_buffer_list_iterator_steal)
-  _WRAP_METHOD(void take(const Glib::RefPtr<Gst::Buffer>& buffer), gst_buffer_list_iterator_take)
-
-  /** Calls the given function for the last buffer returned by next(). next()
-   * must have been called on it before this function is called. remove() and
-   * steal() must not have been called since the last call to next().
-   *
-   * See the SlotProcess docs for more details.
-   *
-   * @param slot The slot to be called.
-   * @return The return value from @a slot.
-   */
-  Glib::RefPtr<Gst::Buffer> process(const SlotProcess& slot);
-
-  _WRAP_METHOD(Glib::RefPtr<Gst::Buffer> merge_group(), gst_buffer_list_iterator_merge_group)
-
-protected:
-  GstBufferListIterator* gobject_;      // The C object.
-  bool take_ownership;                  // Bool signaling ownership.
-
-protected:
-  // So that Gst::BufferList::iterate() can set the C object.
-  void set_gobject(GstBufferListIterator* castitem, bool take_ownership = true);
 };
 
 } // namespace Gst


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