34 #include <ortp/port.h>
39 #include <ortp/rtcp.h>
40 #include <ortp/str_utils.h>
41 #include <ortp/rtpsignaltable.h>
42 #include <ortp/event.h>
69 int adapt_jitt_comp_ts;
77 uint64_t cum_jitter_buffer_size;
78 unsigned int cum_jitter_buffer_count;
96 int (*t_sendto)(
struct _RtpTransport *t,
mblk_t *msg ,
int flags,
const struct sockaddr *to, socklen_t tolen);
97 int (*t_recvfrom)(
struct _RtpTransport *t,
mblk_t *msg,
int flags,
struct sockaddr *from, socklen_t *fromlen);
99 void (*t_close)(
struct _RtpTransport *transport,
void *userData);
114 struct timeval last_check;
119 ortp_socket_t socket;
130 struct sockaddr_storage rem_addr;
132 struct sockaddr_in rem_addr;
136 unsigned long QoSFlowID;
138 uint32_t snd_time_offset;
139 uint32_t snd_ts_offset;
140 uint32_t snd_rand_offset;
141 uint32_t snd_last_ts;
142 uint32_t rcv_time_offset;
143 uint32_t rcv_ts_offset;
144 uint32_t rcv_query_ts_offset;
145 uint32_t rcv_last_ts;
146 uint32_t rcv_last_app_ts;
147 uint32_t rcv_last_ret_ts;
148 uint32_t hwrcv_extseq;
149 uint32_t hwrcv_seq_at_last_SR;
150 uint32_t hwrcv_since_last_SR;
151 uint32_t last_rcv_SR_ts;
152 struct timeval last_rcv_SR_time;
154 uint32_t last_rtcp_packet_count;
155 uint32_t sent_payload_bytes;
156 unsigned int sent_bytes;
157 struct timeval send_bw_start;
158 unsigned int recv_bytes;
159 struct timeval recv_bw_start;
165 int ssrc_changed_thres;
171 ortp_socket_t socket;
177 struct sockaddr_storage rem_addr;
179 struct sockaddr_in rem_addr;
183 uint32_t last_rtcp_report_snt_r;
184 uint32_t last_rtcp_report_snt_s;
185 uint32_t rtcp_report_snt_interval_r;
186 uint32_t rtcp_report_snt_interval_s;
210 int telephone_events_pt;
212 unsigned int inc_ssrc_candidate;
213 int inc_same_ssrc_count;
223 struct _OList *signal_tables;
233 int multicast_loopback;
236 struct timeval last_recv_time;
242 unsigned int lost_packets_test_vector;
243 unsigned int interarrival_jitter_test_vector;
244 unsigned int delay_test_vector;
247 bool_t symmetric_rtp;
263 ORTP_PUBLIC
RtpSession *rtp_session_new(
int mode);
264 ORTP_PUBLIC
void rtp_session_set_scheduling_mode(
RtpSession *session,
int yesno);
265 ORTP_PUBLIC
void rtp_session_set_blocking_mode(
RtpSession *session,
int yesno);
272 ORTP_PUBLIC
int rtp_session_signal_connect(
RtpSession *session,
const char *signal_name, RtpCallback cb,
unsigned long user_data);
273 ORTP_PUBLIC
int rtp_session_signal_disconnect_by_callback(
RtpSession *session,
const char *signal_name, RtpCallback cb);
274 ORTP_PUBLIC
void rtp_session_set_ssrc(
RtpSession *session, uint32_t ssrc);
275 ORTP_PUBLIC uint32_t rtp_session_get_send_ssrc(
RtpSession* session);
276 ORTP_PUBLIC uint32_t rtp_session_get_recv_ssrc(
RtpSession *session);
277 ORTP_PUBLIC
void rtp_session_set_seq_number(
RtpSession *session, uint16_t seq);
278 ORTP_PUBLIC uint16_t rtp_session_get_seq_number(
RtpSession *session);
279 ORTP_PUBLIC uint32_t rtp_session_get_rcv_ext_seq_number(
RtpSession *session);
281 ORTP_PUBLIC
void rtp_session_enable_jitter_buffer(
RtpSession *session , bool_t enabled);
282 ORTP_PUBLIC bool_t rtp_session_jitter_buffer_enabled(
const RtpSession *session);
287 ORTP_PUBLIC
void rtp_session_set_jitter_compensation(
RtpSession *session,
int milisec);
288 ORTP_PUBLIC
void rtp_session_enable_adaptive_jitter_compensation(
RtpSession *session, bool_t val);
289 ORTP_PUBLIC bool_t rtp_session_adaptive_jitter_compensation_enabled(
RtpSession *session);
291 ORTP_PUBLIC
void rtp_session_set_time_jump_limit(
RtpSession *session,
int miliseconds);
292 ORTP_PUBLIC
int rtp_session_set_local_addr(
RtpSession *session,
const char *addr,
int rtp_port,
int rtcp_port);
293 ORTP_PUBLIC
int rtp_session_get_local_port(
const RtpSession *session);
296 rtp_session_set_remote_addr_full (
RtpSession * session,
const char * rtp_addr,
int rtp_port,
const char * rtcp_addr,
int rtcp_port);
298 ORTP_PUBLIC
int rtp_session_set_remote_addr_and_port (
RtpSession * session,
const char * addr,
int rtp_port,
int rtcp_port);
299 ORTP_PUBLIC
int rtp_session_set_remote_addr(
RtpSession *session,
const char *addr,
int port);
302 ORTP_PUBLIC
void rtp_session_set_sockets(
RtpSession *session,
int rtpfd,
int rtcpfd);
306 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtp_socket(
const RtpSession *session);
307 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtcp_socket(
const RtpSession *session);
311 ORTP_PUBLIC
int rtp_session_set_dscp(
RtpSession *session,
int dscp);
312 ORTP_PUBLIC
int rtp_session_get_dscp(
const RtpSession *session);
316 ORTP_PUBLIC
int rtp_session_set_pktinfo(
RtpSession *session,
int activate);
319 ORTP_PUBLIC
int rtp_session_set_multicast_ttl(
RtpSession *session,
int ttl);
320 ORTP_PUBLIC
int rtp_session_get_multicast_ttl(
RtpSession *session);
322 ORTP_PUBLIC
int rtp_session_set_multicast_loopback(
RtpSession *session,
int yesno);
323 ORTP_PUBLIC
int rtp_session_get_multicast_loopback(
RtpSession *session);
327 ORTP_PUBLIC
int rtp_session_set_send_payload_type(
RtpSession *session,
int paytype);
328 ORTP_PUBLIC
int rtp_session_get_send_payload_type(
const RtpSession *session);
330 ORTP_PUBLIC
int rtp_session_get_recv_payload_type(
const RtpSession *session);
331 ORTP_PUBLIC
int rtp_session_set_recv_payload_type(
RtpSession *session,
int pt);
333 ORTP_PUBLIC
int rtp_session_set_payload_type(
RtpSession *session,
int pt);
335 ORTP_PUBLIC
void rtp_session_set_symmetric_rtp (
RtpSession * session, bool_t yesno);
337 ORTP_PUBLIC
void rtp_session_set_connected_mode(
RtpSession *session, bool_t yesno);
339 ORTP_PUBLIC
void rtp_session_enable_rtcp(
RtpSession *session, bool_t yesno);
341 ORTP_PUBLIC
void rtp_session_set_rtcp_report_interval(
RtpSession *session,
int value_ms);
343 ORTP_PUBLIC
void rtp_session_set_ssrc_changed_threshold(
RtpSession *session,
int numpackets);
346 ORTP_PUBLIC
mblk_t * rtp_session_recvm_with_ts (
RtpSession * session, uint32_t user_ts);
347 ORTP_PUBLIC
mblk_t * rtp_session_create_packet(
RtpSession *session,
int header_size,
const uint8_t *payload,
int payload_size);
348 ORTP_PUBLIC
mblk_t * rtp_session_create_packet_with_data(
RtpSession *session, uint8_t *payload,
int payload_size,
void (*freefn)(
void*));
349 ORTP_PUBLIC
mblk_t * rtp_session_create_packet_in_place(
RtpSession *session,uint8_t *buffer,
int size,
void (*freefn)(
void*) );
350 ORTP_PUBLIC
int rtp_session_sendm_with_ts (
RtpSession * session,
mblk_t *mp, uint32_t userts);
352 ORTP_PUBLIC
int rtp_session_recv_with_ts(
RtpSession *session, uint8_t *buffer,
int len, uint32_t ts,
int *have_more);
353 ORTP_PUBLIC
int rtp_session_send_with_ts(
RtpSession *session,
const uint8_t *buffer,
int len, uint32_t userts);
361 ORTP_PUBLIC
float rtp_session_compute_send_bandwidth(
RtpSession *session);
362 ORTP_PUBLIC
float rtp_session_compute_recv_bandwidth(
RtpSession *session);
364 ORTP_PUBLIC
void rtp_session_send_rtcp_APP(
RtpSession *session, uint8_t subtype,
const char *name,
const uint8_t *data,
int datalen);
366 ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(
RtpSession *session);
367 ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(
RtpSession *session);
368 ORTP_PUBLIC
void rtp_session_flush_sockets(
RtpSession *session);
369 ORTP_PUBLIC
void rtp_session_release_sockets(
RtpSession *session);
370 ORTP_PUBLIC
void rtp_session_resync(
RtpSession *session);
371 ORTP_PUBLIC
void rtp_session_reset(
RtpSession *session);
372 ORTP_PUBLIC
void rtp_session_destroy(
RtpSession *session);
376 ORTP_PUBLIC
void rtp_session_reset_stats(
RtpSession *session);
378 ORTP_PUBLIC
void rtp_session_set_data(
RtpSession *session,
void *data);
379 ORTP_PUBLIC
void *rtp_session_get_data(
const RtpSession *session);
381 ORTP_PUBLIC
void rtp_session_set_recv_buf_size(
RtpSession *session,
int bufsize);
382 ORTP_PUBLIC
void rtp_session_set_rtp_socket_send_buffer_size(
RtpSession * session,
unsigned int size);
383 ORTP_PUBLIC
void rtp_session_set_rtp_socket_recv_buffer_size(
RtpSession * session,
unsigned int size);
386 ORTP_PUBLIC uint32_t rtp_session_ts_to_time(
RtpSession *session,uint32_t timestamp);
387 ORTP_PUBLIC uint32_t rtp_session_time_to_ts(
RtpSession *session,
int millisecs);
391 ORTP_PUBLIC
void rtp_session_make_time_distorsion(
RtpSession *session,
int milisec);
394 ORTP_PUBLIC
void rtp_session_set_source_description(
RtpSession *session,
const char *cname,
395 const char *name,
const char *email,
const char *phone,
396 const char *loc,
const char *tool,
const char *note);
397 ORTP_PUBLIC
void rtp_session_add_contributing_source(
RtpSession *session, uint32_t csrc,
398 const char *cname,
const char *name,
const char *email,
const char *phone,
399 const char *loc,
const char *tool,
const char *note);
400 ORTP_PUBLIC
void rtp_session_remove_contributing_sources(
RtpSession *session, uint32_t csrc);
401 ORTP_PUBLIC
mblk_t* rtp_session_create_rtcp_sdes_packet(
RtpSession *session);
403 ORTP_PUBLIC
void rtp_session_get_last_recv_time(
RtpSession *session,
struct timeval *tv);
404 ORTP_PUBLIC
int rtp_session_bye(
RtpSession *session,
const char *reason);
406 ORTP_PUBLIC
int rtp_session_get_last_send_error_code(
RtpSession *session);
407 ORTP_PUBLIC
void rtp_session_clear_send_error_code(
RtpSession *session);
408 ORTP_PUBLIC
int rtp_session_get_last_recv_error_code(
RtpSession *session);
409 ORTP_PUBLIC
void rtp_session_clear_recv_error_code(
RtpSession *session);
412 ORTP_PUBLIC
float rtp_session_get_round_trip_propagation(
RtpSession *session);
416 ORTP_PUBLIC
void rtp_session_rtcp_set_lost_packet_value(
RtpSession *session,
const unsigned int value );
417 ORTP_PUBLIC
void rtp_session_rtcp_set_jitter_value(
RtpSession *session,
const unsigned int value );
418 ORTP_PUBLIC
void rtp_session_rtcp_set_delay_value(
RtpSession *session,
const unsigned int value );
419 ORTP_PUBLIC
mblk_t * rtp_session_pick_with_cseq (
RtpSession * session,
const uint16_t sequence_number);
421 ORTP_PUBLIC
void rtp_session_init(
RtpSession *session,
int mode);
422 #define rtp_session_set_flag(session,flag) (session)->flags|=(flag)
423 #define rtp_session_unset_flag(session,flag) (session)->flags&=~(flag)
424 ORTP_PUBLIC
void rtp_session_uninit(
RtpSession *session);
427 ORTP_PUBLIC
void rtp_session_set_reuseaddr(
RtpSession *session, bool_t yes);