ProxyPluginMgr.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  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. #ifndef TINYWRAP_PROXY_PLUGIN_MGR_H
  23. #define TINYWRAP_PROXY_PLUGIN_MGR_H
  24. #include "tinymedia.h"
  25. #include "Common.h"
  26. class ProxyPlugin;
  27. class ProxyConsumer;
  28. class ProxyAudioConsumer;
  29. class ProxyVideoConsumer;
  30. class ProxyAudioProducer;
  31. class ProxyVideoProducer;
  32. class ProxyPluginMgrCallback;
  33. typedef enum twrap_proxy_plugin_type_e {
  34. twrap_proxy_plugin_audio_producer,
  35. twrap_proxy_plugin_video_producer,
  36. twrap_proxy_plugin_audio_consumer,
  37. twrap_proxy_plugin_video_consumer,
  38. }
  39. twrap_proxy_plugin_type_t;
  40. /* ============ ProxyPluginMgr Class ================= */
  41. typedef tsk_list_t twrap_proxy_plungins_L_t; // contains "twrap_proxy_plungin_t" elements
  42. class ProxyPluginMgr
  43. {
  44. private:
  45. ProxyPluginMgr(ProxyPluginMgrCallback* callback);
  46. public:
  47. virtual ~ProxyPluginMgr();
  48. // SWIG %newobject
  49. static ProxyPluginMgr* createInstance(ProxyPluginMgrCallback* pCallback);
  50. #if !defined(SWIG)
  51. static void destroyInstance(ProxyPluginMgr** ppInstance);
  52. #endif
  53. static ProxyPluginMgr* getInstance();
  54. #if !defined(SWIG)
  55. static uint64_t getUniqueId();
  56. int addPlugin(ProxyPlugin**);
  57. const ProxyPlugin* findPlugin(tsk_object_t* wrapped_plugin);
  58. int removePlugin(uint64_t id);
  59. int removePlugin(ProxyPlugin**);
  60. inline ProxyPluginMgrCallback* getCallback() {
  61. return this->callback;
  62. }
  63. #endif
  64. const ProxyPlugin* findPlugin(uint64_t id);
  65. const ProxyAudioConsumer* findAudioConsumer(uint64_t id);
  66. const ProxyVideoConsumer* findVideoConsumer(uint64_t id);
  67. const ProxyAudioProducer* findAudioProducer(uint64_t id);
  68. const ProxyVideoProducer* findVideoProducer(uint64_t id);
  69. private:
  70. static ProxyPluginMgr* instance;
  71. ProxyPluginMgrCallback* callback;
  72. twrap_proxy_plungins_L_t* plugins;
  73. };
  74. /* ============ ProxyPluginMgrCallback Class ================= */
  75. class ProxyPluginMgrCallback
  76. {
  77. public:
  78. ProxyPluginMgrCallback() { }
  79. virtual ~ProxyPluginMgrCallback() { }
  80. virtual int OnPluginCreated(uint64_t id, enum twrap_proxy_plugin_type_e type) {
  81. return -1;
  82. }
  83. virtual int OnPluginDestroyed(uint64_t id, enum twrap_proxy_plugin_type_e type) {
  84. return -1;
  85. }
  86. };
  87. /* ============ ProxyPlugin Class ================= */
  88. class ProxyPlugin
  89. {
  90. public:
  91. #if !defined SWIG
  92. ProxyPlugin(twrap_proxy_plugin_type_t _type) {
  93. this->type=_type;
  94. this->id = ProxyPluginMgr::getUniqueId();
  95. }
  96. #endif
  97. virtual ~ProxyPlugin() {}
  98. #if !defined(SWIG)
  99. virtual bool operator ==(const ProxyPlugin &plugin)const {
  100. return this->getId() == plugin.getId();
  101. }
  102. virtual inline bool isWrapping(tsk_object_t* wrapped_plugin) = 0;
  103. virtual inline uint64_t getMediaSessionId() = 0;
  104. #endif
  105. inline twrap_proxy_plugin_type_t getType()const {
  106. return this->type;
  107. }
  108. inline uint64_t getId()const {
  109. return this->id;
  110. }
  111. protected:
  112. uint64_t id;
  113. twrap_proxy_plugin_type_t type;
  114. };
  115. #endif /* TINYWRAP_PROXY_PLUGIN_MGR_H */