Creating a New GStreamer Element or Application Using Templates: Difference between revisions

From RidgeRun Developer Wiki
mNo edit summary
Line 1: Line 1:
<seo title="Creating a GStreamer Element using Templates | Creating a GStreamer Application using Templates" titlemode="replace" keywords=" GStreamer, Embedded Linux, Device Drivers, NVIDIA, Xilinx, TI, NXP, Freescale, Embedded Linux driver development, Linux Software development, GStreamer Element, GStreamer Application, Creating GStreamer Element, Creating GStreamer application" description="Learn more about how to create a new GStreamer Element or Application Using Templates."></seo>
{{#seo:
 
|title=Creating a GStreamer Element using Templates
|title_mode=replace
|description={{{description|Learn more about how to create a new GStreamer Element or Application Using Templates.}}}
}}
This wiki describes how to make use of the rather hidden tools included with GStreamer to create empty skeletons for different GStreamer elements.
This wiki describes how to make use of the rather hidden tools included with GStreamer to create empty skeletons for different GStreamer elements.
<br>
{|
<br>
| style="text-align:right; vertical-align:top;" | __TOC__
<table>
| {{ContactUs Button}}
<tr>
|}
<td><div class="clear; float:right">__TOC__</div></td>
<td valign=top>
{{ContactUs Button}}
</td>
</table>


== Preparation for Creating a new GStreamer Element or GStreamer application using Templates  ==
== Preparation for Creating a new GStreamer Element or GStreamer application using Templates  ==
Line 16: Line 14:
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.  
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.  


<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
git clone https://github.com/GStreamer/gstreamer.git
git clone https://github.com/GStreamer/gstreamer.git


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


<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev indent
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev indent
</syntaxhighlight>
</syntaxhighlight>
Line 38: Line 36:
The <tt>gst-project-maker</tt> tool creates a barebones Meson project to hold your new plugin.
The <tt>gst-project-maker</tt> tool creates a barebones Meson project to hold your new plugin.


<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
cd subprojects/gst-plugins-bad/tools/
cd subprojects/gst-plugins-bad/tools/
./gst-project-maker my_project
./gst-project-maker my_project
Line 44: Line 42:


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:
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:
<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
cd gst-my_project
cd gst-my_project
meson setup builddir --werror --prefix /usr/
meson setup builddir --werror --prefix /usr/
Line 51: Line 49:


There are a few additional options you may check by running:
There are a few additional options you may check by running:
<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
./gst-project-maker --help
./gst-project-maker --help
</syntaxhighlight>
</syntaxhighlight>
Line 88: Line 86:


To create a new element/object using the BASE_CLASS parameter (for example BASE_CLASS=videofilter), you may run the following:
To create a new element/object using the BASE_CLASS parameter (for example BASE_CLASS=videofilter), you may run the following:
<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
cd subprojects/gst-plugins-bad/tools
cd subprojects/gst-plugins-bad/tools


Line 122: Line 120:
This tool creates a barebones GStreamer application.
This tool creates a barebones GStreamer application.


<syntaxhighlight lang=bash>
<syntaxhighlight lang="bash">
cd subprojects/gst-plugins-bad/tools
cd subprojects/gst-plugins-bad/tools



Revision as of 14:59, 5 January 2025

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.