1 /*
2  * Copyright (c) 2004-2006 Maxim Sobolev <sobomax@FreeBSD.org>
3  * Copyright (c) 2006-2007 Sippy Software, Inc., http://www.sippysoft.com
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _RTP_ANALYZE_H_
30 #define _RTP_ANALYZE_H_
31 
32 struct rtpp_log;
33 struct rtpa_stats_jitter;
34 
35 #define PT_UNKN 128
36 
37 struct rtpp_session_stat_last {
38     long long pcount;
39     uint32_t min_seq;
40     uint32_t max_seq;
41     uint32_t seq_offset;
42     struct rtpp_ssrc ssrc;
43     uint32_t seen[4096];
44     uint32_t duplicates;
45     uint32_t base_ts;
46     uint16_t seq;
47     uint8_t pt;
48     double base_rtime;
49 };
50 
51 struct rtp_analyze_jitter;
52 
53 struct rtpp_session_stat {
54     uint32_t ssrc_changes;
55     uint32_t psent;
56     uint32_t precvd;
57     uint32_t duplicates;
58     uint32_t desync_count;
59     uint32_t seq_res_count;
60     struct rtpp_session_stat_last last;
61     struct rtp_analyze_jitter *jdata;
62 };
63 
64 enum update_rtpp_stats_rval {UPDATE_OK = 0, UPDATE_SSRC_CHG = 1, UPDATE_ERR = -1};
65 
66 int rtpp_stats_init(struct rtpp_session_stat *);
67 void rtpp_stats_destroy(struct rtpp_session_stat *);
68 enum update_rtpp_stats_rval update_rtpp_stats(struct rtpp_log *,
69   struct rtpp_session_stat *, rtp_hdr_t *, struct rtp_info *, double);
70 void update_rtpp_totals(struct rtpp_session_stat *, struct rtpp_session_stat *);
71 int get_jitter_stats(struct rtp_analyze_jitter *, struct rtpa_stats_jitter *);
72 
73 #endif
74