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 maanden geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef _rfc4566_sdp_h_
  2. #define _rfc4566_sdp_h_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef struct sdp_t sdp_t;
  7. enum { SDP_V_VERSION_0 = 0 };
  8. enum { SDP_C_NETWORK_UNKNOWN=0, SDP_C_NETWORK_IN };
  9. enum { SDP_C_ADDRESS_UNKNOWN=0, SDP_C_ADDRESS_IP4, SDP_C_ADDRESS_IP6 };
  10. enum { SDP_A_INACTIVE = 0, SDP_A_SENDONLY = 0x01, SDP_A_RECVONLY = 0x02, SDP_A_SENDRECV = 0x03 /*default*/, };
  11. enum { SDP_M_MEDIA_UNKOWN = 0, SDP_M_MEDIA_AUDIO, SDP_M_MEDIA_VIDEO, SDP_M_MEDIA_TEXT, SDP_M_MEDIA_APPLICATION, SDP_M_MEDIA_MESSAGE };
  12. sdp_t* sdp_parse(const char* s, int len);
  13. void sdp_destroy(sdp_t* sdp);
  14. int sdp_version_get(sdp_t* sdp);
  15. /// 5.2. Origin ("o=")
  16. /// @param[out] username username
  17. /// @param[out] session session id
  18. /// @param[out] version session version
  19. /// @param[out] network network type, IN-internet
  20. /// @param[out] addrtype address type, IP4-IP v4, IP6-IP v6
  21. /// @param[out] address connection address, multicast/unicast address
  22. /// @return 0-ok, -1 if don't have connection
  23. int sdp_origin_get(sdp_t* sdp, const char **username, const char** session, const char** version, const char** network, const char** addrtype, const char** address);
  24. int sdp_origin_get_network(sdp_t* sdp); // SDP_C_NETWORK_IN
  25. int sdp_origin_get_addrtype(sdp_t* sdp); // SDP_C_ADDRESS_IP4/SDP_C_ADDRESS_IP6
  26. /// @return NULL-if don't have keyword
  27. const char* sdp_session_get_name(sdp_t* sdp);
  28. const char* sdp_session_get_information(sdp_t* sdp);
  29. const char* sdp_uri_get(sdp_t* sdp);
  30. int sdp_email_count(sdp_t* sdp);
  31. int sdp_phone_count(sdp_t* sdp);
  32. const char* sdp_email_get(sdp_t* sdp, int idx);
  33. const char* sdp_phone_get(sdp_t* sdp, int idx);
  34. // c=IN IP4 224.2.36.42/127
  35. // c=IN IP4 224.2.1.1/127/3
  36. // c=IN IP6 FF15::101/3
  37. /// @param[out] network network type, IN-internet
  38. /// @param[out] addrtype address type, IP4-IP v4, IP6-IP v6
  39. /// @param[out] address connection address, multicast/unicast address
  40. /// @return 0-ok, -1 if don't have connection
  41. int sdp_connection_get(sdp_t* sdp, const char** network, const char** addrtype, const char** address);
  42. int sdp_connection_get_address(sdp_t* sdp, char* ip, int bytes); // ipv4/ipv6 address, alloc by caller
  43. int sdp_connection_get_network(sdp_t* sdp); // SDP_C_NETWORK_IN
  44. int sdp_connection_get_addrtype(sdp_t* sdp); // SDP_C_ADDRESS_IP4/SDP_C_ADDRESS_IP6
  45. int sdp_bandwidth_count(sdp_t* sdp);
  46. const char* sdp_bandwidth_get_type(sdp_t* sdp, int idx); // CT/AS
  47. int sdp_bandwidth_get_value(sdp_t* sdp, int idx); // kbps-kilobits per second
  48. // 1. These values are the decimal representation of Network Time Protocol (NTP) time values in seconds
  49. // since 1900 [13]. To convert these values to UNIX time, subtract decimal 2208988800.
  50. // 2. If the <stop-time> is set to zero, then the session is not bounded, though it will not become active
  51. // until after the <start-time>. If the <start-time> is also zero, the session is regarded as permanent.
  52. int sdp_timing_count(sdp_t* sdp);
  53. int sdp_timing_repeat_count(sdp_t* sdp, int time);
  54. int sdp_timing_repeat_offset_count(sdp_t* sdp, int time);
  55. int sdp_timing_timezone_count(sdp_t* sdp, int time);
  56. int sdp_timing_get(sdp_t* sdp, int idx, const char** start, const char** stop);
  57. const char* sdp_repeat_get(sdp_t* sdp, int idx);
  58. const char* sdp_timezone_get(sdp_t* sdp, int idx);
  59. /// @return NULL-if don't have keyword
  60. const char* sdp_encryption_get(sdp_t* sdp);
  61. int sdp_media_count(sdp_t* sdp);
  62. const char* sdp_media_type(sdp_t* sdp, int media);
  63. int sdp_media_port(sdp_t* sdp, int media, int port[], int num); // return port count
  64. const char* sdp_media_proto(sdp_t* sdp, int media);
  65. int sdp_media_formats(sdp_t* sdp, int media, int *formats, int count); // return format count
  66. /*
  67. RFC4566 4.1. Media and Transport Information
  68. In addition to media format and transport protocol, SDP conveys
  69. address and port details. For an IP multicast session, these
  70. comprise:
  71. The multicast group address for media
  72. The transport port for media
  73. This address and port are the destination address and destination
  74. port of the multicast stream, whether being sent, received, or both.
  75. For unicast IP sessions, the following are conveyed:
  76. The remote address for media
  77. The remote transport port for media
  78. The semantics of this address and port depend on the media and
  79. transport protocol defined. By default, this SHOULD be the remote
  80. address and remote port to which data is sent.
  81. RFC 4570 SDP Source Filters
  82. c=IN IP4 224.2.1.1/127/3
  83. a=source-filter: incl IN IP4 224.2.1.1 192.0.2.10
  84. a=source-filter: incl IN IP4 224.2.1.3 192.0.2.42
  85. */
  86. int sdp_media_get_connection(sdp_t* sdp, int media, const char** network, const char** addrtype, const char** address);
  87. int sdp_media_get_connection_address(sdp_t* sdp, int media, char* ip, int bytes);
  88. int sdp_media_get_connection_network(sdp_t* sdp, int media);
  89. int sdp_media_get_connection_addrtype(sdp_t* sdp, int media);
  90. const char* sdp_media_attribute_find(sdp_t* sdp, int media, const char* name);
  91. int sdp_media_attribute_list(sdp_t* sdp, int media, const char* name, void (*onattr)(void* param, const char* name, const char* value), void* param);
  92. const char* sdp_media_get_information(sdp_t* sdp, int media);
  93. int sdp_media_bandwidth_count(sdp_t* sdp, int media);
  94. const char* sdp_media_bandwidth_get_type(sdp_t* sdp, int media, int idx); // CT/AS
  95. int sdp_media_bandwidth_get_value(sdp_t* sdp, int media, int idx); // kbps-kilobits per second
  96. int sdp_attribute_count(sdp_t* sdp);
  97. /// param[in] name attrbution name, NULL-for list all attributions
  98. int sdp_attribute_list(sdp_t* sdp, const char* name, void (*onattr)(void* param, const char* name, const char* value), void* param);
  99. int sdp_attribute_get(sdp_t* sdp, int idx, const char** name, const char** value);
  100. const char* sdp_attribute_find(sdp_t* sdp, const char* name);
  101. /// "sendrecv" SHOULD be assumed as the default for sessions that
  102. /// are not of the conference type "broadcast" or "H332" (see below).
  103. /// return -1-not found, SDP_A_SENDRECV/SDP_A_SENDONLY/SDP_A_XXX
  104. int sdp_media_mode(struct sdp_t* sdp, int media);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* !_sdp_h_ */