1 /* 2 * The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) implementation with additional features. 3 * Copyright (C) 2017 Belledonne Communications SARL 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program 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 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 #ifndef rtpsession_priv_h 21 #define rtpsession_priv_h 22 23 #include "ortp/rtpsession.h" 24 25 #define IP_UDP_OVERHEAD (20 + 8) 26 #define IP6_UDP_OVERHEAD (40 + 8) 27 28 #define RTCP_XR_GMIN 16 /* Recommended value of Gmin from RFC3611, section 4.7.6 */ 29 30 typedef enum { 31 RTP_SESSION_RECV_SYNC=1, /* the rtp session is synchronising in the incoming stream */ 32 RTP_SESSION_FIRST_PACKET_DELIVERED=1<<1, 33 RTP_SESSION_SCHEDULED=1<<2,/* the scheduler controls this session*/ 34 RTP_SESSION_BLOCKING_MODE=1<<3, /* in blocking mode */ 35 RTP_SESSION_RECV_NOT_STARTED=1<<4, /* the application has not started to try to recv */ 36 RTP_SESSION_SEND_NOT_STARTED=1<<5, /* the application has not started to send something */ 37 RTP_SESSION_IN_SCHEDULER=1<<6, /* the rtp session is in the scheduler list */ 38 RTP_SESSION_USING_EXT_SOCKETS=1<<7, /* the session is using externaly supplied sockets */ 39 RTP_SOCKET_CONNECTED=1<<8, 40 RTCP_SOCKET_CONNECTED=1<<9, 41 RTP_SESSION_USING_TRANSPORT=1<<10, 42 RTCP_OVERRIDE_LOST_PACKETS=1<<11, 43 RTCP_OVERRIDE_JITTER=1<<12, 44 RTCP_OVERRIDE_DELAY=1<<13, 45 RTP_SESSION_RECV_SEQ_INIT=1<<14, 46 RTP_SESSION_FLUSH=1<<15, 47 RTP_SESSION_SOCKET_REFRESH_REQUESTED=1<<16 48 }RtpSessionFlags; 49 50 #define rtp_session_using_transport(s, stream) (((s)->flags & RTP_SESSION_USING_TRANSPORT) && (s->stream.gs.tr != 0)) 51 52 int rtp_session_rtp_recv_abstract(ortp_socket_t socket, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen); 53 54 void rtp_session_update_payload_type(RtpSession * session, int pt); 55 int rtp_putq(queue_t *q, mblk_t *mp); 56 mblk_t * rtp_getq(queue_t *q, uint32_t ts, int *rejected); 57 int rtp_session_rtp_recv(RtpSession * session, uint32_t ts); 58 int rtp_session_rtcp_recv(RtpSession * session); 59 int rtp_session_rtp_send (RtpSession * session, mblk_t * m); 60 61 #define rtp_session_rtcp_send rtp_session_rtcp_sendm_raw 62 63 void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts, struct sockaddr *addr, socklen_t addrlen); 64 65 void rtp_session_run_rtcp_send_scheduler(RtpSession *session); 66 void update_avg_rtcp_size(RtpSession *session, int bytes); 67 68 mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t *is_rtp_packet); 69 void ortp_network_simulator_destroy(OrtpNetworkSimulatorCtx *sim); 70 71 void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len); 72 73 mblk_t * make_xr_rcvr_rtt(RtpSession *session); 74 mblk_t * make_xr_dlrr(RtpSession *session); 75 mblk_t * make_xr_stat_summary(RtpSession *session); 76 mblk_t * make_xr_voip_metrics(RtpSession *session); 77 78 bool_t rtcp_is_RTPFB_internal(const mblk_t *m); 79 bool_t rtcp_is_PSFB_internal(const mblk_t *m); 80 bool_t rtp_session_has_fb_packets_to_send(RtpSession *session); 81 void rtp_session_send_regular_rtcp_packet_and_reschedule(RtpSession *session, uint64_t tc); 82 void rtp_session_send_fb_rtcp_packet_and_reschedule(RtpSession *session); 83 84 void ortp_stream_clear_aux_addresses(OrtpStream *os); 85 /* 86 * no more public, use modifier instead 87 * */ 88 void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr, RtpTransport *rtcptr); 89 90 bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt); 91 92 ortp_socket_t rtp_session_get_socket(RtpSession *session, bool_t is_rtp); 93 94 void rtp_session_do_splice(RtpSession *session, mblk_t *packet, bool_t is_rtp); 95 96 /* 97 * Update remote addr in the following case: 98 * rtp symetric == TRUE && socket not connected && remote addr has changed && ((rtp/rtcp packet && not only at start) or (no rtp/rtcp packets received)) 99 * @param[in] session on which to perform change 100 * @param[in] mp packet where remote addr is retreived 101 * @param[in] is_rtp true if rtp 102 * @param[in] only_at_start only perform changes if no valid packets received yet 103 * @return 0 if chaged was performed 104 * 105 */ 106 107 int rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_t is_rtp,bool_t only_at_start); 108 109 void rtp_session_process_incoming(RtpSession * session, mblk_t *mp, bool_t is_rtp_packet, uint32_t ts, bool_t received_via_rtcp_mux); 110 void update_sent_bytes(OrtpStream *os, int nbytes); 111 112 void _rtp_session_apply_socket_sizes(RtpSession *session); 113 114 void jb_parameters_init(JBParameters *jbp); 115 void rtp_session_init_jitter_buffer(RtpSession *session); 116 117 118 #endif 119