You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 10 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #ifndef _sdp_a_webrtc_h_
  2. #define _sdp_a_webrtc_h_
  3. #include <inttypes.h>
  4. #include <stdint.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define ICE_UFRAG_LEN 255
  9. #define ICE_PASSWORD_LEN 255
  10. #define RTP_PORT_INACTIVE 0 // inactive
  11. #define RTP_PORT_UNDEFINED 9 // port by ice candidate
  12. // https://www.rfc-editor.org/rfc/rfc8888.html#name-sdp-signaling
  13. // a=rtcp-fb:* ack ccfb
  14. // a=ecn-capable-rtp:
  15. #define RTCP_FEEDBACK_ACK "ack" // https://datatracker.ietf.org/doc/html/rfc4585#section-9
  16. #define RTCP_FEEDBACK_NACK "nack" // https://datatracker.ietf.org/doc/html/rfc4585#section-9
  17. #define RTCP_FEEDBACK_CCM "ccm" // https://www.rfc-editor.org/rfc/rfc5104.html#section-8
  18. // a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
  19. #define RTCP_FEEDBACK_TCC "transport-cc" // https://datatracker.ietf.org/doc/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#section-5
  20. // a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
  21. #define RTCP_FEEDBACK_REMB "goog-remb" // https://datatracker.ietf.org/doc/html/draft-alvestrand-rmcat-remb-03#section-3
  22. #define RTCP_FEEDBACK_ACK_RPSI "rpsi"
  23. #define RTCP_FEEDBACK_ACK_CCFB "ccfb"
  24. #define RTCP_FEEDBACK_NACK_PLI "pli"
  25. #define RTCP_FEEDBACK_NACK_SLI "sli"
  26. #define RTCP_FEEDBACK_NACK_RPSI "rpsi"
  27. #define RTCP_FEEDBACK_CCM_FIR "fir"
  28. #define RTCP_FEEDBACK_CCM_TMMBR "tmmbr"
  29. #define RTCP_FEEDBACK_CCM_VBCM "vbcm"
  30. #define RTCP_FEEDBACK_CCM_TSTR "tstr"
  31. enum OPTIONAL_BOOL { OPTIONAL_BOOL_UNSET = -1, OPTIONAL_BOOL_FALSE = 0, OPTIONAL_BOOL_TRUE = 1, };
  32. // sdp c: connection, address: unicast-source address, mulitcast-multicast address(RFC4566 4.1. Media and Transport Information)
  33. struct sdp_address_t
  34. {
  35. char network[16]; // IN
  36. char addrtype[16]; // IP4/IP6
  37. char address[64]; // ip or dns
  38. char source[64]; // multicast address
  39. int port[2]; // rtcp-mux: port[0] == port[1]
  40. };
  41. // RFC4585 Extended RTP Profile for Real-time Transport Control Protocol (RTCP)-Based Feedback (RTP/AVPF)
  42. // RFC5104 Codec Control Messages in the RTP Audio-Visual Profile with Feedback (AVPF)
  43. struct sdp_rtcp_fb_t
  44. {
  45. int fmt; // payload id, -1 for all(-1 ==> * / all)
  46. char feedback[16]; // ack/nack/ccm
  47. char param[64]; // ack:rpsi,app; nack: pli,sli,rpsi,app; ccm: fir,tmmbr,tstr,vbcm
  48. int trr_int;
  49. };
  50. // RFC3611 RTP Control Protocol Extended Reports (RTCP XR)
  51. struct sdp_rtcp_xr_t
  52. {
  53. int loss; // pkt-loss-rle
  54. int dup; // pkt-dup-rle
  55. int rcpt_times; // pkt-rcpt-times
  56. int rcvr_rtt;
  57. int rcvr_rtt_mode; // 0-sender, 1-all
  58. int stat_summary; // 0x01-loss, 0x02-dup, 0x04-jitt, 0x08-TTL
  59. int voip_metrics;
  60. };
  61. // https://tools.ietf.org/html/draft-ietf-mmusic-ice-sip-sdp-39
  62. // https://www.tech-invite.com/fo-abnf/tinv-fo-abnf-sdpatt-rfc5245.html
  63. // a=candidate:3 1 UDP 1862270847 10.95.49.227 63259 typ prflx raddr 192.168.137.93 rport 7078
  64. struct sdp_ice_candidate_t
  65. {
  66. char foundation[33];
  67. char transport[8]; // UDP
  68. char candtype[8];
  69. uint16_t component; // rtp/rtcp component id, [1, 256]
  70. uint16_t port;
  71. uint32_t priority; // [1, 2**31 - 1]
  72. char address[65];
  73. char** extensions; // include raddr/rport/generation
  74. int nextension;
  75. // extersions
  76. char reladdr[65];
  77. uint16_t relport;
  78. int generation; // google webrtc externsion
  79. };
  80. struct sdp_simulcast_t
  81. {
  82. char** sends;
  83. char** recvs;
  84. int nsend;
  85. int nrecv;
  86. };
  87. struct sdp_ssrc_group_t
  88. {
  89. char key[64];
  90. char** values;
  91. int count;
  92. };
  93. struct sdp_rid_t
  94. {
  95. char rid[65];
  96. char direction[8];
  97. // rid-pt-param-list
  98. char** payloads;
  99. int npayload;
  100. int width; // max-width
  101. int height; // max-height
  102. int fps; // max-fps
  103. int fs; // max-fs
  104. int br; // max-br
  105. int pps; // max-pps
  106. double bpp; // max-bpp
  107. char** depends;
  108. int ndepend;
  109. // rid-param-list(include pt/width/height/fps/fs/br/pps/bpp/depend/...)
  110. char** params;
  111. int nparam;
  112. };
  113. /// @param[out] direction sendonly/receonly/sendrecv/inactive, default sendrecv
  114. /// @return 0-ok, other-error
  115. int sdp_a_extmap(const char* s, int n, int* ext, int* direction, char url[128]);
  116. /// free(*param)
  117. /// @return 0-ok, other-error
  118. int sdp_a_fmtp(const char* s, int n, int* fmt, char **param);
  119. /// @return 0-ok, other-error
  120. int sdp_a_fingerprint(const char* s, int n, char hash[16], char fingerprint[128]);
  121. /// free(groups)
  122. /// @return 0-ok, other-error
  123. int sdp_a_group(const char* s, int n, char semantics[32], char*** groups, int* count);
  124. /// free(c->extensions)
  125. /// @return 0-ok, other-error
  126. int sdp_a_ice_candidate(const char* s, int n, struct sdp_ice_candidate_t* c);
  127. /// @return 0-ok, other-error
  128. int sdp_a_ice_remote_candidates(const char* s, int n, struct sdp_ice_candidate_t* c);
  129. /// @return 0-ok, other-error
  130. int sdp_a_ice_pacing(const char* s, int n, int* pacing);
  131. /// @param[out] options free(options)
  132. /// @param[out] count options number
  133. /// @return 0-ok, other-error
  134. int sdp_a_ice_options(const char* s, int n, char*** options, int* count);
  135. /// @return 0-ok, other-error
  136. int sdp_a_msid(const char* s, int n, char id[65], char appdata[65]);
  137. /// @return 0-ok, other-error
  138. int sdp_a_mid(const char* s, int n, char tag[256]);
  139. /// @param[out] orient portrait / landscape / seascape
  140. /// @return 0-ok, other-error
  141. int sdp_a_orient(const char* s, int n, char orient[16]);
  142. /// free(rid->params) / free(rid->depends) / free(rid->payloads)
  143. /// @return 0-ok, other-error
  144. int sdp_a_rid(const char* s, int n, struct sdp_rid_t* rid);
  145. /// @return 0-ok, other-error
  146. int sdp_a_rtcp(const char* s, int n, struct sdp_address_t* addr);
  147. /// @return 0-ok, other-error
  148. int sdp_a_rtcp_fb(const char* s, int n, struct sdp_rtcp_fb_t* fb);
  149. /// free(simulcast->sends) / free(simulcast->recvs)
  150. /// @return 0-ok, other-error
  151. int sdp_a_simulcast(const char* s, int n, struct sdp_simulcast_t* simulcast);
  152. /// @return 0-ok, other-error
  153. int sdp_a_ssrc(const char* s, int n, uint32_t *ssrc, char attribute[64], char value[128]);
  154. /// free(group->values)
  155. /// @return 0-ok, other-error
  156. int sdp_a_ssrc_group(const char* s, int n, struct sdp_ssrc_group_t* group);
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* !_sdp_a_webrtc_h_ */