2 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
3 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
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.
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.
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
24 #include <ortp/port.h>
25 #include <ortp/str_utils.h>
28 #define UDP_MAX_SIZE 1500
29 #define RTP_FIXED_HEADER_SIZE 12
30 #define RTP_DEFAULT_JITTER_TIME 80 /*miliseconds*/
31 #define RTP_DEFAULT_MULTICAST_TTL 5 /*hops*/
32 #define RTP_DEFAULT_MULTICAST_LOOPBACK 0 /*false*/
33 #define RTP_DEFAULT_DSCP 0x00 /*best effort*/
37 typedef struct rtp_header
63 typedef struct rtp_stats
66 uint64_t sent; /* bytes sent */
67 uint64_t recv; /* bytes of payload received and delivered in time to the application */
68 uint64_t hw_recv; /* bytes of payload received */
69 uint64_t packet_recv; /* number of packets received */
70 uint64_t unavaillable; /* packets not availlable when they were queried */
71 uint64_t outoftime; /* number of packets that were received too late */
72 uint64_t cum_packet_loss; /* cumulative number of packet lost */
73 uint64_t bad; /* packets that did not appear to be RTP */
74 uint64_t discarded; /* incoming packets discarded because the queue exceeds its max size */
77 #define RTP_TIMESTAMP_IS_NEWER_THAN(ts1,ts2) \
78 ((uint32_t)((uint32_t)(ts1) - (uint32_t)(ts2))< (uint32_t)(1<<31))
80 #define RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(ts1,ts2) \
81 ( ((uint32_t)((uint32_t)(ts1) - (uint32_t)(ts2))< (uint32_t)(1<<31)) && (ts1)!=(ts2) )
83 #define TIME_IS_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_NEWER_THAN(t1,t2)
85 #define TIME_IS_STRICTLY_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(t1,t2)
93 /* the first argument is a mblk_t. The header is supposed to be not splitted */
94 #define rtp_set_markbit(mp,value) ((rtp_header_t*)((mp)->b_rptr))->markbit=(value)
95 #define rtp_set_seqnumber(mp,seq) ((rtp_header_t*)((mp)->b_rptr))->seq_number=(seq)
96 #define rtp_set_timestamp(mp,ts) ((rtp_header_t*)((mp)->b_rptr))->timestamp=(ts)
97 #define rtp_set_ssrc(mp,_ssrc) ((rtp_header_t*)((mp)->b_rptr))->ssrc=(_ssrc)
98 void rtp_add_csrc(mblk_t *mp ,uint32_t csrc);
99 #define rtp_set_payload_type(mp,pt) ((rtp_header_t*)((mp)->b_rptr))->paytype=(pt)
101 #define rtp_get_markbit(mp) (((rtp_header_t*)((mp)->b_rptr))->markbit)
102 #define rtp_get_timestamp(mp) (((rtp_header_t*)((mp)->b_rptr))->timestamp)
103 #define rtp_get_seqnumber(mp) (((rtp_header_t*)((mp)->b_rptr))->seq_number)
104 #define rtp_get_payload_type(mp) (((rtp_header_t*)((mp)->b_rptr))->paytype)
105 #define rtp_get_ssrc(mp) (((rtp_header_t*)((mp)->b_rptr))->ssrc)
106 #define rtp_get_cc(mp) (((rtp_header_t*)((mp)->b_rptr))->cc)
107 #define rtp_get_csrc(mp, idx) (((rtp_header_t*)((mp)->b_rptr))->csrc[idx])
109 int rtp_get_payload(mblk_t *packet, unsigned char **start);