25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

127 satır
3.5KB

  1. #ifndef _rtsp_media_h_
  2. #define _rtsp_media_h_
  3. #include "rtsp-header-range.h"
  4. #if defined(__cplusplus)
  5. extern "C" {
  6. #endif
  7. // RFC4585 Extended RTP Profile for Real-time Transport Control Protocol (RTCP)-Based Feedback (RTP/AVPF)
  8. // RFC5104 Codec Control Messages in the RTP Audio-Visual Profile with Feedback (AVPF)
  9. struct rtsp_fb_t
  10. {
  11. int fb_id;
  12. int trr_int;
  13. char ack[8]; // rpsi,app
  14. char nack[8]; // pli,sli,rpsi,app
  15. char ccm[8]; // fir,tmmbr,tstr,vbcm
  16. };
  17. // RFC3611 RTP Control Protocol Extended Reports (RTCP XR)
  18. struct rtsp_xr_t
  19. {
  20. int loss; // pkt-loss-rle
  21. int dup; // pkt-dup-rle
  22. int rcpt_times; // pkt-rcpt-times
  23. int rcvr_rtt;
  24. int rcvr_rtt_mode; // 0-sender, 1-all
  25. int stat_summary; // 0x01-loss, 0x02-dup, 0x04-jitt, 0x08-TTL
  26. int voip_metrics;
  27. };
  28. // rfc 5576
  29. struct sdp_ssrc_t
  30. {
  31. uint32_t ssrc;
  32. // TODO:
  33. // ssrc attribute(s)
  34. // multiple ssrc
  35. // ssrc-group
  36. };
  37. struct sdp_candidate_t
  38. {
  39. char foundation[33];
  40. char transport[8]; // UDP
  41. char candtype[8];
  42. uint16_t component; // rtp/rtcp component id, [1, 256]
  43. uint16_t port;
  44. uint32_t priority; // [1, 2**31 - 1]
  45. char address[65];
  46. char reladdr[65];
  47. uint16_t relport;
  48. };
  49. // https://tools.ietf.org/html/draft-ietf-mmusic-ice-sip-sdp-39
  50. // https://www.tech-invite.com/fo-abnf/tinv-fo-abnf-sdpatt-rfc5245.html
  51. // a=candidate:3 1 UDP 1862270847 10.95.49.227 63259 typ prflx raddr 192.168.137.93 rport 7078
  52. struct sdp_ice_t
  53. {
  54. char *pwd; // [22,256]
  55. char *ufrag; // [4, 256]
  56. int lite;
  57. int pacing;
  58. int mismatch;
  59. struct sdp_candidate_t *candidates[64];
  60. struct sdp_candidate_t *remotes[64];
  61. int candidate_count;
  62. int remote_count;
  63. };
  64. struct rtsp_media_t
  65. {
  66. char uri[256]; // rtsp setup url
  67. char session_uri[256]; // rtsp session url(aggregate control url), empty if non-aggregate control
  68. //unsigned int cseq; // rtsp sequence, unused if aggregate control available
  69. int64_t start, stop; // sdp t: NTP time since 1900
  70. char network[16], addrtype[16], address[64], source[64]; // sdp c: connection, address: unicast-source address, mulitcast-multicast address(RFC4566 4.1. Media and Transport Information)
  71. struct rtsp_header_range_t range;
  72. char media[32]; //audio, video, text, application, message
  73. char proto[64]; // udp, RTP/AVP, RTP/SAVP, RTP/AVPF
  74. int nport, port[8]; // rtcp-mux: port[0] == port[1]
  75. int mode; // SDP_A_SENDRECV/SDP_A_SENDONLY/SDP_A_RECVONLY/SDP_A_INACTIVE, @sdp.h
  76. int setup; // SDP_A_SETUP_ACTPASS/SDP_A_SETUP_ACTIVE/SDP_A_SETUP_PASSIVE, @sdp-utils.h
  77. int avformat_count;
  78. struct avformat_t
  79. {
  80. int fmt; // RTP payload type
  81. int rate; // RTP payload frequency
  82. int channel; // RTP payload channel
  83. char encoding[64]; // RTP payload encoding
  84. char *fmtp; // RTP fmtp value
  85. struct rtsp_fb_t fb;
  86. } avformats[16];
  87. struct rtsp_xr_t xr;
  88. struct sdp_ice_t ice;
  89. struct sdp_ssrc_t ssrc; // rfc 5576
  90. int offset;
  91. char ptr[8 * 1024]; // RTP fmtp value
  92. };
  93. /// @return <0-error, >count-try again, other-ok
  94. int rtsp_media_sdp(const char* sdp, int len, struct rtsp_media_t* medias, int count);
  95. /// Update session and media control url
  96. /// @param[in] base The RTSP Content-Base field
  97. /// @param[in] location The RTSP Content-Location field
  98. /// @param[in] request The RTSP request URL
  99. /// return 0-ok, other-error
  100. int rtsp_media_set_url(struct rtsp_media_t* media, const char* base, const char* location, const char* request);
  101. /// create media sdp
  102. /// @return -0-no media, >0-ok, <0-error
  103. int rtsp_media_to_sdp(const struct rtsp_media_t* m, char* line, int bytes);
  104. #if defined(__cplusplus)
  105. }
  106. #endif
  107. #endif /* !_rtsp_media_h_ */