oRTP 0.16.3
|
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 00021 #ifndef RTP_H 00022 #define RTP_H 00023 00024 #include <ortp/port.h> 00025 #include <ortp/str_utils.h> 00026 00027 #define IPMAXLEN 20 00028 #define UDP_MAX_SIZE 1500 00029 #define RTP_FIXED_HEADER_SIZE 12 00030 #define RTP_DEFAULT_JITTER_TIME 80 /*miliseconds*/ 00031 #define RTP_DEFAULT_MULTICAST_TTL 5 /*hops*/ 00032 #define RTP_DEFAULT_MULTICAST_LOOPBACK 0 /*false*/ 00033 #define RTP_DEFAULT_DSCP 0x00 /*best effort*/ 00034 00035 00036 00037 typedef struct rtp_header 00038 { 00039 #ifdef ORTP_BIGENDIAN 00040 uint16_t version:2; 00041 uint16_t padbit:1; 00042 uint16_t extbit:1; 00043 uint16_t cc:4; 00044 uint16_t markbit:1; 00045 uint16_t paytype:7; 00046 #else 00047 uint16_t cc:4; 00048 uint16_t extbit:1; 00049 uint16_t padbit:1; 00050 uint16_t version:2; 00051 uint16_t paytype:7; 00052 uint16_t markbit:1; 00053 #endif 00054 uint16_t seq_number; 00055 uint32_t timestamp; 00056 uint32_t ssrc; 00057 uint32_t csrc[16]; 00058 } rtp_header_t; 00059 00060 00061 00062 00063 typedef struct rtp_stats 00064 { 00065 uint64_t packet_sent; 00066 uint64_t sent; /* bytes sent */ 00067 uint64_t recv; /* bytes of payload received and delivered in time to the application */ 00068 uint64_t hw_recv; /* bytes of payload received */ 00069 uint64_t packet_recv; /* number of packets received */ 00070 uint64_t unavaillable; /* totally useless*/ 00071 uint64_t outoftime; /* number of packets that were received too late */ 00072 uint64_t cum_packet_loss; /* cumulative number of packet lost */ 00073 uint64_t bad; /* packets that did not appear to be RTP */ 00074 uint64_t discarded; /* incoming packets discarded because the queue exceeds its max size */ 00075 } rtp_stats_t; 00076 00077 #define RTP_TIMESTAMP_IS_NEWER_THAN(ts1,ts2) \ 00078 ((uint32_t)((uint32_t)(ts1) - (uint32_t)(ts2))< (uint32_t)(1<<31)) 00079 00080 #define RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(ts1,ts2) \ 00081 ( ((uint32_t)((uint32_t)(ts1) - (uint32_t)(ts2))< (uint32_t)(1<<31)) && (ts1)!=(ts2) ) 00082 00083 #define TIME_IS_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_NEWER_THAN(t1,t2) 00084 00085 #define TIME_IS_STRICTLY_NEWER_THAN(t1,t2) RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(t1,t2) 00086 00087 00088 #ifdef __cplusplus 00089 extern "C"{ 00090 #endif 00091 00092 /* packet api */ 00093 /* the first argument is a mblk_t. The header is supposed to be not splitted */ 00094 #define rtp_set_markbit(mp,value) ((rtp_header_t*)((mp)->b_rptr))->markbit=(value) 00095 #define rtp_set_seqnumber(mp,seq) ((rtp_header_t*)((mp)->b_rptr))->seq_number=(seq) 00096 #define rtp_set_timestamp(mp,ts) ((rtp_header_t*)((mp)->b_rptr))->timestamp=(ts) 00097 #define rtp_set_ssrc(mp,_ssrc) ((rtp_header_t*)((mp)->b_rptr))->ssrc=(_ssrc) 00098 void rtp_add_csrc(mblk_t *mp ,uint32_t csrc); 00099 #define rtp_set_payload_type(mp,pt) ((rtp_header_t*)((mp)->b_rptr))->paytype=(pt) 00100 00101 #define rtp_get_markbit(mp) (((rtp_header_t*)((mp)->b_rptr))->markbit) 00102 #define rtp_get_timestamp(mp) (((rtp_header_t*)((mp)->b_rptr))->timestamp) 00103 #define rtp_get_seqnumber(mp) (((rtp_header_t*)((mp)->b_rptr))->seq_number) 00104 #define rtp_get_payload_type(mp) (((rtp_header_t*)((mp)->b_rptr))->paytype) 00105 #define rtp_get_ssrc(mp) (((rtp_header_t*)((mp)->b_rptr))->ssrc) 00106 #define rtp_get_cc(mp) (((rtp_header_t*)((mp)->b_rptr))->cc) 00107 #define rtp_get_csrc(mp, idx) (((rtp_header_t*)((mp)->b_rptr))->csrc[idx]) 00108 00109 int rtp_get_payload(mblk_t *packet, unsigned char **start); 00110 00111 #ifdef __cplusplus 00112 } 00113 #endif 00114 00115 #endif