00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mpf_rtp_stat.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef MPF_RTP_STAT_H 00020 #define MPF_RTP_STAT_H 00021 00022 /** 00023 * @file mpf_rtp_stat.h 00024 * @brief RTP/RTCP Statistics 00025 */ 00026 00027 #include "mpf.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 /** RTP receiver statistics */ 00032 typedef struct rtp_rx_stat_t rtp_rx_stat_t; 00033 00034 /** RTCP statistics used in Sender Report (SR) */ 00035 typedef struct rtcp_sr_stat_t rtcp_sr_stat_t; 00036 /** RTCP statistics used in Receiver Report (RR) */ 00037 typedef struct rtcp_rr_stat_t rtcp_rr_stat_t; 00038 00039 00040 /** RTP receiver statistics */ 00041 struct rtp_rx_stat_t { 00042 /** number of valid RTP packets received */ 00043 apr_uint32_t received_packets; 00044 /** number of invalid RTP packets received */ 00045 apr_uint32_t invalid_packets; 00046 00047 /** number of discarded in jitter buffer packets */ 00048 apr_uint32_t discarded_packets; 00049 /** number of ignored packets */ 00050 apr_uint32_t ignored_packets; 00051 00052 /** number of lost in network packets */ 00053 apr_uint32_t lost_packets; 00054 00055 /** number of restarts */ 00056 apr_byte_t restarts; 00057 }; 00058 00059 /** RTCP statistics used in Sender Report (SR) */ 00060 struct rtcp_sr_stat_t { 00061 /** sender source identifier */ 00062 apr_uint32_t ssrc; 00063 /** NTP timestamp (seconds) */ 00064 apr_uint32_t ntp_sec; 00065 /** NTP timestamp (fractions) */ 00066 apr_uint32_t ntp_frac; 00067 /** RTP timestamp */ 00068 apr_uint32_t rtp_ts; 00069 /** packets sent */ 00070 apr_uint32_t sent_packets; 00071 /** octets (bytes) sent */ 00072 apr_uint32_t sent_octets; 00073 }; 00074 00075 /** RTCP statistics used in Receiver Report (RR) */ 00076 struct rtcp_rr_stat_t { 00077 /** source identifier of RTP stream being received */ 00078 apr_uint32_t ssrc; 00079 /** fraction lost since last SR/RR */ 00080 apr_uint32_t fraction:8; 00081 /** cumulative number of packets lost (signed!) */ 00082 apr_int32_t lost:24; 00083 /** extended last sequence number received */ 00084 apr_uint32_t last_seq; 00085 /** interarrival jitter (RFC3550) */ 00086 apr_uint32_t jitter; 00087 /** last SR packet from this source */ 00088 apr_uint32_t lsr; 00089 /** delay since last SR packet */ 00090 apr_uint32_t dlsr; 00091 }; 00092 00093 00094 00095 /** Reset RTCP SR statistics */ 00096 static APR_INLINE void mpf_rtcp_sr_stat_reset(rtcp_sr_stat_t *sr_stat) 00097 { 00098 memset(sr_stat,0,sizeof(rtcp_sr_stat_t)); 00099 } 00100 00101 /** Reset RTCP RR statistics */ 00102 static APR_INLINE void mpf_rtcp_rr_stat_reset(rtcp_rr_stat_t *rr_stat) 00103 { 00104 memset(rr_stat,0,sizeof(rtcp_rr_stat_t)); 00105 } 00106 00107 /** Reset RTP receiver statistics */ 00108 static APR_INLINE void mpf_rtp_rx_stat_reset(rtp_rx_stat_t *rx_stat) 00109 { 00110 memset(rx_stat,0,sizeof(rtp_rx_stat_t)); 00111 } 00112 00113 APT_END_EXTERN_C 00114 00115 #endif /* MPF_RTP_STAT_H */