oRTP  0.25.0
src/rtpsession_priv.h
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 
00020 #ifndef rtpsession_priv_h
00021 #define rtpsession_priv_h
00022 
00023 #include "ortp/rtpsession.h"
00024 
00025 #define IP_UDP_OVERHEAD (20 + 8)
00026 #define IP6_UDP_OVERHEAD (40 + 8)
00027 
00028 #define RTCP_XR_GMIN 16 /* Recommended value of Gmin from RFC3611, section 4.7.6 */
00029 
00030 typedef enum {
00031         RTP_SESSION_RECV_SYNC=1,        /* the rtp session is synchronising in the incoming stream */
00032         RTP_SESSION_FIRST_PACKET_DELIVERED=1<<1,
00033         RTP_SESSION_SCHEDULED=1<<2,/* the scheduler controls this session*/
00034         RTP_SESSION_BLOCKING_MODE=1<<3, /* in blocking mode */
00035         RTP_SESSION_RECV_NOT_STARTED=1<<4,      /* the application has not started to try to recv */
00036         RTP_SESSION_SEND_NOT_STARTED=1<<5,  /* the application has not started to send something */
00037         RTP_SESSION_IN_SCHEDULER=1<<6,  /* the rtp session is in the scheduler list */
00038         RTP_SESSION_USING_EXT_SOCKETS=1<<7, /* the session is using externaly supplied sockets */
00039         RTP_SOCKET_CONNECTED=1<<8,
00040         RTCP_SOCKET_CONNECTED=1<<9,
00041         RTP_SESSION_USING_TRANSPORT=1<<10,
00042         RTCP_OVERRIDE_LOST_PACKETS=1<<11,
00043         RTCP_OVERRIDE_JITTER=1<<12,
00044         RTCP_OVERRIDE_DELAY=1<<13,
00045         RTP_SESSION_RECV_SEQ_INIT=1<<14,
00046         RTP_SESSION_FLUSH=1<<15,
00047         RTP_SESSION_SOCKET_REFRESH_REQUESTED=1<<16
00048 }RtpSessionFlags;
00049 
00050 #define rtp_session_using_transport(s, stream) (((s)->flags & RTP_SESSION_USING_TRANSPORT) && (s->stream.gs.tr != 0))
00051 
00052 int rtp_session_rtp_recv_abstract(ortp_socket_t socket, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
00053 
00054 void rtp_session_update_payload_type(RtpSession * session, int pt);
00055 int rtp_putq(queue_t *q, mblk_t *mp);
00056 mblk_t * rtp_getq(queue_t *q, uint32_t ts, int *rejected);
00057 int rtp_session_rtp_recv(RtpSession * session, uint32_t ts);
00058 int rtp_session_rtcp_recv(RtpSession * session);
00059 int rtp_session_rtp_send (RtpSession * session, mblk_t * m);
00060 int rtp_session_rtcp_send (RtpSession * session, mblk_t * m);
00061 
00062 void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts, struct sockaddr *addr, socklen_t addrlen);
00063 
00064 void rtp_session_run_rtcp_send_scheduler(RtpSession *session);
00065 void update_avg_rtcp_size(RtpSession *session, int bytes);
00066 
00067 mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t *is_rtp_packet);
00068 void ortp_network_simulator_destroy(OrtpNetworkSimulatorCtx *sim);
00069 
00070 void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len);
00071 
00072 mblk_t * make_xr_rcvr_rtt(RtpSession *session);
00073 mblk_t * make_xr_dlrr(RtpSession *session);
00074 mblk_t * make_xr_stat_summary(RtpSession *session);
00075 mblk_t * make_xr_voip_metrics(RtpSession *session);
00076 
00077 bool_t rtcp_is_RTPFB_internal(const mblk_t *m);
00078 bool_t rtcp_is_PSFB_internal(const mblk_t *m);
00079 bool_t rtp_session_has_fb_packets_to_send(RtpSession *session);
00080 void rtp_session_send_regular_rtcp_packet_and_reschedule(RtpSession *session, uint64_t tc);
00081 void rtp_session_send_fb_rtcp_packet_and_reschedule(RtpSession *session);
00082 
00083 void ortp_stream_clear_aux_addresses(OrtpStream *os);
00084 /*
00085  * no more public, use modifier instead
00086  * */
00087 void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr, RtpTransport *rtcptr);
00088 
00089 ORTP_PUBLIC bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt);
00090 
00091 #endif