From 1d5e7dbd8e213b4f1f420c96b93bb4a8988435fb Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 2 Sep 2018 16:03:07 +0200 Subject: [PATCH 1/4] webradio changes --- .gitignore | 3 ++- BufferPool.cpp | 2 +- BufferPool.h | 2 +- OpusEncoder.cpp | 8 ++++---- VoIPController.cpp | 2 +- VoIPController.h | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index e8739ba3..1dba4704 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bin build */Debug/* */Release/* +*.o # Build results [Dd]ebug/ @@ -23,4 +24,4 @@ DerivedData/ .vs/ xcuserdata/ -autom4te.cache/ \ No newline at end of file +autom4te.cache/ diff --git a/BufferPool.cpp b/BufferPool.cpp index 59c03a5b..d00904b3 100644 --- a/BufferPool.cpp +++ b/BufferPool.cpp @@ -12,7 +12,7 @@ using namespace tgvoip; BufferPool::BufferPool(unsigned int size, unsigned int count){ - assert(count<=64); + assert(count<=1024); buffers[0]=(unsigned char*) malloc(size*count); bufferCount=count; unsigned int i; diff --git a/BufferPool.h b/BufferPool.h index a89a044a..14fd532a 100644 --- a/BufferPool.h +++ b/BufferPool.h @@ -24,7 +24,7 @@ class BufferPool{ uint64_t usedBuffers; int bufferCount; size_t size; - unsigned char* buffers[64]; + unsigned char* buffers[1024]; Mutex mutex; }; } diff --git a/OpusEncoder.cpp b/OpusEncoder.cpp index e30f814e..00336e97 100644 --- a/OpusEncoder.cpp +++ b/OpusEncoder.cpp @@ -17,11 +17,11 @@ tgvoip::OpusEncoder::OpusEncoder(MediaStreamItf *source, bool needSecondary):queue(11), bufferPool(960*2, 10){ this->source=source; source->SetCallback(tgvoip::OpusEncoder::Callback, this); - enc=opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, NULL); + enc=opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, NULL); opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(15)); opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); + opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); requestedBitrate=32000; currentBitrate=0; @@ -37,9 +37,9 @@ tgvoip::OpusEncoder::OpusEncoder(MediaStreamItf *source, bool needSecondary):que secondaryEncoderEnabled=false; if(needSecondary){ - secondaryEncoder=opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, NULL); + secondaryEncoder=opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, NULL); opus_encoder_ctl(secondaryEncoder, OPUS_SET_COMPLEXITY(10)); - opus_encoder_ctl(secondaryEncoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); + opus_encoder_ctl(secondaryEncoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_VBR(0)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_BITRATE(8000)); diff --git a/VoIPController.cpp b/VoIPController.cpp index 84098b36..6e9e4bb1 100644 --- a/VoIPController.cpp +++ b/VoIPController.cpp @@ -140,7 +140,7 @@ VoIPController::VoIPController() : activeNetItfName(""), audioTimestampIn=0; audioTimestampOut=0; stopping=false; - sendQueue=new BlockingQueue(21); + sendQueue=new BlockingQueue(21*4); memset(recvPacketTimes, 0, sizeof(double)*32); memset(&stats, 0, sizeof(TrafficStats)); lastRemoteAckSeq=0; diff --git a/VoIPController.h b/VoIPController.h index 12849d7e..1339b343 100644 --- a/VoIPController.h +++ b/VoIPController.h @@ -53,6 +53,7 @@ namespace tgvoip{ }; enum{ + STATE_CREATED=0, STATE_WAIT_INIT=1, STATE_WAIT_INIT_ACK, STATE_ESTABLISHED, From 9bc966c64feecd45b468590e025c1a739c8fb7dd Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 2 Sep 2018 19:53:58 +0200 Subject: [PATCH 2/4] Use local include --- audio/AudioIOCallback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/AudioIOCallback.h b/audio/AudioIOCallback.h index 36ba03b4..5fae189e 100644 --- a/audio/AudioIOCallback.h +++ b/audio/AudioIOCallback.h @@ -7,7 +7,7 @@ #ifndef LIBTGVOIP_AUDIO_IO_CALLBACK #define LIBTGVOIP_AUDIO_IO_CALLBACK -#include +#include "AudioIO.h" #include #include "../threading.h" From 00f3aabc6fbc57aa1bac061e438462c9d2797478 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 28 Mar 2019 20:43:14 +0100 Subject: [PATCH 3/4] Add opus music and desktop DSP flags to configure.ac --- .gitignore | 15 +++++++++++++++ Makefile.am | 8 ++++++++ Makefile.in | 29 ++++++++++++++++------------- OpusEncoder.cpp | 14 ++++++++++++-- configure | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 6 ++++++ 6 files changed, 105 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 1dba4704..d7eedeb2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,18 @@ DerivedData/ xcuserdata/ autom4te.cache/ + +# Autoconf build files +*.lo +*.Plo +.libs +.dirstamp +libtool +stamp-h1 +libtgvoip.l1 +libtgvoip.la +config.h +config.log +config.status +Makefile +libtgvoip.la \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 0d1f1b50..70624299 100644 --- a/Makefile.am +++ b/Makefile.am @@ -401,6 +401,14 @@ TGVOIP_HDRS += \ audio/AudioIOCallback.h endif +if ENABLE_DESKTOP_DSP +CFLAGS += -DTGVOIP_USE_DESKTOP_DSP +endif + +if ENABLE_OPUS_MUSIC +CFLAGS += -DTGVOIP_USE_OPUS_MUSIC +endif + if TARGET_CPU_ARM SRC += \ webrtc_dsp/common_audio/signal_processing/complex_bit_reverse_arm.S \ diff --git a/Makefile.in b/Makefile.in index c401d281..83f66e24 100644 --- a/Makefile.in +++ b/Makefile.in @@ -419,13 +419,15 @@ host_triplet = @host@ @ENABLE_AUDIO_CALLBACK_TRUE@@ENABLE_DSP_TRUE@am__append_17 = \ @ENABLE_AUDIO_CALLBACK_TRUE@@ENABLE_DSP_TRUE@audio/AudioIOCallback.h -@ENABLE_DSP_TRUE@@TARGET_CPU_ARM_TRUE@am__append_18 = \ +@ENABLE_DESKTOP_DSP_TRUE@@ENABLE_DSP_TRUE@am__append_18 = -DTGVOIP_USE_DESKTOP_DSP +@ENABLE_DSP_TRUE@@ENABLE_OPUS_MUSIC_TRUE@am__append_19 = -DTGVOIP_USE_OPUS_MUSIC +@ENABLE_DSP_TRUE@@TARGET_CPU_ARM_TRUE@am__append_20 = \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/common_audio/signal_processing/complex_bit_reverse_arm.S \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_arm.S -@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_19 = -mfpu=neon -mfloat-abi=hard -@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_20 = -mfpu=neon -mfloat-abi=hard -@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_21 = \ +@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_21 = -mfpu=neon -mfloat-abi=hard +@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_22 = -mfpu=neon -mfloat-abi=hard +@ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@am__append_23 = \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/common_audio/signal_processing/cross_correlation_neon.c \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/common_audio/signal_processing/downsample_fast_neon.c \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/common_audio/signal_processing/min_max_operations_neon.c \ @@ -435,13 +437,13 @@ host_triplet = @host@ @ENABLE_DSP_TRUE@@TARGET_CPU_ARMV7_TRUE@@TARGET_CPU_ARM_TRUE@webrtc_dsp/modules/audio_processing/utility/ooura_fft_neon.cc # webrtc_dsp/common_audio/signal_processing/filter_ar_fast_q12_armv7.S -@ENABLE_DSP_TRUE@@TARGET_CPU_ARM_FALSE@am__append_22 = \ +@ENABLE_DSP_TRUE@@TARGET_CPU_ARM_FALSE@am__append_24 = \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARM_FALSE@webrtc_dsp/common_audio/signal_processing/complex_bit_reverse.c \ @ENABLE_DSP_TRUE@@TARGET_CPU_ARM_FALSE@webrtc_dsp/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c # headers -@ENABLE_DSP_TRUE@am__append_23 = \ +@ENABLE_DSP_TRUE@am__append_25 = \ @ENABLE_DSP_TRUE@webrtc_dsp/system_wrappers/include/field_trial.h \ @ENABLE_DSP_TRUE@webrtc_dsp/system_wrappers/include/cpu_features_wrapper.h \ @ENABLE_DSP_TRUE@webrtc_dsp/system_wrappers/include/asm_defines.h \ @@ -761,8 +763,8 @@ host_triplet = @host@ @ENABLE_DSP_TRUE@webrtc_dsp/common_audio/vad/vad_sp.h \ @ENABLE_DSP_TRUE@webrtc_dsp/common_audio/vad/vad_filterbank.h -@ENABLE_DSP_FALSE@am__append_24 = -DTGVOIP_NO_DSP -@TARGET_OS_OSX_TRUE@am__append_25 = -std=gnu++0x $(CFLAGS) +@ENABLE_DSP_FALSE@am__append_26 = -DTGVOIP_NO_DSP +@TARGET_OS_OSX_TRUE@am__append_27 = -std=gnu++0x $(CFLAGS) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -2227,11 +2229,12 @@ AWK = @AWK@ CC = @CC@ CCAS = @CCAS@ CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ $(am__append_9) $(am__append_20) +CCASFLAGS = @CCASFLAGS@ $(am__append_9) $(am__append_22) CCDEPMODE = @CCDEPMODE@ CFLAGS = -Wall -DHAVE_CONFIG_H -Wno-unknown-pragmas $(am__append_8) \ $(am__append_11) $(am__append_13) $(am__append_15) \ - $(am__append_19) $(am__append_24) + $(am__append_18) $(am__append_19) $(am__append_21) \ + $(am__append_26) CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ @@ -2272,7 +2275,7 @@ NM = @NM@ NMEDIT = @NMEDIT@ OBJCXX = @OBJCXX@ OBJCXXDEPMODE = @OBJCXXDEPMODE@ -OBJCXXFLAGS = @OBJCXXFLAGS@ $(am__append_25) +OBJCXXFLAGS = @OBJCXXFLAGS@ $(am__append_27) OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ @@ -2357,8 +2360,8 @@ SRC = VoIPController.cpp Buffers.cpp CongestionControl.cpp \ video/VideoRenderer.cpp video/ScreamCongestionController.cpp \ json11.cpp $(am__append_1) $(am__append_4) $(am__append_6) \ $(am__append_10) $(am__append_12) $(am__append_14) \ - $(am__append_16) $(am__append_18) $(am__append_21) \ - $(am__append_22) $(am__append_23) + $(am__append_16) $(am__append_20) $(am__append_23) \ + $(am__append_24) $(am__append_25) TGVOIP_HDRS = VoIPController.h Buffers.h BlockingQueue.h \ PrivateDefines.h CongestionControl.h EchoCanceller.h \ JitterBuffer.h logging.h threading.h MediaStreamItf.h \ diff --git a/OpusEncoder.cpp b/OpusEncoder.cpp index b5c95d4e..169f649a 100755 --- a/OpusEncoder.cpp +++ b/OpusEncoder.cpp @@ -36,11 +36,16 @@ namespace{ tgvoip::OpusEncoder::OpusEncoder(MediaStreamItf *source, bool needSecondary):queue(11), bufferPool(960*2, 10){ this->source=source; source->SetCallback(tgvoip::OpusEncoder::Callback, this); +#ifdef TGVOIP_USE_OPUS_MUSIC enc=opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, NULL); + opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); +#else + enc=opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, NULL); + opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); +#endif opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10)); opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(1)); opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1)); - opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); requestedBitrate=20000; currentBitrate=0; @@ -56,9 +61,14 @@ tgvoip::OpusEncoder::OpusEncoder(MediaStreamItf *source, bool needSecondary):que secondaryEncoderEnabled=false; if(needSecondary){ +#ifdef TGVOIP_USE_OPUS_MUSIC secondaryEncoder=opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, NULL); - opus_encoder_ctl(secondaryEncoder, OPUS_SET_COMPLEXITY(10)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); +#else + secondaryEncoder=opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, NULL); + opus_encoder_ctl(secondaryEncoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE)); +#endif + opus_encoder_ctl(secondaryEncoder, OPUS_SET_COMPLEXITY(10)); //opus_encoder_ctl(secondaryEncoder, OPUS_SET_VBR(0)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_BITRATE(8000)); opus_encoder_ctl(secondaryEncoder, OPUS_SET_BANDWIDTH(secondaryEnabledBandwidth)); diff --git a/configure b/configure index 2cdfbf6e..9d53ca08 100755 --- a/configure +++ b/configure @@ -643,6 +643,10 @@ WITH_ALSA_FALSE WITH_ALSA_TRUE WITH_PULSE_FALSE WITH_PULSE_TRUE +ENABLE_OPUS_MUSIC_FALSE +ENABLE_OPUS_MUSIC_TRUE +ENABLE_DESKTOP_DSP_FALSE +ENABLE_DESKTOP_DSP_TRUE ENABLE_AUDIO_CALLBACK_FALSE ENABLE_AUDIO_CALLBACK_TRUE TARGET_OS_OSX_FALSE @@ -798,6 +802,8 @@ with_gnu_ld with_sysroot enable_libtool_lock enable_audio_callback +enable_desktop_dsp +enable_opus_music with_pulse with_alsa enable_dsp @@ -1450,6 +1456,8 @@ Optional Features: speeds up one-time build --disable-libtool-lock avoid locking (might break parallel builds) --enable-audio-callback enable callback-based audio I/O + --enable-desktop-dsp enable desktop DSP + --enable-opus-music enable music preset in OPUS encoder --disable-dsp disable signal processing (echo cancellation, noise suppression, and automatic gain control) @@ -17698,6 +17706,38 @@ else fi +# Check whether --enable-desktop-dsp was given. +if test "${enable_desktop_dsp+set}" = set; then : + enableval=$enable_desktop_dsp; +else + enable_desktop_dsp=no +fi + + if test "x$enable_desktop_dsp" == xyes; then + ENABLE_DESKTOP_DSP_TRUE= + ENABLE_DESKTOP_DSP_FALSE='#' +else + ENABLE_DESKTOP_DSP_TRUE='#' + ENABLE_DESKTOP_DSP_FALSE= +fi + + +# Check whether --enable-opus-music was given. +if test "${enable_opus_music+set}" = set; then : + enableval=$enable_opus_music; +else + enable_opus_music=no +fi + + if test "x$enable_opus_music" == xyes; then + ENABLE_OPUS_MUSIC_TRUE= + ENABLE_OPUS_MUSIC_FALSE='#' +else + ENABLE_OPUS_MUSIC_TRUE='#' + ENABLE_OPUS_MUSIC_FALSE= +fi + + if test "x$os_osx" != xyes && test "x$enable_audio_callback" != xyes; then : # Linux { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 @@ -18754,6 +18794,14 @@ if test -z "${ENABLE_AUDIO_CALLBACK_TRUE}" && test -z "${ENABLE_AUDIO_CALLBACK_F as_fn_error $? "conditional \"ENABLE_AUDIO_CALLBACK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_DESKTOP_DSP_TRUE}" && test -z "${ENABLE_DESKTOP_DSP_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_DESKTOP_DSP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_OPUS_MUSIC_TRUE}" && test -z "${ENABLE_OPUS_MUSIC_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_OPUS_MUSIC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${WITH_PULSE_TRUE}" && test -z "${WITH_PULSE_FALSE}"; then as_fn_error $? "conditional \"WITH_PULSE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 222f541e..1eb995c3 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,12 @@ AM_CONDITIONAL(TARGET_OS_OSX, test "x$os_osx" == xyes) AC_ARG_ENABLE([audio-callback], [AS_HELP_STRING([--enable-audio-callback], [enable callback-based audio I/O])], [], [enable_audio_callback=no]) AM_CONDITIONAL(ENABLE_AUDIO_CALLBACK, test "x$enable_audio_callback" == xyes) +AC_ARG_ENABLE([desktop-dsp], [AS_HELP_STRING([--enable-desktop-dsp], [enable desktop DSP])], [], [enable_desktop_dsp=no]) +AM_CONDITIONAL(ENABLE_DESKTOP_DSP, test "x$enable_desktop_dsp" == xyes) + +AC_ARG_ENABLE([opus-music], [AS_HELP_STRING([--enable-opus-music], [enable music preset in OPUS encoder])], [], [enable_opus_music=no]) +AM_CONDITIONAL(ENABLE_OPUS_MUSIC, test "x$enable_opus_music" == xyes) + AS_IF([test "x$os_osx" != xyes && test "x$enable_audio_callback" != xyes], [ # Linux AC_CHECK_LIB([dl], [dlopen]) From 29fd5772894f1938e75717f1aa66282dac5751b9 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 28 Mar 2019 20:51:00 +0100 Subject: [PATCH 4/4] Remove useless gitignore elements --- .gitignore | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.gitignore b/.gitignore index d7eedeb2..76f8754e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ bin build */Debug/* */Release/* -*.o # Build results [Dd]ebug/ @@ -25,18 +24,3 @@ DerivedData/ xcuserdata/ autom4te.cache/ - -# Autoconf build files -*.lo -*.Plo -.libs -.dirstamp -libtool -stamp-h1 -libtgvoip.l1 -libtgvoip.la -config.h -config.log -config.status -Makefile -libtgvoip.la \ No newline at end of file