dllmain_wasapi.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_wasapi_config.h"
  20. #include "tinymedia/tmedia_producer.h"
  21. #include "tinymedia/tmedia_consumer.h"
  22. #include "tsk_plugin.h"
  23. #include "tsk_debug.h"
  24. #include <windows.h>
  25. #if defined(_MSC_VER)
  26. #endif
  27. #if !defined(PLUGIN_WASAPI_ENABLE)
  28. # define PLUGIN_WASAPI_ENABLE 1
  29. #endif
  30. extern const tmedia_producer_plugin_def_t *plugin_wasapi_producer_audio_plugin_def_t;
  31. extern const tmedia_consumer_plugin_def_t *plugin_wasapi_consumer_audio_plugin_def_t;
  32. PLUGIN_WASAPI_BEGIN_DECLS /* BEGIN */
  33. PLUGIN_WASAPI_API int __plugin_get_def_count();
  34. PLUGIN_WASAPI_API tsk_plugin_def_type_t __plugin_get_def_type_at(int index);
  35. PLUGIN_WASAPI_API tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index);
  36. PLUGIN_WASAPI_API tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index);
  37. PLUGIN_WASAPI_END_DECLS /* END */
  38. BOOL APIENTRY DllMain( HMODULE hModule,
  39. DWORD ul_reason_for_call,
  40. LPVOID lpReserved
  41. )
  42. {
  43. switch (ul_reason_for_call) {
  44. case DLL_PROCESS_ATTACH:
  45. break;
  46. case DLL_THREAD_ATTACH:
  47. break;
  48. case DLL_THREAD_DETACH:
  49. break;
  50. case DLL_PROCESS_DETACH:
  51. break;
  52. }
  53. return TRUE;
  54. }
  55. typedef enum PLUGIN_INDEX_E {
  56. #if PLUGIN_WASAPI_ENABLE
  57. PLUGIN_INDEX_CONSUMER,
  58. PLUGIN_INDEX_PRODUCER,
  59. #endif
  60. PLUGIN_INDEX_COUNT
  61. }
  62. PLUGIN_INDEX_T;
  63. int __plugin_get_def_count()
  64. {
  65. return PLUGIN_INDEX_COUNT;
  66. }
  67. tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
  68. {
  69. #if PLUGIN_WASAPI_ENABLE
  70. switch(index) {
  71. case PLUGIN_INDEX_CONSUMER: {
  72. return tsk_plugin_def_type_consumer;
  73. }
  74. case PLUGIN_INDEX_PRODUCER: {
  75. return tsk_plugin_def_type_producer;
  76. }
  77. }
  78. #endif
  79. TSK_DEBUG_ERROR("No plugin at index %d", index);
  80. return tsk_plugin_def_type_none;
  81. }
  82. tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
  83. {
  84. #if PLUGIN_WASAPI_ENABLE
  85. switch(index) {
  86. case PLUGIN_INDEX_CONSUMER:
  87. case PLUGIN_INDEX_PRODUCER: {
  88. return tsk_plugin_def_media_type_audio;
  89. }
  90. }
  91. #endif
  92. TSK_DEBUG_ERROR("No plugin at index %d", index);
  93. return tsk_plugin_def_media_type_none;
  94. }
  95. tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
  96. {
  97. #if PLUGIN_WASAPI_ENABLE
  98. switch(index) {
  99. case PLUGIN_INDEX_CONSUMER: {
  100. return plugin_wasapi_consumer_audio_plugin_def_t;
  101. }
  102. case PLUGIN_INDEX_PRODUCER: {
  103. return plugin_wasapi_producer_audio_plugin_def_t;
  104. }
  105. }
  106. #endif
  107. TSK_DEBUG_ERROR("No plugin at index %d", index);
  108. return tsk_null;
  109. }