[gstreamermm] Wrapped Gst::AudioSink and Gst::AudioSrc vfuncs.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Subject: [gstreamermm] Wrapped Gst::AudioSink and Gst::AudioSrc vfuncs.
- Date: Mon, 11 May 2009 23:11:01 -0400 (EDT)
commit 984f104acb42a2a1e2976b432d9bace2e3a45b7d
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Mon May 11 22:24:10 2009 -0400
Wrapped Gst::AudioSink and Gst::AudioSrc vfuncs.
---
ChangeLog | 10 +++
gstreamer/src/audiosink.ccg | 123 +++++++++++++++++++++++++++++++++++++++++
gstreamer/src/audiosink.hg | 51 ++++++++++++++++-
gstreamer/src/audiosrc.ccg | 123 +++++++++++++++++++++++++++++++++++++++++
gstreamer/src/audiosrc.hg | 52 ++++++++++++++++--
gstreamer/src/gst_vfuncs.defs | 88 +++++++++++++++++++++++++++++
gstreamer/src/index.hg | 10 +---
7 files changed, 441 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fa43091..9ad06f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-05-11 José Alburquerque <jaalburqu svn gnome org>
+
+ * gstreamer/src/audiosink.ccg:
+ * gstreamer/src/audiosink.hg:
+ * gstreamer/src/audiosrc.ccg:
+ * gstreamer/src/audiosrc.hg:
+ * gstreamer/src/gst_vfuncs.defs: Wrapped Gst::AudioSink and
+ Gst::AudioSrc vfuncs.
+ * gstreamer/src/index.hg: Modified TODO.
+
2009-05-10 José Alburquerque <jaalburqu svn gnome org>
* gstreamer/src/baseaudiosrc.ccg:
diff --git a/gstreamer/src/audiosink.ccg b/gstreamer/src/audiosink.ccg
index 9ce9bfe..7ad916d 100644
--- a/gstreamer/src/audiosink.ccg
+++ b/gstreamer/src/audiosink.ccg
@@ -19,3 +19,126 @@
#include <gst/audio/gstaudiosink.h>
_PINCLUDE(gstreamermm/private/baseaudiosink_p.h)
+
+namespace Gst
+{
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+gboolean AudioSink_Class::prepare_vfunc_callback(GstAudioSink* self, GstRingBufferSpec* spec)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ // Call the virtual member method, which derived classes might override.
+ Gst::RingBufferSpec cpp_spec(spec);
+ return static_cast<int>(obj->prepare_vfunc(cpp_spec));
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->prepare)
+ return (*base->prepare)(self, spec);
+
+
+ typedef gboolean RType;
+ return RType();
+}
+bool Gst::AudioSink::prepare_vfunc(Gst::RingBufferSpec& spec)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->prepare)
+ {
+ GstRingBufferSpec gst_spec;
+ spec.copy_fields_to(gst_spec);
+ return (*base->prepare)(gobj(),&gst_spec);
+ }
+
+ typedef bool RType;
+ return RType();
+}
+guint AudioSink_Class::write_vfunc_callback(GstAudioSink* self, gpointer data, guint length)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ // Call the virtual member method, which derived classes might override.
+ return obj->write_vfunc(data, length);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->write)
+ return (*base->write)(self, data, length);
+
+
+ typedef guint RType;
+ return RType();
+}
+guint Gst::AudioSink::write_vfunc(const void* data, guint length)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->write)
+ return (*base->write)(gobj(),const_cast<void*>(data),length);
+
+ typedef guint RType;
+ return RType();
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
+} // namespace Gst
diff --git a/gstreamer/src/audiosink.hg b/gstreamer/src/audiosink.hg
index 0568719..48d7f82 100644
--- a/gstreamer/src/audiosink.hg
+++ b/gstreamer/src/audiosink.hg
@@ -19,6 +19,7 @@
#include <gst/audio/gstaudiosink.h>
#include <gstreamermm/baseaudiosink.h>
+#include <gstreamermm/ringbuffer.h>
_DEFS(gstreamermm,gst)
@@ -33,8 +34,8 @@ namespace Gst
* - prepare_vfunc() - Configure the device with the specified format.
* - write_vfunc() - Write samples to the device.
* - reset_vfunc() - Unblock writes and flush the device.
- * - delay_vfunc() - Get the number of samples written but not yet played by
- * the device.
+ * - get_delay_vfunc() - Get the number of samples written but not yet played
+ * by the device.
* - unprepare_vfunc() - Undo operations done by prepare.
* - close_vfunc() - Close the device.
*
@@ -51,7 +52,51 @@ class AudioSink : public Gst::BaseAudioSink
_CLASS_GOBJECT(AudioSink, GstAudioSink, GST_AUDIO_SINK, Gst::BaseAudioSink, GstBaseAudioSink)
public:
- //TODO: Wrap vfuncs.
+ /** vfunc to open the device. No configuration needs to be done at this
+ * point. This function is also used to check if the device is available.
+ */
+ _WRAP_VFUNC(bool open(), "open")
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+ /** vfunc to prepare the device to operate with the specified parameters.
+ */
+ virtual bool prepare_vfunc(Gst::RingBufferSpec& spec);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+ /** vfunc to undo operations done in prepare.
+ */
+ _WRAP_VFUNC(bool unprepare(), "unprepare")
+
+ /** vfunc to close the device.
+ */
+ _WRAP_VFUNC(bool close(), "close")
+
+ #ifdef GLIBMM_VFUNCS_ENABLED
+ /** vfunc to write data to the device.
+ */
+ virtual guint write_vfunc(const void* data, guint length);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+ /** vfunc to return how many samples are still in the device. This is used to
+ * drive the synchronisation.
+ */
+ _WRAP_VFUNC(guint get_delay(), "delay")
+
+ /** vfunc to return as quickly as possible from a write and flush any pending
+ * samples from the device.
+ */
+ _WRAP_VFUNC(void reset(), "reset")
+
+protected:
+#m4begin
+ _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+ klass->prepare = &prepare_vfunc_callback;
+ klass->write = &write_vfunc_callback;
+ _SECTION(SECTION_PH_VFUNCS)
+ static gboolean prepare_vfunc_callback(GstAudioSink* self, GstRingBufferSpec* spec);
+ static guint write_vfunc_callback(GstAudioSink* self, gpointer data, guint length);
+ _POP()
+#m4end
};
} // namespace Gst
diff --git a/gstreamer/src/audiosrc.ccg b/gstreamer/src/audiosrc.ccg
index cada882..18c0605 100644
--- a/gstreamer/src/audiosrc.ccg
+++ b/gstreamer/src/audiosrc.ccg
@@ -19,3 +19,126 @@
#include <gst/audio/gstaudiosrc.h>
_PINCLUDE(gstreamermm/private/baseaudiosrc_p.h)
+
+namespace Gst
+{
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+gboolean AudioSrc_Class::prepare_vfunc_callback(GstAudioSrc* self, GstRingBufferSpec* spec)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ // Call the virtual member method, which derived classes might override.
+ Gst::RingBufferSpec cpp_spec(spec);
+ return static_cast<int>(obj->prepare_vfunc(cpp_spec));
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->prepare)
+ return (*base->prepare)(self, spec);
+
+
+ typedef gboolean RType;
+ return RType();
+}
+bool Gst::AudioSrc::prepare_vfunc(Gst::RingBufferSpec& spec)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->prepare)
+ {
+ GstRingBufferSpec gst_spec;
+ spec.copy_fields_to(gst_spec);
+ return (*base->prepare)(gobj(),&gst_spec);
+ }
+
+ typedef bool RType;
+ return RType();
+}
+guint AudioSrc_Class::read_vfunc_callback(GstAudioSrc* self, gpointer data, guint length)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ // Call the virtual member method, which derived classes might override.
+ return obj->read_vfunc(data, length);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && base->read)
+ return (*base->read)(self, data, length);
+
+
+ typedef guint RType;
+ return RType();
+}
+guint Gst::AudioSrc::read_vfunc(const void* data, guint length)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && base->read)
+ return (*base->read)(gobj(),const_cast<void*>(data),length);
+
+ typedef guint RType;
+ return RType();
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
+} // namespace Gst
diff --git a/gstreamer/src/audiosrc.hg b/gstreamer/src/audiosrc.hg
index ad2f977..4af0771 100644
--- a/gstreamer/src/audiosrc.hg
+++ b/gstreamer/src/audiosrc.hg
@@ -19,6 +19,7 @@
#include <gst/audio/gstaudiosrc.h>
#include <gstreamermm/baseaudiosrc.h>
+#include <gstreamermm/ringbuffer.h>
_DEFS(gstreamermm,gst)
@@ -31,10 +32,10 @@ namespace Gst
*
* - open_vfunc() - Open the device.
* - prepare_vfunc() - Configure the device with the specified format.
- * - write_vfunc() - Write samples to the device.
- * - reset_vfunc() - Unblock writes and flush the device.
- * - delay_vfunc() - Get the number of samples written but not yet played by
- * the device.
+ * - read_vfunc() - Read samples from the device.
+ * - reset_vfunc() - Unblock reads and flush the device.
+ * - get_delay_vfunc() - Get the number of samples written but not yet played
+ * by the device.
* - unprepare_vfunc() - Undo operations done by prepare.
* - close_vfunc() - Close the device.
*
@@ -51,7 +52,48 @@ class AudioSrc : public Gst::BaseAudioSrc
_CLASS_GOBJECT(AudioSrc, GstAudioSrc, GST_AUDIO_SRC, Gst::BaseAudioSrc, GstBaseAudioSrc)
public:
- //TODO: Wrap vfuncs.
+ /** vfunc to open the device.
+ */
+ _WRAP_VFUNC(bool open(), "open")
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+ /** vfunc to configure device with spec.
+ */
+ virtual bool prepare_vfunc(Gst::RingBufferSpec& spec);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+ /** vfunc to undo the configuration.
+ */
+ _WRAP_VFUNC(bool unprepare(), "unprepare")
+
+ /** vfunc to close the device.
+ */
+ _WRAP_VFUNC(bool close(), "close")
+
+ #ifdef GLIBMM_VFUNCS_ENABLED
+ /** vfunc to read samples to the audio device.
+ */
+ virtual guint read_vfunc(const void* data, guint length);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+ /** vfunc to get the number of samples queued in the device.
+ */
+ _WRAP_VFUNC(guint get_delay(), "delay")
+
+ /** vfunc to unblock a read to the device and reset.
+ */
+ _WRAP_VFUNC(void reset(), "reset")
+
+protected:
+#m4begin
+ _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+ klass->prepare = &prepare_vfunc_callback;
+ klass->read = &read_vfunc_callback;
+ _SECTION(SECTION_PH_VFUNCS)
+ static gboolean prepare_vfunc_callback(GstAudioSrc* self, GstRingBufferSpec* spec);
+ static guint read_vfunc_callback(GstAudioSrc* self, gpointer data, guint length);
+ _POP()
+#m4end
};
} // namespace Gst
diff --git a/gstreamer/src/gst_vfuncs.defs b/gstreamer/src/gst_vfuncs.defs
index 57fd174..a40d420 100644
--- a/gstreamer/src/gst_vfuncs.defs
+++ b/gstreamer/src/gst_vfuncs.defs
@@ -694,6 +694,94 @@
)
)
+; GstAudioSink
+
+(define-vfunc open
+ (of-object "GstAudioSink")
+ (return-type "gboolean")
+)
+
+(define-vfunc prepare
+ (of-object "GstAudioSink")
+ (return-type "gboolean")
+ (parameters
+ '("GstRingBufferSpec*" "spec")
+ )
+)
+
+(define-vfunc unprepare
+ (of-object "GstAudioSink")
+ (return-type "gboolean")
+)
+
+(define-vfunc close
+ (of-object "GstAudioSink")
+ (return-type "gboolean")
+)
+
+(define-vfunc write
+ (of-object "GstAudioSink")
+ (return-type "guint")
+ (parameters
+ '("gpointer" "data")
+ '("guint" "length")
+ )
+)
+
+(define-vfunc delay
+ (of-object "GstAudioSink")
+ (return-type "guint")
+)
+
+(define-vfunc reset
+ (of-object "GstAudioSink")
+ (return-type "void")
+)
+
+; GstAudioSrc
+
+(define-vfunc open
+ (of-object "GstAudioSrc")
+ (return-type "gboolean")
+)
+
+(define-vfunc prepare
+ (of-object "GstAudioSrc")
+ (return-type "gboolean")
+ (parameters
+ '("GstRingBufferSpec*" "spec")
+ )
+)
+
+(define-vfunc unprepare
+ (of-object "GstAudioSrc")
+ (return-type "gboolean")
+)
+
+(define-vfunc close
+ (of-object "GstAudioSrc")
+ (return-type "gboolean")
+)
+
+(define-vfunc read
+ (of-object "GstAudioSrc")
+ (return-type "guint")
+ (parameters
+ '("gpointer" "data")
+ '("guint" "length")
+ )
+)
+
+(define-vfunc delay
+ (of-object "GstAudioSrc")
+ (return-type "guint")
+)
+
+(define-vfunc reset
+ (of-object "GstAudioSrc")
+ (return-type "void")
+)
+
; GstBaseAudioSink
(define-vfunc create_ringbuffer
diff --git a/gstreamer/src/index.hg b/gstreamer/src/index.hg
index 77dc9f9..b706a8f 100644
--- a/gstreamer/src/index.hg
+++ b/gstreamer/src/index.hg
@@ -166,14 +166,8 @@ public:
virtual void add_entry_vfunc(Gst::IndexEntry& entry);
#endif //GLIBMM_VFUNCS_ENABLED
- //TODO: This vfunc is strange because the prototype in the class structure
- //includes a "gpointer user_data" parameter. Is this a bug? Jose.
- //
- //No. It's normal that this "function" takes a user_data parameter because it also
- //takes a callback function, to which that user_data should be passed.
- //Once the nasty C callback is replaced by a sigc::slot in our C++ version of this vfunc
- //then there will probably be no need for the user_data parameter. But that will all
- //be rather difficult, so I would just ignore this for now unless it is very useful. murrayc.
+ //TODO: Leave this vfunc for later because it is not absolutely necessary
+ //right now.
//_WRAP_VFUNC(void get_assoc_entry(Gst::LookupMethod method, Gst::AssocFlags flags, Gst::Format format, gint64 value, const SlotCompareData& compare_slot), "get_assoc_entry")
protected:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]