tsdp_header_M.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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. /**@file tsdp_header_M.h
  23. * @brief SDP "m=" header (Media Descriptions).
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. *
  28. */
  29. #ifndef _TSDP_HEADER_M_H_
  30. #define _TSDP_HEADER_M_H_
  31. #include "tinysdp_config.h"
  32. #include "tinysdp/headers/tsdp_header.h"
  33. #include "tinysdp/headers/tsdp_header_A.h"
  34. #include "tinysdp/headers/tsdp_header_B.h"
  35. #include "tinysdp/headers/tsdp_header_C.h"
  36. #include "tinysdp/headers/tsdp_header_I.h"
  37. #include "tinysdp/headers/tsdp_header_K.h"
  38. #include "tsk_string.h"
  39. TSDP_BEGIN_DECLS
  40. #define TSDP_HEADER_M_VA_ARGS(media, port, proto) tsdp_header_M_def_t, (const char*)media, (uint32_t)port, (const char*)proto
  41. #define TSDP_HEADER_M(self) ((tsdp_header_M_t*)(self))
  42. #define TSDP_FMT_VA_ARGS(fmt) tsdp_fmt_def_t, (const char*)fmt
  43. typedef tsk_string_t tsdp_fmt_t;
  44. typedef tsk_strings_L_t tsk_fmts_L_t;
  45. #define tsdp_fmt_def_t tsk_string_def_t
  46. #define TSDP_FMT_STR(self) TSK_STRING_STR(self)
  47. TINYSDP_API tsdp_fmt_t* tsdp_fmt_create(const char* fmt);
  48. //#define TSDP_HEADER_M_SET_FMT(fmt) (int)0x01, (const char*)fmt
  49. //#define TSDP_HEADER_M_SET_A(field, value) (int)0x02, (const char*)field, (const char*)value
  50. //#define TSDP_HEADER_M_SET_NULL() (int)0x00
  51. ////////////////////////////////////////////////////////////////////////////////////////////////////
  52. /// @struct
  53. ///
  54. /// @brief SDP "m=" header (Media Descriptions).
  55. ///
  56. /// @par ABNF : m=*(media-field
  57. /// information-field
  58. /// *connection-field
  59. /// bandwidth-fields
  60. /// key-field
  61. /// attribute-fields)
  62. ///
  63. /// media-field = %x6d "=" media SP port ["/" integer] SP proto 1*(SP fmt) CRLF
  64. /// media = token
  65. /// port = 1*DIGIT
  66. /// proto = token *("/" token)
  67. /// fmt = token
  68. ///
  69. ////////////////////////////////////////////////////////////////////////////////////////////////////
  70. typedef struct tsdp_header_M_s {
  71. TSDP_DECLARE_HEADER;
  72. char* media;
  73. uint32_t port;
  74. uint32_t nports; /**< <number of ports> */
  75. char* proto;
  76. tsk_fmts_L_t* FMTs;
  77. // Fields below will be set by the message parser.
  78. tsdp_header_I_t* I;
  79. tsdp_header_C_t* C;
  80. tsdp_headers_B_L_t* Bandwidths; // (zero or more bandwidth information lines)
  81. tsdp_header_K_t* K; // (encryption key)
  82. tsdp_headers_A_L_t* Attributes; // (zero or more media attribute lines)
  83. }
  84. tsdp_header_M_t;
  85. typedef enum tsdp_header_M_diff_e {
  86. tsdp_header_M_diff_none = 0x0000000,
  87. tsdp_header_M_diff_hold_resume = (0x0000001 << 0),
  88. tsdp_header_M_diff_index = (0x0000001 << 1),
  89. tsdp_header_M_diff_codecs = (0x0000001 << 2),
  90. tsdp_header_M_diff_network_info = (0x0000001 << 3),
  91. tsdp_header_M_diff_ice_enabled = (0x0000001 << 4),
  92. tsdp_header_M_diff_ice_restart = (0x0000001 << 5),
  93. tsdp_header_M_diff_dtls_fingerprint = (0x0000001 << 6),
  94. tsdp_header_M_diff_sdes_crypto = (0x0000001 << 7),
  95. tsdp_header_M_diff_media_type = (0x0000001 << 8),
  96. tsdp_header_M_diff_all = 0xFFFFFFFF
  97. }
  98. tsdp_header_M_diff_t;
  99. typedef tsk_list_t tsdp_headers_M_L_t;
  100. TINYSDP_API tsdp_header_M_t* tsdp_header_M_create(const char* media, uint32_t port, const char* proto);
  101. TINYSDP_API tsdp_header_M_t* tsdp_header_M_create_null();
  102. TINYSDP_API tsdp_header_M_t *tsdp_header_M_parse(const char *data, tsk_size_t size);
  103. TINYSDP_API int tsdp_header_M_remove(tsdp_header_M_t* self, tsdp_header_type_t type);
  104. TINYSDP_API int tsdp_header_M_add(tsdp_header_M_t* self, const tsdp_header_t* header);
  105. TINYSDP_API int tsdp_header_M_add_headers(tsdp_header_M_t* self, ...);
  106. TINYSDP_API int tsdp_header_M_add_headers_2(tsdp_header_M_t* self, const tsdp_headers_L_t* headers);
  107. TINYSDP_API int tsdp_header_M_add_fmt(tsdp_header_M_t* self, const char* fmt);
  108. TINYSDP_API int tsdp_header_M_remove_fmt(tsdp_header_M_t* self, const char* fmt);
  109. TINYSDP_API tsk_bool_t tsdp_header_M_have_fmt(const tsdp_header_M_t* self, const char* fmt);
  110. TINYSDP_API const tsdp_header_A_t* tsdp_header_M_findA_at(const tsdp_header_M_t* self, const char* field, tsk_size_t index);
  111. TINYSDP_API const tsdp_header_A_t* tsdp_header_M_findA(const tsdp_header_M_t* self, const char* field);
  112. TINYSDP_API char* tsdp_header_M_getAValue(const tsdp_header_M_t* self, const char* field, const char* fmt);
  113. #define tsdp_header_M_get_rtpmap(self, fmt) tsdp_header_M_getAValue((self), "rtpmap", (fmt))
  114. #define tsdp_header_M_get_fmtp(self, fmt) tsdp_header_M_getAValue((self), "fmtp", (fmt))
  115. #define tsdp_header_M_get_imageattr(self, fmt) tsdp_header_M_getAValue((self), "imageattr", (fmt))
  116. TINYSDP_API int tsdp_header_M_hold(tsdp_header_M_t* self, tsk_bool_t local);
  117. TINYSDP_API tsk_bool_t tsdp_header_M_is_held(const tsdp_header_M_t* self, tsk_bool_t local);
  118. TINYSDP_API int tsdp_header_M_set_holdresume_att(tsdp_header_M_t* self, tsk_bool_t lo_held, tsk_bool_t ro_held);
  119. TINYSDP_API const char* tsdp_header_M_get_holdresume_att(const tsdp_header_M_t* self);
  120. TINYSDP_API int tsdp_header_M_resume(tsdp_header_M_t* self, tsk_bool_t local);
  121. TINYSDP_API tsk_bool_t tsdp_header_M_is_ice_enabled(const tsdp_header_M_t* self);
  122. TINYSDP_API tsk_bool_t tsdp_header_M_is_ice_restart(const tsdp_header_M_t* self);
  123. TINYSDP_API int tsdp_header_M_diff(const tsdp_header_M_t* M_old, const tsdp_header_M_t* M_new, tsdp_header_M_diff_t* diff);
  124. TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_M_def_t;
  125. TSDP_END_DECLS
  126. #endif /* _TSDP_HEADER_M_H_ */