oRTP  0.25.0
include/ortp/rtpsession.h
Go to the documentation of this file.
00001  /*
00002   The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
00003   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00030 #ifndef RTPSESSION_H
00031 #define RTPSESSION_H
00032 
00033 
00034 #include <ortp/port.h>
00035 #include <ortp/rtp.h>
00036 #include <ortp/payloadtype.h>
00037 #include <ortp/rtpprofile.h>
00038 #include <ortp/sessionset.h>
00039 #include <ortp/rtcp.h>
00040 #include <ortp/str_utils.h>
00041 #include <ortp/rtpsignaltable.h>
00042 #include <ortp/event.h>
00043 
00044 
00045 #define ORTP_AVPF_FEATURE_NONE 0
00046 #define ORTP_AVPF_FEATURE_TMMBR (1 << 0)
00047 #define ORTP_AVPF_FEATURE_GENERIC_NACK (1 << 1)
00048 
00049 
00050 typedef enum {
00051         RTP_SESSION_RECVONLY,
00052         RTP_SESSION_SENDONLY,
00053         RTP_SESSION_SENDRECV
00054 } RtpSessionMode;
00055 
00056 
00059 typedef struct _JBParameters{
00060         int min_size; 
00061         int nom_size; 
00062         int max_size; 
00063         bool_t adaptive;
00064         bool_t pad[3];
00065         int max_packets; 
00066 } JBParameters;
00067 
00068 typedef struct _JitterControl
00069 {
00070         unsigned int count;
00071         int jitt_comp;   /* the user jitt_comp in miliseconds*/
00072         int jitt_comp_ts; /* the jitt_comp converted in rtp time (same unit as timestamp) */
00073         int adapt_jitt_comp_ts;
00074         int64_t slide;
00075         int64_t prev_slide;
00076         float jitter;
00077         int olddiff;
00078         float inter_jitter;     /* interarrival jitter as defined in the RFC */
00079         int corrective_step;
00080         int corrective_slide;
00081         uint64_t cum_jitter_buffer_size; /*in timestamp units*/
00082         unsigned int cum_jitter_buffer_count; /*used for computation of jitter buffer size*/
00083         int clock_rate;
00084         bool_t adaptive;
00085         bool_t enabled;
00086 } JitterControl;
00087 
00088 typedef struct _WaitPoint
00089 {
00090         ortp_mutex_t lock;
00091         ortp_cond_t  cond;
00092         uint32_t time;
00093         bool_t wakeup;
00094 } WaitPoint;
00095 
00096 typedef struct _RtpTransportModifier
00097 {
00098         void *data;
00099         struct _RtpSession *session;//<back pointer to the owning session, set by oRTP
00100         int  (*t_process_on_send)(struct _RtpTransportModifier *t, mblk_t *msg);
00101         int  (*t_process_on_receive)(struct _RtpTransportModifier *t, mblk_t *msg);
00102         void  (*t_process_on_schedule)(struct _RtpTransportModifier *t); /*invoked each time rtp_session_recvm is called even is no message are available*/
00107         void  (*t_destroy)(struct _RtpTransportModifier *transport);
00108 } RtpTransportModifier;
00109 
00110 typedef struct _RtpTransport
00111 {
00112         void *data;
00113         struct _RtpSession *session;//<back pointer to the owning session, set by oRTP
00114         ortp_socket_t (*t_getsocket)(struct _RtpTransport *t);
00115         int  (*t_sendto)(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
00116         int  (*t_recvfrom)(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
00117         void  (*t_close)(struct _RtpTransport *transport, void *userData);
00122         void  (*t_destroy)(struct _RtpTransport *transport);
00123 }  RtpTransport;
00124 
00125 typedef enum _OrtpNetworkSimulatorMode{
00126         OrtpNetworkSimulatorInvalid=-1,
00127         OrtpNetworkSimulatorInbound,
00128         OrtpNetworkSimulatorOutbound, 
00129         OrtpNetworkSimulatorOutboundControlled 
00131 }OrtpNetworkSimulatorMode;
00132 
00136 typedef struct _OrtpNetworkSimulatorParams{
00137         int enabled; 
00138         float max_bandwidth; 
00139         int max_buffer_size; 
00140         float loss_rate; 
00141         uint32_t latency; 
00142         float consecutive_loss_probability;
00143         float jitter_burst_density; 
00144         float jitter_strength; 
00145         OrtpNetworkSimulatorMode mode; 
00146 }OrtpNetworkSimulatorParams;
00147 
00148 typedef struct _OrtpNetworkSimulatorCtx{
00149         OrtpNetworkSimulatorParams params;
00150         int bit_budget;
00151         int qsize;
00152         queue_t q;/*queue used for simulating bandwidth limit*/
00153         queue_t latency_q;
00154         queue_t send_q; /*used only for OrtpNetworkSimulatorOutbound direction*/
00155         struct timeval last_check;
00156         uint64_t last_jitter_event;
00157         int consecutive_drops;
00158         int drops_to_ignore;
00159         int drop_by_congestion;
00160         int drop_by_loss;
00161         int total_count; /*total number of packets gone through the simulator*/
00162         ortp_mutex_t mutex;
00163         ortp_thread_t thread;
00164         bool_t in_jitter_event;
00165         bool_t thread_started;
00166 }OrtpNetworkSimulatorCtx;
00167 
00168 typedef struct OrtpRtcpSendAlgorithm {
00169         uint64_t tn; /* Time of the next scheduled RTCP RR transmission in milliseconds. */
00170         uint64_t tp; /* Time of the last scheduled RTCP RR transmission in milliseconds. */
00171         uint64_t t_rr_last; /* Time of the last regular RTCP packet sent in milliseconds. */
00172         uint32_t T_rr; /* Interval for the scheduling of the next regular RTCP packet. */
00173         uint32_t T_max_fb_delay; /* Interval within which a feeback message is considered to be useful to the sender. */
00174         uint32_t T_rr_interval; /* Minimal interval to be used between regular RTCP packets. */
00175         uint32_t T_rr_current_interval;
00176         uint32_t Tmin; /* Minimal interval between RTCP packets. */
00177         float avg_rtcp_size;
00178         mblk_t *fb_packets;
00179         bool_t initialized; /* Whether the RTCP send algorithm is fully initialized. */
00180         bool_t initial;
00181         bool_t allow_early;
00182         bool_t tmmbr_scheduled;
00183         bool_t tmmbn_scheduled;
00184 } OrtpRtcpSendAlgorithm;
00185 
00186 typedef struct OrtpRtcpFbConfiguration {
00187         bool_t generic_nack_enabled;
00188         bool_t tmmbr_enabled;
00189 } OrtpRtcpFbConfiguration;
00190 
00191 #define ORTP_RTCP_XR_UNAVAILABLE_PARAMETER 127
00192 
00193 typedef enum {
00194         OrtpRtcpXrNoPlc,
00195         OrtpRtcpXrSilencePlc,
00196         OrtpRtcpXrEnhancedPlc
00197 } OrtpRtcpXrPlcStatus;
00198 
00199 typedef OrtpRtcpXrPlcStatus (*OrtpRtcpXrPlcCallback)(void *userdata);
00200 typedef int (*OrtpRtcpXrSignalLevelCallback)(void *userdata);
00201 typedef int (*OrtpRtcpXrNoiseLevelCallback)(void *userdata);
00202 typedef float (*OrtpRtcpXrAverageQualityIndicatorCallback)(void *userdata);
00203 
00204 typedef struct OrtpRtcpXrMediaCallbacks {
00205         OrtpRtcpXrPlcCallback plc;
00206         OrtpRtcpXrSignalLevelCallback signal_level;
00207         OrtpRtcpXrNoiseLevelCallback noise_level;
00208         OrtpRtcpXrAverageQualityIndicatorCallback average_qi;
00209         OrtpRtcpXrAverageQualityIndicatorCallback average_lq_qi;
00210         void *userdata;
00211 } OrtpRtcpXrMediaCallbacks;
00212 
00213 typedef enum {
00214         OrtpRtcpXrRcvrRttNone,
00215         OrtpRtcpXrRcvrRttAll,
00216         OrtpRtcpXrRcvrRttSender
00217 } OrtpRtcpXrRcvrRttMode;
00218 
00219 typedef enum {
00220         OrtpRtcpXrStatSummaryLoss = (1 << 7),
00221         OrtpRtcpXrStatSummaryDup = (1 << 6),
00222         OrtpRtcpXrStatSummaryJitt = (1 << 5),
00223         OrtpRtcpXrStatSummaryTTL = (1 << 3),
00224         OrtpRtcpXrStatSummaryHL = (1 << 4)
00225 } OrtpRtcpXrStatSummaryFlag;
00226 
00227 typedef struct OrtpRtcpXrConfiguration {
00228         bool_t enabled;
00229         bool_t stat_summary_enabled;
00230         bool_t voip_metrics_enabled;
00231         OrtpRtcpXrRcvrRttMode rcvr_rtt_mode;
00232         int rcvr_rtt_max_size;
00233         OrtpRtcpXrStatSummaryFlag stat_summary_flags;
00234 } OrtpRtcpXrConfiguration;
00235 
00236 typedef struct OrtpRtcpXrStats {
00237         uint32_t last_rcvr_rtt_ts;      /* NTP timestamp (middle 32 bits) of last received XR rcvr-rtt */
00238         struct timeval last_rcvr_rtt_time;      /* Time at which last XR rcvr-rtt was received  */
00239         uint16_t rcv_seq_at_last_stat_summary;  /* Received sequence number at last XR stat-summary sent */
00240         uint32_t rcv_since_last_stat_summary;   /* The number of packets received since last XR stat-summary was sent */
00241         uint32_t dup_since_last_stat_summary;   /* The number of duplicate packets received since last XR stat-summary was sent */
00242         uint32_t min_jitter_since_last_stat_summary;    /* The minimum value of jitter since last XR stat-summary was sent */
00243         uint32_t max_jitter_since_last_stat_summary;    /* The maximum value of jitter since last XR stat-summary was sent */
00244         double olds_jitter_since_last_stat_summary;
00245         double oldm_jitter_since_last_stat_summary;
00246         double news_jitter_since_last_stat_summary;
00247         double newm_jitter_since_last_stat_summary;
00248         int64_t last_jitter_diff_since_last_stat_summary;
00249         double olds_ttl_or_hl_since_last_stat_summary;
00250         double oldm_ttl_or_hl_since_last_stat_summary;
00251         double news_ttl_or_hl_since_last_stat_summary;
00252         double newm_ttl_or_hl_since_last_stat_summary;
00253         uint8_t min_ttl_or_hl_since_last_stat_summary;  /* The minimum value of TTL/HL since last XR stat-summary was sent */
00254         uint8_t max_ttl_or_hl_since_last_stat_summary;  /* The maximum value of TTL/HL since last XR stat-summary was sent */
00255         uint32_t first_rcv_seq;
00256         uint32_t last_rcv_seq;
00257         uint32_t rcv_count;
00258         uint32_t discarded_count;
00259 } OrtpRtcpXrStats;
00260 
00261 typedef struct OrtpRtcpTmmbrInfo {
00262         mblk_t *sent;
00263         mblk_t *received;
00264 } OrtpRtcpTmmbrInfo;
00265 
00266 typedef struct _OrtpAddress{
00267         struct sockaddr_storage addr;
00268         socklen_t len;
00269 }OrtpAddress;
00270 
00271 typedef struct _OrtpStream {
00272         ortp_socket_t socket;
00273         int sockfamily;
00274         int loc_port;
00275         socklen_t rem_addrlen;
00276         struct sockaddr_storage rem_addr;
00277         socklen_t loc_addrlen;
00278         struct sockaddr_storage loc_addr;
00279         struct _RtpTransport *tr;
00280         mblk_t *cached_mp;
00281         struct timeval send_bw_start; /* used for bandwidth estimation */
00282         struct timeval recv_bw_start; /* used for bandwidth estimation */
00283         unsigned int sent_bytes; /* used for bandwidth estimation */
00284         unsigned int recv_bytes; /* used for bandwidth estimation */
00285         float upload_bw;
00286         float download_bw;
00287         OList *aux_destinations; /*list of OrtpAddress */
00288 } OrtpStream;
00289 
00290 typedef struct _RtpStream
00291 {
00292         OrtpStream gs;
00293         int max_rq_size;
00294         int time_jump;
00295         uint32_t ts_jump;
00296         queue_t rq;
00297         queue_t tev_rq;
00298         void *QoSHandle;
00299         unsigned long QoSFlowID;
00300         JitterControl jittctl;
00301         uint32_t snd_time_offset;/*the scheduler time when the application send its first timestamp*/
00302         uint32_t snd_ts_offset; /* the first application timestamp sent by the application */
00303         uint32_t snd_rand_offset;       /* a random number added to the user offset to make the stream timestamp*/
00304         uint32_t snd_last_ts;   /* the last stream timestamp sended */
00305         uint32_t rcv_time_offset; /*the scheduler time when the application ask for its first timestamp*/
00306         uint32_t rcv_ts_offset;  /* the first stream timestamp */
00307         uint32_t rcv_query_ts_offset;   /* the first user timestamp asked by the application */
00308         uint32_t rcv_last_ts;   /* the last stream timestamp got by the application */
00309         uint16_t rcv_last_seq;  /* the last stream sequence number got by the application*/
00310         uint16_t pad;
00311         uint32_t rcv_last_app_ts; /* the last application timestamp asked by the application */
00312         uint32_t rcv_last_ret_ts; /* the timestamp of the last sample returned (only for continuous audio)*/
00313         uint32_t hwrcv_extseq; /* last received on socket extended sequence number */
00314         uint32_t hwrcv_seq_at_last_SR;
00315         uint32_t hwrcv_since_last_SR;
00316         uint32_t last_rcv_SR_ts;     /* NTP timestamp (middle 32 bits) of last received SR */
00317         struct timeval last_rcv_SR_time;   /* time at which last SR was received  */
00318         uint16_t snd_seq; /* send sequence number */
00319         uint32_t last_rtcp_packet_count; /*the sender's octet count in the last sent RTCP SR*/
00320         uint32_t sent_payload_bytes; /*used for RTCP sender reports*/
00321         rtp_stats_t stats;
00322         int recv_errno;
00323         int send_errno;
00324         int snd_socket_size;
00325         int rcv_socket_size;
00326         int ssrc_changed_thres;
00327         jitter_stats_t jitter_stats;
00328 }RtpStream;
00329 
00330 typedef struct _RtcpStream
00331 {
00332         OrtpStream gs;
00333         OrtpRtcpSendAlgorithm send_algo;
00334         OrtpRtcpXrConfiguration xr_conf;
00335         OrtpRtcpXrMediaCallbacks xr_media_callbacks;
00336         OrtpRtcpTmmbrInfo tmmbr_info;
00337         bool_t enabled; /*tells whether we can send RTCP packets */
00338         bool_t rtcp_xr_dlrr_to_send;
00339         uint8_t rtcp_fb_fir_seq_nr;     /* The FIR command sequence number */
00340         uint32_t last_rtcp_fb_pli_snt;
00341 } RtcpStream;
00342 
00343 typedef struct _RtpSession RtpSession;
00344 
00345 
00354 struct _RtpSession
00355 {
00356         RtpSession *next;       /* next RtpSession, when the session are enqueued by the scheduler */
00357         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*/
00358         struct {
00359                 RtpProfile *profile;
00360                 int pt;
00361                 unsigned int ssrc;
00362                 WaitPoint wp;
00363         } snd,rcv;
00364         unsigned int inc_ssrc_candidate;
00365         int inc_same_ssrc_count;
00366         int hw_recv_pt; /* recv payload type before jitter buffer */
00367         int recv_buf_size;
00368         int target_upload_bandwidth; /* Target upload bandwidth at nework layer (with IP and UDP headers) in bits/s */
00369         RtpSignalTable on_ssrc_changed;
00370         RtpSignalTable on_payload_type_changed;
00371         RtpSignalTable on_telephone_event_packet;
00372         RtpSignalTable on_telephone_event;
00373         RtpSignalTable on_timestamp_jump;
00374         RtpSignalTable on_network_error;
00375         RtpSignalTable on_rtcp_bye;
00376         struct _OList *signal_tables;
00377         struct _OList *eventqs;
00378         msgb_allocator_t allocator;
00379         RtpStream rtp;
00380         RtcpStream rtcp;
00381         OrtpRtcpXrStats rtcp_xr_stats;
00382         RtpSessionMode mode;
00383         struct _RtpScheduler *sched;
00384         uint32_t flags;
00385         int dscp;
00386         int multicast_ttl;
00387         int multicast_loopback;
00388         float duplication_ratio; /* Number of times a packet should be duplicated */
00389         float duplication_left ; /* Remainder of the duplication ratio */
00390         void * user_data;
00391         /* FIXME: Should be a table for all session participants. */
00392         struct timeval last_recv_time; /* Time of receiving the RTP/RTCP packet. */
00393         mblk_t *pending;
00394         /* telephony events extension */
00395         int tev_send_pt; /*telephone event to be used for sending*/
00396         mblk_t *current_tev;            /* the pending telephony events */
00397         mblk_t *minimal_sdes;
00398         mblk_t *full_sdes;
00399         queue_t contributing_sources;
00400         int64_t lost_packets_test_vector;
00401         unsigned int interarrival_jitter_test_vector;
00402         unsigned int delay_test_vector;
00403         float rtt;/*last round trip delay calculated*/
00404         int cum_loss;
00405         OrtpNetworkSimulatorCtx *net_sim_ctx;
00406         bool_t symmetric_rtp;
00407         bool_t permissive; /*use the permissive algorithm*/
00408         bool_t use_connect; /* use connect() on the socket */
00409         bool_t ssrc_set;
00410         bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
00411         unsigned char avpf_features; 
00412 };
00413 
00414 
00415 
00416 
00417 #ifdef __cplusplus
00418 extern "C"
00419 {
00420 #endif
00421 
00422 ORTP_PUBLIC const char *ortp_network_simulator_mode_to_string(OrtpNetworkSimulatorMode mode);
00423 ORTP_PUBLIC OrtpNetworkSimulatorMode ortp_network_simulator_mode_from_string(const char *str);
00424 
00425         
00426 /* public API */
00427 ORTP_PUBLIC RtpSession *rtp_session_new(int mode);
00428 ORTP_PUBLIC void rtp_session_set_scheduling_mode(RtpSession *session, int yesno);
00429 ORTP_PUBLIC void rtp_session_set_blocking_mode(RtpSession *session, int yesno);
00430 ORTP_PUBLIC void rtp_session_set_profile(RtpSession *session, RtpProfile *profile);
00431 ORTP_PUBLIC void rtp_session_set_send_profile(RtpSession *session,RtpProfile *profile);
00432 ORTP_PUBLIC void rtp_session_set_recv_profile(RtpSession *session,RtpProfile *profile);
00433 ORTP_PUBLIC RtpProfile *rtp_session_get_profile(RtpSession *session);
00434 ORTP_PUBLIC RtpProfile *rtp_session_get_send_profile(RtpSession *session);
00435 ORTP_PUBLIC RtpProfile *rtp_session_get_recv_profile(RtpSession *session);
00436 ORTP_PUBLIC int rtp_session_signal_connect(RtpSession *session,const char *signal_name, RtpCallback cb, void *user_data);
00437 ORTP_PUBLIC int rtp_session_signal_disconnect_by_callback(RtpSession *session,const char *signal_name, RtpCallback cb);
00438 ORTP_PUBLIC void rtp_session_set_ssrc(RtpSession *session, uint32_t ssrc);
00439 ORTP_PUBLIC uint32_t rtp_session_get_send_ssrc(RtpSession* session);
00440 ORTP_PUBLIC uint32_t rtp_session_get_recv_ssrc(RtpSession *session);
00441 ORTP_PUBLIC void rtp_session_set_seq_number(RtpSession *session, uint16_t seq);
00442 ORTP_PUBLIC uint16_t rtp_session_get_seq_number(RtpSession *session);
00443 ORTP_PUBLIC uint32_t rtp_session_get_rcv_ext_seq_number(RtpSession *session);
00444 ORTP_PUBLIC int rtp_session_get_cum_loss(RtpSession *session);
00445 ORTP_PUBLIC void rtp_session_set_duplication_ratio(RtpSession *session, float ratio);
00446 
00447 ORTP_PUBLIC void rtp_session_enable_jitter_buffer(RtpSession *session , bool_t enabled);
00448 ORTP_PUBLIC bool_t rtp_session_jitter_buffer_enabled(const RtpSession *session);
00449 ORTP_PUBLIC void rtp_session_set_jitter_buffer_params(RtpSession *session, const JBParameters *par);
00450 ORTP_PUBLIC void rtp_session_get_jitter_buffer_params(RtpSession *session, JBParameters *par);
00451 
00452 /*deprecated jitter control functions*/
00453 ORTP_PUBLIC void rtp_session_set_jitter_compensation(RtpSession *session, int milisec);
00454 ORTP_PUBLIC void rtp_session_enable_adaptive_jitter_compensation(RtpSession *session, bool_t val);
00455 ORTP_PUBLIC bool_t rtp_session_adaptive_jitter_compensation_enabled(RtpSession *session);
00456 
00457 ORTP_PUBLIC void rtp_session_set_time_jump_limit(RtpSession *session, int miliseconds);
00458 ORTP_PUBLIC int rtp_session_join_multicast_group(RtpSession *session, const char *ip);
00459 ORTP_PUBLIC int rtp_session_set_local_addr(RtpSession *session,const char *addr, int rtp_port, int rtcp_port);
00460 ORTP_PUBLIC int rtp_session_get_local_port(const RtpSession *session);
00461 ORTP_PUBLIC int rtp_session_get_local_rtcp_port(const RtpSession *session);
00462 
00463 ORTP_PUBLIC int
00464 rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port);
00465 /*same as previous function, old name:*/
00466 ORTP_PUBLIC int rtp_session_set_remote_addr_and_port (RtpSession * session, const char * addr, int rtp_port, int rtcp_port);
00467 ORTP_PUBLIC int rtp_session_set_remote_addr(RtpSession *session,const char *addr, int port);
00468 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);
00469 ORTP_PUBLIC void rtp_session_clear_aux_remote_addr(RtpSession * session);
00470 /* alternatively to the set_remote_addr() and set_local_addr(), an application can give
00471 a valid socket (potentially connect()ed )to be used by the RtpSession */
00472 ORTP_PUBLIC void rtp_session_set_sockets(RtpSession *session, int rtpfd, int rtcpfd);
00473 
00474 ORTP_PUBLIC void rtp_session_get_transports(const RtpSession *session, RtpTransport **rtptr, RtpTransport **rtcptr);
00475 /*those methods are provided for people who wants to send non-RTP messages using the RTP/RTCP sockets */
00476 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session);
00477 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtcp_socket(const RtpSession *session);
00478 ORTP_PUBLIC void rtp_session_refresh_sockets(RtpSession *session);
00479 
00480 
00481 /* QOS / DSCP */
00482 ORTP_PUBLIC int rtp_session_set_dscp(RtpSession *session, int dscp);
00483 ORTP_PUBLIC int rtp_session_get_dscp(const RtpSession *session);
00484 
00485 
00486 /* Packet info */
00487 ORTP_PUBLIC int rtp_session_set_pktinfo(RtpSession *session, int activate);
00488 
00489 /* Multicast methods */
00490 ORTP_PUBLIC int rtp_session_set_multicast_ttl(RtpSession *session, int ttl);
00491 ORTP_PUBLIC int rtp_session_get_multicast_ttl(RtpSession *session);
00492 
00493 ORTP_PUBLIC int rtp_session_set_multicast_loopback(RtpSession *session, int yesno);
00494 ORTP_PUBLIC int rtp_session_get_multicast_loopback(RtpSession *session);
00495 
00496 
00497 
00498 ORTP_PUBLIC int rtp_session_set_send_payload_type(RtpSession *session, int paytype);
00499 ORTP_PUBLIC int rtp_session_get_send_payload_type(const RtpSession *session);
00500 
00501 ORTP_PUBLIC int rtp_session_get_recv_payload_type(const RtpSession *session);
00502 ORTP_PUBLIC int rtp_session_set_recv_payload_type(RtpSession *session, int pt);
00503 
00504 ORTP_PUBLIC int rtp_session_set_send_telephone_event_payload_type(RtpSession *session, int paytype);
00505 
00506 ORTP_PUBLIC int rtp_session_set_payload_type(RtpSession *session, int pt);
00507 
00508 ORTP_PUBLIC void rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yesno);
00509 
00510 ORTP_PUBLIC bool_t rtp_session_get_symmetric_rtp (const RtpSession * session);
00511 
00512 ORTP_PUBLIC void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno);
00513 
00514 ORTP_PUBLIC void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno);
00515 
00516 ORTP_PUBLIC void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms);
00517 
00518 ORTP_PUBLIC void rtp_session_set_target_upload_bandwidth(RtpSession *session, int target_bandwidth);
00519 
00520 ORTP_PUBLIC void rtp_session_configure_rtcp_xr(RtpSession *session, const OrtpRtcpXrConfiguration *config);
00521 ORTP_PUBLIC void rtp_session_set_rtcp_xr_media_callbacks(RtpSession *session, const OrtpRtcpXrMediaCallbacks *cbs);
00522 
00523 ORTP_PUBLIC void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int numpackets);
00524 
00525 /*low level recv and send functions */
00526 ORTP_PUBLIC mblk_t * rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts);
00527 ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session, size_t header_size, const uint8_t *payload, size_t payload_size);
00528 ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, size_t packet_size);
00529 ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, size_t payload_size, void (*freefn)(void*));
00530 ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, size_t size, void (*freefn)(void*) );
00531 ORTP_PUBLIC int rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t userts);
00532 /* high level recv and send functions */
00533 ORTP_PUBLIC int rtp_session_recv_with_ts(RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more);
00534 ORTP_PUBLIC int rtp_session_send_with_ts(RtpSession *session, const uint8_t *buffer, int len, uint32_t userts);
00535 
00536 /* event API*/
00537 ORTP_PUBLIC void rtp_session_register_event_queue(RtpSession *session, OrtpEvQueue *q);
00538 ORTP_PUBLIC void rtp_session_unregister_event_queue(RtpSession *session, OrtpEvQueue *q);
00539 
00540 
00541 /* IP bandwidth usage estimation functions, returning bits/s*/
00542 ORTP_PUBLIC float rtp_session_compute_send_bandwidth(RtpSession *session);
00543 ORTP_PUBLIC float rtp_session_compute_recv_bandwidth(RtpSession *session);
00544 ORTP_PUBLIC float rtp_session_get_send_bandwidth(RtpSession *session);
00545 ORTP_PUBLIC float rtp_session_get_recv_bandwidth(RtpSession *session);
00546 ORTP_PUBLIC float rtp_session_get_rtp_send_bandwidth(RtpSession *session);
00547 ORTP_PUBLIC float rtp_session_get_rtp_recv_bandwidth(RtpSession *session);
00548 ORTP_PUBLIC float rtp_session_get_rtcp_send_bandwidth(RtpSession *session);
00549 ORTP_PUBLIC float rtp_session_get_rtcp_recv_bandwidth(RtpSession *session);
00550 
00551 ORTP_PUBLIC void rtp_session_send_rtcp_APP(RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen);
00552 
00553 ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(RtpSession *session);
00554 ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(RtpSession *session);
00555 ORTP_PUBLIC void rtp_session_flush_sockets(RtpSession *session);
00556 ORTP_PUBLIC void rtp_session_release_sockets(RtpSession *session);
00557 ORTP_PUBLIC void rtp_session_resync(RtpSession *session);
00558 ORTP_PUBLIC void rtp_session_reset(RtpSession *session);
00559 ORTP_PUBLIC void rtp_session_destroy(RtpSession *session);
00560 
00561 ORTP_PUBLIC const rtp_stats_t * rtp_session_get_stats(const RtpSession *session);
00562 ORTP_PUBLIC const jitter_stats_t * rtp_session_get_jitter_stats( const RtpSession *session );
00563 ORTP_PUBLIC void rtp_session_reset_stats(RtpSession *session);
00564 
00565 ORTP_PUBLIC void rtp_session_set_data(RtpSession *session, void *data);
00566 ORTP_PUBLIC void *rtp_session_get_data(const RtpSession *session);
00567 
00568 ORTP_PUBLIC void rtp_session_set_recv_buf_size(RtpSession *session, int bufsize);
00569 ORTP_PUBLIC void rtp_session_set_rtp_socket_send_buffer_size(RtpSession * session, unsigned int size);
00570 ORTP_PUBLIC void rtp_session_set_rtp_socket_recv_buffer_size(RtpSession * session, unsigned int size);
00571 
00572 /* in use with the scheduler to convert a timestamp in scheduler time unit (ms) */
00573 ORTP_PUBLIC uint32_t rtp_session_ts_to_time(RtpSession *session,uint32_t timestamp);
00574 ORTP_PUBLIC uint32_t rtp_session_time_to_ts(RtpSession *session, int millisecs);
00575 /* this function aims at simulating senders with "imprecise" clocks, resulting in
00576 rtp packets sent with timestamp uncorrelated with the system clock .
00577 This is only availlable to sessions working with the oRTP scheduler */
00578 ORTP_PUBLIC void rtp_session_make_time_distorsion(RtpSession *session, int milisec);
00579 
00580 /*RTCP functions */
00581 ORTP_PUBLIC void rtp_session_set_source_description(RtpSession *session, const char *cname,
00582         const char *name, const char *email, const char *phone,
00583     const char *loc, const char *tool, const char *note);
00584 ORTP_PUBLIC void rtp_session_add_contributing_source(RtpSession *session, uint32_t csrc,
00585     const char *cname, const char *name, const char *email, const char *phone,
00586     const char *loc, const char *tool, const char *note);
00587 /* DEPRECATED: Use rtp_session_remove_contributing_source instead of rtp_session_remove_contributing_sources */
00588 #define rtp_session_remove_contributing_sources rtp_session_remove_contributing_source
00589 ORTP_PUBLIC void rtp_session_remove_contributing_source(RtpSession *session, uint32_t csrc);
00590 ORTP_PUBLIC mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session, bool_t full);
00591 
00592 ORTP_PUBLIC void rtp_session_get_last_recv_time(RtpSession *session, struct timeval *tv);
00593 ORTP_PUBLIC int rtp_session_bye(RtpSession *session, const char *reason);
00594 
00595 ORTP_PUBLIC int rtp_session_get_last_send_error_code(RtpSession *session);
00596 ORTP_PUBLIC void rtp_session_clear_send_error_code(RtpSession *session);
00597 ORTP_PUBLIC int rtp_session_get_last_recv_error_code(RtpSession *session);
00598 ORTP_PUBLIC void rtp_session_clear_recv_error_code(RtpSession *session);
00599 
00600 
00601 ORTP_PUBLIC float rtp_session_get_round_trip_propagation(RtpSession *session);
00602 
00603 
00604 ORTP_PUBLIC void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetworkSimulatorParams *params);
00605 
00606 ORTP_PUBLIC void rtp_session_rtcp_set_lost_packet_value( RtpSession *session, const int64_t value );
00607 ORTP_PUBLIC void rtp_session_rtcp_set_jitter_value(RtpSession *session, const unsigned int value );
00608 ORTP_PUBLIC void rtp_session_rtcp_set_delay_value(RtpSession *session, const unsigned int value );
00609 ORTP_PUBLIC mblk_t * rtp_session_pick_with_cseq (RtpSession * session, const uint16_t sequence_number);
00610 
00611 
00612 ORTP_PUBLIC void rtp_session_send_rtcp_xr_rcvr_rtt(RtpSession *session);
00613 ORTP_PUBLIC void rtp_session_send_rtcp_xr_dlrr(RtpSession *session);
00614 ORTP_PUBLIC void rtp_session_send_rtcp_xr_stat_summary(RtpSession *session);
00615 ORTP_PUBLIC void rtp_session_send_rtcp_xr_voip_metrics(RtpSession *session);
00616 
00617 
00618 ORTP_PUBLIC bool_t rtp_session_avpf_enabled(RtpSession *session);
00619 ORTP_PUBLIC bool_t rtp_session_avpf_payload_type_feature_enabled(RtpSession *session, unsigned char feature);
00620 ORTP_PUBLIC bool_t rtp_session_avpf_feature_enabled(RtpSession *session, unsigned char feature);
00621 ORTP_PUBLIC void rtp_session_enable_avpf_feature(RtpSession *session, unsigned char feature, bool_t enable);
00622 ORTP_PUBLIC uint16_t rtp_session_get_avpf_rr_interval(RtpSession *session);
00623 ORTP_PUBLIC bool_t rtp_session_rtcp_psfb_scheduled(RtpSession *session, rtcp_psfb_type_t type);
00624 ORTP_PUBLIC bool_t rtp_session_rtcp_rtpfb_scheduled(RtpSession *session, rtcp_rtpfb_type_t type);
00625 ORTP_PUBLIC void rtp_session_send_rtcp_fb_generic_nack(RtpSession *session, uint16_t pid, uint16_t blp);
00626 ORTP_PUBLIC void rtp_session_send_rtcp_fb_pli(RtpSession *session);
00627 ORTP_PUBLIC void rtp_session_send_rtcp_fb_fir(RtpSession *session);
00628 ORTP_PUBLIC void rtp_session_send_rtcp_fb_sli(RtpSession *session, uint16_t first, uint16_t number, uint8_t picture_id);
00629 ORTP_PUBLIC void rtp_session_send_rtcp_fb_rpsi(RtpSession *session, uint8_t *bit_string, uint16_t bit_string_len);
00630 ORTP_PUBLIC void rtp_session_send_rtcp_fb_tmmbr(RtpSession *session, uint64_t mxtbr);
00631 ORTP_PUBLIC void rtp_session_send_rtcp_fb_tmmbn(RtpSession *session, uint32_t ssrc);
00632 
00633 
00634 /*private */
00635 ORTP_PUBLIC void rtp_session_init(RtpSession *session, int mode);
00636 #define rtp_session_set_flag(session,flag) (session)->flags|=(flag)
00637 #define rtp_session_unset_flag(session,flag) (session)->flags&=~(flag)
00638 ORTP_PUBLIC void rtp_session_uninit(RtpSession *session);
00639 ORTP_PUBLIC void rtp_session_dispatch_event(RtpSession *session, OrtpEvent *ev);
00640 
00641 ORTP_PUBLIC void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes);
00642 
00643 
00644 ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags);
00656 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) ;
00657 
00664 ORTP_PUBLIC RtpTransport* meta_rtp_transport_get_endpoint(const RtpTransport *transport);
00671 ORTP_PUBLIC void meta_rtp_transport_set_endpoint(RtpTransport *transport,RtpTransport *endpoint);
00672 
00673 ORTP_PUBLIC void meta_rtp_transport_destroy(RtpTransport *tp);
00674 ORTP_PUBLIC void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm);
00675 #ifdef __cplusplus
00676 }
00677 #endif
00678 
00679 #endif