123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef __RTPSESSION_H__
- #define __RTPSESSION_H__
- #pragma once
- #include "config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "rtp.h"
- typedef struct rtp_session_t rtp_session_t;
- #define RTP_SESSION_FLAG_NONE 0x00
- #define RTP_SESSION_FLAG_SENDONLY 0x01
- #define RTP_SESSION_FLAG_RECVONLY 0x02
- #define RTP_SESSION_FLAG_SENDRECV 0x03
- #define RTP_SESSION_FLAG_NO_RTCP 0x04
- TOOLKIT_API int rtp_session_create(const char* local_ip, /* network byte order */
- unsigned short start_port,
- unsigned short num_port,
- rtp_session_t **pp_s);
- TOOLKIT_API int rtp_session_create2(unsigned long local_ip,
- unsigned short start_port,
- unsigned short num_port,
- rtp_session_t **pp_s);
- TOOLKIT_API int rtp_session_destroy(rtp_session_t *sess);
- TOOLKIT_API int rtp_session_reset(rtp_session_t *sess,
- unsigned flags,
- const char* remote_ip, /* remote address , network byte order */
- unsigned short remote_rtp_port,
- unsigned short remote_rtcp_port); // if rtcp port == 0, no rtcp
- TOOLKIT_API int rtp_session_reset2(rtp_session_t *sess,
- unsigned flags,
- unsigned long remote_ip, /* remote address , network byte order */
- unsigned short remote_rtp_port,
- unsigned short remote_rtcp_port); // if rtcp port == 0, no rtcp
- TOOLKIT_API int rtp_session_send(rtp_session_t *sess,
- unsigned *rtcp_rx_flags,
- unsigned pt,
- unsigned mark,
- unsigned delta_ts,
- const char *buf,
- int n);
- TOOLKIT_API int rtp_session_send_hook(rtp_session_t *sess,
- unsigned *rtcp_rx_flags,
- unsigned pt,
- unsigned mark,
- unsigned delta_ts,
- const char *buf,
- int n,
- void (*on_tx_hook)(const char *buf, int size, void *arg), void *hook_arg);
- TOOLKIT_API int rtp_session_send_hook2(rtp_session_t *sess,
- unsigned *rtcp_rx_flags,
- const rtp_hdr *hdr,
- const char *buf,
- int n,
- void (*on_tx_hook)(const char *buf, int size, void *arg), void *hook_arg);
- TOOLKIT_API int rtp_session_send_raw(rtp_session_t *sess,
- unsigned *rtcp_rx_flags,
- const char *buf,
- int n);
- // huawei openeye need this
- TOOLKIT_API int rtp_session_send_rtcp_h261_fir(rtp_session_t *sess);
- // bitrate control
- TOOLKIT_API int rtp_session_send_rtcp_fb_tmmbr(rtp_session_t *sess, u__int64_t mxtbr);
- #define RTP_SESSION_HAS_SDES 0x01
- #define RTP_SESSION_HAS_FIR 0x02
- #define RTP_SESSION_HAS_BYE 0x04
- #define RTP_SESSION_HAS_SR 0x08
- #define RTP_SESSION_HAS_RR 0x10
- #define RTP_SESSION_HAS_APP 0x20
- #define RTP_SESSION_HAS_NACK 0x40
- #define RTP_SESSION_HAS_RTPFB_TMMBR 0x80
- TOOLKIT_API int rtp_session_recv(rtp_session_t *sess,
- unsigned *pt,
- unsigned *mark,
- unsigned *ts,
- unsigned short *seq,
- char *buf,
- int n);
- TOOLKIT_API int rtp_session_recv_hook(rtp_session_t *sess,
- unsigned *pt,
- unsigned *mark,
- unsigned *ts,
- unsigned short *seq,
- char *buf,
- int n,
- void (*on_rx_hook)(const char *buf, int size, void *arg), void *hook_arg);
- TOOLKIT_API int rtp_session_recv_hook2(rtp_session_t *sess,
- rtp_hdr *hdr,
- char *buf,
- int n,
- void (*on_rx_hook)(const char *buf, int size, void *arg), void *hook_arg);
- TOOLKIT_API int rtp_session_recv_raw(rtp_session_t *sess,
- char *buf,
- int n);
- TOOLKIT_API int rtp_session_recv_rtcp(rtp_session_t *sess, unsigned *rtcp_rx_flags);
- TOOLKIT_API int rtp_session_advance_timestamp(rtp_session_t *sess, unsigned int delta_ts);
- TOOLKIT_API int rtp_session_get_rtcp_stat(rtp_session_t *sess, rtcp_statistics *stat);
- TOOLKIT_API rtp_state *rtp_session_get_rtp_state(rtp_session_t *sess);
- TOOLKIT_API int rtp_session_get_local_ip(rtp_session_t *sess, unsigned long *p_local_ip);
- TOOLKIT_API int rtp_session_get_local_rtp_port(rtp_session_t *sess, unsigned short *p_rtp);
- TOOLKIT_API int rtp_session_get_local_rtcp_port(rtp_session_t *sess, unsigned short *p_rtcp);
- TOOLKIT_API int rtp_session_get_remote_ip(rtp_session_t *sess, unsigned long *p_remote_ip);
- TOOLKIT_API int rtp_session_get_remote_rtp_port(rtp_session_t *sess, unsigned short *p_rtp);
- TOOLKIT_API int rtp_session_get_remote_rtcp_port(rtp_session_t *sess, unsigned short *p_rtcp);
- TOOLKIT_API int rtp_session_get_raw_fd(rtp_session_t *sess, int *rtp_fd, int *rtcp_fd);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__RTPSESSION_H__
|