pulse: allow per feature registration

Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
This commit is contained in:
Stéphane Cerveau 2021-02-12 11:12:34 +01:00
parent 65e0bc21a5
commit 8c4c4b5cff
6 changed files with 105 additions and 25 deletions

View file

@ -0,0 +1,53 @@
/*
* GStreamer pulseaudio plugin
*
* Copyright (c) 2004-2008 Lennart Poettering
*
* gst-pulse is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* gst-pulse 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with gst-pulse; 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 <gst/gst-i18n-plugin.h>
#include "gstpulseelements.h"
#include "pulsedeviceprovider.h"
GST_DEBUG_CATEGORY (pulse_debug);
GST_DEVICE_PROVIDER_REGISTER_DEFINE (pulsedeviceprovider, "pulsedeviceprovider",
GST_RANK_PRIMARY, GST_TYPE_PULSE_DEVICE_PROVIDER);
void
pulse_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
GST_DEBUG_CATEGORY_INIT (pulse_debug, "pulse", 0, "PulseAudio elements");
g_once_init_leave (&res, TRUE);
}
}

View file

@ -0,0 +1,39 @@
/*
* GStreamer pulseaudio plugin
*
* Copyright (c) 2004-2008 Lennart Poettering
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Julian Bouzas <julian.bouzas@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_PULSE_ELEMENTS_H__
#define __GST_PULSE_ELEMENTS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
void pulse_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (pulsesink);
GST_ELEMENT_REGISTER_DECLARE (pulsesrc);
GST_DEVICE_PROVIDER_REGISTER_DECLARE (pulsedeviceprovider);
G_END_DECLS
#endif /* __GST_PULSE_ELEMENTS_H__ */

View file

@ -1,4 +1,5 @@
pulse_sources = [
'gstpulseelement.c',
'plugin.c',
'pulsesink.c',
'pulsesrc.c',

View file

@ -23,38 +23,19 @@
#include "config.h"
#endif
#include <gst/gst-i18n-plugin.h>
#include "pulsesink.h"
#include "pulsesrc.h"
#include "pulsedeviceprovider.h"
GST_DEBUG_CATEGORY (pulse_debug);
#include "gstpulseelements.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
gboolean ret = FALSE;
if (!gst_element_register (plugin, "pulsesink", GST_RANK_PRIMARY + 10,
GST_TYPE_PULSESINK))
return FALSE;
ret |= GST_ELEMENT_REGISTER (pulsesink, plugin);
ret |= GST_ELEMENT_REGISTER (pulsesrc, plugin);
if (!gst_element_register (plugin, "pulsesrc", GST_RANK_PRIMARY + 10,
GST_TYPE_PULSESRC))
return FALSE;
ret |= GST_DEVICE_PROVIDER_REGISTER (pulsedeviceprovider, plugin);
if (!gst_device_provider_register (plugin, "pulsedeviceprovider",
GST_RANK_PRIMARY, GST_TYPE_PULSE_DEVICE_PROVIDER))
return FALSE;
GST_DEBUG_CATEGORY_INIT (pulse_debug, "pulse", 0, "PulseAudio elements");
return TRUE;
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -59,6 +59,7 @@
#include <gst/glib-compat-private.h>
#include "gstpulseelements.h"
#include "pulsesink.h"
#include "pulseutil.h"
@ -1820,6 +1821,8 @@ G_DEFINE_TYPE_WITH_CODE (GstPulseSink, gst_pulsesink, GST_TYPE_AUDIO_BASE_SINK,
gst_pulsesink_init_contexts ();
G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL)
);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (pulsesink, "pulsesink",
GST_RANK_PRIMARY + 10, GST_TYPE_PULSESINK, pulse_element_init (plugin));
static GstAudioRingBuffer *
gst_pulsesink_create_ringbuffer (GstAudioBaseSink * sink)

View file

@ -45,6 +45,7 @@
#include <gst/gsttaglist.h>
#include <gst/audio/audio.h>
#include "gstpulseelements.h"
#include "pulsesrc.h"
#include "pulseutil.h"
@ -115,6 +116,8 @@ static GstClockTime gst_pulsesrc_get_time (GstClock * clock, GstPulseSrc * src);
#define gst_pulsesrc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstPulseSrc, gst_pulsesrc, GST_TYPE_AUDIO_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_STREAM_VOLUME, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (pulsesrc, "pulsesrc",
GST_RANK_PRIMARY + 10, GST_TYPE_PULSESRC, pulse_element_init (plugin));
static void
gst_pulsesrc_class_init (GstPulseSrcClass * klass)