00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 65536
00029 #define RTP_FIXED_HEADER_SIZE 12
00030 #define RTP_DEFAULT_JITTER_TIME 80
00031 #define RTP_DEFAULT_MULTICAST_TTL 5
00032 #define RTP_DEFAULT_MULTICAST_LOOPBACK 0
00033 #define RTP_DEFAULT_DSCP 0x00
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;
00067 uint64_t recv;
00068 uint64_t hw_recv;
00069 uint64_t packet_recv;
00070 uint64_t unavaillable;
00071 uint64_t outoftime;
00072 uint64_t cum_packet_loss;
00073 uint64_t bad;
00074 uint64_t discarded;
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
00089
00090 #define rtp_set_markbit(mp,value) ((rtp_header_t*)((mp)->b_rptr))->markbit=(value)
00091 #define rtp_set_seqnumber(mp,seq) ((rtp_header_t*)((mp)->b_rptr))->seq_number=(seq)
00092 #define rtp_set_timestamp(mp,ts) ((rtp_header_t*)((mp)->b_rptr))->timestamp=(ts)
00093 #define rtp_set_ssrc(mp,_ssrc) ((rtp_header_t*)((mp)->b_rptr))->ssrc=(_ssrc)
00094 void rtp_add_csrc(mblk_t *mp ,uint32_t csrc);
00095 #define rtp_set_payload_type(mp,pt) ((rtp_header_t*)((mp)->b_rptr))->paytype=(pt)
00096
00097 #define rtp_get_markbit(mp) (((rtp_header_t*)((mp)->b_rptr))->markbit)
00098 #define rtp_get_timestamp(mp) (((rtp_header_t*)((mp)->b_rptr))->timestamp)
00099 #define rtp_get_seqnumber(mp) (((rtp_header_t*)((mp)->b_rptr))->seq_number)
00100 #define rtp_get_payload_type(mp) (((rtp_header_t*)((mp)->b_rptr))->paytype)
00101 #define rtp_get_ssrc(mp) (((rtp_header_t*)((mp)->b_rptr))->ssrc)
00102 #define rtp_get_cc(mp) (((rtp_header_t*)((mp)->b_rptr))->cc)
00103 #define rtp_get_csrc(mp, idx) (((rtp_header_t*)((mp)->b_rptr))->csrc[idx])
00104
00105
00106 #endif