[gstreamermm] Gst::VideoFrame: add GstVideoFrame wrapper



commit 5d0307a9dc8ff5270bc186bd899b1d8f054231f3
Author: Marcin Kolny <marcin kolny flytronic pl>
Date:   Tue Jul 7 15:46:24 2015 +0200

    Gst::VideoFrame: add GstVideoFrame wrapper
    
        * .gitignore: add videoframe autogenerated files to ignore list.
        * gstreamer/src/filelist.am: add videoframe to build.
        * gstreamer/src/videoframe.{ccg|hg}: add gstvideoframe wrapper.
        * tools/m4/convert_gst.m4: add a few necessary convert definitions.

 .gitignore                   |    2 +
 gstreamer/src/filelist.am    |    1 +
 gstreamer/src/videoframe.ccg |   37 ++++++++++++++++++++++
 gstreamer/src/videoframe.hg  |   71 ++++++++++++++++++++++++++++++++++++++++++
 tools/m4/convert_gst.m4      |   12 +++++++
 5 files changed, 123 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 18361a8..57542dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -331,6 +331,8 @@ gstreamer/gstreamermm/videoconvert.cc
 gstreamer/gstreamermm/videoconvert.h
 gstreamer/gstreamermm/videoformat.cc
 gstreamer/gstreamermm/videoformat.h
+gstreamer/gstreamermm/videoframe.cc
+gstreamer/gstreamermm/videoframe.h
 gstreamer/gstreamermm/videoinfo.cc
 gstreamer/gstreamermm/videoinfo.h
 gstreamer/gstreamermm/videooverlay.h
diff --git a/gstreamer/src/filelist.am b/gstreamer/src/filelist.am
index 2e243bc..7706607 100644
--- a/gstreamer/src/filelist.am
+++ b/gstreamer/src/filelist.am
@@ -151,6 +151,7 @@ files_hg  =                     \
         valuelist.hg            \
         videochroma.hg          \
         videoformat.hg          \
+        videoframe.hg           \
         videoinfo.hg            \
         videoorientation.hg     \
         videosink.hg            \
diff --git a/gstreamer/src/videoframe.ccg b/gstreamer/src/videoframe.ccg
new file mode 100644
index 0000000..afc59f3
--- /dev/null
+++ b/gstreamer/src/videoframe.ccg
@@ -0,0 +1,37 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008-2015 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ 
+#include <cstring>
+
+namespace Gst
+{
+
+VideoFrame::VideoFrame()
+{
+  std::memset(&gobject_, 0, sizeof(GstVideoFrame));
+}
+
+VideoFrame::VideoFrame(const GstVideoFrame* gobject)
+{
+  if(gobject)
+    gobject_ = *gobject;
+  else
+    std::memset(&gobject_, 0, sizeof(GstVideoFrame));
+}
+}
diff --git a/gstreamer/src/videoframe.hg b/gstreamer/src/videoframe.hg
new file mode 100644
index 0000000..586b2c9
--- /dev/null
+++ b/gstreamer/src/videoframe.hg
@@ -0,0 +1,71 @@
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008-2015 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_DEFS(gstreamermm,gst)
+
+#include <gst/video/video-frame.h>
+#include <gstreamermm/videoinfo.h>
+#include <gstreamermm/buffer.h>
+
+namespace Gst
+{
+
+  _WRAP_ENUM(VideoFrameFlags, GstVideoFrameFlags)
+  _WRAP_ENUM(VideoBufferFlags, GstVideoBufferFlags)
+  _WRAP_ENUM(VideoFrameMapFlags, GstVideoFrameMapFlags)
+
+class VideoFrame
+{
+  _CLASS_GENERIC(VideoFrame, GstVideoFrame)
+public:
+  VideoFrame();
+  explicit VideoFrame(const GstVideoFrame* gobject); // always takes a copy
+  ///Provides access to the underlying C instance.
+  GstVideoFrame*       gobj()       { return &gobject_; }
+  ///Provides access to the underlying C instance.
+  const GstVideoFrame* gobj() const { return &gobject_; }
+
+protected:
+  GstVideoFrame gobject_;
+
+public:
+  _WRAP_METHOD(bool map(const VideoInfo& info, const Glib::RefPtr<Gst::Buffer>& buffer, Gst::MapFlags 
flags), gst_video_frame_map)
+  _WRAP_METHOD(bool map_id(const VideoInfo& info, const Glib::RefPtr<Gst::Buffer>& buffer, gint id, 
Gst::MapFlags flags), gst_video_frame_map_id)
+  _WRAP_METHOD(void unmap(), gst_video_frame_unmap)
+  _WRAP_METHOD(static bool copy(const VideoFrame& dest, const VideoFrame& src), gst_video_frame_copy)
+  _WRAP_METHOD(static bool copy_plane(const VideoFrame& dest, const VideoFrame& src, guint plane), 
gst_video_frame_copy_plane)
+
+  _MEMBER_SET(info, info, VideoInfo, GstVideoInfo)
+  _MEMBER_GET(info, info, VideoInfo, GstVideoInfo)
+  
+
+  _MEMBER_SET(flags, flags, Gst::VideoFrameFlags, GstVideoFrameFlags)
+  _MEMBER_GET(flags, flags, Gst::VideoFrameFlags, GstVideoFrameFlags)
+
+  _MEMBER_SET(buffer, buffer, Glib::RefPtr<Gst::Buffer>, GstBuffer*)
+  _MEMBER_GET(buffer, buffer, Glib::RefPtr<Gst::Buffer>, GstBuffer*)
+
+  _MEMBER_SET(meta, meta, gpointer, gpointer)
+  _MEMBER_GET(meta, meta, gpointer, gpointer)
+
+  _MEMBER_SET(id, id, gint, gint)
+  _MEMBER_GET(id, id, gint, gint)
+};
+
+}
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index 12ab676..0679869 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -57,10 +57,13 @@ _CONV_ENUM(Gst,TocEntryType)
 _CONV_ENUM(Gst,TocScope)
 _CONV_ENUM(Gst,TunerChannelFlags)
 _CONV_ENUM(Gst,URIType)
+_CONV_ENUM(Gst,VideoBufferFlags)
 _CONV_ENUM(Gst,VideoChromaSite)
 _CONV_ENUM(Gst,VideoFlags)
 _CONV_ENUM(Gst,VideoFormat)
 _CONV_ENUM(Gst,VideoFormatFlags)
+_CONV_ENUM(Gst,VideoFrameFlags)
+_CONV_ENUM(Gst,VideoFrameMapFlags)
 _CONV_ENUM(Gst,VideoInterlaceMode)
 _CONV_ENUM(Gst,VideoMultiviewFlags)
 _CONV_ENUM(Gst,VideoMultiviewFramePacking)
@@ -284,10 +287,19 @@ _CONVERSION(`Gst::TypeFind&',`GstTypeFind*',`$3.gobj()')
 dnl VideoInfo
 _CONVERSION(`VideoInfo', `GstVideoInfo*', `$3.gobj()')
 _CONVERSION(`const VideoInfo&', `const GstVideoInfo*', `$3.gobj()')
+_CONVERSION(`const VideoInfo&', `GstVideoInfo*', `const_cast<GstVideoInfo*>($3.gobj())')
+_CONVERSION(`const VideoInfo&', `GstVideoInfo', `*($3.gobj())')
+_CONVERSION(`VideoInfo', `GstVideoInfo', `*($3.gobj())')
+_CONVERSION(`GstVideoInfo', `VideoInfo', `VideoInfo(VideoInfo(const_cast<GstVideoInfo*>(&$3), false))')
 
 dnl VideoFormatInfo
 _CONVERSION(`const GstVideoFormatInfo*', `const VideoFormatInfo&', `VideoFormatInfo($3)')
 
+dnl VideoFrame
+_CONVERSION(`const VideoFrame&', `GstVideoFrame*', `$3.gobj()')
+_CONVERSION(`const VideoFrame&', `const GstVideoFrame*', `$3.gobj()')
+_CONVERSION(`const VideoFrame&', `GstVideoFrame*', `const_cast<GstVideoFrame*>($3.gobj())')
+
 
 dnl ############## gstreamermm Interface Conversions ######################
 


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