tmedia_qos.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 tmedia_qos.h
  23. * @brief RFC 3312 (Preconditions) implementation.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. #ifndef TINYMEDIA_QOS_H
  29. #define TINYMEDIA_QOS_H
  30. #include "tinymedia_config.h"
  31. #include "tinysdp/tsdp_message.h"
  32. #include "tsk_object.h"
  33. TMEDIA_BEGIN_DECLS
  34. #define TMEDIA_QOS_TLINE(self) ((tmedia_qos_tline_t*)(self))
  35. /** List of all supported statues*/
  36. typedef enum tmedia_qos_status_e {
  37. //! current-status
  38. tmedia_qos_status_curr,
  39. //! desired-status
  40. tmedia_qos_status_des,
  41. //! confirm-status
  42. tmedia_qos_status_conf
  43. }
  44. tmedia_qos_status_t;
  45. /** List of all supported precondition types */
  46. typedef enum tmedia_qos_ptype_e {
  47. tmedia_qos_ptype_qos
  48. }
  49. tmedia_qos_ptype_t;
  50. /** List of all supported status types */
  51. typedef enum tmedia_qos_stype_e {
  52. tmedia_qos_stype_none,/* not part of the RFC */
  53. tmedia_qos_stype_segmented,
  54. tmedia_qos_stype_e2e,
  55. }
  56. tmedia_qos_stype_t;
  57. /** strengths */
  58. typedef enum tmedia_qos_strength_e {
  59. /* do no change the order (none -> optional -> manadatory) */
  60. tmedia_qos_strength_none,
  61. tmedia_qos_strength_failure,
  62. tmedia_qos_strength_unknown,
  63. tmedia_qos_strength_optional,
  64. tmedia_qos_strength_mandatory
  65. }
  66. tmedia_qos_strength_t;
  67. /** directions */
  68. typedef enum tmedia_qos_direction_e {
  69. tmedia_qos_direction_none = 0x01,
  70. tmedia_qos_direction_send = (0x01 << 1),
  71. tmedia_qos_direction_recv = (0x01 << 2),
  72. tmedia_qos_direction_sendrecv = (tmedia_qos_direction_send | tmedia_qos_direction_recv)
  73. }
  74. tmedia_qos_direction_t;
  75. /* QoS table-line */
  76. typedef struct tmedia_qos_tline_s {
  77. TSK_DECLARE_OBJECT;
  78. tmedia_qos_stype_t type;
  79. }
  80. tmedia_qos_tline_t;
  81. #define TMEDIA_DECLARE_QOS_TLINE tmedia_qos_tline_t __tline__
  82. TINYMEDIA_API tmedia_qos_tline_t* tmedia_qos_tline_create(tmedia_qos_stype_t type, tmedia_qos_strength_t strength);
  83. TINYMEDIA_API tmedia_qos_stype_t tmedia_qos_get_type(const tsdp_header_M_t* m);
  84. TINYMEDIA_API tmedia_qos_tline_t* tmedia_qos_tline_from_sdp(const tsdp_header_M_t* m);
  85. TINYMEDIA_API int tmedia_qos_tline_to_sdp(const tmedia_qos_tline_t* self, tsdp_header_M_t* m);
  86. TINYMEDIA_API int tmedia_qos_tline_set_ro(tmedia_qos_tline_t* self, const tmedia_qos_tline_t* ro);
  87. TINYMEDIA_API tsk_bool_t tmedia_qos_tline_canresume(const tmedia_qos_tline_t* self);
  88. /* QoS table-line for E2E type*/
  89. typedef struct tmedia_qos_tline_e2e_s {
  90. TMEDIA_DECLARE_QOS_TLINE;
  91. /* RFC 3312 - 5.1 Generating an offer
  92. Direction Current Desired Strength
  93. ____________________________________
  94. send no mandatory
  95. recv no mandatory
  96. */
  97. struct {
  98. unsigned current:1;
  99. unsigned confirm:1;
  100. tmedia_qos_strength_t strength;
  101. } send;
  102. struct {
  103. unsigned current:1;
  104. unsigned confirm:1;
  105. tmedia_qos_strength_t strength;
  106. } recv;
  107. }
  108. tmedia_qos_tline_e2e_t;
  109. TINYMEDIA_API tmedia_qos_tline_e2e_t* tmedia_qos_tline_e2e_create(tmedia_qos_strength_t strength);
  110. TINYMEDIA_API tmedia_qos_tline_e2e_t* tmedia_qos_tline_e2e_from_sdp(const tsdp_header_M_t* m);
  111. TINYMEDIA_API int tmedia_qos_tline_e2e_to_sdp(const tmedia_qos_tline_e2e_t* self, tsdp_header_M_t* m);
  112. TINYMEDIA_API int tmedia_qos_tline_e2e_set_ro(tmedia_qos_tline_e2e_t* self, const tmedia_qos_tline_e2e_t* ro);
  113. TINYMEDIA_API tsk_bool_t tmedia_qos_tline_e2e_canresume(const tmedia_qos_tline_e2e_t* self);
  114. /* QoS table-line for Segented type*/
  115. typedef struct tmedia_qos_tline_segmented_s {
  116. TMEDIA_DECLARE_QOS_TLINE;
  117. /* RFC 3312 - 5.1 Generating an offer
  118. Direction Current Desired Strength
  119. ______________________________________
  120. local send no none
  121. local recv no none
  122. remote send no optional
  123. remote recv no none
  124. */
  125. /* can be done in two lines but I prefer doing it like this (easier) */
  126. struct {
  127. unsigned current:1;
  128. unsigned confirm:1;
  129. tmedia_qos_strength_t strength;
  130. } local_send;
  131. struct {
  132. unsigned current:1;
  133. unsigned confirm:1;
  134. tmedia_qos_strength_t strength;
  135. } local_recv;
  136. struct {
  137. unsigned current:1;
  138. unsigned confirm:1;
  139. tmedia_qos_strength_t strength;
  140. } remote_send;
  141. struct {
  142. unsigned current:1;
  143. unsigned confirm:1;
  144. tmedia_qos_strength_t strength;
  145. } remote_recv;
  146. }
  147. tmedia_qos_tline_segmented_t;
  148. TINYMEDIA_API tmedia_qos_tline_segmented_t* tmedia_qos_tline_segmented_create(tmedia_qos_strength_t strength);
  149. TINYMEDIA_API tmedia_qos_tline_segmented_t* tmedia_qos_tline_segmented_from_sdp(const tsdp_header_M_t* m);
  150. TINYMEDIA_API int tmedia_qos_tline_segmented_to_sdp(const tmedia_qos_tline_segmented_t* self, tsdp_header_M_t* m);
  151. TINYMEDIA_API int tmedia_qos_tline_segmented_set_ro(tmedia_qos_tline_segmented_t* self, const tmedia_qos_tline_segmented_t* ro);
  152. TINYMEDIA_API tsk_bool_t tmedia_qos_tline_segmented_canresume(const tmedia_qos_tline_segmented_t* self);
  153. TINYMEDIA_GEXTERN const tsk_object_def_t *tmedia_qos_tline_segmented_def_t;
  154. TINYMEDIA_GEXTERN const tsk_object_def_t *tmedia_qos_tline_e2e_def_t;
  155. TMEDIA_END_DECLS
  156. #endif /* TINYMEDIA_QOS_H */