rtpsession.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef __RTPSESSION_H__
  2. #define __RTPSESSION_H__
  3. #pragma once
  4. #include "config.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include "rtp.h"
  9. typedef struct rtp_session_t rtp_session_t;
  10. #define RTP_SESSION_FLAG_NONE 0x00
  11. #define RTP_SESSION_FLAG_SENDONLY 0x01
  12. #define RTP_SESSION_FLAG_RECVONLY 0x02
  13. #define RTP_SESSION_FLAG_SENDRECV 0x03
  14. #define RTP_SESSION_FLAG_NO_RTCP 0x04
  15. TOOLKIT_API int rtp_session_create(const char* local_ip, /* network byte order */
  16. unsigned short start_port,
  17. unsigned short num_port,
  18. rtp_session_t **pp_s);
  19. TOOLKIT_API int rtp_session_create2(unsigned long local_ip,
  20. unsigned short start_port,
  21. unsigned short num_port,
  22. rtp_session_t **pp_s);
  23. TOOLKIT_API int rtp_session_destroy(rtp_session_t *sess);
  24. TOOLKIT_API int rtp_session_reset(rtp_session_t *sess,
  25. unsigned flags,
  26. const char* remote_ip, /* remote address , network byte order */
  27. unsigned short remote_rtp_port,
  28. unsigned short remote_rtcp_port); // if rtcp port == 0, no rtcp
  29. TOOLKIT_API int rtp_session_reset2(rtp_session_t *sess,
  30. unsigned flags,
  31. unsigned long remote_ip, /* remote address , network byte order */
  32. unsigned short remote_rtp_port,
  33. unsigned short remote_rtcp_port); // if rtcp port == 0, no rtcp
  34. TOOLKIT_API int rtp_session_send(rtp_session_t *sess,
  35. unsigned *rtcp_rx_flags,
  36. unsigned pt,
  37. unsigned mark,
  38. unsigned delta_ts,
  39. const char *buf,
  40. int n);
  41. TOOLKIT_API int rtp_session_send_hook(rtp_session_t *sess,
  42. unsigned *rtcp_rx_flags,
  43. unsigned pt,
  44. unsigned mark,
  45. unsigned delta_ts,
  46. const char *buf,
  47. int n,
  48. void (*on_tx_hook)(const char *buf, int size, void *arg), void *hook_arg);
  49. TOOLKIT_API int rtp_session_send_hook2(rtp_session_t *sess,
  50. unsigned *rtcp_rx_flags,
  51. const rtp_hdr *hdr,
  52. const char *buf,
  53. int n,
  54. void (*on_tx_hook)(const char *buf, int size, void *arg), void *hook_arg);
  55. TOOLKIT_API int rtp_session_send_raw(rtp_session_t *sess,
  56. unsigned *rtcp_rx_flags,
  57. const char *buf,
  58. int n);
  59. // huawei openeye need this
  60. TOOLKIT_API int rtp_session_send_rtcp_h261_fir(rtp_session_t *sess);
  61. // bitrate control
  62. TOOLKIT_API int rtp_session_send_rtcp_fb_tmmbr(rtp_session_t *sess, u__int64_t mxtbr);
  63. #define RTP_SESSION_HAS_SDES 0x01
  64. #define RTP_SESSION_HAS_FIR 0x02
  65. #define RTP_SESSION_HAS_BYE 0x04
  66. #define RTP_SESSION_HAS_SR 0x08
  67. #define RTP_SESSION_HAS_RR 0x10
  68. #define RTP_SESSION_HAS_APP 0x20
  69. #define RTP_SESSION_HAS_NACK 0x40
  70. #define RTP_SESSION_HAS_RTPFB_TMMBR 0x80
  71. TOOLKIT_API int rtp_session_recv(rtp_session_t *sess,
  72. unsigned *pt,
  73. unsigned *mark,
  74. unsigned *ts,
  75. unsigned short *seq,
  76. char *buf,
  77. int n);
  78. TOOLKIT_API int rtp_session_recv_hook(rtp_session_t *sess,
  79. unsigned *pt,
  80. unsigned *mark,
  81. unsigned *ts,
  82. unsigned short *seq,
  83. char *buf,
  84. int n,
  85. void (*on_rx_hook)(const char *buf, int size, void *arg), void *hook_arg);
  86. TOOLKIT_API int rtp_session_recv_hook2(rtp_session_t *sess,
  87. rtp_hdr *hdr,
  88. char *buf,
  89. int n,
  90. void (*on_rx_hook)(const char *buf, int size, void *arg), void *hook_arg);
  91. TOOLKIT_API int rtp_session_recv_raw(rtp_session_t *sess,
  92. char *buf,
  93. int n);
  94. TOOLKIT_API int rtp_session_recv_rtcp(rtp_session_t *sess, unsigned *rtcp_rx_flags);
  95. TOOLKIT_API int rtp_session_advance_timestamp(rtp_session_t *sess, unsigned int delta_ts);
  96. TOOLKIT_API int rtp_session_get_rtcp_stat(rtp_session_t *sess, rtcp_statistics *stat);
  97. TOOLKIT_API rtp_state *rtp_session_get_rtp_state(rtp_session_t *sess);
  98. TOOLKIT_API int rtp_session_get_local_ip(rtp_session_t *sess, unsigned long *p_local_ip);
  99. TOOLKIT_API int rtp_session_get_local_rtp_port(rtp_session_t *sess, unsigned short *p_rtp);
  100. TOOLKIT_API int rtp_session_get_local_rtcp_port(rtp_session_t *sess, unsigned short *p_rtcp);
  101. TOOLKIT_API int rtp_session_get_remote_ip(rtp_session_t *sess, unsigned long *p_remote_ip);
  102. TOOLKIT_API int rtp_session_get_remote_rtp_port(rtp_session_t *sess, unsigned short *p_rtp);
  103. TOOLKIT_API int rtp_session_get_remote_rtcp_port(rtp_session_t *sess, unsigned short *p_rtcp);
  104. TOOLKIT_API int rtp_session_get_raw_fd(rtp_session_t *sess, int *rtp_fd, int *rtcp_fd);
  105. #ifdef __cplusplus
  106. } // extern "C" {
  107. #endif
  108. #endif //__RTPSESSION_H__