Commit ffb7158a authored by Guillaume Desmottes's avatar Guillaume Desmottes 🐐

identity-light: add simple identity element

parent 3fdfd54b
Pipeline #127121 waiting for manual action with stages
in 23 seconds
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstidentity-light.h"
GST_DEBUG_CATEGORY_STATIC (gst_identity_light_debug);
#define GST_CAT_DEFAULT gst_identity_light_debug
#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_identity_light_debug, "identity-light", 0, "identity element");
#define gst_identity_light_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstIdentityLight, gst_identity_light, GST_TYPE_ELEMENT,
_do_init);
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void
gst_identity_light_class_init (GstIdentityLightClass * klass)
{
GstElementClass *gstelement_class;
gstelement_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_static_metadata (gstelement_class,
"Identity",
"Generic",
"Does nothing with the data",
"Guillaume Desmottes <guillaume.desmottes@collabora.com>");
gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
}
static GstFlowReturn
identity_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstIdentityLight *self = GST_IDENTITY_LIGHT (parent);
GST_LOG_OBJECT (pad, "Handling buffer %" GST_PTR_FORMAT, buffer);
return gst_pad_push (self->srcpad, buffer);
}
static gboolean
identity_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstIdentityLight *self = GST_IDENTITY_LIGHT (parent);
GST_LOG_OBJECT (pad, "Handling event %" GST_PTR_FORMAT, event);
return gst_pad_push_event (self->srcpad, event);
}
static gboolean
identity_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstIdentityLight *self = GST_IDENTITY_LIGHT (parent);
GST_LOG_OBJECT (pad, "Handling query %" GST_PTR_FORMAT, query);
return gst_pad_peer_query (self->srcpad, query);
}
static gboolean
identity_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstIdentityLight *self = GST_IDENTITY_LIGHT (parent);
GST_LOG_OBJECT (pad, "Handling event %" GST_PTR_FORMAT, event);
return gst_pad_push_event (self->sinkpad, event);
}
static gboolean
identity_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
GstIdentityLight *self = GST_IDENTITY_LIGHT (parent);
GST_LOG_OBJECT (pad, "Handling query %" GST_PTR_FORMAT, query);
return gst_pad_peer_query (self->sinkpad, query);
}
static void
gst_identity_light_init (GstIdentityLight * self)
{
self->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
self->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
gst_pad_set_chain_function (self->sinkpad, identity_sink_chain);
gst_pad_set_event_function (self->sinkpad, identity_sink_event);
gst_pad_set_query_function (self->sinkpad, identity_sink_query);
gst_pad_set_event_function (self->srcpad, identity_src_event);
gst_pad_set_query_function (self->srcpad, identity_src_query);
gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad);
gst_element_add_pad (GST_ELEMENT_CAST (self), self->sinkpad);
}
static gboolean
plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "identity_light", GST_RANK_NONE,
GST_TYPE_IDENTITY_LIGHT);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
identitylight,
"light identity",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
#ifndef __GST_IDENTITY_H__
#define __GST_IDENTITY_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_IDENTITY_LIGHT (gst_identity_light_get_type ())
G_DECLARE_FINAL_TYPE (GstIdentityLight, gst_identity_light, GST, IDENTITY_LIGHT, GstElement)
struct _GstIdentityLight
{
GstElement parent;
GstPad *srcpad;
GstPad *sinkpad;
};
G_END_DECLS
#endif
gstidentity_light = library('gstidentitylight',
'gstidentity-light.c',
c_args : gst_plugins_good_args,
include_directories : [configinc, libsinc],
dependencies : [gst_dep],
install : true,
install_dir : plugins_install_dir,
)
pkgconfig.generate(gstidentity_light, install_dir : plugins_pkgconfig_install_dir)
plugins += [gstidentity_light]
......@@ -11,3 +11,4 @@ foreach plugin : ['alpha', 'apetag', 'audiofx', 'audioparsers', 'auparse',
subdir(plugin)
endif
endforeach
subdir('identity-light')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment