34 #include <ortp/port.h>
38 #include <ortp/rtcp.h>
39 #include <ortp/str_utils.h>
40 #include <ortp/rtpsignaltable.h>
41 #include <ortp/event.h>
68 int adapt_jitt_comp_ts;
92 int (*t_sendto)(
struct _RtpTransport *t,
mblk_t *msg ,
int flags,
const struct sockaddr *to, socklen_t tolen);
93 int (*t_recvfrom)(
struct _RtpTransport *t,
mblk_t *msg,
int flags,
struct sockaddr *from, socklen_t *fromlen);
101 ortp_socket_t socket;
112 struct sockaddr_storage rem_addr;
114 struct sockaddr_in rem_addr;
118 uint32_t snd_time_offset;
119 uint32_t snd_ts_offset;
120 uint32_t snd_rand_offset;
121 uint32_t snd_last_ts;
122 uint32_t rcv_time_offset;
123 uint32_t rcv_ts_offset;
124 uint32_t rcv_query_ts_offset;
125 uint32_t rcv_last_ts;
126 uint32_t rcv_last_app_ts;
127 uint32_t rcv_last_ret_ts;
128 uint32_t hwrcv_extseq;
129 uint32_t hwrcv_seq_at_last_SR;
130 uint32_t hwrcv_since_last_SR;
131 uint32_t last_rcv_SR_ts;
132 struct timeval last_rcv_SR_time;
134 uint32_t last_rtcp_report_snt_r;
135 uint32_t last_rtcp_report_snt_s;
136 uint32_t rtcp_report_snt_interval;
137 uint32_t last_rtcp_packet_count;
138 uint32_t sent_payload_bytes;
139 unsigned int sent_bytes;
140 struct timeval send_bw_start;
141 unsigned int recv_bytes;
142 struct timeval recv_bw_start;
152 ortp_socket_t socket;
158 struct sockaddr_storage rem_addr;
160 struct sockaddr_in rem_addr;
186 int telephone_events_pt;
188 unsigned int inc_ssrc_candidate;
189 int inc_same_ssrc_count;
199 struct _OList *signal_tables;
209 int multicast_loopback;
212 struct timeval last_recv_time;
218 bool_t symmetric_rtp;
234 void rtp_session_set_scheduling_mode(
RtpSession *session,
int yesno);
235 void rtp_session_set_blocking_mode(
RtpSession *session,
int yesno);
242 int rtp_session_signal_connect(
RtpSession *session,
const char *signal_name, RtpCallback cb,
unsigned long user_data);
243 int rtp_session_signal_disconnect_by_callback(
RtpSession *session,
const char *signal_name, RtpCallback cb);
244 void rtp_session_set_ssrc(
RtpSession *session, uint32_t ssrc);
245 void rtp_session_set_seq_number(
RtpSession *session, uint16_t seq);
246 uint16_t rtp_session_get_seq_number(
RtpSession *session);
248 void rtp_session_enable_jitter_buffer(
RtpSession *session , bool_t enabled);
249 bool_t rtp_session_jitter_buffer_enabled(
const RtpSession *session);
254 void rtp_session_set_jitter_compensation(
RtpSession *session,
int milisec);
255 void rtp_session_enable_adaptive_jitter_compensation(
RtpSession *session, bool_t val);
256 bool_t rtp_session_adaptive_jitter_compensation_enabled(
RtpSession *session);
258 void rtp_session_set_time_jump_limit(
RtpSession *session,
int miliseconds);
259 int rtp_session_set_local_addr(
RtpSession *session,
const char *addr,
int port);
260 int rtp_session_get_local_port(
const RtpSession *session);
263 rtp_session_set_remote_addr_full (
RtpSession * session,
const char * addr,
int rtp_port,
int rtcp_port);
265 int rtp_session_set_remote_addr_and_port (
RtpSession * session,
const char * addr,
int rtp_port,
int rtcp_port);
266 int rtp_session_set_remote_addr(
RtpSession *session,
const char *addr,
int port);
269 void rtp_session_set_sockets(
RtpSession *session,
int rtpfd,
int rtcpfd);
273 ortp_socket_t rtp_session_get_rtp_socket(
const RtpSession *session);
274 ortp_socket_t rtp_session_get_rtcp_socket(
const RtpSession *session);
278 int rtp_session_set_dscp(
RtpSession *session,
int dscp);
279 int rtp_session_get_dscp(
const RtpSession *session);
283 int rtp_session_set_multicast_ttl(
RtpSession *session,
int ttl);
284 int rtp_session_get_multicast_ttl(
RtpSession *session);
286 int rtp_session_set_multicast_loopback(
RtpSession *session,
int yesno);
287 int rtp_session_get_multicast_loopback(
RtpSession *session);
291 int rtp_session_set_send_payload_type(
RtpSession *session,
int paytype);
292 int rtp_session_get_send_payload_type(
const RtpSession *session);
294 int rtp_session_get_recv_payload_type(
const RtpSession *session);
295 int rtp_session_set_recv_payload_type(
RtpSession *session,
int pt);
297 int rtp_session_set_payload_type(
RtpSession *session,
int pt);
299 void rtp_session_set_symmetric_rtp (
RtpSession * session, bool_t yesno);
301 void rtp_session_set_connected_mode(
RtpSession *session, bool_t yesno);
303 void rtp_session_enable_rtcp(
RtpSession *session, bool_t yesno);
306 mblk_t * rtp_session_recvm_with_ts (
RtpSession * session, uint32_t user_ts);
307 mblk_t * rtp_session_create_packet(
RtpSession *session,
int header_size,
const uint8_t *payload,
int payload_size);
308 mblk_t * rtp_session_create_packet_with_data(
RtpSession *session, uint8_t *payload,
int payload_size,
void (*freefn)(
void*));
309 mblk_t * rtp_session_create_packet_in_place(
RtpSession *session,uint8_t *buffer,
int size,
void (*freefn)(
void*) );
310 int rtp_session_sendm_with_ts (
RtpSession * session,
mblk_t *mp, uint32_t userts);
312 int rtp_session_recv_with_ts(
RtpSession *session, uint8_t *buffer,
int len, uint32_t ts,
int *have_more);
313 int rtp_session_send_with_ts(
RtpSession *session,
const uint8_t *buffer,
int len, uint32_t userts);
321 float rtp_session_compute_send_bandwidth(
RtpSession *session);
322 float rtp_session_compute_recv_bandwidth(
RtpSession *session);
324 void rtp_session_send_rtcp_APP(
RtpSession *session, uint8_t subtype,
const char *name,
const uint8_t *data,
int datalen);
326 uint32_t rtp_session_get_current_send_ts(
RtpSession *session);
327 uint32_t rtp_session_get_current_recv_ts(
RtpSession *session);
328 void rtp_session_flush_sockets(
RtpSession *session);
329 void rtp_session_release_sockets(
RtpSession *session);
332 void rtp_session_destroy(
RtpSession *session);
335 void rtp_session_reset_stats(
RtpSession *session);
337 void rtp_session_set_data(
RtpSession *session,
void *data);
338 void *rtp_session_get_data(
const RtpSession *session);
340 void rtp_session_set_recv_buf_size(
RtpSession *session,
int bufsize);
341 void rtp_session_set_rtp_socket_send_buffer_size(
RtpSession * session,
unsigned int size);
342 void rtp_session_set_rtp_socket_recv_buffer_size(
RtpSession * session,
unsigned int size);
345 uint32_t rtp_session_ts_to_time(
RtpSession *session,uint32_t timestamp);
346 uint32_t rtp_session_time_to_ts(
RtpSession *session,
int millisecs);
350 void rtp_session_make_time_distorsion(
RtpSession *session,
int milisec);
353 void rtp_session_set_source_description(
RtpSession *session,
const char *cname,
354 const char *name,
const char *email,
const char *phone,
355 const char *loc,
const char *tool,
const char *note);
356 void rtp_session_add_contributing_source(
RtpSession *session, uint32_t csrc,
357 const char *cname,
const char *name,
const char *email,
const char *phone,
358 const char *loc,
const char *tool,
const char *note);
359 void rtp_session_remove_contributing_sources(
RtpSession *session, uint32_t csrc);
362 void rtp_session_get_last_recv_time(
RtpSession *session,
struct timeval *tv);
363 int rtp_session_bye(
RtpSession *session,
const char *reason);
365 int rtp_session_get_last_send_error_code(
RtpSession *session);
366 void rtp_session_clear_send_error_code(
RtpSession *session);
367 int rtp_session_get_last_recv_error_code(
RtpSession *session);
368 void rtp_session_clear_recv_error_code(
RtpSession *session);
371 void rtp_session_init(
RtpSession *session,
int mode);
372 #define rtp_session_set_flag(session,flag) (session)->flags|=(flag)
373 #define rtp_session_unset_flag(session,flag) (session)->flags&=~(flag)