switchbin: Initial checkin

Add code from Stream Unlimited implementing a bin
which switches between different internal decoding/processing
chains based on input caps
This commit is contained in:
Jan Schmidt 2019-11-05 01:40:04 +11:00 committed by Jan Schmidt
parent bfe2447a3b
commit e367258eef
6 changed files with 1208 additions and 1 deletions

View file

@ -9,7 +9,7 @@ foreach plugin : ['accurip', 'adpcmdec', 'adpcmenc', 'aiff', 'asfmux',
'midi', 'mpegdemux', 'mpegpsmux', 'mpegtsdemux', 'mpegtsmux',
'mxf', 'netsim', 'onvif', 'pcapparse', 'pnm', 'proxy',
'rawparse', 'removesilence', 'rist', 'rtmp2', 'rtp', 'sdp',
'segmentclip', 'siren', 'smooth', 'speed', 'subenc',
'segmentclip', 'siren', 'smooth', 'speed', 'subenc', 'switchbin',
'timecode', 'transcode', 'videofilters',
'videoframe_audiolevel', 'videoparsers', 'videosignal',
'vmnc', 'y4m', 'yadif']

1062
gst/switchbin/gstswitchbin.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,87 @@
/* switchbin
* Copyright (C) 2016 Carlos Rafael Giani
*
* gstswitchbin.h: Header for GstSwitchBin object
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef GSTSWITCHBIN_H___
#define GSTSWITCHBIN_H___
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstSwitchBin GstSwitchBin;
typedef struct _GstSwitchBinClass GstSwitchBinClass;
typedef struct _GstSwitchBinPath GstSwitchBinPath;
#define GST_TYPE_SWITCH_BIN (gst_switch_bin_get_type())
#define GST_SWITCH_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SWITCH_BIN, GstSwitchBin))
#define GST_SWITCH_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SWITCH_BIN, GstSwitchBinClass))
#define GST_SWITCH_BIN_CAST(obj) ((GstSwitchBin *)(obj))
#define GST_IS_SWITCH_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SWITCH_BIN))
#define GST_IS_SWITCH_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SWITCH_BIN))
struct _GstSwitchBin
{
GstBin parent;
GMutex path_mutex;
GstSwitchBinPath **paths;
GstSwitchBinPath *current_path;
guint num_paths;
GstElement *input_identity;
GstEvent *last_stream_start;
GstPad *sinkpad, *srcpad;
gulong blocking_probe_id, drop_probe_id;
GstCaps *last_caps;
};
struct _GstSwitchBinClass
{
GstBinClass parent_class;
};
struct _GstSwitchBinPath
{
GstObject parent;
GstElement *element;
GstCaps *caps;
GstSwitchBin *bin;
};
GType gst_switch_bin_get_type(void);
GType gst_switch_bin_path_get_type(void);
G_END_DECLS
#endif

14
gst/switchbin/meson.build Normal file
View file

@ -0,0 +1,14 @@
switchbin_sources = [
'gstswitchbin.c', 'plugin.c'
]
gstswitchbin = library('gstswitchbin',
switchbin_sources,
c_args : gst_plugins_bad_args,
include_directories : [configinc],
dependencies : [gst_dep],
install : true,
install_dir : plugins_install_dir,
)
pkgconfig.generate(gstswitchbin, install_dir : plugins_pkgconfig_install_dir)
plugins += [gstswitchbin]

43
gst/switchbin/plugin.c Normal file
View file

@ -0,0 +1,43 @@
/* switchbin
* Copyright (C) 2016 Carlos Rafael Giani
*
* gstswitchbin.c: Element for switching between paths based on input caps
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstswitchbin.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret = TRUE;
ret = ret
&& gst_element_register (plugin, "switchbin", GST_RANK_NONE,
gst_switch_bin_get_type ());
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
switchbin,
"switchbin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -57,6 +57,7 @@ option('siren', type : 'feature', value : 'auto')
option('smooth', type : 'feature', value : 'auto')
option('speed', type : 'feature', value : 'auto')
option('subenc', type : 'feature', value : 'auto')
option('switchbin', type : 'feature', value : 'auto')
option('timecode', type : 'feature', value : 'auto')
option('videofilters', type : 'feature', value : 'auto')
option('videoframe_audiolevel', type : 'feature', value : 'auto')