gnomemm r1321 - in gstreamermm/trunk: . gstreamer/src tools/m4



Author: murrayc
Date: Tue Feb  5 21:39:49 2008
New Revision: 1321
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1321&view=rev

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

* gstreamer/src/event.hg:
* gstreamer/src/message.hg:
* tools/m4/convert_gst.m4: Use _MEMBER_GET_GOBJECT() where appropriate, 
because this does proper reference-counting and creates const and 
non-const versions.

* gstreamer/src/buffer.[hg|cc]: Some const fixes. Methods that 
return new instance do not need both const and non-const versions.

Added:
   gstreamermm/trunk/gstreamer/src/buffer.ccg
   gstreamermm/trunk/gstreamer/src/buffer.hg
Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/event.hg
   gstreamermm/trunk/gstreamer/src/message.hg
   gstreamermm/trunk/tools/m4/convert_gst.m4

Added: gstreamermm/trunk/gstreamer/src/buffer.ccg
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/gstreamer/src/buffer.ccg	Tue Feb  5 21:39:49 2008
@@ -0,0 +1,18 @@
+#include <gst/gstbuffer.h>
+#include <gst/gstutils.h>
+#include <stdexcept>
+
+namespace Gst
+{
+
+Glib::RefPtr<Buffer> Buffer::create(const guint& size)
+{
+  GstBuffer* buffer = gst_buffer_try_new_and_alloc(size);
+
+  if(buffer != NULL)
+    return wrap(buffer, false);
+  else
+    throw std::runtime_error("not enough memory to allocate the buffer");
+}
+
+}//namespace Gst

Added: gstreamermm/trunk/gstreamer/src/buffer.hg
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/gstreamer/src/buffer.hg	Tue Feb  5 21:39:49 2008
@@ -0,0 +1,69 @@
+#include <gstreamermm/miniobject.h>
+#include <gstreamermm/wrap.h>
+#include <gstreamermm/enums.h>
+#include <gstreamermm/caps.h>
+#include <gstreamermm/clock.h>
+_PINCLUDE(gstreamermm/private/miniobject_p.h)
+_DEFS(gstreamermm,gst)
+
+namespace Gst
+{
+
+class Buffer : public MiniObject
+{
+protected:
+  _CLASS_GSTMINIOBJECT(Buffer, GstBuffer, GST_BUFFER, Gst::MiniObject, GstMiniObject)
+
+public:
+  static Glib::RefPtr<Buffer> create(const guint& size);
+
+  _WRAP_METHOD(guint flags() const, GST_BUFFER_FLAGS)
+  _WRAP_METHOD(bool flag_is_set(BufferFlag flag) const, GST_BUFFER_FLAG_IS_SET)
+  _WRAP_METHOD(void flag_set(BufferFlag flag), GST_BUFFER_FLAG_SET)
+  _WRAP_METHOD(void flag_unset(BufferFlag flag), GST_BUFFER_FLAG_UNSET)
+
+  _WRAP_METHOD(Glib::RefPtr<Buffer> copy() const, gst_buffer_copy)
+
+  _WRAP_METHOD(void copy_metadata(const Glib::RefPtr<Buffer>& source_buffer, BufferCopyFlags flags), gst_buffer_copy_metadata)
+
+  _WRAP_METHOD(bool is_metadata_writable() const, gst_buffer_is_metadata_writable)
+
+  //This is not const because it sometimes returns the same buffer:
+  _WRAP_METHOD(Glib::RefPtr<Buffer> make_writable(), gst_buffer_make_writable)
+
+  //This is const because it always returns a new buffer:
+  _WRAP_METHOD(Glib::RefPtr<Buffer> make_metadata_writable() const, gst_buffer_make_metadata_writable)
+
+  // TODO: Do we need to hand code this to throw an exception when the C API returns NULL ?
+  _WRAP_METHOD(Glib::RefPtr<Caps> get_caps(), gst_buffer_get_caps)
+  _WRAP_METHOD(Glib::RefPtr<Caps const> get_caps() const, gst_buffer_get_caps, constversion)
+
+  _WRAP_METHOD(void set_caps(const Glib::RefPtr<Caps>& caps), gst_buffer_set_caps)
+
+  // TODO: Do we need to hand code this to throw an exception when the C API returns NULL ?
+  _WRAP_METHOD(Glib::RefPtr<Buffer> create_sub(const guint& offset, const guint& size), gst_buffer_create_sub)
+  _WRAP_METHOD(Glib::RefPtr<Buffer const> create_sub(const guint& offset, const guint& size) const, gst_buffer_create_sub, constversion)
+
+  _WRAP_METHOD(bool is_span_fast(const Glib::RefPtr<Buffer>& other_buffer) const, gst_buffer_is_span_fast)
+
+  //This is const because it always returns a new buffer:
+  _WRAP_METHOD(Glib::RefPtr<Buffer> span(const guint32& offset, const Glib::RefPtr<Buffer>& other_buffer, const guint32& len) const, gst_buffer_span)
+
+  _WRAP_METHOD(Glib::RefPtr<Buffer> join(const Glib::RefPtr<Buffer>& other_buffer), gst_buffer_join)
+
+  //This is const because it always returns a new buffer:
+  _WRAP_METHOD(Glib::RefPtr<Buffer> join(const Glib::RefPtr<Buffer>& other_buffer) const, gst_buffer_join)
+
+  //This is const because it always returns a new buffer: (TODO: though maybe not: see the documentation. murrayc)
+  _WRAP_METHOD(Glib::RefPtr<Buffer> merge(const Glib::RefPtr<Buffer>& other_buffer) const, gst_buffer_merge)
+
+  _MEMBER_GET(data, data, guint8*, guint8*)
+  _MEMBER_GET(size, size, guint, guint)
+  _MEMBER_GET(timestamp, timestamp, ClockTime, GstClockTime)
+  _MEMBER_GET(duration, duration, ClockTime, GstClockTime)
+  _MEMBER_GET(offset, offset, guint64, guint64)
+  _MEMBER_GET(offset_end, offset_end, guint64, guint64)
+  _MEMBER_GET(malloc_data, malloc_data, guint8*, guint8*)
+};
+
+}//namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/event.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.hg	Tue Feb  5 21:39:49 2008
@@ -16,10 +16,6 @@
   const Structure& get_structure();
 
 public:
-  _MEMBER_GET(event_type, type, EventType, GstEventType)
-  _MEMBER_GET(timestamp, timestamp, ClockTime, guint64)
-  _MEMBER_GET(source, src, Glib::RefPtr<Gst::Object>, GstObject)
-
   /** Wrap a GstEvent* in a C++ instance, creating an instance of a derived
    * Gst::Event. Gst::wrap() would just create a Gst::Event (rather than a
    * derived one) because the derived Gst::Event classes do not correspond
@@ -31,6 +27,10 @@
   bool is_upstream() const;
   bool is_serialized() const;
 
+  _MEMBER_GET(event_type, type, EventType, GstEventType)
+  _MEMBER_GET(timestamp, timestamp, ClockTime, guint64)
+  _MEMBER_GET_GOBJECT(source, src, Gst::Object, GstObject*)
+
 protected:
   Structure structure_;
 };

Modified: gstreamermm/trunk/gstreamer/src/message.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.hg	Tue Feb  5 21:39:49 2008
@@ -16,9 +16,6 @@
   const Structure& get_structure();
 
 public:
-  _MEMBER_GET(message_type, type, MessageType, GstMessageType)
-  _MEMBER_GET(timestamp, timestamp, ClockTime, guint64)
-  _MEMBER_GET(source, src, Glib::RefPtr<Gst::Object>, GstObject)
 
   /** Wrap a GstMessage* in a C++ instance, creating an instance of a
    *  derived Gst::Message.  Gst::wrap() would just create a Gst::Message
@@ -27,6 +24,10 @@
    */
   static Glib::RefPtr<Message> wrap(GstMessage* message, bool take_copy=false);
 
+  _MEMBER_GET(message_type, type, MessageType, GstMessageType)
+  _MEMBER_GET(timestamp, timestamp, ClockTime, guint64)
+  _MEMBER_GET_GOBJECT(source, src, Gst::Object, GstObject*)
+
 protected: 
   Structure structure_;
 };

Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4	(original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4	Tue Feb  5 21:39:49 2008
@@ -8,7 +8,9 @@
 _CONVERSION(`$1', `GST$1', ((GST$1)(__ARG3__)))
 ')dnl
 
-_CONVERSION(`GstObject',`Glib::RefPtr<Gst::Object>',`Glib::wrap($3, true)')
+_CONVERSION(`GstObject*',`Glib::RefPtr<Gst::Object>',`Glib::wrap($3)')
+_CONVERSION(`GstObject*',`Glib::RefPtr<const Gst::Object>',`Glib::wrap($3)')
+
 #_CONVERSION(`Glib::RefPtr<Object>&',`GstObject*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`State&',`GstState*',`((GstState*) (&($3)))')
 _CONVERSION(`GstClockTime',`ClockTime',`$3')
@@ -44,7 +46,6 @@
 _CONVERSION(`const Glib::RefPtr<Buffer>&',`GstBuffer*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<Buffer>&',`const GstBuffer*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`Glib::RefPtr<Buffer>',`GstBuffer*',__CONVERT_REFPTR_TO_P)
-_CONVERSION(`GstCaps*',`Glib::RefPtr<Caps const>',`wrap($3)')
 
 _CONVERSION(`Structure&',`GstStructure*',`((GstStructure*)(&($3)))')
 _CONVERSION(`GstStructure*',`Structure*',`((Structure*) ($3))')



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