test_sessions.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (C) 2009 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 Lesser 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 _TINYDEV_TEST_SESSIONS_H
  23. #define _TINYDEV_TEST_SESSIONS_H
  24. #include "tinymsrp.h"
  25. #define SDP_RO \
  26. "v=0\r\n" \
  27. "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" \
  28. "s=\r\n" \
  29. "i=A Seminar on the session description protocol\r\n" \
  30. "u=http://www.example.com/seminars/sdp.pdf\r\n" \
  31. "e=j.doe@example.com (Jane Doe)\r\n" \
  32. "p=+1 617 555-6011\r\n" \
  33. "c=IN IP4 192.168.0.13\r\n" \
  34. "b=X-YZ:128\r\n" \
  35. "z=2882844526 -1h 2898848070 0\r\n" \
  36. "k=base64:ZWFzdXJlLg==\r\n" \
  37. "t=3034423619 3042462419\r\n" \
  38. "r=7d 1h 0 25h\r\n" \
  39. "r=604800 3600 0 90000\r\n" \
  40. "w=my dummy header\r\n" \
  41. "m=audio 6061 RTP/AVP 18 0 115 97 96 3 102 103 8\r\n" \
  42. "i=Audio line\r\n" \
  43. "c=IN IP4 192.168.0.13\r\n" \
  44. "k=base64:ZWFzdXJlLgdddddddddddddddddddddd==\r\n" \
  45. "a=rtpmap:96 iLBC/8000\r\n" \
  46. "a=rtpmap:3 GSM/8000\r\n" \
  47. "a=rtpmap:8 PCMA/8000\r\n" \
  48. "a=rtpmap:0 PCMU/8000\r\n" \
  49. "a=rtpmap:103 AMR/8000\r\n" \
  50. "a=rtpmap:102 AMR/8000\r\n" \
  51. "a=rtpmap:97 SPEEX/8000\r\n" \
  52. "a=rtpmap:115 BV16/8000\r\n" \
  53. "a=fmtp:102 octet-align=0; mode-set=0,1,2,3,4,5,6,7; mode-change-period=1; mode-change-capability=2; mode-change-neighbor=0\r\n" \
  54. "a=fmtp:103 octet-align=1; mode-set=0,1,2,3,4,5,6,7; mode-change-period=1; mode-change-capability=2; mode-change-neighbor=0\r\n" \
  55. "m=video 6060 RTP/AVP 125 98 111 121 31 126 34 32\r\n" \
  56. "i=Video line\r\n" \
  57. "b=A-YZ:92\r\n" \
  58. "b=B-YZ:256\r\n" \
  59. "a=rtpmap:125 VP8/90000\r\n" \
  60. "a=fmtp:125 QCIF=2;CIF=2 MaxBR=4520\r\n" \
  61. "a=rtpmap:121 MP4V-ES/90000\r\n" \
  62. "a=fmtp:121 profile-level-id=1\r\n" \
  63. "a=rtpmap:126 theora/90000\r\n" \
  64. "a=rtpmap:34 H263/90000\r\n" \
  65. "a=fmtp:34 QCIF=1 MaxBR=4520\r\n" \
  66. "a=rtpmap:111 H263-1998/90000\r\n" \
  67. "a=rtpmap:31 H261/90000\r\n" \
  68. "a=rtpmap:32 MPV/90000\r\n" \
  69. "a=rtpmap:98 H264/90000\r\n" \
  70. "a=fmtp:98 profile-level-id=42e01e; packetization-mode=1; max-br=452; max-mbps=11880\r\n" \
  71. "a=recvonly\r\n" \
  72. "m=toto 51372 RTP/AVP 31 32\r\n" \
  73. "i=Video line\r\n" \
  74. "b=A-YZ:92\r\n" \
  75. "b=B-YZ:256\r\n" \
  76. "a=rtpmap:31 H261/90000\r\n" \
  77. "a=rtpmap:32 MPV/90000\r\n" \
  78. "a=recvonly\r\n" \
  79. "m=message 2000 TCP/MSRP *\r\n" \
  80. "c=IN IP4 192.168.0.14\r\n" \
  81. "a=path:msrp://192.168.0.12:2000/fdxfircvscx;tcp\r\n" \
  82. "a=accept-types:message/CPIM\r\n" \
  83. "a=setup:passive\r\n" \
  84. "a=file-transfer-id:wcysyycqpevikeffmznimkkasvwsrenz\r\n" \
  85. "a=file-selector:name:\"test.zip\" type:application/octet-stream size:11376 hash:sha-1:8D:55:24:2B:F4:F9:9B:A2:54:A3:5B:91:00:15:9E:A3:D4:48:D7:DF\r\n" \
  86. static int test_session_msrp_cb(const tmsrp_event_t* _event);
  87. void test_sessions_client()
  88. {
  89. tmedia_session_mgr_t* mgr;
  90. const tsdp_message_t* sdp_lo;
  91. tsdp_message_t* sdp_ro;
  92. char* temp;
  93. tmedia_type_t type = tmedia_video/*tmedia_msrp | tmedia_audio*//*| tmedia_video tmedia_msrp*/;
  94. tdav_codec_set_priority(tdav_codec_id_vp8, 0);
  95. mgr = tmedia_session_mgr_create(type,
  96. "192.168.0.13", tsk_false, tsk_true/* offerer */);
  97. /* set MSRP callback */
  98. //tmedia_session_mgr_set_msrp_cb(mgr, tsk_null, test_session_msrp_cb);
  99. /* MSRP File Transfer */
  100. /*tmedia_session_mgr_set(mgr,
  101. TMEDIA_SESSION_MSRP_SET_STR("file-path", "C:\\avatar.png"),
  102. TMEDIA_SESSION_MSRP_SET_STR("accept-types", "message/CPIM application/octet-stream"),
  103. TMEDIA_SESSION_MSRP_SET_STR("accept-wrapped-types", "application/octet-stream"),
  104. TMEDIA_SESSION_MSRP_SET_STR("accept-wrapped-types", "application/octet-stream"),
  105. TMEDIA_SESSION_MSRP_SET_STR("file-selector", "name:\"test.zip\" type:application/octet-stream size:20312 hash:sha-1:27:D0:AE:39:48:77:37:1D:FD:39:7E:2D:78:2F:BC:7B:94:48:29:81"),
  106. TMEDIA_SESSION_MSRP_SET_STR("file-disposition", "attachment"),
  107. TMEDIA_SESSION_MSRP_SET_STR("file-date", "creation:2010-02-13T17:50:31.763Z"),
  108. TMEDIA_SESSION_MSRP_SET_STR("file-icon", "cid:test@doubango.org"),
  109. TMEDIA_SESSION_SET_NULL());*/
  110. /* get lo */
  111. sdp_lo = tmedia_session_mgr_get_lo(mgr);
  112. if((temp = tsdp_message_tostring(sdp_lo))) {
  113. TSK_DEBUG_INFO("sdp_lo=%s", temp);
  114. TSK_FREE(temp);
  115. }
  116. /* set ro */
  117. if((sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))) {
  118. tmedia_session_mgr_set_ro(mgr, sdp_ro);
  119. TSK_OBJECT_SAFE_FREE(sdp_ro);
  120. }
  121. /* start() */
  122. tmedia_session_mgr_start(mgr);
  123. /* send file */
  124. //tmedia_session_mgr_send_file(mgr, "C:\\avatar.png", TMEDIA_SESSION_SET_NULL());
  125. //getchar();
  126. /* for fun, send DTMF */
  127. //tmedia_session_mgr_send_dtmf(mgr, 1);
  128. //tmedia_session_mgr_send_dtmf(mgr, 10);
  129. //tmedia_session_mgr_send_dtmf(mgr, 11);
  130. getchar();
  131. /* stop() */
  132. //tmedia_session_mgr_stop(mgr);
  133. //getchar();
  134. TSK_OBJECT_SAFE_FREE(mgr);
  135. }
  136. void test_sessions_server()
  137. {
  138. tmedia_session_mgr_t* mgr;
  139. const tsdp_message_t* sdp_lo;
  140. tsdp_message_t* sdp_ro;
  141. char* temp;
  142. tmedia_type_t type;
  143. /* get ro (INVITE) */
  144. if((sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))) {
  145. //type = tmedia_type_from_sdp(sdp_ro);
  146. type = tmedia_video;
  147. mgr = tmedia_session_mgr_create(type,
  148. "192.168.0.13", tsk_false, tsk_false/* answerer */);
  149. tmedia_session_mgr_set_ro(mgr, sdp_ro);
  150. TSK_OBJECT_SAFE_FREE(sdp_ro);
  151. }
  152. else {
  153. TSK_DEBUG_ERROR("Failed to deserialize remote sdp");
  154. return;
  155. }
  156. /* get lo (200 OK) */
  157. sdp_lo = tmedia_session_mgr_get_lo(mgr);
  158. if((temp = tsdp_message_tostring(sdp_lo))) {
  159. TSK_DEBUG_INFO("sdp_lo=%s", temp);
  160. TSK_FREE(temp);
  161. }
  162. /* ACK */
  163. /* start() */
  164. tmedia_session_mgr_start(mgr);
  165. getchar();
  166. /* stop() */
  167. //tmedia_session_mgr_stop(mgr);
  168. //getchar();
  169. TSK_OBJECT_SAFE_FREE(mgr);
  170. }
  171. void test_sessions()
  172. {
  173. test_sessions_client();
  174. //test_sessions_server();
  175. }
  176. int test_session_msrp_cb(const tmsrp_event_t* _event)
  177. {
  178. if(TMSRP_MESSAGE_IS_REQUEST(_event->message)) {
  179. TSK_DEBUG_INFO("Received MSRP request");
  180. }
  181. else {
  182. TSK_DEBUG_INFO("Received MSRP response");
  183. }
  184. return 0;
  185. }
  186. #endif /* _TINYDEV_TEST_SESSIONS_H */