trtp_rtcp_report_fb.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  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 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 TINYRTP_RTCP_REPORT_FB_H
  23. #define TINYRTP_RTCP_REPORT_FB_H
  24. #include "tinyrtp_config.h"
  25. #include "tinyrtp/rtcp/trtp_rtcp_packet.h"
  26. #define TRTP_RTCP_REPORT_FB(self) ((trtp_rtcp_report_fb_t*)(self))
  27. #define TRTP_DECLARE_RTCP_FB_PACKET trtp_rtcp_report_fb_t __packet_fb__
  28. // RFC 4585 6.1. Common Packet Format for Feedback Messages
  29. typedef struct trtp_rtcp_report_fb_s {
  30. TRTP_DECLARE_RTCP_PACKET;
  31. uint32_t ssrc_sender; /* SSRC of packet sender */
  32. uint32_t ssrc_media; /* SSRC of media source */
  33. }
  34. trtp_rtcp_report_fb_t;
  35. typedef enum trtp_rtcp_rtpfb_fci_type_e {
  36. trtp_rtcp_rtpfb_fci_type_nack = 1, // RFC 4585
  37. trtp_rtcp_rtpfb_fci_type_tmmbn = 4, // RFC 5104
  38. }
  39. trtp_rtcp_rtpfb_fci_type_t;
  40. // Transport layer FB message
  41. typedef struct trtp_rtcp_report_rtpfb_s {
  42. TRTP_DECLARE_RTCP_FB_PACKET;
  43. trtp_rtcp_rtpfb_fci_type_t fci_type;
  44. union {
  45. struct {
  46. tsk_size_t count; // not part of the specification
  47. uint16_t* pid; // 16 bits
  48. uint16_t* blp; // 16 bits
  49. } nack;
  50. struct {
  51. tsk_size_t count; // not part of the specification
  52. uint32_t* ssrc; // 32 bits
  53. uint8_t* MxTBR_Exp; // 6 bits
  54. uint32_t* MxTBR_Mantissa; // 17 bits
  55. uint16_t* MeasuredOverhead; // 9 bits
  56. } tmmbn;
  57. };
  58. }
  59. trtp_rtcp_report_rtpfb_t;
  60. trtp_rtcp_report_rtpfb_t* trtp_rtcp_report_rtpfb_create_null();
  61. trtp_rtcp_report_rtpfb_t* trtp_rtcp_report_rtpfb_create(struct trtp_rtcp_header_s* header);
  62. trtp_rtcp_report_rtpfb_t* trtp_rtcp_report_rtpfb_create_2(trtp_rtcp_rtpfb_fci_type_t fci_type, uint32_t ssrc_sender, uint32_t ssrc_media_src);
  63. trtp_rtcp_report_rtpfb_t* trtp_rtcp_report_rtpfb_create_nack(uint32_t ssrc_sender, uint32_t ssrc_media_src, const uint16_t* seq_nums, tsk_size_t count);
  64. trtp_rtcp_report_rtpfb_t* trtp_rtcp_report_rtpfb_deserialize(const void* data, tsk_size_t size);
  65. int trtp_rtcp_report_rtpfb_serialize_to(const trtp_rtcp_report_rtpfb_t* self, void* data, tsk_size_t size);
  66. tsk_size_t trtp_rtcp_report_rtpfb_get_size(const trtp_rtcp_report_rtpfb_t* self);
  67. typedef enum trtp_rtcp_psfb_fci_type_e {
  68. trtp_rtcp_psfb_fci_type_pli = 1, /* rfc 4585: Picture Loss Indication (PLI) */
  69. trtp_rtcp_psfb_fci_type_sli = 2, /* rfc 4585: Slice Loss Indication (SLI) */
  70. trtp_rtcp_psfb_fci_type_rpsi = 3, /* rfc 4585: Reference Picture Selection Indication (RPSI) */
  71. trtp_rtcp_psfb_fci_type_fir = 4, /* rfc 5104: Full Intra Request (FIR) Command*/
  72. trtp_rtcp_psfb_fci_type_afb = 15, /* rfc 4585: Application layer FB (AFB) message */
  73. }
  74. trtp_rtcp_psfb_fci_type_t;
  75. /* rfc 4585: Application layer FB (AFB) message */
  76. typedef enum trtp_rtcp_psfb_afb_type_e {
  77. trtp_rtcp_psfb_afb_type_none,
  78. trtp_rtcp_psfb_afb_type_remb, // draft-alvestrand-rmcat-remb-02
  79. trtp_rtcp_psfb_afb_type_jcng, // doubango congestion control estimation
  80. }
  81. trtp_rtcp_psfb_afb_type_t;
  82. // Payload-specific FB message
  83. typedef struct trtp_rtcp_report_psfb_s {
  84. TRTP_DECLARE_RTCP_FB_PACKET;
  85. trtp_rtcp_psfb_fci_type_t fci_type;
  86. union {
  87. // struct{ //rfc 4585: 6.3.1.2
  88. // } pli;
  89. struct { // rfc 4585: 6.3.2.2
  90. uint16_t* first;
  91. uint16_t* number;
  92. uint8_t* pic_id;
  93. } sli;
  94. struct { // rfc 4585: 6.3.3.2
  95. unsigned pb:8;
  96. unsigned pt:7;
  97. uint8_t* bytes;
  98. } rpsi;
  99. struct { // rfc 5104: 4.3.1.1
  100. tsk_size_t count;
  101. uint32_t* ssrc; // 32 bits
  102. uint8_t* seq_num; // 8 bits
  103. } fir;
  104. struct { // rfc 4585: 6.4
  105. trtp_rtcp_psfb_afb_type_t type;
  106. union {
  107. struct { // draft-alvestrand-rmcat-remb-02: 2.2
  108. // MxTBR = mantissa * 2^exp = (mantissa << exp) bps
  109. uint8_t num_ssrc;
  110. uint8_t exp; // 6bits
  111. uint32_t mantissa; // 18bits
  112. uint32_t* ssrc_feedbacks; // 'num_ssrc'nth SSRC entries
  113. } remb;
  114. struct { // jitter buffer congestion estimation: doubango
  115. uint8_t num_ssrc;
  116. uint8_t q; // 8bits
  117. uint32_t* ssrc_feedbacks; // 'num_ssrc'nth SSRC entries
  118. } jcng;
  119. struct {
  120. uint8_t* bytes; // store bytes to allow reconstruction
  121. } none; // unknown type
  122. };
  123. } afb;
  124. };
  125. }
  126. trtp_rtcp_report_psfb_t;
  127. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_null();
  128. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create(struct trtp_rtcp_header_s* header);
  129. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_2(trtp_rtcp_psfb_fci_type_t fci_type, uint32_t ssrc_sender, uint32_t ssrc_media_src);
  130. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_pli(uint32_t ssrc_sender, uint32_t ssrc_media_src);
  131. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_fir(uint8_t seq_num, uint32_t ssrc_sender, uint32_t ssrc_media_src);
  132. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_afb_remb(uint32_t ssrc_sender, const uint32_t* ssrc_media_src_list, uint32_t ssrc_media_src_list_count, uint32_t bitrate/*in bps*/);
  133. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_create_afb_jcng(uint32_t ssrc_sender, const uint32_t* ssrc_media_src_list, uint32_t ssrc_media_src_list_count, float jcng_q/*in quality metric*/);
  134. trtp_rtcp_report_psfb_t* trtp_rtcp_report_psfb_deserialize(const void* data, tsk_size_t size);
  135. int trtp_rtcp_report_psfb_serialize_to(const trtp_rtcp_report_psfb_t* self, void* data, tsk_size_t size);
  136. tsk_size_t trtp_rtcp_report_psfb_get_size(const trtp_rtcp_report_psfb_t* self);
  137. #endif /* TINYRTP_RTCP_REPORT_FB_H */