dllmain_audio_dsp.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Copyright (C) 2013 Mamadou DIOP
  2. * Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. */
  19. #include "plugin_audio_dsp_utils.h"
  20. #include "tinymedia/tmedia_resampler.h"
  21. #include "tinymedia/tmedia_denoise.h"
  22. #include "tsk_plugin.h"
  23. #include "tsk_debug.h"
  24. #include <windows.h>
  25. #if defined(_MSC_VER)
  26. # pragma comment(lib, "wmcodecdspuuid")
  27. # pragma comment(lib, "Msdmo")
  28. # pragma comment(lib, "Dmoguids")
  29. # pragma comment(lib, "amstrmid")
  30. # pragma comment(lib, "Mfplat")
  31. # pragma comment(lib, "mfuuid")
  32. #endif
  33. #if !defined(PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE)
  34. # define PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE 1
  35. #endif
  36. #if !defined(PLUGIN_AUDIO_DSP_DENOISER_ENABLE)
  37. # define PLUGIN_AUDIO_DSP_DENOISER_ENABLE 0 /* Filter mode doesn't support AEC */
  38. #endif
  39. extern const tmedia_resampler_plugin_def_t *plugin_audio_dsp_resampler_plugin_def_t;
  40. extern const tmedia_denoise_plugin_def_t *plugin_audio_dsp_denoise_plugin_def_t;
  41. PLUGIN_AUDIO_DSP_BEGIN_DECLS /* BEGIN */
  42. PLUGIN_AUDIO_DSP_API int __plugin_get_def_count();
  43. PLUGIN_AUDIO_DSP_API tsk_plugin_def_type_t __plugin_get_def_type_at(int index);
  44. PLUGIN_AUDIO_DSP_API tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index);
  45. PLUGIN_AUDIO_DSP_API tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index);
  46. PLUGIN_AUDIO_DSP_END_DECLS /* END */
  47. BOOL APIENTRY DllMain( HMODULE hModule,
  48. DWORD ul_reason_for_call,
  49. LPVOID lpReserved
  50. )
  51. {
  52. switch (ul_reason_for_call) {
  53. case DLL_PROCESS_ATTACH:
  54. break;
  55. case DLL_THREAD_ATTACH:
  56. break;
  57. case DLL_THREAD_DETACH:
  58. break;
  59. case DLL_PROCESS_DETACH:
  60. break;
  61. }
  62. return TRUE;
  63. }
  64. typedef enum PLUGIN_INDEX_E {
  65. #if PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE
  66. PLUGIN_INDEX_RESAMPLER,
  67. #endif
  68. #if PLUGIN_AUDIO_DSP_DENOISER_ENABLE
  69. PLUGIN_INDEX_DENOISER,
  70. #endif
  71. PLUGIN_INDEX_COUNT
  72. }
  73. PLUGIN_INDEX_T;
  74. int __plugin_get_def_count()
  75. {
  76. return PLUGIN_INDEX_COUNT;
  77. }
  78. tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
  79. {
  80. switch(index) {
  81. #if PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE
  82. case PLUGIN_INDEX_RESAMPLER: {
  83. return tsk_plugin_def_type_resampler;
  84. }
  85. #endif
  86. #if PLUGIN_AUDIO_DSP_DENOISER_ENABLE
  87. case PLUGIN_INDEX_DENOISER: {
  88. return tsk_plugin_def_type_denoiser;
  89. }
  90. #endif
  91. }
  92. TSK_DEBUG_ERROR("No plugin at index %d", index);
  93. return tsk_plugin_def_type_none;
  94. }
  95. tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
  96. {
  97. switch(index) {
  98. #if PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE
  99. case PLUGIN_INDEX_RESAMPLER: {
  100. return tsk_plugin_def_media_type_audio;
  101. }
  102. #endif
  103. #if PLUGIN_AUDIO_DSP_DENOISER_ENABLE
  104. case PLUGIN_INDEX_DENOISER: {
  105. return tsk_plugin_def_media_type_audio;
  106. }
  107. #endif
  108. }
  109. TSK_DEBUG_ERROR("No plugin at index %d", index);
  110. return tsk_plugin_def_media_type_none;
  111. }
  112. tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
  113. {
  114. switch(index) {
  115. #if PLUGIN_AUDIO_DSP_RESAMPLER_ENABLE
  116. case PLUGIN_INDEX_RESAMPLER: {
  117. return plugin_audio_dsp_resampler_plugin_def_t;
  118. }
  119. #endif
  120. #if PLUGIN_AUDIO_DSP_DENOISER_ENABLE
  121. case PLUGIN_INDEX_DENOISER: {
  122. return plugin_audio_dsp_denoise_plugin_def_t;
  123. }
  124. #endif
  125. }
  126. TSK_DEBUG_ERROR("No plugin at index %d", index);
  127. return tsk_null;
  128. }