[gstreamermm] Gst::AudioInfo: refactor class
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::AudioInfo: refactor class
- Date: Sat, 23 Apr 2016 18:26:54 +0000 (UTC)
commit 215e44c347af6c70b275ecb2658b6aa6c55cebe7
Author: Marcin Kolny <marcin kolny gmail com>
Date: Sat Apr 23 18:53:28 2016 +0200
Gst::AudioInfo: refactor class
* gstreamer/src/audiofilter.hg: remove unnecessary conversion.
* gstreamer/src/audioformat.{ccg|hg}: add constructor allowing create
AudioFormatInfo object from underlying C structure.
* gstreamer/src/audioinfo.{ccg|hg}: wrap AudioInfo as boxed type,
add member getters/setters.
* tools/m4/convert_gst.m4: add missing conversion.
gstreamer/src/audiofilter.hg | 1 -
gstreamer/src/audioformat.ccg | 9 ++++++
gstreamer/src/audioformat.hg | 2 +
gstreamer/src/audioinfo.ccg | 22 +++++++++------
gstreamer/src/audioinfo.hg | 58 +++++++++++++++++++++++++++++------------
tools/m4/convert_gst.m4 | 6 ++++
6 files changed, 71 insertions(+), 27 deletions(-)
---
diff --git a/gstreamer/src/audiofilter.hg b/gstreamer/src/audiofilter.hg
index 976e264..8e4285a 100644
--- a/gstreamer/src/audiofilter.hg
+++ b/gstreamer/src/audiofilter.hg
@@ -48,7 +48,6 @@ class AudioFilter : public Gst::BaseTransform
_CLASS_GOBJECT(AudioFilter, GstAudioFilter, GST_AUDIO_FILTER, Gst::BaseTransform, GstBaseTransform)
public:
-#m4 _CONVERSION(`const GstAudioInfo*', `const Gst::AudioInfo&', `Gst::AudioInfo($3, false)')
/** Virtual function, called whenever the format changes.
*/
_WRAP_VFUNC(bool setup(const Gst::AudioInfo& info), "setup")
diff --git a/gstreamer/src/audioformat.ccg b/gstreamer/src/audioformat.ccg
index 87c80c0..07f7baa 100644
--- a/gstreamer/src/audioformat.ccg
+++ b/gstreamer/src/audioformat.ccg
@@ -17,3 +17,12 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+namespace Gst
+{
+
+AudioFormatInfo::AudioFormatInfo(const GstAudioFormatInfo *m_info)
+: m_info(*m_info)
+{
+}
+
+}
diff --git a/gstreamer/src/audioformat.hg b/gstreamer/src/audioformat.hg
index 12dc31e..f051c6a 100644
--- a/gstreamer/src/audioformat.hg
+++ b/gstreamer/src/audioformat.hg
@@ -37,6 +37,8 @@ class AudioFormatInfo
{
_CLASS_GENERIC(AudioFormatInfo, GstAudioFormatInfo)
public:
+ AudioFormatInfo(const GstAudioFormatInfo *m_info);
+
/// Gets the underlying gobject.
GstAudioFormatInfo* gobj() { return &m_info; };
diff --git a/gstreamer/src/audioinfo.ccg b/gstreamer/src/audioinfo.ccg
index 0670640..a0579eb 100644
--- a/gstreamer/src/audioinfo.ccg
+++ b/gstreamer/src/audioinfo.ccg
@@ -1,6 +1,6 @@
/* gstreamermm - a C++ wrapper for gstreamer
*
- * Copyright 2008-2009 The gstreamermm Development Team
+ * Copyright 2008-2016 The gstreamermm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,18 +17,22 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <gstreamermm/caps.h>
+#include <gstreamermm/handle_error.h>
+
namespace Gst
{
-AudioInfo::~AudioInfo()
+AudioInfo::AudioInfo(const Glib::RefPtr<const Gst::Caps>& caps)
+: AudioInfo()
{
- if (take_ownership)
- delete m_info;
-}
+ if (!from_caps(caps))
+ {
+ gstreamermm_handle_error(
+ "Gst::AudioInfo::AudioInfo(const Glib::RefPtr<const Gst::Caps>&): "
+ "Failed to construct Gst::AudioInfo from caps: " + caps->to_string());
-AudioInfo::AudioInfo(const GstAudioInfo* info, bool take_ownership)
- : m_info(info),
- take_ownership(take_ownership)
-{
+ }
}
+
}
diff --git a/gstreamer/src/audioinfo.hg b/gstreamer/src/audioinfo.hg
index 9a664ac..200275b 100644
--- a/gstreamer/src/audioinfo.hg
+++ b/gstreamer/src/audioinfo.hg
@@ -1,6 +1,6 @@
/* gstreamermm - a C++ wrapper for gstreamer
*
- * Copyright 2008-2009 The gstreamermm Development Team
+ * Copyright 2008-2016 The gstreamermm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,36 +17,60 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <gstreamermm/audioformat.h>
#include <gst/audio/audio-info.h>
+#include <gstreamermm/audioformat.h>
_DEFS(gstreamermm,gst)
namespace Gst
{
- _WRAP_ENUM(AudioFlags, GstAudioFlags)
- _WRAP_ENUM(AudioLayout, GstAudioLayout)
+_WRAP_ENUM(AudioFlags, GstAudioFlags)
+_WRAP_ENUM(AudioLayout, GstAudioLayout)
+
+class Caps;
-/**
- * Information for an audio format.
+/** Information describing audio properties. This information can be filled
+ * in from Gst::Caps with from_caps() or Gst::AudioInfo() constructor.
+ *
+ * Last reviewed on 2016-04-23 (1.8.0).
*/
-class AudioInfo : public Gst::AudioFormatInfo
+class AudioInfo
{
- _CLASS_GENERIC(AudioInfo, GstAudioInfo)
+ _CLASS_BOXEDTYPE(AudioInfo, GstAudioInfo, gst_audio_info_new, gst_audio_info_copy, gst_audio_info_free)
public:
- AudioInfo(const GstAudioInfo* info, bool take_ownership = false);
+ /** Create AudioInfo from @a caps.
+ *
+ * @param caps A Gst::Caps.
+ *
+ * @throw std::runtime_error if @a caps could not be parsed.
+ */
+ AudioInfo(const Glib::RefPtr<const Gst::Caps>& caps);
+
+ _WRAP_METHOD(bool is_equal(const Gst::AudioInfo& other) const, gst_audio_info_is_equal)
+
+ _WRAP_METHOD(void init(), gst_audio_info_init)
+
+ _WRAP_METHOD(bool from_caps(const Glib::RefPtr<const Gst::Caps>& caps), gst_audio_info_from_caps)
+ _WRAP_METHOD(Glib::RefPtr<Gst::Caps> to_caps() const, gst_audio_info_to_caps)
+
+ _MEMBER_GET(flags, flags, Gst::AudioFlags, GstAudioFlags)
+ _MEMBER_SET(flags, flags, Gst::AudioFlags, GstAudioFlags)
+
+ _MEMBER_GET(layout, layout, Gst::AudioLayout, GstAudioLayout)
+ _MEMBER_SET(layout, layout, Gst::AudioLayout, GstAudioLayout)
+
+ _MEMBER_GET(rate, rate, int, gint)
+ _MEMBER_SET(rate, rate, int, gint)
+
+ _MEMBER_GET(channels, channels, int, gint)
+ _MEMBER_SET(channels, channels, int, gint)
- virtual ~AudioInfo();
- /// Gets the underlying gobject.
- const GstAudioInfo* gobj() const { return m_info; };
+ _MEMBER_GET(bpf, bpf, int, gint)
+ _MEMBER_SET(bpf, bpf, int, gint)
-protected:
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
- const GstAudioInfo* m_info;
- bool take_ownership;
-#endif
+ _MEMBER_GET(finfo, finfo, const Gst::AudioFormatInfo, const GstAudioFormatInfo*)
};
}
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index 9513b7c..1169e2b 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -6,6 +6,8 @@ _CONV_ENUM(Gst,AutoplugSelectResult)
_CONV_ENUM(Gst,AudioBaseSinkSlaveMethod)
_CONV_ENUM(Gst,AudioBaseSinkDiscontReason)
_CONV_ENUM(Gst,AudioBaseSrcSlaveMethod)
+_CONV_ENUM(Gst,AudioFlags)
+_CONV_ENUM(Gst,AudioLayout)
_CONV_ENUM(Gst,BufferCopyFlags)
_CONV_ENUM(Gst,BufferFlags)
_CONV_ENUM(Gst,AudioFormat)
@@ -89,8 +91,12 @@ _CONVERSION(`const Glib::RefPtr<Gst::Allocator>&',`GstAllocator*', `const_cast<G
_CONVERSION(`Glib::RefPtr<Gst::Allocator>&&',`GstAllocator*',`($3) ? $3.release()->gobj() : nullptr');
_CONVERSION(`GstAllocator*', `Glib::RefPtr<Gst::Allocator>', `Glib::wrap($3)')
+dnl AudioFormatInfo
+_CONVERSION(`const GstAudioFormatInfo*', `const Gst::AudioFormatInfo', `Gst::AudioFormatInfo($3)')
+
dnl AudioInfo
_CONVERSION(`const Gst::AudioInfo&', `const GstAudioInfo*', `$3.gobj()')
+_CONVERSION(`const GstAudioInfo*', `const Gst::AudioInfo&', `Gst::AudioInfo(const_cast<GstAudioInfo*>($3))')
dnl Buffer
_CONVERSION(`GstBuffer*',`Glib::RefPtr<Gst::Buffer>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]