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