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.

rtsp-header-transport.h 2.3KB

10 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _rtsp_header_transport_h_
  2. #define _rtsp_header_transport_h_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum {
  7. RTSP_TRANSPORT_UNICAST = 1,
  8. RTSP_TRANSPORT_MULTICAST,
  9. };
  10. // transport
  11. enum {
  12. RTSP_TRANSPORT_RTP_UDP = 1,
  13. RTSP_TRANSPORT_RTP_TCP,
  14. RTSP_TRANSPORT_RAW,
  15. };
  16. // transport mode
  17. enum {
  18. RTSP_TRANSPORT_PLAY = 1,
  19. RTSP_TRANSPORT_RECORD
  20. };
  21. // Transport: RTP/AVP/TCP;interleaved=0-1
  22. // Transport: RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257
  23. // Transport: RTP/AVP;multicast;destination=224.2.0.1;port=3456-3457;ttl=16
  24. struct rtsp_header_transport_t
  25. {
  26. int transport; // RTSP_TRANSPORT_xxx
  27. int multicast; // 0-unicast/1-multicast, default multicast
  28. char destination[65]; // IPv4/IPv6
  29. char source[65]; // IPv4/IPv6
  30. int layer; // rtsp setup response only
  31. int mode; // PLAY/RECORD, default PLAY, rtsp setup response only
  32. int append; // use with RECORD mode only, rtsp setup response only
  33. int interleaved1, interleaved2; // rtsp setup response only
  34. union rtsp_header_transport_rtp_u
  35. {
  36. struct rtsp_header_transport_multicast_t
  37. {
  38. int ttl; // multicast only
  39. unsigned short port1, port2; // multicast only
  40. } m;
  41. struct rtsp_header_transport_unicast_t
  42. {
  43. unsigned short client_port1, client_port2; // unicast RTP/RTCP port pair, RTP only
  44. unsigned short server_port1, server_port2; // unicast RTP/RTCP port pair, RTP only
  45. unsigned int ssrc; // RTP only(synchronization source (SSRC) identifier) 4-bytes
  46. } u;
  47. } rtp;
  48. };
  49. /// parse RTSP Transport header
  50. /// @return 0-ok, other-error
  51. /// usage 1:
  52. /// struct rtsp_header_transport_t transport;
  53. /// const char* header = "Transport: RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257";
  54. /// r = rtsp_header_transport("RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257", &transport);
  55. /// check(r)
  56. ///
  57. /// usage 2:
  58. /// const char* header = "Transport: RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257,RTP/AVP;unicast;client_port=5000-5001;server_port=6000-6001";
  59. /// split(header, ',');
  60. /// r1 = rtsp_header_transport("RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257", &transport);
  61. /// r2 = rtsp_header_transport("RTP/AVP;unicast;client_port=5000-5001;server_port=6000-6001", &transport);
  62. /// check(r1, r2)
  63. int rtsp_header_transport(const char* field, struct rtsp_header_transport_t* transport);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* !_rtsp_header_transport_h_ */