#include "config.h"
#endif
+#include "gstaudiomixerelements.h"
#include "gstaudiointerleave.h"
-#include <gst/audio/audio.h>
-
-#include <string.h>
#define GST_CAT_DEFAULT gst_audio_interleave_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
G_DEFINE_TYPE (GstAudioInterleavePad, gst_audio_interleave_pad,
GST_TYPE_AUDIO_AGGREGATOR_PAD);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (audiointerleave, "audiointerleave",
+ GST_RANK_NONE, GST_TYPE_AUDIO_INTERLEAVE, audiomixer_element_init (plugin));
static void
gst_audio_interleave_pad_get_property (GObject * object, guint prop_id,
#include "config.h"
#endif
-#include "gstaudiomixer.h"
-#include <gst/audio/audio.h>
-#include <string.h> /* strcmp */
+#include "gstaudiomixerelements.h"
#include "gstaudiomixerorc.h"
-#include "gstaudiointerleave.h"
-
-#define GST_CAT_DEFAULT gst_audiomixer_debug
-GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define DEFAULT_PAD_VOLUME (1.0)
#define DEFAULT_PAD_MUTE (FALSE)
G_DEFINE_TYPE (GstAudioMixerPad, gst_audiomixer_pad,
GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (audiomixer, "audiomixer",
+ GST_RANK_NONE, GST_TYPE_AUDIO_MIXER, audiomixer_element_init (plugin));
static void
gst_audiomixer_pad_get_property (GObject * object, guint prop_id,
iface->get_child_by_index = gst_audiomixer_child_proxy_get_child_by_index;
iface->get_children_count = gst_audiomixer_child_proxy_get_children_count;
}
-
-/* Empty liveadder alias with non-zero latency */
-
-typedef GstAudioMixer GstLiveAdder;
-typedef GstAudioMixerClass GstLiveAdderClass;
-
-static GType gst_live_adder_get_type (void);
-#define GST_TYPE_LIVE_ADDER gst_live_adder_get_type ()
-
-G_DEFINE_TYPE (GstLiveAdder, gst_live_adder, GST_TYPE_AUDIO_MIXER);
-
-enum
-{
- LIVEADDER_PROP_LATENCY = 1
-};
-
-static void
-gst_live_adder_init (GstLiveAdder * self)
-{
-}
-
-static void
-gst_live_adder_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- switch (prop_id) {
- case LIVEADDER_PROP_LATENCY:
- {
- GParamSpec *parent_spec =
- g_object_class_find_property (G_OBJECT_CLASS
- (gst_live_adder_parent_class), "latency");
- GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
- GValue v = { 0 };
-
- g_value_init (&v, G_TYPE_UINT64);
-
- g_value_set_uint64 (&v, g_value_get_uint (value) * GST_MSECOND);
-
- G_OBJECT_CLASS (pspec_class)->set_property (object,
- parent_spec->param_id, &v, parent_spec);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_live_adder_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec)
-{
- switch (prop_id) {
- case LIVEADDER_PROP_LATENCY:
- {
- GParamSpec *parent_spec =
- g_object_class_find_property (G_OBJECT_CLASS
- (gst_live_adder_parent_class), "latency");
- GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
- GValue v = { 0 };
-
- g_value_init (&v, G_TYPE_UINT64);
-
- G_OBJECT_CLASS (pspec_class)->get_property (object,
- parent_spec->param_id, &v, parent_spec);
-
- g_value_set_uint (value, g_value_get_uint64 (&v) / GST_MSECOND);
- break;
- }
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-static void
-gst_live_adder_class_init (GstLiveAdderClass * klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = gst_live_adder_set_property;
- gobject_class->get_property = gst_live_adder_get_property;
-
- g_object_class_install_property (gobject_class, LIVEADDER_PROP_LATENCY,
- g_param_spec_uint ("latency", "Buffer latency",
- "Additional latency in live mode to allow upstream "
- "to take longer to produce buffers for the current "
- "position (in milliseconds)", 0, G_MAXUINT,
- 30, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "audiomixer", 0,
- "audio mixing element");
-
- if (!gst_element_register (plugin, "audiomixer", GST_RANK_NONE,
- GST_TYPE_AUDIO_MIXER))
- return FALSE;
-
- if (!gst_element_register (plugin, "liveadder", GST_RANK_NONE,
- GST_TYPE_LIVE_ADDER))
- return FALSE;
-
- if (!gst_element_register (plugin, "audiointerleave", GST_RANK_NONE,
- GST_TYPE_AUDIO_INTERLEAVE))
- return FALSE;
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- audiomixer,
- "Mixes multiple audio streams",
- plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
--- /dev/null
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2001 Thomas <thomas@apestaart.org>
+ * 2005,2006 Wim Taymans <wim@fluendo.com>
+ * 2013 Sebastian Dröge <sebastian@centricular.com>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * @Author: Stéphane Cerveau <scerveau@collabora.com>
+ *
+ * audiomixer.c: AudioMixer element, N in, one out, samples are added
+ *
+ * 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.
+ */
+
+
+#include "gstaudiomixerelements.h"
+
+#define GST_CAT_DEFAULT gst_audiomixer_debug
+GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
+
+void
+audiomixer_element_init (GstPlugin * plugin)
+{
+ static gsize res = FALSE;
+ if (g_once_init_enter (&res)) {
+ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "audiomixer", 0,
+ "audio mixing element");
+ g_once_init_leave (&res, TRUE);
+ }
+}
--- /dev/null
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2001 Thomas <thomas@apestaart.org>
+ * 2005,2006 Wim Taymans <wim@fluendo.com>
+ * 2013 Sebastian Dröge <sebastian@centricular.com>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * @Author: Stéphane Cerveau <scerveau@collabora.com>
+ *
+ *
+ * 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 __GST_AUDIO_MIXER_ELEMENTS_H__
+#define __GST_AUDIO_MIXER_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+#include <gst/audio/gstaudioaggregator.h>
+
+#include "gstaudiomixer.h"
+#include "gstaudiointerleave.h"
+
+G_BEGIN_DECLS
+
+G_GNUC_INTERNAL void audiomixer_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (audiomixer);
+GST_ELEMENT_REGISTER_DECLARE (liveadder);
+GST_ELEMENT_REGISTER_DECLARE (audiointerleave);
+
+
+#endif /* __GST_AUDIO_MIXER_ELEMENTS_H__ */
--- /dev/null
+/* GStreamer
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * @Author: Stéphane Cerveau <scerveau@collabora.com>
+ *
+ * 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.
+ */
+
+#include "gstaudiomixerelements.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ gboolean ret = FALSE;
+
+ ret |= GST_ELEMENT_REGISTER (audiomixer, plugin);
+ ret |= GST_ELEMENT_REGISTER (liveadder, plugin);
+ ret |= GST_ELEMENT_REGISTER (audiointerleave, plugin);
+
+ return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ audiomixer,
+ "Mixes multiple audio streams",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
--- /dev/null
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2001 Thomas <thomas@apestaart.org>
+ * 2005,2006 Wim Taymans <wim@fluendo.com>
+ * 2013 Sebastian Dröge <sebastian@centricular.com>
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * @Author: Stéphane Cerveau <scerveau@collabora.com>
+ *
+ * audiomixer.c: AudioMixer element, N in, one out, samples are added
+ *
+ * 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.
+ */
+/**
+ * SECTION:element-liveadder
+ * @title: liveadder
+ *
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstaudiomixerelements.h"
+#include "gstaudiomixerorc.h"
+
+#include "gstaudiointerleave.h"
+
+/* Empty liveadder alias with non-zero latency */
+
+typedef GstAudioMixer GstLiveAdder;
+typedef GstAudioMixerClass GstLiveAdderClass;
+
+static GType gst_live_adder_get_type (void);
+#define GST_TYPE_LIVE_ADDER gst_live_adder_get_type ()
+
+G_DEFINE_TYPE (GstLiveAdder, gst_live_adder, GST_TYPE_AUDIO_MIXER);
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (liveadder, "liveadder",
+ GST_RANK_NONE, GST_TYPE_LIVE_ADDER, audiomixer_element_init (plugin));
+
+enum
+{
+ LIVEADDER_PROP_LATENCY = 1
+};
+
+static void
+gst_live_adder_init (GstLiveAdder * self)
+{
+}
+
+static void
+gst_live_adder_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ switch (prop_id) {
+ case LIVEADDER_PROP_LATENCY:
+ {
+ GParamSpec *parent_spec =
+ g_object_class_find_property (G_OBJECT_CLASS
+ (gst_live_adder_parent_class), "latency");
+ GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
+ GValue v = { 0 };
+
+ g_value_init (&v, G_TYPE_UINT64);
+
+ g_value_set_uint64 (&v, g_value_get_uint (value) * GST_MSECOND);
+
+ G_OBJECT_CLASS (pspec_class)->set_property (object,
+ parent_spec->param_id, &v, parent_spec);
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_live_adder_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ switch (prop_id) {
+ case LIVEADDER_PROP_LATENCY:
+ {
+ GParamSpec *parent_spec =
+ g_object_class_find_property (G_OBJECT_CLASS
+ (gst_live_adder_parent_class), "latency");
+ GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
+ GValue v = { 0 };
+
+ g_value_init (&v, G_TYPE_UINT64);
+
+ G_OBJECT_CLASS (pspec_class)->get_property (object,
+ parent_spec->param_id, &v, parent_spec);
+
+ g_value_set_uint (value, g_value_get_uint64 (&v) / GST_MSECOND);
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_live_adder_class_init (GstLiveAdderClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->set_property = gst_live_adder_set_property;
+ gobject_class->get_property = gst_live_adder_get_property;
+
+ g_object_class_install_property (gobject_class, LIVEADDER_PROP_LATENCY,
+ g_param_spec_uint ("latency", "Buffer latency",
+ "Additional latency in live mode to allow upstream "
+ "to take longer to produce buffers for the current "
+ "position (in milliseconds)", 0, G_MAXUINT,
+ 30, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
+}
audiomixer_sources = [
'gstaudiomixer.c',
+ 'gstaudiomixerelement.c',
+ 'gstliveadder.c',
'gstaudiointerleave.c',
+ 'gstaudiomixerplugin.c'
]
orcsrc = 'gstaudiomixerorc'