-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dafca55
Showing
7 changed files
with
367 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# temporary files | ||
*~ | ||
|
||
# IDE files | ||
/.vscode | ||
|
||
# build results | ||
/build/ | ||
/builddir/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Thomas Vander Stichele <thomas@apestaart.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
https://opensource.org/licenses/mit | ||
|
||
Copyright 2020, Peter Körner <peter@mazdermind.de> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# EBU-R 128 Plugin | ||
|
||
This plugin contains two elements | ||
|
||
* ebur128: | ||
Passes audio, emitting Events for ebur128 loudness (similar to the level-Elemenr) | ||
|
||
* ebur128display: | ||
Visualizes EBU-R Levels over a period of time as a comfigurable Video-Stream | ||
|
||
## License | ||
|
||
This code is provided under a MIT license [MIT], which basically means "do | ||
with it as you wish, but don't blame us if it doesn't work". | ||
|
||
## Usage | ||
|
||
Configure and build as such: | ||
|
||
meson builddir | ||
ninja -C builddir | ||
|
||
See <https://mesonbuild.com/Quick-guide.html> on how to install the Meson | ||
build system and ninja. | ||
|
||
You can check if it has been built correctly with: | ||
|
||
gst-inspect-1.0 builddir/gst-plugins/src/libgstplugin.so | ||
|
||
GST_PLUGIN_PATH=$(realpath builddir) gst-inspect-1.0 ebur128 | ||
GST_PLUGIN_PATH=$(realpath builddir) gst-inspect-1.0 ebur128display | ||
|
||
And Test it as with: | ||
|
||
GST_PLUGIN_PATH=$(realpath builddir) gst-launch-1.0 -m audiotestsrc ! \ | ||
audio/x-raw,format=S16LE,channels=2,rate=48000 ! \ | ||
ebur128 ! autoaudiosink | ||
|
||
GST_PLUGIN_PATH=$(realpath builddir) gst-launch-1.0 -m audiotestsrc ! \ | ||
audio/x-raw,format=S16LE,channels=2,rate=48000 ! \ | ||
ebur128display ! \ | ||
video/x-raw,format=RGBA,width=640,height=480,framerate=60/1 ! | ||
glimagesink | ||
|
||
[MIT]: http://www.opensource.org/licenses/mit-license.php or COPYING.MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
project('gst-ebur128', 'c', version : '1.0.0.0', license : 'MIT') | ||
|
||
plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0') | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
gst_version = meson.project_version() | ||
|
||
api_version = '1.0' | ||
|
||
gst_dep = dependency('gstreamer-1.0', fallback : ['gstreamer', 'gst_dep']) | ||
|
||
plugin_c_args = ['-DHAVE_CONFIG_H'] | ||
|
||
cdata = configuration_data() | ||
cdata.set_quoted('PACKAGE_VERSION', gst_version) | ||
cdata.set_quoted('PACKAGE', 'gst-ebur128-plugin') | ||
cdata.set_quoted('GST_LICENSE', 'LGPL') | ||
cdata.set_quoted('GST_API_VERSION', api_version) | ||
cdata.set_quoted('GST_PACKAGE_NAME', 'GStreamer ebur128 Plug-ins') | ||
cdata.set_quoted('GST_PACKAGE_ORIGIN', 'https://gstreamer.freedesktop.org') | ||
configure_file(output : 'config.h', configuration : cdata) | ||
|
||
gstaudio_dep = dependency('gstreamer-audio-1.0', | ||
fallback: ['gst-plugins-base', 'audio_dep']) | ||
|
||
# Plugin 1 | ||
plugin_sources = [ | ||
'src/gstebur128.c', | ||
] | ||
|
||
ebur128 = library('gstebur128', | ||
plugin_sources, | ||
c_args: plugin_c_args, | ||
dependencies : [gst_dep], | ||
install : true, | ||
install_dir : plugins_install_dir, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
/** | ||
* SECTION:element-ebur128 | ||
* | ||
* FIXME:Calculates the EBU-R 128 Loudness of an Audio-Stream and emits them as Message | ||
* | ||
* <refsect2> | ||
* <title>Example launch line</title> | ||
* |[ | ||
* gst-launch-1.0 -m audiotestsrc ! \ | ||
audio/x-raw,format=S16LE,channels=2,rate=48000 ! \ | ||
ebur128 ! autoaudiosink | ||
* ]| | ||
* </refsect2> | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include <config.h> | ||
#endif | ||
|
||
#include <gst/gst.h> | ||
|
||
#include "gstebur128.h" | ||
|
||
GST_DEBUG_CATEGORY_STATIC (gst_ebur128_debug); | ||
#define GST_CAT_DEFAULT gst_ebur128_debug | ||
|
||
/* Filter signals and args */ | ||
enum | ||
{ | ||
/* FILL ME */ | ||
LAST_SIGNAL | ||
}; | ||
|
||
enum | ||
{ | ||
PROP_0, | ||
PROP_SILENT | ||
}; | ||
|
||
/* the capabilities of the inputs and outputs. | ||
* | ||
* describe the real formats here. | ||
*/ | ||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", | ||
GST_PAD_SINK, | ||
GST_PAD_ALWAYS, | ||
GST_STATIC_CAPS ("ANY") | ||
); | ||
|
||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", | ||
GST_PAD_SRC, | ||
GST_PAD_ALWAYS, | ||
GST_STATIC_CAPS ("ANY") | ||
); | ||
|
||
#define gst_ebur128_parent_class parent_class | ||
G_DEFINE_TYPE (Gstebur128, gst_ebur128, GST_TYPE_ELEMENT); | ||
|
||
static void gst_ebur128_set_property (GObject * object, guint prop_id, | ||
const GValue * value, GParamSpec * pspec); | ||
static void gst_ebur128_get_property (GObject * object, guint prop_id, | ||
GValue * value, GParamSpec * pspec); | ||
|
||
static gboolean gst_ebur128_sink_event (GstPad * pad, GstObject * parent, GstEvent * event); | ||
static GstFlowReturn gst_ebur128_chain (GstPad * pad, GstObject * parent, GstBuffer * buf); | ||
|
||
/* GObject vmethod implementations */ | ||
|
||
/* initialize the ebur128's class */ | ||
static void | ||
gst_ebur128_class_init (Gstebur128Class * klass) | ||
{ | ||
GObjectClass *gobject_class; | ||
GstElementClass *gstelement_class; | ||
|
||
gobject_class = (GObjectClass *) klass; | ||
gstelement_class = (GstElementClass *) klass; | ||
|
||
gobject_class->set_property = gst_ebur128_set_property; | ||
gobject_class->get_property = gst_ebur128_get_property; | ||
|
||
g_object_class_install_property (gobject_class, PROP_SILENT, | ||
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?", | ||
FALSE, G_PARAM_READWRITE)); | ||
|
||
gst_element_class_set_details_simple(gstelement_class, | ||
"ebur128", | ||
"Filter/Analyzer/Audio", | ||
"Calculates the EBU-R 128 Loudness of an Audio-Stream and emits them as Message", | ||
"Peter Körner <peter@mazdermind.de>"); | ||
|
||
gst_element_class_add_pad_template (gstelement_class, | ||
gst_static_pad_template_get (&src_factory)); | ||
gst_element_class_add_pad_template (gstelement_class, | ||
gst_static_pad_template_get (&sink_factory)); | ||
} | ||
|
||
/* initialize the new element | ||
* instantiate pads and add them to element | ||
* set pad calback functions | ||
* initialize instance structure | ||
*/ | ||
static void | ||
gst_ebur128_init (Gstebur128 * filter) | ||
{ | ||
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); | ||
gst_pad_set_event_function (filter->sinkpad, | ||
GST_DEBUG_FUNCPTR(gst_ebur128_sink_event)); | ||
gst_pad_set_chain_function (filter->sinkpad, | ||
GST_DEBUG_FUNCPTR(gst_ebur128_chain)); | ||
GST_PAD_SET_PROXY_CAPS (filter->sinkpad); | ||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); | ||
|
||
filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); | ||
GST_PAD_SET_PROXY_CAPS (filter->srcpad); | ||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); | ||
|
||
filter->silent = FALSE; | ||
} | ||
|
||
static void | ||
gst_ebur128_set_property (GObject * object, guint prop_id, | ||
const GValue * value, GParamSpec * pspec) | ||
{ | ||
Gstebur128 *filter = GST_EBUR128 (object); | ||
|
||
switch (prop_id) { | ||
case PROP_SILENT: | ||
filter->silent = g_value_get_boolean (value); | ||
break; | ||
default: | ||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
break; | ||
} | ||
} | ||
|
||
static void | ||
gst_ebur128_get_property (GObject * object, guint prop_id, | ||
GValue * value, GParamSpec * pspec) | ||
{ | ||
Gstebur128 *filter = GST_EBUR128 (object); | ||
|
||
switch (prop_id) { | ||
case PROP_SILENT: | ||
g_value_set_boolean (value, filter->silent); | ||
break; | ||
default: | ||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
break; | ||
} | ||
} | ||
|
||
/* GstElement vmethod implementations */ | ||
|
||
/* this function handles sink events */ | ||
static gboolean | ||
gst_ebur128_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) | ||
{ | ||
Gstebur128 *filter; | ||
gboolean ret; | ||
|
||
filter = GST_EBUR128 (parent); | ||
|
||
GST_LOG_OBJECT (filter, "Received %s event: %" GST_PTR_FORMAT, | ||
GST_EVENT_TYPE_NAME (event), event); | ||
|
||
switch (GST_EVENT_TYPE (event)) { | ||
case GST_EVENT_CAPS: | ||
{ | ||
GstCaps * caps; | ||
|
||
gst_event_parse_caps (event, &caps); | ||
/* do something with the caps */ | ||
|
||
/* and forward */ | ||
ret = gst_pad_event_default (pad, parent, event); | ||
break; | ||
} | ||
default: | ||
ret = gst_pad_event_default (pad, parent, event); | ||
break; | ||
} | ||
return ret; | ||
} | ||
|
||
/* chain function | ||
* this function does the actual processing | ||
*/ | ||
static GstFlowReturn | ||
gst_ebur128_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) | ||
{ | ||
Gstebur128 *filter; | ||
|
||
filter = GST_EBUR128 (parent); | ||
|
||
if (filter->silent == FALSE) | ||
g_print ("I'm plugged, therefore I'm in.\n"); | ||
|
||
/* just push out the incoming buffer without touching it */ | ||
return gst_pad_push (filter->srcpad, buf); | ||
} | ||
|
||
|
||
/* entry point to initialize the plug-in | ||
* initialize the plug-in itself | ||
* register the element factories and other features | ||
*/ | ||
static gboolean | ||
ebur128_init (GstPlugin * ebur128) | ||
{ | ||
/* debug category for fltering log messages | ||
*/ | ||
GST_DEBUG_CATEGORY_INIT (gst_ebur128_debug, "ebur128", | ||
0, "EBU-R 128 Plugin"); | ||
|
||
return gst_element_register (ebur128, "ebur128", GST_RANK_NONE, | ||
GST_TYPE_EBUR128); | ||
} | ||
|
||
/* PACKAGE: this is usually set by meson depending on some _INIT macro | ||
* in meson.build and then written into and defined in config.h, but we can | ||
* just set it ourselves here in case someone doesn't use meson to | ||
* compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined. | ||
*/ | ||
#ifndef PACKAGE | ||
#define PACKAGE "ebur128" | ||
#endif | ||
|
||
/* gstreamer looks for this structure to register ebur128s | ||
*/ | ||
GST_PLUGIN_DEFINE ( | ||
GST_VERSION_MAJOR, | ||
GST_VERSION_MINOR, | ||
ebur128, | ||
"The EBU-R 128 Plugin ('ebur128') provides Elements for calculating the EBU-R 128 Loudness of an Audio-Stream and " | ||
"to generate a Video-Stream visualizing the Loudness over Time", | ||
ebur128_init, | ||
PACKAGE_VERSION, | ||
GST_LICENSE, | ||
GST_PACKAGE_NAME, | ||
GST_PACKAGE_ORIGIN | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef __GST_EBUR128_H__ | ||
#define __GST_EBUR128_H__ | ||
|
||
#include <gst/gst.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define GST_TYPE_EBUR128 (gst_ebur128_get_type()) | ||
G_DECLARE_FINAL_TYPE (Gstebur128, gst_ebur128, | ||
GST, EBUR128, GstElement) | ||
|
||
struct _Gstebur128 | ||
{ | ||
GstElement element; | ||
|
||
GstPad *sinkpad, *srcpad; | ||
|
||
gboolean silent; | ||
}; | ||
|
||
G_END_DECLS | ||
|
||
#endif /* __GST_EBUR128_H__ */ |