mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
efence: remove plugin
Valgrind is much more useful these days.
This commit is contained in:
parent
3c292543bc
commit
c6dafad169
6 changed files with 1 additions and 756 deletions
|
@ -202,7 +202,6 @@
|
||||||
<xi:include href="xml/plugin-deinterlace.xml" />
|
<xi:include href="xml/plugin-deinterlace.xml" />
|
||||||
<xi:include href="xml/plugin-directsound.xml" />
|
<xi:include href="xml/plugin-directsound.xml" />
|
||||||
<xi:include href="xml/plugin-dv.xml" />
|
<xi:include href="xml/plugin-dv.xml" />
|
||||||
<xi:include href="xml/plugin-efence.xml" />
|
|
||||||
<xi:include href="xml/plugin-equalizer.xml" />
|
<xi:include href="xml/plugin-equalizer.xml" />
|
||||||
<xi:include href="xml/plugin-effectv.xml" />
|
<xi:include href="xml/plugin-effectv.xml" />
|
||||||
<xi:include href="xml/plugin-flac.xml" />
|
<xi:include href="xml/plugin-flac.xml" />
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
<plugin>
|
|
||||||
<name>efence</name>
|
|
||||||
<description>This element converts a stream of normal GStreamer buffers into a stream of buffers that are allocated in such a way that out-of-bounds access to data in the buffer is more likely to cause segmentation faults. This allocation method is very similar to the debugging tool "Electric Fence".</description>
|
|
||||||
<filename>../../gst/debugutils/.libs/libgstefence.so</filename>
|
|
||||||
<basename>libgstefence.so</basename>
|
|
||||||
<version>0.10.30.1</version>
|
|
||||||
<license>LGPL</license>
|
|
||||||
<source>gst-plugins-good</source>
|
|
||||||
<package>GStreamer Good Plug-ins git</package>
|
|
||||||
<origin>Unknown package origin</origin>
|
|
||||||
<elements>
|
|
||||||
<element>
|
|
||||||
<name>efence</name>
|
|
||||||
<longname>Electric Fence</longname>
|
|
||||||
<class>Testing</class>
|
|
||||||
<description>This element converts a stream of normal GStreamer buffers into a stream of buffers that are allocated in such a way that out-of-bounds access to data in the buffer is more likely to cause segmentation faults. This allocation method is very similar to the debugging tool "Electric Fence".</description>
|
|
||||||
<author>David A. Schleef <ds@schleef.org></author>
|
|
||||||
<pads>
|
|
||||||
<caps>
|
|
||||||
<name>sink</name>
|
|
||||||
<direction>sink</direction>
|
|
||||||
<presence>always</presence>
|
|
||||||
<details>ANY</details>
|
|
||||||
</caps>
|
|
||||||
<caps>
|
|
||||||
<name>src</name>
|
|
||||||
<direction>source</direction>
|
|
||||||
<presence>always</presence>
|
|
||||||
<details>ANY</details>
|
|
||||||
</caps>
|
|
||||||
</pads>
|
|
||||||
</element>
|
|
||||||
</elements>
|
|
||||||
</plugin>
|
|
|
@ -1,15 +1,8 @@
|
||||||
if GST_HAVE_MMAP
|
|
||||||
#EFENCE_PLUGIN=libgstefence.la
|
|
||||||
EFENCE_PLUGIN=
|
|
||||||
else
|
|
||||||
EFENCE_PLUGIN=
|
|
||||||
endif
|
|
||||||
|
|
||||||
plugin_LTLIBRARIES = $(EFENCE_PLUGIN) libgstdebug.la libgstnavigationtest.la
|
plugin_LTLIBRARIES = libgstdebug.la libgstnavigationtest.la
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
cpureport.h \
|
cpureport.h \
|
||||||
efence.h \
|
|
||||||
gstcapsdebug.h \
|
gstcapsdebug.h \
|
||||||
gstcapssetter.h \
|
gstcapssetter.h \
|
||||||
gstnavigationtest.h \
|
gstnavigationtest.h \
|
||||||
|
@ -19,12 +12,6 @@ noinst_HEADERS = \
|
||||||
progressreport.h \
|
progressreport.h \
|
||||||
tests.h
|
tests.h
|
||||||
|
|
||||||
#libgstefence_la_SOURCES = efence.c
|
|
||||||
#libgstefence_la_CFLAGS = $(GST_CFLAGS)
|
|
||||||
#libgstefence_la_LIBADD = $(GST_LIBS)
|
|
||||||
#libgstefence_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|
||||||
#libgstefence_la_LIBTOOLFLAGS = --tag=disable-static
|
|
||||||
|
|
||||||
libgstnavigationtest_la_SOURCES = gstnavigationtest.c
|
libgstnavigationtest_la_SOURCES = gstnavigationtest.c
|
||||||
libgstnavigationtest_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
|
libgstnavigationtest_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) \
|
||||||
$(GST_PLUGINS_BASE_CFLAGS)
|
$(GST_PLUGINS_BASE_CFLAGS)
|
||||||
|
|
|
@ -1,517 +0,0 @@
|
||||||
/*
|
|
||||||
* GStreamer
|
|
||||||
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
|
||||||
* Copyright (C) 2002 David A. Schleef <ds@schleef.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 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
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
|
|
||||||
#include "efence.h"
|
|
||||||
|
|
||||||
#ifndef MAP_ANONYMOUS
|
|
||||||
#ifdef MAP_ANON
|
|
||||||
#define MAP_ANONYMOUS MAP_ANON
|
|
||||||
#else
|
|
||||||
/* assume we don't need it */
|
|
||||||
#define MAP_ANONYMOUS 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_efence_debug);
|
|
||||||
#define GST_CAT_DEFAULT gst_efence_debug
|
|
||||||
|
|
||||||
/* Filter signals and args */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
/* FILL ME */
|
|
||||||
LAST_SIGNAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
ARG_0,
|
|
||||||
ARG_FENCE_TOP
|
|
||||||
};
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_efence_sink_factory =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS_ANY);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_efence_src_factory =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS_ANY);
|
|
||||||
|
|
||||||
static void gst_efence_base_init (gpointer g_class);
|
|
||||||
static void gst_efence_class_init (GstEFenceClass * klass);
|
|
||||||
static void gst_efence_init (GstEFence * filter);
|
|
||||||
|
|
||||||
static void gst_efence_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec);
|
|
||||||
static void gst_efence_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec);
|
|
||||||
|
|
||||||
static GstFlowReturn gst_efence_chain (GstPad * pad, GstBuffer * buf);
|
|
||||||
static GstFlowReturn gst_efence_getrange (GstPad * pad, guint64 offset,
|
|
||||||
guint length, GstBuffer ** buffer);
|
|
||||||
static gboolean gst_efence_checkgetrange (GstPad * pad);
|
|
||||||
static gboolean gst_efence_activate_src_pull (GstPad * pad, gboolean active);
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
|
||||||
|
|
||||||
typedef struct _GstMetaFenced
|
|
||||||
{
|
|
||||||
GstMeta meta;
|
|
||||||
|
|
||||||
void *region;
|
|
||||||
unsigned int length;
|
|
||||||
} GstMetaFenced;
|
|
||||||
|
|
||||||
static const GstMetaInfo *
|
|
||||||
gst_meta_fenced_get_info (void)
|
|
||||||
{
|
|
||||||
static const GstMetaInfo *meta_fenced_info = NULL;
|
|
||||||
|
|
||||||
if (meta_fenced_info == NULL) {
|
|
||||||
meta_fenced_info = gst_meta_register ("GstMetaFenced", "GstMetaFenced",
|
|
||||||
sizeof (GstMetaFenced),
|
|
||||||
(GstMetaInitFunction) NULL,
|
|
||||||
(GstMetaFreeFunction) NULL,
|
|
||||||
(GstMetaCopyFunction) NULL, (GstMetaTransformFunction) NULL);
|
|
||||||
}
|
|
||||||
return meta_fenced_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GST_META_FENCED_GET(buf) ((GstMetaFenced *)gst_buffer_get_meta(buf,gst_meta_fenced_get_info()))
|
|
||||||
#define GST_META_FENCED_ADD(buf) ((GstMetaFenced *)gst_buffer_add_meta(buf,gst_meta_fenced_get_info(),NULL))
|
|
||||||
|
|
||||||
static void gst_fenced_buffer_dispose (GstBuffer * buf);
|
|
||||||
static GstBuffer *gst_fenced_buffer_copy (const GstBuffer * buffer);
|
|
||||||
static void *gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
|
||||||
gboolean fence_top);
|
|
||||||
#if 0
|
|
||||||
static GstFlowReturn gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
|
|
||||||
guint size, GstCaps * caps, GstBuffer ** buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_gst_efence_get_type (void)
|
|
||||||
{
|
|
||||||
static GType plugin_type = 0;
|
|
||||||
|
|
||||||
if (!plugin_type) {
|
|
||||||
static const GTypeInfo plugin_info = {
|
|
||||||
sizeof (GstEFenceClass),
|
|
||||||
gst_efence_base_init,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_efence_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstEFence),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_efence_init,
|
|
||||||
};
|
|
||||||
|
|
||||||
plugin_type = g_type_register_static (GST_TYPE_ELEMENT,
|
|
||||||
"GstEFence", &plugin_info, 0);
|
|
||||||
}
|
|
||||||
return plugin_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_efence_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_efence_sink_factory));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_efence_src_factory));
|
|
||||||
gst_element_class_set_details_simple (element_class, "Electric Fence",
|
|
||||||
"Testing",
|
|
||||||
"This element converts a stream of normal GStreamer buffers into a "
|
|
||||||
"stream of buffers that are allocated in such a way that out-of-bounds "
|
|
||||||
"access to data in the buffer is more likely to cause segmentation "
|
|
||||||
"faults. This allocation method is very similar to the debugging tool "
|
|
||||||
"\"Electric Fence\".", "David A. Schleef <ds@schleef.org>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the plugin's class */
|
|
||||||
static void
|
|
||||||
gst_efence_class_init (GstEFenceClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class;
|
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_efence_set_property;
|
|
||||||
gobject_class->get_property = gst_efence_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, ARG_FENCE_TOP,
|
|
||||||
g_param_spec_boolean ("fence-top", "Fence Top",
|
|
||||||
"Align buffers with top of fenced region", TRUE,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the new element
|
|
||||||
* instantiate pads and add them to element
|
|
||||||
* set functions
|
|
||||||
* initialize structure
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
gst_efence_init (GstEFence * filter)
|
|
||||||
{
|
|
||||||
filter->sinkpad =
|
|
||||||
gst_pad_new_from_static_template (&gst_efence_sink_factory, "sink");
|
|
||||||
gst_pad_set_getcaps_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
|
||||||
gst_pad_set_setcaps_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
|
|
||||||
gst_pad_set_chain_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_efence_chain));
|
|
||||||
#if 0
|
|
||||||
gst_pad_set_bufferalloc_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_efence_buffer_alloc));
|
|
||||||
#endif
|
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
|
||||||
|
|
||||||
filter->srcpad =
|
|
||||||
gst_pad_new_from_static_template (&gst_efence_src_factory, "src");
|
|
||||||
gst_pad_set_getcaps_function (filter->srcpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
|
|
||||||
gst_pad_set_setcaps_function (filter->srcpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
|
|
||||||
gst_pad_set_checkgetrange_function (filter->srcpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_efence_checkgetrange));
|
|
||||||
gst_pad_set_getrange_function (filter->srcpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_efence_getrange));
|
|
||||||
gst_pad_set_activatepull_function (filter->srcpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_efence_activate_src_pull));
|
|
||||||
|
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
|
||||||
|
|
||||||
filter->fence_top = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* chain function
|
|
||||||
* this function does the actual processing
|
|
||||||
*/
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_efence_chain (GstPad * pad, GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstEFence *efence;
|
|
||||||
GstBuffer *copy;
|
|
||||||
|
|
||||||
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
|
||||||
g_return_val_if_fail (GST_IS_EFENCE (efence), GST_FLOW_ERROR);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (GST_IS_FENCED_BUFFER (buffer)) {
|
|
||||||
GST_DEBUG_OBJECT (efence, "Passing on existing fenced buffer with caps %"
|
|
||||||
GST_PTR_FORMAT, GST_BUFFER_CAPS (buffer));
|
|
||||||
return gst_pad_push (efence->srcpad, buffer);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
copy = (GstBuffer *) gst_fenced_buffer_copy (buffer);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (efence, "Pushing newly fenced buffer with caps %"
|
|
||||||
GST_PTR_FORMAT ", data=%p, size=%u", GST_BUFFER_CAPS (copy),
|
|
||||||
GST_BUFFER_DATA (copy), GST_BUFFER_SIZE (copy));
|
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
|
|
||||||
return gst_pad_push (efence->srcpad, copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_efence_getrange (GstPad * pad, guint64 offset,
|
|
||||||
guint length, GstBuffer ** buffer)
|
|
||||||
{
|
|
||||||
GstEFence *efence;
|
|
||||||
GstFlowReturn ret;
|
|
||||||
GstBuffer *ownbuf;
|
|
||||||
GstPad *peer;
|
|
||||||
|
|
||||||
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
|
||||||
|
|
||||||
peer = gst_pad_get_peer (efence->sinkpad);
|
|
||||||
if (!peer)
|
|
||||||
return GST_FLOW_NOT_LINKED;
|
|
||||||
|
|
||||||
if ((ret = gst_pad_get_range (peer, offset, length, buffer)) != GST_FLOW_OK)
|
|
||||||
goto beach;
|
|
||||||
|
|
||||||
ownbuf = (GstBuffer *) gst_fenced_buffer_copy (*buffer);
|
|
||||||
gst_buffer_unref ((GstBuffer *) * buffer);
|
|
||||||
*buffer = ownbuf;
|
|
||||||
|
|
||||||
beach:
|
|
||||||
gst_object_unref (peer);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_efence_checkgetrange (GstPad * pad)
|
|
||||||
{
|
|
||||||
GstEFence *efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
|
||||||
|
|
||||||
return gst_pad_check_pull_range (efence->sinkpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_efence_activate_src_pull (GstPad * pad, gboolean active)
|
|
||||||
{
|
|
||||||
GstEFence *efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
|
||||||
|
|
||||||
return gst_pad_activate_pull (efence->sinkpad, active);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_efence_buffer_alloc (GstPad * pad, guint64 offset,
|
|
||||||
guint size, GstCaps * caps, GstBuffer ** buf)
|
|
||||||
{
|
|
||||||
GstBuffer *buffer;
|
|
||||||
GstEFence *efence;
|
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
|
||||||
|
|
||||||
efence = GST_EFENCE (GST_OBJECT_PARENT (pad));
|
|
||||||
|
|
||||||
buffer = (GstBuffer *) gst_mini_object_new (GST_TYPE_FENCED_BUFFER);
|
|
||||||
|
|
||||||
GST_BUFFER_DATA (buffer) = gst_fenced_buffer_alloc (buffer, size,
|
|
||||||
efence->fence_top);
|
|
||||||
GST_BUFFER_SIZE (buffer) = size;
|
|
||||||
GST_BUFFER_OFFSET (buffer) = offset;
|
|
||||||
|
|
||||||
if (caps)
|
|
||||||
gst_buffer_set_caps (buffer, caps);
|
|
||||||
|
|
||||||
*buf = buffer;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (efence, "Allocated buffer of size %u, caps: %"
|
|
||||||
GST_PTR_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_CAPS (buffer));
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_efence_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstEFence *filter;
|
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_EFENCE (object));
|
|
||||||
filter = GST_EFENCE (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case ARG_FENCE_TOP:
|
|
||||||
filter->fence_top = g_value_get_boolean (value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_efence_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
GstEFence *filter;
|
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_EFENCE (object));
|
|
||||||
filter = GST_EFENCE (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case ARG_FENCE_TOP:
|
|
||||||
g_value_set_boolean (value, filter->fence_top);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* entry point to initialize the plug-in
|
|
||||||
* initialize the plug-in itself
|
|
||||||
* register the element factories and pad templates
|
|
||||||
* register the features
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
plugin_init (GstPlugin * plugin)
|
|
||||||
{
|
|
||||||
if (!gst_element_register (plugin, "efence", GST_RANK_NONE, GST_TYPE_EFENCE))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_efence_debug, "efence", 0,
|
|
||||||
"Debug output from the efence element");
|
|
||||||
|
|
||||||
/* plugin initialisation succeeded */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
||||||
GST_VERSION_MINOR,
|
|
||||||
"efence",
|
|
||||||
"This element converts a stream of normal GStreamer buffers into a "
|
|
||||||
"stream of buffers that are allocated in such a way that out-of-bounds "
|
|
||||||
"access to data in the buffer is more likely to cause segmentation "
|
|
||||||
"faults. This allocation method is very similar to the debugging tool "
|
|
||||||
"\"Electric Fence\".",
|
|
||||||
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_fenced_buffer_dispose (GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstMetaFenced *meta;
|
|
||||||
|
|
||||||
meta = GST_META_FENCED_GET (buffer);
|
|
||||||
|
|
||||||
GST_DEBUG ("free buffer=%p", buffer);
|
|
||||||
|
|
||||||
/* free our data */
|
|
||||||
if (GST_BUFFER_DATA (buffer)) {
|
|
||||||
GST_DEBUG ("free region %p %d", meta->region, meta->length);
|
|
||||||
munmap (meta->region, meta->length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstBuffer *
|
|
||||||
gst_fenced_buffer_copy (const GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstBuffer *copy;
|
|
||||||
void *ptr;
|
|
||||||
guint mask;
|
|
||||||
|
|
||||||
g_return_val_if_fail (buffer != NULL, NULL);
|
|
||||||
|
|
||||||
/* create a fresh new buffer */
|
|
||||||
copy = gst_buffer_new ();
|
|
||||||
|
|
||||||
/* we simply copy everything from our parent */
|
|
||||||
ptr = gst_fenced_buffer_alloc (copy, GST_BUFFER_SIZE (buffer), TRUE);
|
|
||||||
memcpy (ptr, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
|
|
||||||
|
|
||||||
/* copy relevant flags */
|
|
||||||
mask = GST_BUFFER_FLAG_PREROLL | GST_BUFFER_FLAG_IN_CAPS |
|
|
||||||
GST_BUFFER_FLAG_DELTA_UNIT;
|
|
||||||
GST_MINI_OBJECT (copy)->flags |= GST_MINI_OBJECT (buffer)->flags & mask;
|
|
||||||
|
|
||||||
GST_BUFFER_DATA (copy) = ptr;
|
|
||||||
GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer);
|
|
||||||
GST_BUFFER_TIMESTAMP (copy) = GST_BUFFER_TIMESTAMP (buffer);
|
|
||||||
GST_BUFFER_DURATION (copy) = GST_BUFFER_DURATION (buffer);
|
|
||||||
GST_BUFFER_OFFSET (copy) = GST_BUFFER_OFFSET (buffer);
|
|
||||||
GST_BUFFER_OFFSET_END (copy) = GST_BUFFER_OFFSET_END (buffer);
|
|
||||||
|
|
||||||
if (GST_BUFFER_CAPS (buffer))
|
|
||||||
GST_BUFFER_CAPS (copy) = gst_caps_ref (GST_BUFFER_CAPS (buffer));
|
|
||||||
else
|
|
||||||
GST_BUFFER_CAPS (copy) = NULL;
|
|
||||||
|
|
||||||
GST_DEBUG ("Copied buffer %p with ts %" GST_TIME_FORMAT
|
|
||||||
", caps: %" GST_PTR_FORMAT, buffer,
|
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (copy)), GST_BUFFER_CAPS (copy));
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
gst_fenced_buffer_alloc (GstBuffer * buffer, unsigned int length,
|
|
||||||
gboolean fence_top)
|
|
||||||
{
|
|
||||||
int alloc_size;
|
|
||||||
void *region;
|
|
||||||
GstMetaFenced *meta;
|
|
||||||
int page_size;
|
|
||||||
|
|
||||||
GST_DEBUG ("buffer=%p length=%d fence_top=%d", buffer, length, fence_top);
|
|
||||||
|
|
||||||
if (length == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
#ifdef _SC_PAGESIZE
|
|
||||||
page_size = sysconf (_SC_PAGESIZE);
|
|
||||||
#else
|
|
||||||
page_size = getpagesize ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Allocate a complete page, and one on either side */
|
|
||||||
alloc_size = ((length - 1) & ~(page_size - 1)) + page_size;
|
|
||||||
alloc_size += 2 * page_size;
|
|
||||||
|
|
||||||
region = mmap (NULL, alloc_size, PROT_READ | PROT_WRITE,
|
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
|
||||||
if (region == MAP_FAILED) {
|
|
||||||
g_warning ("mmap failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_MINI_OBJECT_CAST (buffer)->dispose =
|
|
||||||
(GstMiniObjectDisposeFunction) gst_fenced_buffer_dispose;
|
|
||||||
GST_MINI_OBJECT_CAST (buffer)->copy =
|
|
||||||
(GstMiniObjectCopyFunction) gst_fenced_buffer_copy;
|
|
||||||
|
|
||||||
meta = GST_META_FENCED_ADD (buffer);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
munmap (region, page_size);
|
|
||||||
munmap (region + alloc_size - page_size, page_size);
|
|
||||||
|
|
||||||
meta->region = region + page_size;
|
|
||||||
meta->length = alloc_size - page_size;
|
|
||||||
#else
|
|
||||||
mprotect (region, page_size, PROT_NONE);
|
|
||||||
mprotect ((char *) region + alloc_size - page_size, page_size, PROT_NONE);
|
|
||||||
|
|
||||||
meta->region = region;
|
|
||||||
meta->length = alloc_size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GST_DEBUG ("new region %p %d", meta->region, meta->length);
|
|
||||||
|
|
||||||
if (fence_top) {
|
|
||||||
int offset;
|
|
||||||
|
|
||||||
/* Align to top of region, but force alignment to 4 bytes */
|
|
||||||
offset = alloc_size - page_size - length;
|
|
||||||
offset &= ~0x3;
|
|
||||||
return (void *) ((char *) region + offset);
|
|
||||||
} else {
|
|
||||||
return (void *) ((char *) region + page_size);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* efence.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GST_EFENCE_H__
|
|
||||||
#define __GST_EFENCE_H__
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
/* #define's don't like whitespacey bits */
|
|
||||||
#define GST_TYPE_EFENCE \
|
|
||||||
(gst_gst_efence_get_type())
|
|
||||||
#define GST_EFENCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EFENCE,GstEFence))
|
|
||||||
#define GST_EFENCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EFENCE,GstEFenceClass))
|
|
||||||
#define GST_IS_EFENCE(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EFENCE))
|
|
||||||
#define GST_IS_EFENCE_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EFENCE))
|
|
||||||
typedef struct _GstEFence GstEFence;
|
|
||||||
typedef struct _GstEFenceClass GstEFenceClass;
|
|
||||||
|
|
||||||
struct _GstEFence
|
|
||||||
{
|
|
||||||
GstElement element;
|
|
||||||
|
|
||||||
GstPad *sinkpad, *srcpad;
|
|
||||||
|
|
||||||
gboolean fence_top;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstEFenceClass
|
|
||||||
{
|
|
||||||
GstElementClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_gst_efence_get_type (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
#endif /* __GST_EFENCE_H__ */
|
|
|
@ -1,148 +0,0 @@
|
||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="7.10"
|
|
||||||
Name="efence"
|
|
||||||
ProjectGUID="{979C216F-0ACF-4956-AE00-055A42D678AE}"
|
|
||||||
Keyword="Win32Proj">
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"/>
|
|
||||||
</Platforms>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="../../win32/Debug"
|
|
||||||
IntermediateDirectory="../../win32/Debug"
|
|
||||||
ConfigurationType="2"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;"../../gst-libs";../../../popt/include;../../../libxml2/include/libxml2"
|
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;efence_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
|
|
||||||
MinimalRebuild="TRUE"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
|
||||||
DebugInformationFormat="4"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
|
|
||||||
OutputFile="$(OutDir)/gstefence.dll"
|
|
||||||
LinkIncremental="2"
|
|
||||||
AdditionalLibraryDirectories="../../../gstreamer/win32/Debug;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
|
|
||||||
ModuleDefinitionFile=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
ProgramDatabaseFile="$(OutDir)/efence.pdb"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
ImportLibrary="$(OutDir)/gstefence.lib"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="../../win32/Release"
|
|
||||||
IntermediateDirectory="../../win32/Release"
|
|
||||||
ConfigurationType="2"
|
|
||||||
CharacterSet="2">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;"../../gst-libs";../../../popt/include;../../../libxml2/include/libxml2"
|
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;efence_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
UsePrecompiledHeader="0"
|
|
||||||
WarningLevel="3"
|
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
|
||||||
DebugInformationFormat="3"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
|
|
||||||
OutputFile="$(OutDir)/gstefence.dll"
|
|
||||||
LinkIncremental="1"
|
|
||||||
AdditionalLibraryDirectories="../../../gstreamer/win32/Release;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
|
|
||||||
ModuleDefinitionFile=""
|
|
||||||
GenerateDebugInformation="TRUE"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
ImportLibrary="$(OutDir)/gstefence.lib"
|
|
||||||
TargetMachine="1"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebDeploymentTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
|
||||||
<File
|
|
||||||
RelativePath=".\efence.c">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
|
||||||
<File
|
|
||||||
RelativePath=".\efence.h">
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
|
||||||
</Filter>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
Loading…
Reference in a new issue