oRTP  0.23.0
rtpsession.h
Go to the documentation of this file.
1  /*
2  The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
3  Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
30 #ifndef RTPSESSION_H
31 #define RTPSESSION_H
32 
33 
34 #include <ortp/port.h>
35 #include <ortp/rtp.h>
36 #include <ortp/payloadtype.h>
37 #include <ortp/rtpprofile.h>
38 #include <ortp/sessionset.h>
39 #include <ortp/rtcp.h>
40 #include <ortp/str_utils.h>
41 #include <ortp/rtpsignaltable.h>
42 #include <ortp/event.h>
43 
44 
45 
46 typedef enum {
47  RTP_SESSION_RECVONLY,
48  RTP_SESSION_SENDONLY,
49  RTP_SESSION_SENDRECV
50 } RtpSessionMode;
51 
52 
55 typedef struct _JBParameters{
56  int min_size;
57  int nom_size;
58  int max_size;
59  bool_t adaptive;
60  bool_t pad[3];
62 } JBParameters;
63 
64 typedef struct _JitterControl
65 {
66  unsigned int count;
67  int jitt_comp; /* the user jitt_comp in miliseconds*/
68  int jitt_comp_ts; /* the jitt_comp converted in rtp time (same unit as timestamp) */
69  int adapt_jitt_comp_ts;
70  int64_t slide;
71  int64_t prev_slide;
72  float jitter;
73  int olddiff;
74  float inter_jitter; /* interarrival jitter as defined in the RFC */
75  int corrective_step;
76  int corrective_slide;
77  uint64_t cum_jitter_buffer_size; /*in timestamp units*/
78  unsigned int cum_jitter_buffer_count; /*used for computation of jitter buffer size*/
79  int clock_rate;
80  bool_t adaptive;
81  bool_t enabled;
83 
84 typedef struct _WaitPoint
85 {
86  ortp_mutex_t lock;
87  ortp_cond_t cond;
88  uint32_t time;
89  bool_t wakeup;
90 } WaitPoint;
91 
92 typedef struct _RtpTransportModifier
93 {
94  void *data;
95  struct _RtpSession *session;//<back pointer to the owning session, set by oRTP
96  int (*t_process_on_send)(struct _RtpTransportModifier *t, mblk_t *msg);
97  int (*t_process_on_receive)(struct _RtpTransportModifier *t, mblk_t *msg);
98  void (*t_process_on_schedule)(struct _RtpTransportModifier *t); /*invoked each time rtp_session_recvm even is no message are available*/
103  void (*t_destroy)(struct _RtpTransportModifier *transport);
105 
106 typedef struct _RtpTransport
107 {
108  void *data;
109  struct _RtpSession *session;//<back pointer to the owning session, set by oRTP
110  ortp_socket_t (*t_getsocket)(struct _RtpTransport *t);
111  int (*t_sendto)(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
112  int (*t_recvfrom)(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
113  void (*t_close)(struct _RtpTransport *transport, void *userData);
118  void (*t_destroy)(struct _RtpTransport *transport);
119 } RtpTransport;
120 
121 
123  int enabled;
124  float max_bandwidth; /*IP bandwidth, in bit/s*/
125  int max_buffer_size; /*Max number of bit buffered before being discarded*/
126  float loss_rate; /*Percentage*/
127  uint32_t latency; /*Packet transmission delay, in ms*/
128  float consecutive_loss_probability;/* a probablity of having a subsequent loss after a loss occured, in a 0-1 range.*/
129  float jitter_burst_density; /*density of gap/bursts events. A value of 1 means one gap/burst per second approximately*/
130  float jitter_strength; /*percentage of max_bandwidth */
132 
135  int bit_budget;
136  int qsize;
137  queue_t q;
138  queue_t latency_q;
139  struct timeval last_check;
140  uint64_t last_jitter_event;
141  int consecutive_drops;
142  int drops_to_ignore;
143  int drop_by_congestion;
144  int drop_by_loss;
145  int total_count; /*total number of packets gone through the simulator*/
146  bool_t in_jitter_event;
148 
149 typedef struct OrtpRtcpSendAlgorithm {
150  uint64_t tn; /* Time of the next scheduled RTCP RR transmission in milliseconds. */
151  uint64_t tp; /* Time of the last scheduled RTCP RR transmission in milliseconds. */
152  uint64_t t_rr_last; /* Time of the last regular RTCP packet sent in milliseconds. */
153  uint32_t T_rr; /* Interval for the scheduling of the next regular RTCP packet. */
154  uint32_t T_max_fb_delay; /* Interval within which a feeback message is considered to be useful to the sender. */
155  uint32_t T_rr_interval; /* Minimal interval to be used between regular RTCP packets. */
156  uint32_t T_rr_current_interval;
157  uint32_t Tmin; /* Minimal interval between RTCP packets. */
158  float avg_rtcp_size;
159  mblk_t *fb_packets;
160  bool_t initialized; /* Whether the RTCP send algorithm is fully initialized. */
161  bool_t initial;
162  bool_t allow_early;
164 
165 #define ORTP_RTCP_XR_UNAVAILABLE_PARAMETER 127
166 
167 typedef enum {
168  OrtpRtcpXrNoPlc,
169  OrtpRtcpXrSilencePlc,
170  OrtpRtcpXrEnhancedPlc
171 } OrtpRtcpXrPlcStatus;
172 
173 typedef OrtpRtcpXrPlcStatus (*OrtpRtcpXrPlcCallback)(unsigned long userdata);
174 typedef int (*OrtpRtcpXrSignalLevelCallback)(unsigned long userdata);
175 typedef int (*OrtpRtcpXrNoiseLevelCallback)(unsigned long userdata);
176 typedef float (*OrtpRtcpXrAverageQualityIndicatorCallback)(unsigned long userdata);
177 
178 typedef struct OrtpRtcpXrMediaCallbacks {
179  OrtpRtcpXrPlcCallback plc;
180  OrtpRtcpXrSignalLevelCallback signal_level;
181  OrtpRtcpXrNoiseLevelCallback noise_level;
182  OrtpRtcpXrAverageQualityIndicatorCallback average_qi;
183  OrtpRtcpXrAverageQualityIndicatorCallback average_lq_qi;
184  unsigned long userdata;
186 
187 typedef enum {
188  OrtpRtcpXrRcvrRttNone,
189  OrtpRtcpXrRcvrRttAll,
190  OrtpRtcpXrRcvrRttSender
191 } OrtpRtcpXrRcvrRttMode;
192 
193 typedef enum {
194  OrtpRtcpXrStatSummaryLoss = (1 << 7),
195  OrtpRtcpXrStatSummaryDup = (1 << 6),
196  OrtpRtcpXrStatSummaryJitt = (1 << 5),
197  OrtpRtcpXrStatSummaryTTL = (1 << 3),
198  OrtpRtcpXrStatSummaryHL = (1 << 4)
199 } OrtpRtcpXrStatSummaryFlag;
200 
201 typedef struct OrtpRtcpXrConfiguration {
202  bool_t enabled;
203  bool_t stat_summary_enabled;
204  bool_t voip_metrics_enabled;
205  OrtpRtcpXrRcvrRttMode rcvr_rtt_mode;
206  int rcvr_rtt_max_size;
207  OrtpRtcpXrStatSummaryFlag stat_summary_flags;
209 
210 typedef struct OrtpRtcpXrStats {
211  uint32_t last_rcvr_rtt_ts; /* NTP timestamp (middle 32 bits) of last received XR rcvr-rtt */
212  struct timeval last_rcvr_rtt_time; /* Time at which last XR rcvr-rtt was received */
213  uint16_t rcv_seq_at_last_stat_summary; /* Received sequence number at last XR stat-summary sent */
214  uint32_t rcv_since_last_stat_summary; /* The number of packets received since last XR stat-summary was sent */
215  uint32_t dup_since_last_stat_summary; /* The number of duplicate packets received since last XR stat-summary was sent */
216  uint32_t min_jitter_since_last_stat_summary; /* The minimum value of jitter since last XR stat-summary was sent */
217  uint32_t max_jitter_since_last_stat_summary; /* The maximum value of jitter since last XR stat-summary was sent */
218  double olds_jitter_since_last_stat_summary;
219  double oldm_jitter_since_last_stat_summary;
220  double news_jitter_since_last_stat_summary;
221  double newm_jitter_since_last_stat_summary;
222  int64_t last_jitter_diff_since_last_stat_summary;
223  double olds_ttl_or_hl_since_last_stat_summary;
224  double oldm_ttl_or_hl_since_last_stat_summary;
225  double news_ttl_or_hl_since_last_stat_summary;
226  double newm_ttl_or_hl_since_last_stat_summary;
227  uint8_t min_ttl_or_hl_since_last_stat_summary; /* The minimum value of TTL/HL since last XR stat-summary was sent */
228  uint8_t max_ttl_or_hl_since_last_stat_summary; /* The maximum value of TTL/HL since last XR stat-summary was sent */
229  uint32_t first_rcv_seq;
230  uint32_t last_rcv_seq;
231  uint32_t rcv_count;
232  uint32_t discarded_count;
234 
235 typedef struct _OrtpAddress{
236  struct sockaddr_storage addr;
237  socklen_t len;
238 }OrtpAddress;
239 
240 typedef struct _OrtpStream {
241  ortp_socket_t socket;
242  int sockfamily;
243  int loc_port;
244  socklen_t rem_addrlen;
245  struct sockaddr_storage rem_addr;
246  socklen_t loc_addrlen;
247  struct sockaddr_storage loc_addr;
248  struct _RtpTransport *tr;
249  mblk_t *cached_mp;
250  struct timeval send_bw_start; /* used for bandwidth estimation */
251  struct timeval recv_bw_start; /* used for bandwidth estimation */
252  unsigned int sent_bytes; /* used for bandwidth estimation */
253  unsigned int recv_bytes; /* used for bandwidth estimation */
254  float upload_bw;
255  float download_bw;
256  OList *aux_destinations; /*list of OrtpAddress */
257 } OrtpStream;
258 
259 typedef struct _RtpStream
260 {
261  OrtpStream gs;
262  int max_rq_size;
263  int time_jump;
264  uint32_t ts_jump;
265  queue_t rq;
266  queue_t tev_rq;
267  void *QoSHandle;
268  unsigned long QoSFlowID;
269  JitterControl jittctl;
270  uint32_t snd_time_offset;/*the scheduler time when the application send its first timestamp*/
271  uint32_t snd_ts_offset; /* the first application timestamp sent by the application */
272  uint32_t snd_rand_offset; /* a random number added to the user offset to make the stream timestamp*/
273  uint32_t snd_last_ts; /* the last stream timestamp sended */
274  uint32_t rcv_time_offset; /*the scheduler time when the application ask for its first timestamp*/
275  uint32_t rcv_ts_offset; /* the first stream timestamp */
276  uint32_t rcv_query_ts_offset; /* the first user timestamp asked by the application */
277  uint32_t rcv_last_ts; /* the last stream timestamp got by the application */
278  uint16_t rcv_last_seq; /* the last stream sequence number got by the application*/
279  uint16_t pad;
280  uint32_t rcv_last_app_ts; /* the last application timestamp asked by the application */
281  uint32_t rcv_last_ret_ts; /* the timestamp of the last sample returned (only for continuous audio)*/
282  uint32_t hwrcv_extseq; /* last received on socket extended sequence number */
283  uint32_t hwrcv_seq_at_last_SR;
284  uint32_t hwrcv_since_last_SR;
285  uint32_t last_rcv_SR_ts; /* NTP timestamp (middle 32 bits) of last received SR */
286  struct timeval last_rcv_SR_time; /* time at which last SR was received */
287  uint16_t snd_seq; /* send sequence number */
288  uint32_t last_rtcp_packet_count; /*the sender's octet count in the last sent RTCP SR*/
289  uint32_t sent_payload_bytes; /*used for RTCP sender reports*/
290  rtp_stats_t stats;
291  int recv_errno;
292  int send_errno;
293  int snd_socket_size;
294  int rcv_socket_size;
295  int ssrc_changed_thres;
297 }RtpStream;
298 
299 typedef struct _RtcpStream
300 {
301  OrtpStream gs;
302  OrtpRtcpSendAlgorithm send_algo;
303  OrtpRtcpXrConfiguration xr_conf;
304  OrtpRtcpXrMediaCallbacks xr_media_callbacks;
305  bool_t enabled; /*tells whether we can send RTCP packets */
306  bool_t rtcp_xr_dlrr_to_send;
307  uint8_t rtcp_fb_fir_seq_nr; /* The FIR command sequence number */
308  uint32_t last_rtcp_fb_pli_snt;
309 } RtcpStream;
310 
311 typedef struct _RtpSession RtpSession;
312 
313 
323 {
324  RtpSession *next; /* next RtpSession, when the session are enqueued by the scheduler */
325  int mask_pos; /* the position in the scheduler mask of RtpSession : do not move this field: it is part of the ABI since the session_set macros use it*/
326  struct {
327  RtpProfile *profile;
328  int pt;
329  unsigned int ssrc;
330  WaitPoint wp;
331  } snd,rcv;
332  unsigned int inc_ssrc_candidate;
333  int inc_same_ssrc_count;
334  int hw_recv_pt; /* recv payload type before jitter buffer */
335  int recv_buf_size;
336  int target_upload_bandwidth; /* Target upload bandwidth at nework layer (with IP and UDP headers) in bits/s */
337  RtpSignalTable on_ssrc_changed;
338  RtpSignalTable on_payload_type_changed;
339  RtpSignalTable on_telephone_event_packet;
340  RtpSignalTable on_telephone_event;
341  RtpSignalTable on_timestamp_jump;
342  RtpSignalTable on_network_error;
343  RtpSignalTable on_rtcp_bye;
344  struct _OList *signal_tables;
345  struct _OList *eventqs;
346  msgb_allocator_t allocator;
347  RtpStream rtp;
348  RtcpStream rtcp;
349  OrtpRtcpXrStats rtcp_xr_stats;
350  RtpSessionMode mode;
351  struct _RtpScheduler *sched;
352  uint32_t flags;
353  int dscp;
354  int multicast_ttl;
355  int multicast_loopback;
356  float duplication_ratio; /* Number of times a packet should be duplicated */
357  float duplication_left ; /* Remainder of the duplication ratio */
358  void * user_data;
359  /* FIXME: Should be a table for all session participants. */
360  struct timeval last_recv_time; /* Time of receiving the RTP/RTCP packet. */
361  mblk_t *pending;
362  /* telephony events extension */
363  mblk_t *current_tev; /* the pending telephony events */
364  mblk_t *minimal_sdes;
365  mblk_t *full_sdes;
366  queue_t contributing_sources;
367  int64_t lost_packets_test_vector;
368  unsigned int interarrival_jitter_test_vector;
369  unsigned int delay_test_vector;
370  float rtt;/*last round trip delay calculated*/
371  int cum_loss;
372  OrtpNetworkSimulatorCtx *net_sim_ctx;
373  bool_t symmetric_rtp;
374  bool_t permissive; /*use the permissive algorithm*/
375  bool_t use_connect; /* use connect() on the socket */
376  bool_t ssrc_set;
377  bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
378 };
379 
380 
381 
382 
383 #ifdef __cplusplus
384 extern "C"
385 {
386 #endif
387 
388 /* public API */
389 ORTP_PUBLIC RtpSession *rtp_session_new(int mode);
390 ORTP_PUBLIC void rtp_session_set_scheduling_mode(RtpSession *session, int yesno);
391 ORTP_PUBLIC void rtp_session_set_blocking_mode(RtpSession *session, int yesno);
392 ORTP_PUBLIC void rtp_session_set_profile(RtpSession *session, RtpProfile *profile);
393 ORTP_PUBLIC void rtp_session_set_send_profile(RtpSession *session,RtpProfile *profile);
394 ORTP_PUBLIC void rtp_session_set_recv_profile(RtpSession *session,RtpProfile *profile);
395 ORTP_PUBLIC RtpProfile *rtp_session_get_profile(RtpSession *session);
396 ORTP_PUBLIC RtpProfile *rtp_session_get_send_profile(RtpSession *session);
397 ORTP_PUBLIC RtpProfile *rtp_session_get_recv_profile(RtpSession *session);
398 ORTP_PUBLIC int rtp_session_signal_connect(RtpSession *session,const char *signal_name, RtpCallback cb, void *user_data);
399 ORTP_PUBLIC int rtp_session_signal_disconnect_by_callback(RtpSession *session,const char *signal_name, RtpCallback cb);
400 ORTP_PUBLIC void rtp_session_set_ssrc(RtpSession *session, uint32_t ssrc);
401 ORTP_PUBLIC uint32_t rtp_session_get_send_ssrc(RtpSession* session);
402 ORTP_PUBLIC uint32_t rtp_session_get_recv_ssrc(RtpSession *session);
403 ORTP_PUBLIC void rtp_session_set_seq_number(RtpSession *session, uint16_t seq);
404 ORTP_PUBLIC uint16_t rtp_session_get_seq_number(RtpSession *session);
405 ORTP_PUBLIC uint32_t rtp_session_get_rcv_ext_seq_number(RtpSession *session);
406 ORTP_PUBLIC int rtp_session_get_cum_loss(RtpSession *session);
407 ORTP_PUBLIC void rtp_session_set_duplication_ratio(RtpSession *session, float ratio);
408 
409 ORTP_PUBLIC void rtp_session_enable_jitter_buffer(RtpSession *session , bool_t enabled);
410 ORTP_PUBLIC bool_t rtp_session_jitter_buffer_enabled(const RtpSession *session);
411 ORTP_PUBLIC void rtp_session_set_jitter_buffer_params(RtpSession *session, const JBParameters *par);
412 ORTP_PUBLIC void rtp_session_get_jitter_buffer_params(RtpSession *session, JBParameters *par);
413 
414 /*deprecated jitter control functions*/
415 ORTP_PUBLIC void rtp_session_set_jitter_compensation(RtpSession *session, int milisec);
416 ORTP_PUBLIC void rtp_session_enable_adaptive_jitter_compensation(RtpSession *session, bool_t val);
417 ORTP_PUBLIC bool_t rtp_session_adaptive_jitter_compensation_enabled(RtpSession *session);
418 
419 ORTP_PUBLIC void rtp_session_set_time_jump_limit(RtpSession *session, int miliseconds);
420 ORTP_PUBLIC int rtp_session_join_multicast_group(RtpSession *session, const char *ip);
421 ORTP_PUBLIC int rtp_session_set_local_addr(RtpSession *session,const char *addr, int rtp_port, int rtcp_port);
422 ORTP_PUBLIC int rtp_session_get_local_port(const RtpSession *session);
423 ORTP_PUBLIC int rtp_session_get_local_rtcp_port(const RtpSession *session);
424 
425 ORTP_PUBLIC int
426 rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port);
427 /*same as previous function, old name:*/
428 ORTP_PUBLIC int rtp_session_set_remote_addr_and_port (RtpSession * session, const char * addr, int rtp_port, int rtcp_port);
429 ORTP_PUBLIC int rtp_session_set_remote_addr(RtpSession *session,const char *addr, int port);
430 ORTP_PUBLIC int rtp_session_add_aux_remote_addr_full(RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port);
431 ORTP_PUBLIC void rtp_session_clear_aux_remote_addr(RtpSession * session);
432 /* alternatively to the set_remote_addr() and set_local_addr(), an application can give
433 a valid socket (potentially connect()ed )to be used by the RtpSession */
434 ORTP_PUBLIC void rtp_session_set_sockets(RtpSession *session, int rtpfd, int rtcpfd);
435 
436 ORTP_PUBLIC void rtp_session_get_transports(const RtpSession *session, RtpTransport **rtptr, RtpTransport **rtcptr);
437 /*those methods are provided for people who wants to send non-RTP messages using the RTP/RTCP sockets */
438 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session);
439 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtcp_socket(const RtpSession *session);
440 
441 
442 /* QOS / DSCP */
443 ORTP_PUBLIC int rtp_session_set_dscp(RtpSession *session, int dscp);
444 ORTP_PUBLIC int rtp_session_get_dscp(const RtpSession *session);
445 
446 
447 /* Packet info */
448 ORTP_PUBLIC int rtp_session_set_pktinfo(RtpSession *session, int activate);
449 
450 /* Multicast methods */
451 ORTP_PUBLIC int rtp_session_set_multicast_ttl(RtpSession *session, int ttl);
452 ORTP_PUBLIC int rtp_session_get_multicast_ttl(RtpSession *session);
453 
454 ORTP_PUBLIC int rtp_session_set_multicast_loopback(RtpSession *session, int yesno);
455 ORTP_PUBLIC int rtp_session_get_multicast_loopback(RtpSession *session);
456 
457 
458 
459 ORTP_PUBLIC int rtp_session_set_send_payload_type(RtpSession *session, int paytype);
460 ORTP_PUBLIC int rtp_session_get_send_payload_type(const RtpSession *session);
461 
462 ORTP_PUBLIC int rtp_session_get_recv_payload_type(const RtpSession *session);
463 ORTP_PUBLIC int rtp_session_set_recv_payload_type(RtpSession *session, int pt);
464 
465 ORTP_PUBLIC int rtp_session_set_payload_type(RtpSession *session, int pt);
466 
467 ORTP_PUBLIC void rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yesno);
468 
469 ORTP_PUBLIC void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno);
470 
471 ORTP_PUBLIC void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno);
472 
473 ORTP_PUBLIC void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms);
474 
475 ORTP_PUBLIC void rtp_session_set_target_upload_bandwidth(RtpSession *session, int target_bandwidth);
476 
477 ORTP_PUBLIC void rtp_session_configure_rtcp_xr(RtpSession *session, const OrtpRtcpXrConfiguration *config);
478 ORTP_PUBLIC void rtp_session_set_rtcp_xr_media_callbacks(RtpSession *session, const OrtpRtcpXrMediaCallbacks *cbs);
479 
480 ORTP_PUBLIC void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int numpackets);
481 
482 /*low level recv and send functions */
483 ORTP_PUBLIC mblk_t * rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts);
484 ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const uint8_t *payload, int payload_size);
485 ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size);
486 ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, int payload_size, void (*freefn)(void*));
487 ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, int size, void (*freefn)(void*) );
488 ORTP_PUBLIC int rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t userts);
489 /* high level recv and send functions */
490 ORTP_PUBLIC int rtp_session_recv_with_ts(RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more);
491 ORTP_PUBLIC int rtp_session_send_with_ts(RtpSession *session, const uint8_t *buffer, int len, uint32_t userts);
492 
493 /* event API*/
494 ORTP_PUBLIC void rtp_session_register_event_queue(RtpSession *session, OrtpEvQueue *q);
495 ORTP_PUBLIC void rtp_session_unregister_event_queue(RtpSession *session, OrtpEvQueue *q);
496 
497 
498 /* IP bandwidth usage estimation functions, returning bits/s*/
499 ORTP_PUBLIC float rtp_session_compute_send_bandwidth(RtpSession *session);
500 ORTP_PUBLIC float rtp_session_compute_recv_bandwidth(RtpSession *session);
501 ORTP_PUBLIC float rtp_session_get_send_bandwidth(RtpSession *session);
502 ORTP_PUBLIC float rtp_session_get_recv_bandwidth(RtpSession *session);
503 ORTP_PUBLIC float rtp_session_get_rtp_send_bandwidth(RtpSession *session);
504 ORTP_PUBLIC float rtp_session_get_rtp_recv_bandwidth(RtpSession *session);
505 ORTP_PUBLIC float rtp_session_get_rtcp_send_bandwidth(RtpSession *session);
506 ORTP_PUBLIC float rtp_session_get_rtcp_recv_bandwidth(RtpSession *session);
507 
508 ORTP_PUBLIC void rtp_session_send_rtcp_APP(RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen);
509 
510 ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(RtpSession *session);
511 ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(RtpSession *session);
512 ORTP_PUBLIC void rtp_session_flush_sockets(RtpSession *session);
513 ORTP_PUBLIC void rtp_session_release_sockets(RtpSession *session);
514 ORTP_PUBLIC void rtp_session_resync(RtpSession *session);
515 ORTP_PUBLIC void rtp_session_reset(RtpSession *session);
516 ORTP_PUBLIC void rtp_session_destroy(RtpSession *session);
517 
518 ORTP_PUBLIC const rtp_stats_t * rtp_session_get_stats(const RtpSession *session);
519 ORTP_PUBLIC const jitter_stats_t * rtp_session_get_jitter_stats( const RtpSession *session );
520 ORTP_PUBLIC void rtp_session_reset_stats(RtpSession *session);
521 
522 ORTP_PUBLIC void rtp_session_set_data(RtpSession *session, void *data);
523 ORTP_PUBLIC void *rtp_session_get_data(const RtpSession *session);
524 
525 ORTP_PUBLIC void rtp_session_set_recv_buf_size(RtpSession *session, int bufsize);
526 ORTP_PUBLIC void rtp_session_set_rtp_socket_send_buffer_size(RtpSession * session, unsigned int size);
527 ORTP_PUBLIC void rtp_session_set_rtp_socket_recv_buffer_size(RtpSession * session, unsigned int size);
528 
529 /* in use with the scheduler to convert a timestamp in scheduler time unit (ms) */
530 ORTP_PUBLIC uint32_t rtp_session_ts_to_time(RtpSession *session,uint32_t timestamp);
531 ORTP_PUBLIC uint32_t rtp_session_time_to_ts(RtpSession *session, int millisecs);
532 /* this function aims at simulating senders with "imprecise" clocks, resulting in
533 rtp packets sent with timestamp uncorrelated with the system clock .
534 This is only availlable to sessions working with the oRTP scheduler */
535 ORTP_PUBLIC void rtp_session_make_time_distorsion(RtpSession *session, int milisec);
536 
537 /*RTCP functions */
538 ORTP_PUBLIC void rtp_session_set_source_description(RtpSession *session, const char *cname,
539  const char *name, const char *email, const char *phone,
540  const char *loc, const char *tool, const char *note);
541 ORTP_PUBLIC void rtp_session_add_contributing_source(RtpSession *session, uint32_t csrc,
542  const char *cname, const char *name, const char *email, const char *phone,
543  const char *loc, const char *tool, const char *note);
544 /* DEPRECATED: Use rtp_session_remove_contributing_source instead of rtp_session_remove_contributing_sources */
545 #define rtp_session_remove_contributing_sources rtp_session_remove_contributing_source
546 ORTP_PUBLIC void rtp_session_remove_contributing_source(RtpSession *session, uint32_t csrc);
547 ORTP_PUBLIC mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session, bool_t full);
548 
549 ORTP_PUBLIC void rtp_session_get_last_recv_time(RtpSession *session, struct timeval *tv);
550 ORTP_PUBLIC int rtp_session_bye(RtpSession *session, const char *reason);
551 
552 ORTP_PUBLIC int rtp_session_get_last_send_error_code(RtpSession *session);
553 ORTP_PUBLIC void rtp_session_clear_send_error_code(RtpSession *session);
554 ORTP_PUBLIC int rtp_session_get_last_recv_error_code(RtpSession *session);
555 ORTP_PUBLIC void rtp_session_clear_recv_error_code(RtpSession *session);
556 
557 
558 ORTP_PUBLIC float rtp_session_get_round_trip_propagation(RtpSession *session);
559 
560 
561 ORTP_PUBLIC void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetworkSimulatorParams *params);
562 ORTP_PUBLIC void rtp_session_rtcp_set_lost_packet_value( RtpSession *session, const int64_t value );
563 ORTP_PUBLIC void rtp_session_rtcp_set_jitter_value(RtpSession *session, const unsigned int value );
564 ORTP_PUBLIC void rtp_session_rtcp_set_delay_value(RtpSession *session, const unsigned int value );
565 ORTP_PUBLIC mblk_t * rtp_session_pick_with_cseq (RtpSession * session, const uint16_t sequence_number);
566 
567 
568 ORTP_PUBLIC void rtp_session_send_rtcp_xr_rcvr_rtt(RtpSession *session);
569 ORTP_PUBLIC void rtp_session_send_rtcp_xr_dlrr(RtpSession *session);
570 ORTP_PUBLIC void rtp_session_send_rtcp_xr_stat_summary(RtpSession *session);
571 ORTP_PUBLIC void rtp_session_send_rtcp_xr_voip_metrics(RtpSession *session);
572 
573 
574 ORTP_PUBLIC bool_t rtp_session_avpf_enabled(RtpSession *session);
575 ORTP_PUBLIC bool_t rtp_session_avpf_feature_enabled(RtpSession *session, unsigned char feature);
576 ORTP_PUBLIC uint16_t rtp_session_get_avpf_rr_interval(RtpSession *session);
577 ORTP_PUBLIC void rtp_session_send_rtcp_fb_pli(RtpSession *session);
578 ORTP_PUBLIC void rtp_session_send_rtcp_fb_fir(RtpSession *session);
579 ORTP_PUBLIC void rtp_session_send_rtcp_fb_sli(RtpSession *session, uint16_t first, uint16_t number, uint8_t picture_id);
580 ORTP_PUBLIC void rtp_session_send_rtcp_fb_rpsi(RtpSession *session, uint8_t *bit_string, uint16_t bit_string_len);
581 
582 
583 /*private */
584 ORTP_PUBLIC void rtp_session_init(RtpSession *session, int mode);
585 #define rtp_session_set_flag(session,flag) (session)->flags|=(flag)
586 #define rtp_session_unset_flag(session,flag) (session)->flags&=~(flag)
587 ORTP_PUBLIC void rtp_session_uninit(RtpSession *session);
588 ORTP_PUBLIC void rtp_session_dispatch_event(RtpSession *session, OrtpEvent *ev);
589 
590 ORTP_PUBLIC void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes);
591 
592 
593 ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags);
605 ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags,const struct sockaddr *to, socklen_t tolen) ;
606 
613 ORTP_PUBLIC RtpTransport* meta_rtp_transport_get_endpoint(const RtpTransport *transport);
620 ORTP_PUBLIC void meta_rtp_transport_set_endpoint(RtpTransport *transport,RtpTransport *endpoint);
621 
622 ORTP_PUBLIC void meta_rtp_transport_destroy(RtpTransport *tp);
623 ORTP_PUBLIC void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm);
624 #ifdef __cplusplus
625 }
626 #endif
627 
628 #endif
ORTP_PUBLIC int rtp_session_set_payload_type(RtpSession *session, int pt)
Definition: rtpsession.c:750
ORTP_PUBLIC RtpProfile * rtp_session_get_send_profile(RtpSession *session)
Definition: rtpsession.c:483
ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, int payload_size, void(*freefn)(void *))
Definition: rtpsession.c:831
Definition: rtpsession.h:299
Definition: rtpsession.h:210
Definition: rtpsession.h:201
ORTP_PUBLIC void rtp_session_rtcp_set_delay_value(RtpSession *session, const unsigned int value)
For test purpose only, simulates a constant RTT (Round Trip Time) value by setting the LSR field with...
Definition: rtpsession.c:1660
ORTP_PUBLIC void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno)
Definition: rtpsession.c:1715
ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags, const struct sockaddr *to, socklen_t tolen)
Definition: rtpsession.c:2072
ORTP_PUBLIC int rtp_session_get_multicast_ttl(RtpSession *session)
Definition: rtpsession_inet.c:510
ORTP_PUBLIC void rtp_session_rtcp_set_jitter_value(RtpSession *session, const unsigned int value)
For test purpose only, sets a constant interarrival_jitter value within all RTCP output packets...
Definition: rtpsession.c:1634
Definition: rtpsession.h:122
ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size)
Definition: rtpsession.c:804
ORTP_PUBLIC uint32_t rtp_session_get_rcv_ext_seq_number(RtpSession *session)
Definition: rtpsession.c:623
int max_packets
Definition: rtpsession.h:61
ORTP_PUBLIC int rtp_session_get_dscp(const RtpSession *session)
Definition: rtpsession_inet.c:712
Definition of payload types.
ORTP_PUBLIC int rtp_session_set_remote_addr_full(RtpSession *session, const char *rtp_addr, int rtp_port, const char *rtcp_addr, int rtcp_port)
Definition: rtpsession_inet.c:769
ORTP_PUBLIC uint32_t rtp_session_get_recv_ssrc(RtpSession *session)
Definition: rtpsession.c:663
Definition: rtpsession.h:322
ORTP_PUBLIC void rtp_session_flush_sockets(RtpSession *session)
Definition: rtpsession_inet.c:979
Definition: str_utils.h:49
Definition: rtpsession.h:235
ORTP_PUBLIC RtpProfile * rtp_session_get_recv_profile(RtpSession *session)
Definition: rtpsession.c:493
ORTP_PUBLIC uint16_t rtp_session_get_seq_number(RtpSession *session)
Definition: rtpsession.c:616
ORTP_PUBLIC void rtp_session_set_recv_buf_size(RtpSession *session, int bufsize)
Definition: rtpsession.c:505
ORTP_PUBLIC RtpSession * rtp_session_new(int mode)
Definition: rtpsession.c:318
ORTP_PUBLIC mblk_t * rtp_session_recvm_with_ts(RtpSession *session, uint32_t user_ts)
Definition: rtpsession.c:1083
ORTP_PUBLIC int rtp_session_set_multicast_loopback(RtpSession *session, int yesno)
Definition: rtpsession_inet.c:526
Definition: rtpsession.h:259
ORTP_PUBLIC int rtp_session_set_local_addr(RtpSession *session, const char *addr, int rtp_port, int rtcp_port)
Definition: rtpsession_inet.c:339
ORTP_PUBLIC const jitter_stats_t * rtp_session_get_jitter_stats(const RtpSession *session)
Definition: rtpsession.c:1611
ORTP_PUBLIC int rtp_session_set_multicast_ttl(RtpSession *session, int ttl)
Definition: rtpsession_inet.c:459
Definition: rtpsession.h:84
int min_size
Definition: rtpsession.h:56
ORTP_PUBLIC void rtp_session_destroy(RtpSession *session)
Definition: rtpsession.c:1825
Definition: rtpsession.h:149
Definition: rtpsession.h:178
Definition: rtpsignaltable.h:27
ORTP_PUBLIC void rtp_session_set_blocking_mode(RtpSession *session, int yesno)
Definition: rtpsession.c:380
Definition: str_utils.h:78
ORTP_PUBLIC float rtp_session_get_send_bandwidth(RtpSession *session)
Definition: rtpsession.c:1768
ORTP_PUBLIC int rtp_session_get_local_port(const RtpSession *session)
Definition: rtpsession_inet.c:728
ORTP_PUBLIC void rtp_session_get_last_recv_time(RtpSession *session, struct timeval *tv)
Definition: rtpsession.c:1916
ORTP_PUBLIC int rtp_session_get_cum_loss(RtpSession *session)
Definition: rtpsession.c:630
ORTP_PUBLIC void rtp_session_set_rtp_socket_recv_buffer_size(RtpSession *session, unsigned int size)
Definition: rtpsession.c:521
struct _JBParameters JBParameters
Definition: rtp.h:79
int max_size
Definition: rtpsession.h:58
ORTP_PUBLIC int rtp_session_get_multicast_loopback(RtpSession *session)
Definition: rtpsession_inet.c:582
ORTP_PUBLIC int rtp_session_signal_connect(RtpSession *session, const char *signal_name, RtpCallback cb, void *user_data)
Definition: rtpsession.c:559
ORTP_PUBLIC uint32_t rtp_session_get_send_ssrc(RtpSession *session)
Definition: rtpsession.c:653
ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags)
Definition: rtpsession.c:2050
ORTP_PUBLIC void rtp_session_set_time_jump_limit(RtpSession *session, int miliseconds)
Definition: rtpsession.c:1374
Definition: event.h:82
Definition: rtpsession.h:133
ORTP_PUBLIC int rtp_session_recv_with_ts(RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more)
Definition: rtpsession.c:1273
Definition: utils.h:33
ORTP_PUBLIC void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int numpackets)
Definition: rtpsession.c:1541
Definition: rtpsession.h:106
ORTP_PUBLIC mblk_t * rtp_session_pick_with_cseq(RtpSession *session, const uint16_t sequence_number)
Definition: rtpsession.c:1040
ORTP_PUBLIC void rtp_session_set_recv_profile(RtpSession *session, RtpProfile *profile)
Definition: rtpsession.c:459
Definition: rtp.h:63
ORTP_PUBLIC void rtp_session_reset(RtpSession *session)
Definition: rtpsession.c:1575
ORTP_PUBLIC float rtp_session_get_recv_bandwidth(RtpSession *session)
Definition: rtpsession.c:1760
ORTP_PUBLIC int rtp_session_set_pktinfo(RtpSession *session, int activate)
Definition: rtpsession_inet.c:399
ORTP_PUBLIC void rtp_session_set_seq_number(RtpSession *session, uint16_t seq)
Definition: rtpsession.c:604
ORTP_PUBLIC int rtp_session_send_with_ts(RtpSession *session, const uint8_t *buffer, int len, uint32_t userts)
Definition: rtpsession.c:1003
Definition: rtpsession.h:240
ORTP_PUBLIC int rtp_session_set_recv_payload_type(RtpSession *session, int pt)
Definition: rtpsession.c:720
ORTP_PUBLIC int rtp_session_add_aux_remote_addr_full(RtpSession *session, const char *rtp_addr, int rtp_port, const char *rtcp_addr, int rtcp_port)
Definition: rtpsession_inet.c:930
ORTP_PUBLIC RtpTransport * meta_rtp_transport_get_endpoint(const RtpTransport *transport)
Definition: rtpsession.c:2196
ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session, uint8_t *buffer, int size, void(*freefn)(void *))
Definition: rtpsession.c:863
ORTP_PUBLIC void rtp_session_set_send_profile(RtpSession *session, RtpProfile *profile)
Definition: rtpsession.c:441
Definition: rtpsession.h:55
ORTP_PUBLIC void rtp_session_set_source_description(RtpSession *session, const char *cname, const char *name, const char *email, const char *phone, const char *loc, const char *tool, const char *note)
Definition: rtcp.c:128
int nom_size
Definition: rtpsession.h:57
ORTP_PUBLIC void rtp_session_set_data(RtpSession *session, void *data)
Definition: rtpsession.c:1675
Definition: str_utils.h:152
ORTP_PUBLIC void rtp_session_set_symmetric_rtp(RtpSession *session, bool_t yesno)
Definition: rtpsession.c:1697
void(* t_destroy)(struct _RtpTransport *transport)
Definition: rtpsession.h:118
Definition: scheduler.h:28
ORTP_PUBLIC void rtp_session_set_rtp_socket_send_buffer_size(RtpSession *session, unsigned int size)
Definition: rtpsession.c:513
ORTP_PUBLIC void rtp_session_set_profile(RtpSession *session, RtpProfile *profile)
Definition: rtpsession.c:399
ORTP_PUBLIC void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno)
Definition: rtpsession.c:414
ORTP_PUBLIC RtpProfile * rtp_session_get_profile(RtpSession *session)
Definition: rtpsession.c:472
ORTP_PUBLIC const rtp_stats_t * rtp_session_get_stats(const RtpSession *session)
Definition: rtpsession.c:1604
ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(RtpSession *session)
Definition: rtpsession.c:1347
ORTP_PUBLIC int rtp_session_set_send_payload_type(RtpSession *session, int paytype)
Definition: rtpsession.c:693
Sending and receiving multiple streams together with only one thread.
ORTP_PUBLIC void meta_rtp_transport_set_endpoint(RtpTransport *transport, RtpTransport *endpoint)
Definition: rtpsession.c:2200
ORTP_PUBLIC void rtp_session_release_sockets(RtpSession *session)
Definition: rtpsession.c:1385
ORTP_PUBLIC void rtp_session_rtcp_set_lost_packet_value(RtpSession *session, const int64_t value)
For test purpose only, sets a constant lost packet value within all RTCP output packets. .
Definition: rtpsession.c:1622
ORTP_PUBLIC int rtp_session_signal_disconnect_by_callback(RtpSession *session, const char *signal_name, RtpCallback cb)
Definition: rtpsession.c:583
ORTP_PUBLIC void rtp_session_set_ssrc(RtpSession *session, uint32_t ssrc)
Definition: rtpsession.c:642
ORTP_PUBLIC int rtp_session_get_recv_payload_type(const RtpSession *session)
Definition: rtpsession.c:737
ORTP_PUBLIC float rtp_session_get_round_trip_propagation(RtpSession *session)
Definition: rtpsession.c:1815
Using and creating standart and custom RTP profiles.
ORTP_PUBLIC int rtp_session_get_send_payload_type(const RtpSession *session)
Definition: rtpsession.c:704
Definition: rtpprofile.h:41
ORTP_PUBLIC int rtp_session_set_dscp(RtpSession *session, int dscp)
Definition: rtpsession_inet.c:597
Definition: rtpsession.h:64
Definition: rtpsession.h:92
ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session, int header_size, const uint8_t *payload, int payload_size)
Definition: rtpsession.c:782
void(* t_destroy)(struct _RtpTransportModifier *transport)
Definition: rtpsession.h:103
ORTP_PUBLIC int rtp_session_bye(RtpSession *session, const char *reason)
Definition: rtcp.c:627
ORTP_PUBLIC void rtp_session_set_scheduling_mode(RtpSession *session, int yesno)
Definition: rtpsession.c:345
ORTP_PUBLIC void rtp_session_set_jitter_compensation(RtpSession *session, int milisec)
Definition: jitterctl.c:164
ORTP_PUBLIC int rtp_session_set_remote_addr(RtpSession *session, const char *addr, int port)
Definition: rtpsession_inet.c:749
ORTP_PUBLIC int rtp_session_sendm_with_ts(RtpSession *session, mblk_t *mp, uint32_t userts)
Definition: rtpsession.c:983
ORTP_PUBLIC void * rtp_session_get_data(const RtpSession *session)
Definition: rtpsession.c:1683
ORTP_PUBLIC void rtp_session_register_event_queue(RtpSession *session, OrtpEvQueue *q)
Definition: rtpsession.c:1424
ORTP_PUBLIC void rtp_session_resync(RtpSession *session)
Definition: rtpsession.c:1551
ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(RtpSession *session)
Definition: rtpsession.c:1321
ORTP_PUBLIC void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms)
Definition: rtpsession.c:422