tdav_webrtc_denoise.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2011 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tdav_webrtc_denoise.h
  23. * @brief Google WebRTC Denoiser (Noise suppression, AGC, AEC) Plugin
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango.org>
  26. *
  27. */
  28. #ifndef TINYDAV_WEBRTC_DENOISE_H
  29. #define TINYDAV_WEBRTC_DENOISE_H
  30. #include "tinydav_config.h"
  31. #if HAVE_WEBRTC && (!defined(HAVE_WEBRTC_DENOISE) || HAVE_WEBRTC_DENOISE)
  32. #include "tinymedia/tmedia_denoise.h"
  33. #include "tsk_safeobj.h"
  34. /* Speex denoiser works better than WebRTC's denoiser. This is obvious on Android. */
  35. #if !defined(PREFER_SPEEX_DENOISER)
  36. # define PREFER_SPEEX_DENOISER 1
  37. #endif
  38. #if TDAV_UNDER_MOBILE
  39. # include <webrtc/echo_control_mobile.h>
  40. # define TDAV_WebRtcAec_Create(aecInst) WebRtcAecm_Create(aecInst)
  41. # define TDAV_WebRtcAec_Free(aecInst) WebRtcAecm_Free(aecInst)
  42. # define TDAV_WebRtcAec_Init(aecInst, sampFreq, scSampFreq) WebRtcAecm_Init(aecInst, sampFreq)
  43. # define TDAV_WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples) WebRtcAecm_BufferFarend(aecInst, farend, nrOfSamples)
  44. # define TDAV_WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew) WebRtcAecm_Process(aecInst, nearend, nearend, out, nrOfSamples, msInSndCardBuf)
  45. #else
  46. # include <webrtc/echo_cancellation.h>
  47. # define TDAV_WebRtcAec_Create(aecInst) WebRtcAec_Create(aecInst)
  48. # define TDAV_WebRtcAec_Free(aecInst) WebRtcAec_Free(aecInst)
  49. # define TDAV_WebRtcAec_Init(aecInst, sampFreq, scSampFreq) WebRtcAec_Init(aecInst, sampFreq, scSampFreq)
  50. # define TDAV_WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples) WebRtcAec_BufferFarend(aecInst, farend, nrOfSamples)
  51. # define TDAV_WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew) WebRtcAec_Process(aecInst, nearend, nearendH, out, outH, nrOfSamples, msInSndCardBuf, skew)
  52. #endif
  53. #if HAVE_SPEEX_DSP && PREFER_SPEEX_DENOISER
  54. # include <speex/speex_preprocess.h>
  55. #else
  56. # if TDAV_UNDER_MOBILE // Use fixed implementation for Noise Suppression
  57. # include <webrtc/noise_suppression_x.h>
  58. # define TDAV_WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) WebRtcNsx_Process(NS_inst, spframe, spframe_H, outframe, outframe_H)
  59. # define TDAV_WebRtcNs_Init(NS_inst, fs) WebRtcNsx_Init(NS_inst, fs)
  60. # define TDAV_WebRtcNs_Free(NS_inst) WebRtcNsx_Free(NS_inst)
  61. # define TDAV_WebRtcNs_Create(NS_inst) WebRtcNsx_Create(NS_inst)
  62. # define TDAV_NsHandle NsxHandle
  63. # else
  64. # include <webrtc/noise_suppression.h>
  65. # define TDAV_WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H) WebRtcNs_Process(NS_inst, spframe, spframe_H, outframe, outframe_H)
  66. # define TDAV_WebRtcNs_Init(NS_inst, fs) WebRtcNs_Init(NS_inst, fs)
  67. # define TDAV_WebRtcNs_Free(NS_inst) WebRtcNs_Free(NS_inst)
  68. # define TDAV_WebRtcNs_Create(NS_inst) WebRtcNs_Create(NS_inst)
  69. # define TDAV_NsHandle NsHandle
  70. # endif
  71. #endif
  72. TDAV_BEGIN_DECLS
  73. extern const tmedia_denoise_plugin_def_t *tdav_webrtc_denoise_plugin_def_t;
  74. TDAV_END_DECLS
  75. #endif /* #if HAVE_WEBRTC */
  76. #endif /* TINYDAV_WEBRTC_DENOISE_H */