dummy.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
  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. #include "dummy.h"
  23. #include "tsk_string.h"
  24. #include "tsk_memory.h"
  25. #include "tsk_debug.h"
  26. int dummy_start(tmedia_t* self)
  27. {
  28. dummy_t *dummy = DUMMY(self);
  29. TSK_DEBUG_INFO("dummy_start");
  30. return 0;
  31. }
  32. int dummy_pause(tmedia_t* self)
  33. {
  34. dummy_t *dummy = DUMMY(self);
  35. TSK_DEBUG_INFO("dummy_pause");
  36. return 0;
  37. }
  38. int dummy_stop(tmedia_t* self)
  39. {
  40. dummy_t *dummy = DUMMY(self);
  41. TSK_DEBUG_INFO("dummy_stop");
  42. return 0;
  43. }
  44. const tsdp_header_M_t* dummy_get_local_offer(tmedia_t* self, va_list *app)
  45. {
  46. dummy_t *dummy = DUMMY(self);
  47. const tsk_object_def_t* objdef;
  48. tsdp_header_t* header;
  49. TSK_DEBUG_INFO("dummy_get_local_offer");
  50. while((objdef = va_arg(*app, const tsk_object_def_t*))) {
  51. header = tsk_object_new_2(objdef, app);
  52. TSK_OBJECT_SAFE_FREE(header);
  53. }
  54. return tsk_null;
  55. }
  56. const tsdp_header_M_t* dummy_get_negotiated_offer(tmedia_t* self)
  57. {
  58. dummy_t *dummy = DUMMY(self);
  59. TSK_DEBUG_INFO("dummy_get_negotiated_offer");
  60. return tsk_null;
  61. }
  62. int dummy_set_remote_offer(tmedia_t* self, const tsdp_message_t* offer)
  63. {
  64. dummy_t *dummy = DUMMY(self);
  65. TSK_DEBUG_INFO("dummy_set_remote_offer");
  66. return 0;
  67. }
  68. int dummy_perform(tmedia_t* self, tmedia_action_t action, const tsk_params_L_t* params)
  69. {
  70. dummy_t *dummy = DUMMY(self);
  71. switch(action) {
  72. case tma_dummy_say_hello: {
  73. TSK_DEBUG_INFO("dummy_perform (hello to \"%s\")", tsk_params_get_param_value(params, "to"));
  74. break;
  75. }
  76. }
  77. return 0;
  78. }
  79. //========================================================
  80. // Dummy media object definition
  81. //
  82. static void* dummy_create(tsk_object_t *self, va_list * app)
  83. {
  84. dummy_t *dummy = self;
  85. if(dummy) {
  86. // Parameters MUST appear in this order
  87. const char* name = va_arg(*app, const char*);
  88. const char* host = va_arg(*app, const char*);
  89. tnet_socket_type_t socket_type = va_arg(*app, tnet_socket_type_t);
  90. tmedia_init(TMEDIA(dummy), name);
  91. TMEDIA(dummy)->protocol = tsk_strdup("TCP/DUMMY");
  92. }
  93. else {
  94. TSK_DEBUG_ERROR("Failed to create new dummy media.");
  95. }
  96. return self;
  97. }
  98. static void* dummy_destroy(tsk_object_t *self)
  99. {
  100. dummy_t *dummy = self;
  101. if(dummy) {
  102. tmedia_deinit(TMEDIA(dummy));
  103. TSK_FREE(dummy->local_sdp);
  104. TSK_FREE(dummy->remote_sdp);
  105. TSK_FREE(dummy->negotiated_sdp);
  106. }
  107. else {
  108. TSK_DEBUG_ERROR("Null dummy media.");
  109. }
  110. return self;
  111. }
  112. static int dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
  113. {
  114. return -1;
  115. }
  116. static const tsk_object_def_t dummy_def_s = {
  117. sizeof(dummy_t),
  118. dummy_create,
  119. dummy_destroy,
  120. dummy_cmp
  121. };
  122. const tsk_object_def_t *dummy_def_t = &dummy_def_s;
  123. //========================================================
  124. // Dummy media plugin definition
  125. //
  126. static const tmedia_plugin_def_t dummy_plugin_def_s = {
  127. &dummy_def_s,
  128. "dummy plugin",
  129. "audio",
  130. dummy_start,
  131. dummy_pause,
  132. dummy_stop,
  133. dummy_get_local_offer,
  134. dummy_get_negotiated_offer,
  135. dummy_set_remote_offer,
  136. dummy_perform
  137. };
  138. const tmedia_plugin_def_t *dummy_plugin_def_t = &dummy_plugin_def_s;