diff --git a/.gitignore b/.gitignore index e8739ba3..76f8754e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,4 @@ DerivedData/ .vs/ xcuserdata/ -autom4te.cache/ \ No newline at end of file +autom4te.cache/ 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 8786bf5d..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_VOICE)); 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_SIGNAL(OPUS_SIGNAL_MUSIC)); +#else secondaryEncoder=opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, NULL); - opus_encoder_ctl(secondaryEncoder, OPUS_SET_COMPLEXITY(10)); 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/VoIPController.h b/VoIPController.h index bb3c30de..a5176a5e 100755 --- a/VoIPController.h +++ b/VoIPController.h @@ -60,6 +60,7 @@ namespace tgvoip{ }; enum{ + STATE_CREATED=0, STATE_WAIT_INIT=1, STATE_WAIT_INIT_ACK, STATE_ESTABLISHED, 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])