[gstreamermm] CddaBaseSrc: Wrap virtual functions.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] CddaBaseSrc: Wrap virtual functions.
- Date: Fri, 4 Dec 2009 22:53:05 +0000 (UTC)
commit bd11caafe0b6c42aa375f6810e397ca489281833
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Fri Dec 4 17:46:08 2009 -0500
CddaBaseSrc: Wrap virtual functions.
* gstreamer/src/cddabasesrc.ccg:
* gstreamer/src/cddabasesrc.hg:
* gstreamer/src/gst_vfuncs.defs: Wrapped add_track() and virtual
functions. Used std::string for device property. Corrected tag
references in docs.
ChangeLog | 10 +++
gstreamer/src/cddabasesrc.ccg | 136 +++++++++++++++++++++++++++++++++++++++++
gstreamer/src/cddabasesrc.hg | 60 ++++++++++++++++--
gstreamer/src/gst_vfuncs.defs | 33 ++++++++++
4 files changed, 233 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index decfd3f..0dd287f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-04 José Alburquerque <jaalburqu svn gnome org>
+
+ CddaBaseSrc: Wrap virtual functions.
+
+ * gstreamer/src/cddabasesrc.ccg:
+ * gstreamer/src/cddabasesrc.hg:
+ * gstreamer/src/gst_vfuncs.defs: Wrapped add_track() and virtual
+ functions. Used std::string for device property. Corrected tag
+ references in docs.
+
2009-12-03 José Alburquerque <jaalburqu svn gnome org>
TaskPool: Wrap virtual functions.
diff --git a/gstreamer/src/cddabasesrc.ccg b/gstreamer/src/cddabasesrc.ccg
index 0d296e2..7fd9c06 100644
--- a/gstreamer/src/cddabasesrc.ccg
+++ b/gstreamer/src/cddabasesrc.ccg
@@ -18,4 +18,140 @@
*/
#include <gst/cdda/gstcddabasesrc.h>
+#include <gstreamermm/buffer.h>
_PINCLUDE(gstreamermm/private/pushsrc_p.h)
+
+namespace Gst
+{
+
+bool CddaBaseSrc::add_track(guint num, guint start, guint end, bool is_audio,
+ const Gst::TagList& tags)
+{
+ GstCddaBaseSrcTrack track;
+
+ track.num = num;
+ track.start = start;
+ track.end = end;
+ track.is_audio = is_audio;
+
+ if (tags)
+ track.tags = tags.gobj_copy();
+
+ return gst_cdda_base_src_add_track(gobj(), &track);
+}
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+gboolean CddaBaseSrc_Class::open_vfunc_callback(GstCddaBaseSrc* self, const gchar* device)
+{
+ 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.
+ std::string cpp_device(device);
+ return static_cast<int>(obj->open_vfunc(cpp_device));
+ #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->open)
+ return (*base->open)(self, device);
+
+
+ typedef gboolean RType;
+ return RType();
+}
+bool Gst::CddaBaseSrc::open_vfunc(std::string& device)
+{
+ 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->open)
+ return (*base->open)(gobj(),device.c_str());
+
+ typedef bool RType;
+ return RType();
+}
+gchar** CddaBaseSrc_Class::probe_devices_vfunc_callback(GstCddaBaseSrc* self)
+{
+ 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 const_cast<gchar**>(obj->probe_devices_vfunc().data());
+ #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->probe_devices)
+ return (*base->probe_devices)(self);
+
+
+ typedef gchar** RType;
+ return RType();
+}
+Glib::ArrayHandle<std::string> Gst::CddaBaseSrc::probe_devices_vfunc()
+{
+ 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->probe_devices)
+ return Glib::ArrayHandle<std::string>((*base->probe_devices)(gobj()), Glib::OWNERSHIP_DEEP);
+
+ typedef Glib::ArrayHandle<std::string> RType;
+ return RType(0, Glib::OWNERSHIP_NONE);
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
+} // namespace Gst
diff --git a/gstreamer/src/cddabasesrc.hg b/gstreamer/src/cddabasesrc.hg
index 8644f89..67a5d85 100644
--- a/gstreamer/src/cddabasesrc.hg
+++ b/gstreamer/src/cddabasesrc.hg
@@ -19,6 +19,7 @@
#include <gst/cdda/gstcddabasesrc.h>
#include <gstreamermm/pushsrc.h>
+#include <gstreamermm/taglist.h>
_DEFS(gstreamermm,gst)
@@ -45,7 +46,7 @@ _WRAP_ENUM(CddaBaseSrcMode,GstCddaBaseSrcMode)
* Alternatively, applications may retrieve the currently playing track and the
* total number of tracks from the taglist that will be posted on the bus
* whenever the CD is opened or the currently playing track changes. The
- * taglist will contain Gst::Tag::TRACK_NUMBER and Gst::Tag::TRACK_COUNT tags.
+ * taglist will contain Gst::TAG_TRACK_NUMBER and Gst::TAG_TRACK_COUNT tags.
*
* Applications playing back CD audio using playbin and cdda://n URIs should
* issue a seek command in track format to change between tracks, rather than
@@ -54,8 +55,8 @@ _WRAP_ENUM(CddaBaseSrcMode,GstCddaBaseSrcMode)
*
* CDDA sources will automatically emit a number of tags, details about which
* can be found in the libgsttag documentation. Those tags are:
- * Gst::Tag::CDDA_CDDB_DISCID, Gst::Tag::CDDA_CDDB_DISCID_FULL,
- * Gst::Tag::CDDA_MUSICBRAINZ_DISCID, Gst::Tag::CDDA_MUSICBRAINZ_DISCID_FULL,
+ * Gst::TAG_CDDA_CDDB_DISCID, Gst::TAG_CDDA_CDDB_DISCID_FULL,
+ * Gst::TAG_CDDA_MUSICBRAINZ_DISCID, Gst::TAG_CDDA_MUSICBRAINZ_DISCID_FULL,
* among others.
*
* @ingroup GstBaseClasses
@@ -65,13 +66,60 @@ class CddaBaseSrc : public Gst::PushSrc
_CLASS_GOBJECT(CddaBaseSrc, GstCddaBaseSrc, GST_CDDA_BASE_SRC, Gst::PushSrc, GstPushSrc)
public:
- //TODO: _WRAP_METHOD(bool add_track(...), gst_cdda_base_src_add_track)
+ /** CDDA sources use this function from their start vfunc to announce the
+ * available data and audio tracks to the base source class.
+ *
+ * @param num Track number in TOC (usually starts from 1, but not always).
+ * @param start The first sector of the track (LBA).
+ * @param end The last sector of the track (LBA).
+ * @param is_audio Whether this is an audio track.
+ * @param tags Track-specific tags (e.g. from cd-text information).
+ * @return false on error, otherwise true.
+ */
+ bool add_track(guint num, guint start, guint end, bool is_audio = true,
+ const Gst::TagList& tags = Gst::TagList());
+ _IGNORE(gst_cdda_base_src_add_track)
- _WRAP_PROPERTY("device", Glib::ustring)
+ _WRAP_PROPERTY("device", std::string)
_WRAP_PROPERTY("mode", CddaBaseSrcMode)
_WRAP_PROPERTY("track", guint)
- //TODO: Wrap vfuncs.
+#ifdef GLIBMM_VFUNCS_ENABLED
+ /** Virtual function to open a CD device.
+ */
+ virtual bool open_vfunc(std::string& device);
+#endif //GLIBMM_VFUNCS_ENABLED
+
+ /** Virtual function to close the device.
+ */
+ _WRAP_VFUNC(void close(), "close")
+
+ /** Virtual function to read one sector (LBA).
+ */
+ _WRAP_VFUNC(Glib::RefPtr<Gst::Buffer> read_sector(gint sector), "read_sector")
+
+ /** Virtual function to get default device. It is optional and may return
+ * an empty string.
+ */
+ _WRAP_VFUNC(std::string get_default_device(), "get_default_device")
+
+#ifdef GLIBMM_VFUNCS_ENABLED
+ /** Virtual function to return array of CD devices. It is optional and may
+ * return an empty array.
+ */
+ virtual Glib::ArrayHandle<std::string> probe_devices_vfunc();
+#endif //GLIBMM_VFUNCS_ENABLED
+
+protected:
+#m4begin
+ _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+ klass->open = &open_vfunc_callback;
+ klass->probe_devices = &probe_devices_vfunc_callback;
+ _SECTION(SECTION_PH_VFUNCS)
+ static gboolean open_vfunc_callback(GstCddaBaseSrc* self, const gchar* device);
+ static gchar** probe_devices_vfunc_callback(GstCddaBaseSrc* self);
+ _POP()
+#m4end
};
} // namespace Gst
diff --git a/gstreamer/src/gst_vfuncs.defs b/gstreamer/src/gst_vfuncs.defs
index c44c462..b21a7a0 100644
--- a/gstreamer/src/gst_vfuncs.defs
+++ b/gstreamer/src/gst_vfuncs.defs
@@ -829,6 +829,39 @@
(return-type "GstRingBuffer*")
)
+; GstCddaBaseSrc
+
+(define-vfunc open
+ (of-object "GstCddaBaseSrc")
+ (return-type "gboolean")
+ (parameters
+ '("const-gchar*" "device")
+ )
+)
+
+(define-vfunc close
+ (of-object "GstCddaBaseSrc")
+ (return-type "void")
+)
+
+(define-vfunc read_sector
+ (of-object "GstCddaBaseSrc")
+ (return-type "GstBuffer*")
+ (parameters
+ '("gint" "sector")
+ )
+)
+
+(define-vfunc get_default_device
+ (of-object "GstCddaBaseSrc")
+ (return-type "gchar*")
+)
+
+(define-vfunc probe_devices
+ (of-object "GstCddaBaseSrc")
+ (return-type "gchar**")
+)
+
; GstColorBalance
(define-vfunc list_channels
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]