SlideShare a Scribd company logo
Gstreamer Plugin Development
Session VII
Element
• Core of Gstreamer
• Object derived from GstElement
• Source elements provides data to stream
• Filter elements acts on a data in stream
• Sink elements consumes data of stream
Plugin
• Loadable block of code
• Usually shared object or a dynamically linked
library
• Contains implementation of many elements or
just a single one
• Very basic functions reside in the core library
• All other are implemented as plugins
• Are only loaded when their provided elements
are requested
Pads
• Negotiate links and data flows between elements
• Is an port of an element – Output or Input Port
• Specific data handling capabilities
• Can restrict the data that flows through it.
• Links are allowed between two pads when data
types of two pads compatible
• Is similar to plug or jack of a physical device
Pads
• Source Pads
– Data flows out of one element through one or
more source pads
• Sink Pads
– Accepts incoming data flow through one or more
sink pads
GstMiniObject
• Stream of data are chopped up into chunks
that are passed from a source pad on one
element to a sink pad on another element
• Structure used to hold these chunks of data
• Exact type indicating what type of data
• GstMiniObject Types
– Events ( Control )
– Buffers ( Control )
GstBuffer
• Contains any sort of data that two linked pads
know how to handle
• Contains some sort of audio or video data that
flows from one element to another.
• Metadata describing the buffer’s contents
– Pointers to one or more GstMemory Objects
– Ref Counted objects the encapsulate a region of
memory
– Timestamp indicating the preferred display timestamp
of the content in the buffer.
Buffer Allocation
• Able to store chunks of memory of several
different types
• Most generic type of buffer contains memory
allocated by malloc
– Very convenient
– Not always fast, since data often needs to be
copied
Specialized Buffers
• Many specialized elements create buffers that
point to special memory.
– filesrc element maps a file into address space of
application ( using mmap() )
– Creates buffers that point into that address range
– Created by filesrc act like generic buffers, except
that are read only
• Buffer freeing code automatically freed by the
correct method of freeing
GstBufferPool
• Element might get specialized buffers is to request them
from a downstream peer through a GstBufferPool
• Downstream able to provide these objects, upstream can
use them to allocate buffers.
• Accelerated methods for copying data to hardware or
direct access to hardware
• These elements able to create a GstBufferPool for their
upstream peers.
• Example Ximagesink
– Create a buffer that contain Ximages
– Upstream peer copies the data into the buffer, it is copying
directly into the Ximage
– Enables Ximagesink draws the image directly without copy
GstEvent
• Information on the state of the stream flowing
between two linked pads
• Will only be sent if element explicitly support
them, else core will try to handle
automatically
• Events used to indicate ( for example )
– A media type
– End of media stream
– Cache should be flushed
Events
• Subtype indicating the type of contained
event
• Other contents of event depend on the
specific event type
Media Types & Properties
• Uses type system to ensure that the data passed
between the elements in recognized format.
• Type system is important for ensuring that the
parameters required to fully specify the format
match up correctly when linking pads between
elements.
• Each link is made between elements has a
specified type and optionally a set of properties.
• Capabilities Negotiation.
Basic Types
S.No Media Type Description Property Description
1 audio/* All audio types rate Sample Rate
2 channels integer Greater than 0 No of channels
3 audio/x-raw raw integer
audio
Format String
4 audio/mpeg MPEG Audio
encoding
mpegversion Integer
5 framed boolean 0 or 1 True => Frame
available,
false => no frame
6 layer Integer 1,2 or 3 Compression
layer
7 bitrate integer Greater than 0
8 audio/x-vorbis Vorbis audio
data
Building a plugin
• Example file element
– Single input and single output pad
– Simply pass Media Data and Event data from its
sink pad to its source pad without modification.
• Including properties
• Including signal handling
• Examples/pwg/examplefilter
Plugin Template
• To check out gst template,
– git clone git://anongit.freedesktop.org/gstreamer/gst-
template.git
– cd gst-template/gst-plugin/src
– ../tools/make_element MyFilter
– Creates two files
• gstmyfilter.c
• gstmyfilter.h
– autogen.sh
– make && sudo make install
Examing Code
• Basic code structure
• Element metadata
• GstStaticPad
• Constructor
• Plugin_init
• Specifying the pads
Plugin Header
#include <gst/gst.h>
/* Definition of structure storing data for this element. */
typedef struct _GstMyFilter {
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean silent;
} GstMyFilter;
/* Standard definition defining a class for this element. */
typedef struct _GstMyFilterClass {
GstElementClass parent_class;
} GstMyFilterClass;
/* Standard macros for defining types for this element. */
#define GST_TYPE_MY_FILTER (gst_my_filter_get_type())
#define GST_MY_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MY_FILTER,GstMyFilter))
#define GST_MY_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MY_FILTER,GstMyFilterClass))
#define GST_IS_MY_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MY_FILTER))
#define GST_IS_MY_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MY_FILTER))
/* Standard function returning type information. */
GType gst_my_filter_get_type (void);
Setup Object
#include "filter.h"
G_DEFINE_TYPE (GstMyFilter, gst_my_filter,
GST_TYPE_ELEMENT);
Element Meta data
gst_element_class_set_static_metadata (klass,
"An example plugin",
"Example/FirstExample",
"Shows the basic structure of a plugin",
"your name <your.name@your.isp>");
static void gst_my_filter_class_init (GstMyFilterClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
[..]
gst_element_class_set_static_metadata (element_klass,
"An example plugin",
"Example/FirstExample",
"Shows the basic structure of a plugin",
"your name <your.name@your.isp>");
}
Pad Template
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY")
);
Plugin init
static gbooleanplugin_init (GstPlugin *plugin)
{
return gst_element_register (plugin, "my_filter", GST_RANK_NONE, GST_TYPE_MY_FILTER);
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
my_filter,
"My filter plugin",
plugin_init,
VERSION,
"LGPL",
"GStreamer",
"http://gstreamer.net/"
)
Specifying Pads
static voidgst_my_filter_init (GstMyFilter *filter)
{
/* pad through which data comes in to the element */
filter->sinkpad = gst_pad_new_from_static_template (&sink_template,
"sink");
/* pads are configured here with gst_pad_set_*_function () */
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
/* pad through which data goes out of the element */
filter->srcpad = gst_pad_new_from_static_template (&src_template,
"src");
/* pads are configured here with gst_pad_set_*_function () */
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
/* properties initial value */
filter->silent = FALSE;
}
Chain Function
• The function in which all data processing takes
place
• In simple filter, mostly linear functions for
each incoming buffers, one buffer will go out.
Simple Chain Implementation
static GstFlowReturn gst_my_filter_chain (GstPad *pad, GstObject *parent, GstBuffer *buf);
static void gst_my_filter_init (GstMyFilter * filter)
{
/* configure chain function on the pad before adding the pad to the element */
gst_pad_set_chain_function (filter->sinkpad, gst_my_filter_chain);
}
static GstFlowReturn gst_my_filter_chain (GstPad *pad, GstObject *parent, GstBuffer *buf)
{
GstMyFilter *filter = GST_MY_FILTER (parent);
if (!filter->silent)
g_print ("Have data of size %" G_GSIZE_FORMAT" bytes!n",
gst_buffer_get_size (buf));
return gst_pad_push (filter->srcpad, buf);
}

More Related Content

PDF
Gstreamer Basics
PPT
Gstreamer plugin devpt_1
PDF
Gstreamer: an Overview
PDF
Synchronised Multidevice Media Playback with Gstreamer
PDF
Improving GStreamer performance on large pipelines: from profiling to optimiz...
PPT
gstreamer.ppt
PPTX
Gstreamer internals
PPTX
Introduction to Gstreamer
Gstreamer Basics
Gstreamer plugin devpt_1
Gstreamer: an Overview
Synchronised Multidevice Media Playback with Gstreamer
Improving GStreamer performance on large pipelines: from profiling to optimiz...
gstreamer.ppt
Gstreamer internals
Introduction to Gstreamer

What's hot (20)

PPT
GStreamer 101
PDF
BPF: Tracing and more
PDF
Network Programming: Data Plane Development Kit (DPDK)
PDF
eBPF Perf Tools 2019
PDF
Q4.11: Introduction to eMMC
PPTX
Git in 10 minutes
PPTX
FrameGraph: Extensible Rendering Architecture in Frostbite
PDF
Introduction to CUDA
PPTX
Airflow presentation
PDF
Booting Android: bootloaders, fastboot and boot images
PDF
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
PDF
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
PPT
NVIDIA OpenGL 4.6 in 2017
ODP
Dpdk performance
PPTX
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
PPT
Light prepass
PDF
한컴MDS_NVIDIA Jetson Platform
PDF
Apache Spark Streaming in K8s with ArgoCD & Spark Operator
PDF
Siggraph2016 - The Devil is in the Details: idTech 666
PPTX
Git basics to advance with diagrams
GStreamer 101
BPF: Tracing and more
Network Programming: Data Plane Development Kit (DPDK)
eBPF Perf Tools 2019
Q4.11: Introduction to eMMC
Git in 10 minutes
FrameGraph: Extensible Rendering Architecture in Frostbite
Introduction to CUDA
Airflow presentation
Booting Android: bootloaders, fastboot and boot images
promgen - prometheus managemnet tool / simpleclient_java hacks @ Prometheus c...
GStreamer-VAAPI: Hardware-accelerated encoding and decoding on Intel hardware...
NVIDIA OpenGL 4.6 in 2017
Dpdk performance
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
Light prepass
한컴MDS_NVIDIA Jetson Platform
Apache Spark Streaming in K8s with ArgoCD & Spark Operator
Siggraph2016 - The Devil is in the Details: idTech 666
Git basics to advance with diagrams
Ad

Viewers also liked (16)

PDF
About GStreamer 1.0 application development for beginners
PPTX
UDPSRC GStreamer Plugin Session VIII
PPTX
Introduction to Graphics - Session
ODP
GStreamer Instruments
PDF
Building Digital TV Support in Linux
PPTX
TMS20DM8148 Embedded Linux Session II
PPTX
TMS320DM8148 Embedded Linux
PDF
Open GL Programming Training Session I
PDF
オープンセミナー2013@広島
PDF
Guide to GStreamer Application Development Manual: CH1 to CH10
PDF
Video streaming on e-lab
PDF
半透明は飾りです 偉い人にはそれがわからんのですよ
PDF
MIPI DevCon 2016: Accelerating Software Development for MIPI CSI-2 Cameras
PPTX
Visual Studio 2012のDirect3Dアプリ開発者向け新機能を知ろう
DOC
документ Microsoft word (2)
PPTX
Mind Mapping та його використання
About GStreamer 1.0 application development for beginners
UDPSRC GStreamer Plugin Session VIII
Introduction to Graphics - Session
GStreamer Instruments
Building Digital TV Support in Linux
TMS20DM8148 Embedded Linux Session II
TMS320DM8148 Embedded Linux
Open GL Programming Training Session I
オープンセミナー2013@広島
Guide to GStreamer Application Development Manual: CH1 to CH10
Video streaming on e-lab
半透明は飾りです 偉い人にはそれがわからんのですよ
MIPI DevCon 2016: Accelerating Software Development for MIPI CSI-2 Cameras
Visual Studio 2012のDirect3Dアプリ開発者向け新機能を知ろう
документ Microsoft word (2)
Mind Mapping та його використання
Ad

Similar to Gstreamer plugin development (20)

PDF
G Streamer Apps Development Manual
PDF
An introduction to using GStreamer in your GNOME application
PPT
Oo Design And Patterns
PDF
Guadec2007 Gvfs
PPT
Arch stylesandpatternsmi
PDF
The move from a hardware centric design to a software centric design: GStream...
PDF
Matrosov, rodionov win32 flamer. reverse engineering and framework reconstr...
PDF
Win32/Flamer: Reverse Engineering and Framework Reconstruction
PDF
system v ABI
PDF
There is more to C
PDF
Design of Remote Video Monitoring and Motion Detection System based on Arm-Li...
PDF
Seaside Status Message
PDF
Seaside News
PDF
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
PDF
TaskMan-Middleware 2011 - Advanced implementation
PDF
Computer Graphics Concepts
PDF
Infos4
PDF
Android media framework overview
PPT
Symbian OS Architecture
PPT
Symbian os presentation
G Streamer Apps Development Manual
An introduction to using GStreamer in your GNOME application
Oo Design And Patterns
Guadec2007 Gvfs
Arch stylesandpatternsmi
The move from a hardware centric design to a software centric design: GStream...
Matrosov, rodionov win32 flamer. reverse engineering and framework reconstr...
Win32/Flamer: Reverse Engineering and Framework Reconstruction
system v ABI
There is more to C
Design of Remote Video Monitoring and Motion Detection System based on Arm-Li...
Seaside Status Message
Seaside News
Digital Imaging with Free Software - Talk at Sheffield Astronomical Society J...
TaskMan-Middleware 2011 - Advanced implementation
Computer Graphics Concepts
Infos4
Android media framework overview
Symbian OS Architecture
Symbian os presentation

More from NEEVEE Technologies (20)

PPTX
C Language Programming - Program Outline / Schedule
PPTX
Python programming for Beginners - II
PPTX
Python programming for Beginners - I
PPTX
Engineering College - Internship proposal
PPTX
NVDK-ESP32 WiFi Station / Access Point
PPTX
NVDK-ESP32 Quick Start Guide
PPTX
General Purpose Input Output - Brief Introduction
PPTX
Yocto BSP Layer for UDOO NEO Board
PPTX
Building Embedded Linux UDOONEO
PPTX
Open Computer Vision Based Image Processing
PPTX
Introduction to Machine learning
PPTX
Introduction Linux Device Drivers
PPTX
Introduction about Apache MYNEWT RTOS
PPTX
Introduction to Bluetooth Low Energy
PPTX
NXP i.MX6 Multi Media Processor & Peripherals
PPTX
Introduction to Bluetooth low energy
PPTX
Arduino Programming - Brief Introduction
PPTX
MarsBoard - NXP IMX6 Processor
PPTX
NXP IMX6 Processor - Embedded Linux
PPTX
Introduction to Hardware Design Using KiCAD
C Language Programming - Program Outline / Schedule
Python programming for Beginners - II
Python programming for Beginners - I
Engineering College - Internship proposal
NVDK-ESP32 WiFi Station / Access Point
NVDK-ESP32 Quick Start Guide
General Purpose Input Output - Brief Introduction
Yocto BSP Layer for UDOO NEO Board
Building Embedded Linux UDOONEO
Open Computer Vision Based Image Processing
Introduction to Machine learning
Introduction Linux Device Drivers
Introduction about Apache MYNEWT RTOS
Introduction to Bluetooth Low Energy
NXP i.MX6 Multi Media Processor & Peripherals
Introduction to Bluetooth low energy
Arduino Programming - Brief Introduction
MarsBoard - NXP IMX6 Processor
NXP IMX6 Processor - Embedded Linux
Introduction to Hardware Design Using KiCAD

Recently uploaded (20)

PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Welding lecture in detail for understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Geodesy 1.pptx...............................................
PPTX
Construction Project Organization Group 2.pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
composite construction of structures.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
UNIT 4 Total Quality Management .pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Welding lecture in detail for understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Foundation to blockchain - A guide to Blockchain Tech
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
Internet of Things (IOT) - A guide to understanding
Geodesy 1.pptx...............................................
Construction Project Organization Group 2.pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Operating System & Kernel Study Guide-1 - converted.pdf
composite construction of structures.pdf

Gstreamer plugin development

  • 2. Element • Core of Gstreamer • Object derived from GstElement • Source elements provides data to stream • Filter elements acts on a data in stream • Sink elements consumes data of stream
  • 3. Plugin • Loadable block of code • Usually shared object or a dynamically linked library • Contains implementation of many elements or just a single one • Very basic functions reside in the core library • All other are implemented as plugins • Are only loaded when their provided elements are requested
  • 4. Pads • Negotiate links and data flows between elements • Is an port of an element – Output or Input Port • Specific data handling capabilities • Can restrict the data that flows through it. • Links are allowed between two pads when data types of two pads compatible • Is similar to plug or jack of a physical device
  • 5. Pads • Source Pads – Data flows out of one element through one or more source pads • Sink Pads – Accepts incoming data flow through one or more sink pads
  • 6. GstMiniObject • Stream of data are chopped up into chunks that are passed from a source pad on one element to a sink pad on another element • Structure used to hold these chunks of data • Exact type indicating what type of data • GstMiniObject Types – Events ( Control ) – Buffers ( Control )
  • 7. GstBuffer • Contains any sort of data that two linked pads know how to handle • Contains some sort of audio or video data that flows from one element to another. • Metadata describing the buffer’s contents – Pointers to one or more GstMemory Objects – Ref Counted objects the encapsulate a region of memory – Timestamp indicating the preferred display timestamp of the content in the buffer.
  • 8. Buffer Allocation • Able to store chunks of memory of several different types • Most generic type of buffer contains memory allocated by malloc – Very convenient – Not always fast, since data often needs to be copied
  • 9. Specialized Buffers • Many specialized elements create buffers that point to special memory. – filesrc element maps a file into address space of application ( using mmap() ) – Creates buffers that point into that address range – Created by filesrc act like generic buffers, except that are read only • Buffer freeing code automatically freed by the correct method of freeing
  • 10. GstBufferPool • Element might get specialized buffers is to request them from a downstream peer through a GstBufferPool • Downstream able to provide these objects, upstream can use them to allocate buffers. • Accelerated methods for copying data to hardware or direct access to hardware • These elements able to create a GstBufferPool for their upstream peers. • Example Ximagesink – Create a buffer that contain Ximages – Upstream peer copies the data into the buffer, it is copying directly into the Ximage – Enables Ximagesink draws the image directly without copy
  • 11. GstEvent • Information on the state of the stream flowing between two linked pads • Will only be sent if element explicitly support them, else core will try to handle automatically • Events used to indicate ( for example ) – A media type – End of media stream – Cache should be flushed
  • 12. Events • Subtype indicating the type of contained event • Other contents of event depend on the specific event type
  • 13. Media Types & Properties • Uses type system to ensure that the data passed between the elements in recognized format. • Type system is important for ensuring that the parameters required to fully specify the format match up correctly when linking pads between elements. • Each link is made between elements has a specified type and optionally a set of properties. • Capabilities Negotiation.
  • 14. Basic Types S.No Media Type Description Property Description 1 audio/* All audio types rate Sample Rate 2 channels integer Greater than 0 No of channels 3 audio/x-raw raw integer audio Format String 4 audio/mpeg MPEG Audio encoding mpegversion Integer 5 framed boolean 0 or 1 True => Frame available, false => no frame 6 layer Integer 1,2 or 3 Compression layer 7 bitrate integer Greater than 0 8 audio/x-vorbis Vorbis audio data
  • 15. Building a plugin • Example file element – Single input and single output pad – Simply pass Media Data and Event data from its sink pad to its source pad without modification. • Including properties • Including signal handling • Examples/pwg/examplefilter
  • 16. Plugin Template • To check out gst template, – git clone git://anongit.freedesktop.org/gstreamer/gst- template.git – cd gst-template/gst-plugin/src – ../tools/make_element MyFilter – Creates two files • gstmyfilter.c • gstmyfilter.h – autogen.sh – make && sudo make install
  • 17. Examing Code • Basic code structure • Element metadata • GstStaticPad • Constructor • Plugin_init • Specifying the pads
  • 18. Plugin Header #include <gst/gst.h> /* Definition of structure storing data for this element. */ typedef struct _GstMyFilter { GstElement element; GstPad *sinkpad, *srcpad; gboolean silent; } GstMyFilter; /* Standard definition defining a class for this element. */ typedef struct _GstMyFilterClass { GstElementClass parent_class; } GstMyFilterClass; /* Standard macros for defining types for this element. */ #define GST_TYPE_MY_FILTER (gst_my_filter_get_type()) #define GST_MY_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MY_FILTER,GstMyFilter)) #define GST_MY_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MY_FILTER,GstMyFilterClass)) #define GST_IS_MY_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MY_FILTER)) #define GST_IS_MY_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MY_FILTER)) /* Standard function returning type information. */ GType gst_my_filter_get_type (void);
  • 19. Setup Object #include "filter.h" G_DEFINE_TYPE (GstMyFilter, gst_my_filter, GST_TYPE_ELEMENT);
  • 20. Element Meta data gst_element_class_set_static_metadata (klass, "An example plugin", "Example/FirstExample", "Shows the basic structure of a plugin", "your name <your.name@your.isp>"); static void gst_my_filter_class_init (GstMyFilterClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); [..] gst_element_class_set_static_metadata (element_klass, "An example plugin", "Example/FirstExample", "Shows the basic structure of a plugin", "your name <your.name@your.isp>"); }
  • 21. Pad Template static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("ANY") );
  • 22. Plugin init static gbooleanplugin_init (GstPlugin *plugin) { return gst_element_register (plugin, "my_filter", GST_RANK_NONE, GST_TYPE_MY_FILTER); } GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, my_filter, "My filter plugin", plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/" )
  • 23. Specifying Pads static voidgst_my_filter_init (GstMyFilter *filter) { /* pad through which data comes in to the element */ filter->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); /* pads are configured here with gst_pad_set_*_function () */ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); /* pad through which data goes out of the element */ filter->srcpad = gst_pad_new_from_static_template (&src_template, "src"); /* pads are configured here with gst_pad_set_*_function () */ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); /* properties initial value */ filter->silent = FALSE; }
  • 24. Chain Function • The function in which all data processing takes place • In simple filter, mostly linear functions for each incoming buffers, one buffer will go out.
  • 25. Simple Chain Implementation static GstFlowReturn gst_my_filter_chain (GstPad *pad, GstObject *parent, GstBuffer *buf); static void gst_my_filter_init (GstMyFilter * filter) { /* configure chain function on the pad before adding the pad to the element */ gst_pad_set_chain_function (filter->sinkpad, gst_my_filter_chain); } static GstFlowReturn gst_my_filter_chain (GstPad *pad, GstObject *parent, GstBuffer *buf) { GstMyFilter *filter = GST_MY_FILTER (parent); if (!filter->silent) g_print ("Have data of size %" G_GSIZE_FORMAT" bytes!n", gst_buffer_get_size (buf)); return gst_pad_push (filter->srcpad, buf); }