Skip to content

Commit

Permalink
webrtc: Replace dsp and echoprobe by gst webrtcdsp and webrtcechoprobe
Browse files Browse the repository at this point in the history
  • Loading branch information
igsha committed Apr 16, 2024
1 parent f742898 commit 564fee7
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 374 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- run: sudo apt-get update
- run: sudo apt-get remove libunwind-14-dev
- run: sudo apt-get install -y build-essential gettext libadwaita-1-dev libcanberra-dev libgcrypt20-dev libgee-0.8-dev libgpgme-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgtk-4-dev libnice-dev libnotify-dev libqrencode-dev libsignal-protocol-c-dev libsoup2.4-dev libsqlite3-dev libsrtp2-dev libwebrtc-audio-processing-dev meson valac
- run: meson setup build -Dcrypto-backend=auto -Dplugin-ice=enabled -Duse-soup2=true
- run: meson setup build -Duse-soup2=true -Dplugin-rtp-webrtc-audio-processing=disabled
- run: meson compile -C build
- run: meson test -C build
build-flatpak:
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ endif ()

include(CTest)

option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON)

# https://gitlab.kitware.com/cmake/cmake/-/issues/19804
if (WIN32)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .dll)
endif()

# Prepare Plugins
set(DEFAULT_PLUGINS omemo;openpgp;http-files;ice;rtp)
if (WIN32)
Expand Down
11 changes: 11 additions & 0 deletions cmake/FindGstWebrtcDsp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
find_library(GstWebrtcDsp_LIBRARY gstwebrtcdsp PATH_SUFFIXES gstreamer-1.0)

if(GstWebrtcDsp_LIBRARY_FOUND)
find_package(Gst)
set(GstWebrtcDsp_VERSION ${Gst_VERSION})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GstWebrtcDsp
REQUIRED_VARS GstWebrtcDsp_LIBRARY
VERSION_VAR GstWebrtcDsp_VERSION)
12 changes: 0 additions & 12 deletions cmake/FindWebRTCAudioProcessing.cmake

This file was deleted.

9 changes: 7 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ else
libsoup_version = '3.0'
endif

cc = meson.get_compiler('c')

dep_gdk_pixbuf = dependency('gdk-pixbuf-2.0')
dep_gee = dependency('gee-0.8')
dep_gio = dependency('gio-2.0')
Expand All @@ -81,9 +83,12 @@ dep_libsrtp2 = dependency('libsrtp2', disabler: true, required: plugin_crypto)
dep_libsignal_protocol_c = dependency('libsignal-protocol-c', version: ['>=2.3.2', '<2.3.4'], disabler: true, required: get_option('plugin-omemo'))
dep_libsoup = dependency('libsoup-@0@'.format(libsoup_version), disabler: true, required: get_option('plugin-http-files'))
dep_nice = dependency('nice', version: '>=0.1.15', disabler: true, required: get_option('plugin-ice'))
dep_m = meson.get_compiler('c').find_library('m', required: false)
dep_m = cc.find_library('m', required: false)
dep_sqlite3 = dependency('sqlite3', version: '>=3.24')
dep_webrtc_audio_processing = dependency('webrtc-audio-processing', version: ['>=0.2', '<0.4'], required: get_option('plugin-rtp-webrtc-audio-processing'))

dep_gstreamer_bad = dependency('gstreamer-plugins-bad-1.0', disabler: true, required: get_option('plugin-rtp-webrtc-audio-processing'))
gstpluginsdir = dep_gstreamer_bad.get_variable('pluginsdir')
dep_webrtcdsp = cc.find_library('gstwebrtcdsp', dirs: gstpluginsdir, disabler: true, required: get_option('plugin-rtp-webrtc-audio-processing'))

prog_git = find_program('git', required: false)
prog_python = python.find_installation()
Expand Down
28 changes: 10 additions & 18 deletions plugins/rtp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
find_package(GLib ${GLib_GLOBAL_VERSION} REQUIRED)
find_package(WebRTCAudioProcessing 0.2)

set(RTP_DEFINITIONS)
set(RTP_EXTRA_OPTIONS)

if(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING)
set(EXTRA_RTP_PACKAGES GstWebrtcDsp)
list(APPEND RTP_DEFINITIONS WITH_VOICE_PROCESSOR)
endif()

find_packages(RTP_PACKAGES REQUIRED
Gee
GLib
Expand All @@ -11,11 +19,9 @@ find_packages(RTP_PACKAGES REQUIRED
GstAudio
GstRtp
GstVideo
${EXTRA_RTP_PACKAGES}
)

set(RTP_DEFINITIONS)
set(RTP_EXTRA_OPTIONS)

if(GstRtp_VERSION VERSION_GREATER_EQUAL "1.16")
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} GST_1_16)
endif()
Expand Down Expand Up @@ -52,20 +58,6 @@ if(RTP_ENABLE_MSDK)
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} ENABLE_MSDK)
endif()

if(WebRTCAudioProcessing_VERSION GREATER "0.4")
message(STATUS "Ignoring WebRTCAudioProcessing, only versions < 0.4 supported so far")
unset(WebRTCAudioProcessing_FOUND)
endif()

if(WebRTCAudioProcessing_FOUND)
set(RTP_DEFINITIONS ${RTP_DEFINITIONS} WITH_VOICE_PROCESSOR)
set(RTP_VOICE_PROCESSOR_VALA src/voice_processor.vala)
set(RTP_VOICE_PROCESSOR_CXX src/voice_processor_native.cpp)
set(RTP_VOICE_PROCESSOR_LIB webrtc-audio-processing)
else()
message(STATUS "WebRTCAudioProcessing not found, build without voice pre-processing!")
endif()

vala_precompile(RTP_VALA_C
SOURCES
src/codec_util.vala
Expand Down
8 changes: 2 additions & 6 deletions plugins/rtp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ c_args = [
vala_args = [
'--vapidir', meson.current_source_dir() / 'vapi',
]
if dep_webrtc_audio_processing.found()
dependencies += [dep_webrtc_audio_processing]
sources += files(
'src/voice_processor.vala',
'src/voice_processor_native.cpp',
)
if dep_webrtcdsp.found()
dependencies += [dep_webrtcdsp]
vala_args += ['-D', 'WITH_VOICE_PROCESSOR']
endif
if dep_gstreamer_rtp.version() == 'unknown' or dep_gstreamer_rtp.version().version_compare('>=1.16')
Expand Down
5 changes: 2 additions & 3 deletions plugins/rtp/src/device.vala
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,12 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
Gst.Bin bin = new Gst.Bin("voiceprocessorbin");
Gst.Element converter = Gst.ElementFactory.make("audioconvert", @"dsp_convert_$id");
Gst.Element resampler = Gst.ElementFactory.make("audioresample", @"dsp_resmaple_$id");

Gst.Element voiceproc = new VoiceProcessor(plugin.echoprobe as EchoProbe, element as Gst.Audio.StreamVolume);
voiceproc.name = @"dsp_$id";
Gst.Element voiceproc = Gst.ElementFactory.make("webrtcdsp", @"dsp_$id");

bin.add_many(converter, resampler, voiceproc);
converter.link(resampler);
resampler.link(voiceproc);
voiceproc.@set("probe", "webrtcechoprobe0");

Gst.Pad sink_pad = bin.find_unlinked_pad(Gst.PadDirection.SINK);
Gst.Pad src_pad = bin.find_unlinked_pad(Gst.PadDirection.SRC);
Expand Down
14 changes: 6 additions & 8 deletions plugins/rtp/src/plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {
}

#if WITH_VOICE_PROCESSOR
private Gst.Element create_echo_bin(Gst.Element element) {
private Gst.Element create_echo_probe() {
Gst.Bin bin = new Gst.Bin("echoprobebin");
Gst.Element converter = Gst.ElementFactory.make("audioconvert", "echo_convert_");
Gst.Element resampler = Gst.ElementFactory.make("audioresample", "echo_resample_");
Gst.Element webrtcechoprobe = Gst.ElementFactory.make("webrtcechoprobe", "webrtcechoprobe0");

bin.add_many(element, converter, resampler);
element.link(converter);
bin.add_many(webrtcechoprobe, converter, resampler);
webrtcechoprobe.link(converter);
converter.link(resampler);

Gst.Pad sink_pad = bin.find_unlinked_pad(Gst.PadDirection.SINK);
Expand Down Expand Up @@ -100,11 +101,8 @@ public class Dino.Plugins.Rtp.Plugin : RootInterface, VideoCallPlugin, Object {

#if WITH_VOICE_PROCESSOR
// Audio echo probe
echoprobe = new EchoProbe();
if (echoprobe != null) {
echoprobe = create_echo_bin(echoprobe);
pipe.add(echoprobe);
}
echoprobe = create_echo_probe();
pipe.add(echoprobe);
#endif

// Pipeline
Expand Down
176 changes: 0 additions & 176 deletions plugins/rtp/src/voice_processor.vala

This file was deleted.

Loading

0 comments on commit 564fee7

Please sign in to comment.