test_soa.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. * Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  4. *
  5. * This file is part of Open Source Doubango Framework.
  6. *
  7. * DOUBANGO is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * DOUBANGO is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with DOUBANGO.
  19. *
  20. */
  21. #ifndef _TEST_SOA_H
  22. #define _TEST_SOA_H
  23. #define SDP \
  24. "v=0\r\n" \
  25. "o=carol 28908764872 28908764872 IN IP4 100.3.6.6\r\n" \
  26. "s=-\r\n" \
  27. "t=0 0\r\n" \
  28. "c=IN IP4 192.0.2.4\r\n" \
  29. "m=video 0 RTP/AVP 31 34\r\n" \
  30. "a=rtpmap:31 H261/90000\r\n" \
  31. "a=rtpmap:34 H263/90000\r\n"
  32. void test_create_sdp()
  33. {
  34. tsdp_ctx_handle_t* ctx = TSDP_CTX_CREATE();
  35. const tsdp_message_t* sdp;
  36. char* str;
  37. // Create local SDP from string
  38. tsdp_ctx_local_create_sdp_2(ctx, SDP, strlen(SDP));
  39. if((sdp = tsdp_ctx_local_get_sdp(ctx))) {
  40. if((str = tsdp_message_tostring(sdp))) {
  41. TSK_DEBUG_INFO("Local SDP (2)=\n%s", str);
  42. TSK_FREE(str);
  43. }
  44. }
  45. // Create local SDP from object
  46. tsdp_ctx_local_create_sdp(ctx, sdp);
  47. if((sdp = tsdp_ctx_local_get_sdp(ctx))) {
  48. if((str = tsdp_message_tostring(sdp))) {
  49. TSK_DEBUG_INFO("Local SDP (1)=\n%s", str);
  50. TSK_FREE(str);
  51. }
  52. }
  53. // Add media to the local sdp
  54. tsdp_ctx_local_add_media_2(ctx, "audio", 0, "RTP/AVP",
  55. TSDP_HEADER_I_VA_ARGS("this is the (audio)information line"),
  56. // PCMU
  57. TSDP_FMT_VA_ARGS("0"),
  58. TSDP_HEADER_A_VA_ARGS("rtpmap", "0 PCMU/8000"),
  59. // 1016
  60. TSDP_FMT_VA_ARGS("1"),
  61. TSDP_HEADER_A_VA_ARGS("rtpmap", "1 1016/8000"),
  62. // GSM
  63. TSDP_FMT_VA_ARGS("3"),
  64. TSDP_HEADER_A_VA_ARGS("rtpmap", "3 GSM/8000"),
  65. tsk_null);
  66. if((str = tsdp_message_tostring(sdp))) {
  67. TSK_DEBUG_INFO("Local SDP (audio)=\n%s", str);
  68. TSK_FREE(str);
  69. }
  70. // Add headers to the local sdp
  71. tsdp_ctx_local_add_headers(ctx,
  72. TSDP_HEADER_E_VA_ARGS("j.doe@example.com (Jane Doe)"),
  73. TSDP_HEADER_P_VA_ARGS("+44 (123)456789"),
  74. tsk_null);
  75. if((str = tsdp_message_tostring(sdp))) {
  76. TSK_DEBUG_INFO("Local SDP (headers)=\n%s", str);
  77. TSK_FREE(str);
  78. }
  79. TSK_OBJECT_SAFE_FREE(ctx);
  80. }
  81. void test_soa()
  82. {
  83. test_create_sdp();
  84. }
  85. #endif /* _TEST_SOA_H */