dllmain_dshow.cxx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Copyright (C) 2011-2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "plugin_dshow_config.h"
  19. #include "tinymedia/tmedia_producer.h"
  20. #include "tinymedia/tmedia_consumer.h"
  21. #include "tsk_plugin.h"
  22. #include "tsk_debug.h"
  23. #include "internals/DSUtils.h"
  24. #include <streams.h>
  25. #if !defined(ENABLE_SCREENCAST)
  26. # define ENABLE_SCREENCAST 0
  27. #endif /* ENABLE_SCREENCAST */
  28. PLUGIN_DSHOW_BEGIN_DECLS /* BEGIN */
  29. PLUGIN_DSHOW_API int __plugin_get_def_count();
  30. PLUGIN_DSHOW_API tsk_plugin_def_type_t __plugin_get_def_type_at(int index);
  31. PLUGIN_DSHOW_API tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index);
  32. PLUGIN_DSHOW_API tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index);
  33. PLUGIN_DSHOW_END_DECLS /* END */
  34. extern const tmedia_consumer_plugin_def_t *plugin_video_dshow_consumer_plugin_def_t;
  35. extern const tmedia_producer_plugin_def_t *plugin_video_dshow_producer_plugin_def_t;
  36. extern const tmedia_producer_plugin_def_t *plugin_screencast_dshow_producer_plugin_def_t;
  37. CFactoryTemplate g_Templates[]= {
  38. {
  39. L""
  40. , NULL
  41. , NULL
  42. , NULL
  43. , NULL
  44. }
  45. };
  46. int g_cTemplates = sizeof(g_Templates)/sizeof(g_Templates[0]);
  47. #if !defined(_WIN32_WCE)
  48. BOOL APIENTRY DllMain( HMODULE hModule,
  49. DWORD ul_reason_for_call,
  50. LPVOID lpReserved
  51. )
  52. {
  53. switch (ul_reason_for_call) {
  54. case DLL_PROCESS_ATTACH:
  55. case DLL_THREAD_ATTACH:
  56. case DLL_THREAD_DETACH:
  57. case DLL_PROCESS_DETACH:
  58. break;
  59. }
  60. return TRUE;
  61. }
  62. #endif
  63. typedef enum PLUGIN_INDEX_E {
  64. PLUGIN_INDEX_VIDEO_CONSUMER,
  65. PLUGIN_INDEX_VIDEO_PRODUCER,
  66. #if 0
  67. PLUGIN_INDEX_SCREENCAST_PRODUCER,
  68. #endif
  69. PLUGIN_INDEX_COUNT
  70. }
  71. PLUGIN_INDEX_T;
  72. int __plugin_get_def_count()
  73. {
  74. return PLUGIN_INDEX_COUNT;
  75. }
  76. tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
  77. {
  78. switch(index) {
  79. case PLUGIN_INDEX_VIDEO_CONSUMER:
  80. return IsD3D9Supported() ? tsk_plugin_def_type_consumer : tsk_plugin_def_type_none;
  81. case PLUGIN_INDEX_VIDEO_PRODUCER:
  82. #if ENABLE_SCREENCAST
  83. case PLUGIN_INDEX_SCREENCAST_PRODUCER:
  84. #endif
  85. return tsk_plugin_def_type_producer;
  86. default: {
  87. TSK_DEBUG_ERROR("No plugin at index %d", index);
  88. return tsk_plugin_def_type_none;
  89. }
  90. }
  91. }
  92. tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
  93. {
  94. switch(index) {
  95. case PLUGIN_INDEX_VIDEO_CONSUMER: {
  96. return IsD3D9Supported() ? tsk_plugin_def_media_type_video : tsk_plugin_def_media_type_none;
  97. }
  98. case PLUGIN_INDEX_VIDEO_PRODUCER: {
  99. return tsk_plugin_def_media_type_video;
  100. }
  101. #if ENABLE_SCREENCAST
  102. case PLUGIN_INDEX_SCREENCAST_PRODUCER: {
  103. return tsk_plugin_def_media_type_screencast;
  104. }
  105. #endif
  106. default: {
  107. TSK_DEBUG_ERROR("No plugin at index %d", index);
  108. return tsk_plugin_def_media_type_none;
  109. }
  110. }
  111. }
  112. tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
  113. {
  114. switch(index) {
  115. case PLUGIN_INDEX_VIDEO_CONSUMER: {
  116. return IsD3D9Supported() ? plugin_video_dshow_consumer_plugin_def_t : tsk_null;
  117. }
  118. case PLUGIN_INDEX_VIDEO_PRODUCER: {
  119. return plugin_video_dshow_producer_plugin_def_t;
  120. }
  121. #if ENABLE_SCREENCAST
  122. case PLUGIN_INDEX_SCREENCAST_PRODUCER: {
  123. return plugin_screencast_dshow_producer_plugin_def_t;
  124. }
  125. #endif
  126. default: {
  127. TSK_DEBUG_ERROR("No plugin at index %d", index);
  128. return tsk_null;
  129. }
  130. }
  131. }