tsdp_header.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.h
  23. * @brief Defines a SDP header/line (<type>=<value>).
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. #ifndef TINYSDP_HEADER_H
  29. #define TINYSDP_HEADER_H
  30. #include "tinysdp_config.h"
  31. #include "tsk_ragel_state.h"
  32. #include "tsk_list.h"
  33. TSDP_BEGIN_DECLS
  34. struct tsdp_header_s;
  35. #define TSDP_HEADER(self) ((tsdp_header_t*)(self))
  36. #define TSDP_HEADER_CONST(self) ((const tsdp_header_t*)(self))
  37. #define TSDP_HEADER_VALUE_TOSTRING_F(self) ((tsdp_header_value_tostring_f)(self))
  38. typedef int (*tsdp_header_value_tostring_f)(const struct tsdp_header_s* header, tsk_buffer_t* output);
  39. typedef struct tsdp_header_s* (*tsdp_header_clone_f)(const struct tsdp_header_s* header);
  40. #define TSDP_HTYPE_V_RANK 0
  41. #define TSDP_HTYPE_O_RANK 1
  42. #define TSDP_HTYPE_S_RANK 2
  43. #define TSDP_HTYPE_I_RANK 3
  44. #define TSDP_HTYPE_U_RANK 4
  45. #define TSDP_HTYPE_E_RANK 5
  46. #define TSDP_HTYPE_P_RANK 6
  47. #define TSDP_HTYPE_C_RANK 7
  48. #define TSDP_HTYPE_B_RANK 8
  49. #define TSDP_HTYPE_Z_RANK 11
  50. #define TSDP_HTYPE_K_RANK 12
  51. #define TSDP_HTYPE_A_RANK 13
  52. #define TSDP_HTYPE_T_RANK 9
  53. #define TSDP_HTYPE_R_RANK 10
  54. #define TSDP_HTYPE_M_RANK 14
  55. //#define TSDP_HTYPE_I_RANK 15
  56. //#define TSDP_HTYPE_C_RANK 16
  57. //#define TSDP_HTYPE_B_RANK 17
  58. #define TSDP_HTYPE_DUMMY_RANK 255
  59. /**
  60. * @enum tsdp_header_type_e
  61. *
  62. * @brief List of all supported headers.
  63. **/
  64. typedef enum tsdp_header_type_e {
  65. tsdp_htype_A,
  66. tsdp_htype_B,
  67. tsdp_htype_C,
  68. tsdp_htype_Dummy,
  69. tsdp_htype_E,
  70. tsdp_htype_I,
  71. tsdp_htype_K,
  72. tsdp_htype_M,
  73. tsdp_htype_O,
  74. tsdp_htype_P,
  75. tsdp_htype_R,
  76. tsdp_htype_S,
  77. tsdp_htype_T,
  78. tsdp_htype_U,
  79. tsdp_htype_V,
  80. tsdp_htype_Z
  81. }
  82. tsdp_header_type_t;
  83. /*================================
  84. */
  85. typedef struct tsdp_header_s {
  86. TSK_DECLARE_OBJECT;
  87. tsdp_header_type_t type;
  88. //! Because all SDP headers shall appear in a fixed order, the rank is used to place each header.
  89. // Info: RFC 4566 - 5. SDP Specification.
  90. uint8_t rank;
  91. tsdp_header_value_tostring_f tostring;
  92. tsdp_header_clone_f clone;
  93. }
  94. tsdp_header_t;
  95. #define TSDP_DECLARE_HEADER tsdp_header_t __header__
  96. typedef tsk_list_t tsdp_headers_L_t; /**< List of @ref tsdp_header_t elements. */
  97. /*
  98. ================================*/
  99. int tsdp_header_rank_cmp(const tsdp_header_t*, const tsdp_header_t*);
  100. TINYSDP_API tsdp_header_t* tsdp_header_clone(const tsdp_header_t*);
  101. TINYSDP_API char tsdp_header_get_name(tsdp_header_type_t type);
  102. TINYSDP_API char tsdp_header_get_nameex(const tsdp_header_t *self);
  103. TINYSDP_API int tsdp_header_serialize(const tsdp_header_t *self, tsk_buffer_t *output);
  104. TINYSDP_API char* tsdp_header_tostring(const tsdp_header_t *self);
  105. TSDP_END_DECLS
  106. #endif /* TINYSDP_HEADER_H */