Creating a New GStreamer Element or Application Using Templates

From RidgeRun Developer Wiki

This wiki describes how to make use of the rather hidden tools included with GStreamer to create empty skeletons for different GStreamer elements.


Preparation for Creating a new GStreamer Element or GStreamer application using Templates

All the utilities described in this wiki are included within the GStreamer monorepo, so start by cloning it. The steps shown were tested on Ubuntu 22.04.

git clone https://github.com/GStreamer/gstreamer.git

# If you are building for a specific version, switch to it now. Otherwise, you can remain in the 'main' branch.
cd gstreamer
git checkout $BRANCH

# We recommend saving a copy of the gst-indent script somewhere in your PATH
sudo cp scripts/gst-indent /usr/local/bin/

If you are going to be developing a new plugin, then you most likely need to install the GStreamer development libraries as well.

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev indent

Available tools

Create an empty Meson project

The gst-project-maker tool creates a barebones Meson project to hold your new plugin.

cd subprojects/gst-plugins-bad/tools/
./gst-project-maker my_project

Now, you should see a new directory called gst-my_project. You may move this directory to wherever you want and you should be able to build it:

cd gst-my_project
meson setup builddir --werror --prefix /usr/
ninja -C builddir

There are a few additional options you may check by running:

./gst-project-maker --help

Create an empty GStreamer element

The gst-element-maker tool creates a barebones GStreamer element which may inherit from a variety of base classes. As per 1.15, the base classes for elements available are:

  • audiodecoder
  • audioencoder
  • audiofilter
  • audiosink
  • audiosrc
  • baseparse
  • basesink
  • basesrc
  • basetransform
  • element
  • videodecoder
  • videoencoder
  • videofilter
  • videosink

Additionally, you can create classes based on other GStreamer elements such as:

  • sinkpad
  • sinkpad-audio
  • sinkpad-simple
  • sinkpad-template
  • sinkpad-template-video
  • srcpad
  • srcpad-audio
  • srcpad-simple
  • srcpad-template
  • srcpad-template-video

By default, and very conveniently, the skeleton will include an empty implementation containing all of its parent virtual methods. This way you'll just need to delete the ones you're not planning on using.

To create a new element/object using the BASE_CLASS parameter (for example BASE_CLASS=videofilter), you may run the following:

cd subprojects/gst-plugins-bad/tools

# Choose any base class from the list above
BASE_CLASS=videofilter

./gst-element-maker my_element $BASE_CLASS
pkg is gstreamer-video-1.0
Plugin Details:
  Name                     myelement
  Description              FIXME plugin description
  Filename                 ./gstmyelement.so
  Version                  0.0.FIXME
  License                  LGPL
  Source module            FIXME_package
  Binary package           FIXME_package_name
  Origin URL               http://FIXME.org/

  myelement: FIXME Long name

  1 features:
  +-- 1 elements

A new pair of gstmyelement.c and gstmyelement.h are created in the current directory. You may grab those files and integrate them into your project.

./gst-element-maker --help

Create an empty GStreamer Application

This tool creates a barebones GStreamer application.

cd subprojects/gst-plugins-bad/tools

./gst-app-maker my_app

The gst-app-maker command will create a new gstmyapp.c that you may take and integrate into your project.



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.