Coverage Report

Created: 2025-12-11 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rtpproxy/src/rtpp_acct.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2004-2006 Maxim Sobolev <sobomax@FreeBSD.org>
3
 * Copyright (c) 2006-2016 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
#include <stddef.h>
30
#include <stdint.h>
31
#include <stdlib.h>
32
33
#include "rtpp_ssrc.h"
34
#include "rtpa_stats.h"
35
#include "rtpp_types.h"
36
#include "rtpp_time.h"
37
#include "rtpp_pcnts_strm.h"
38
#include "rtpp_pcount.h"
39
#include "rtpp_mallocs.h"
40
#include "rtpp_codeptr.h"
41
#include "rtpp_refcnt.h"
42
#include "rtpp_acct_pipe.h"
43
#include "rtpp_acct.h"
44
#include "rtpp_netaddr.h"
45
46
struct rtpp_acct_face_s {
47
    struct rtpp_pcnts_strm ps;
48
};
49
50
struct rtpp_acct_pipe_s {
51
    struct rtpp_acct_face_s o;
52
    struct rtpp_acct_face_s a;
53
    struct rtpps_pcount pcnts;
54
};
55
56
struct rtpp_acct_priv {
57
    struct rtpp_acct pub;
58
    struct rtpp_acct_pipe_s _rtp;
59
    struct rtpp_acct_pipe_s _rtcp;
60
    struct rtpa_stats _rasto;
61
    struct rtpa_stats _rasta;
62
    struct rtpa_stats_jitter _jrasto;
63
    struct rtpa_stats_jitter _jrasta;
64
    struct rtpp_timestamp _init_ts;
65
    struct rtpp_timestamp _destroy_ts;
66
};
67
68
static void rtpp_acct_dtor(struct rtpp_acct_priv *);
69
70
struct rtpp_acct *
71
rtpp_acct_ctor(uint64_t seuid)
72
29.9k
{
73
29.9k
    struct rtpp_acct_priv *pvt;
74
75
29.9k
    pvt = rtpp_rzmalloc(sizeof(struct rtpp_acct_priv), PVT_RCOFFS(pvt));
76
29.9k
    if (pvt == NULL) {
77
0
        goto e0;
78
0
    }
79
29.9k
    pvt->pub.seuid = seuid;
80
29.9k
    pvt->pub.rtp.pcnts = &pvt->_rtp.pcnts;
81
29.9k
    pvt->pub.rtcp.pcnts = &pvt->_rtcp.pcnts;
82
29.9k
    pvt->pub.rtp.o.ps = &pvt->_rtp.o.ps;
83
29.9k
    pvt->pub.rtp.a.ps = &pvt->_rtp.a.ps;
84
29.9k
    pvt->pub.rtcp.o.ps = &pvt->_rtcp.o.ps;
85
29.9k
    pvt->pub.rtcp.a.ps = &pvt->_rtcp.a.ps;
86
29.9k
    pvt->pub.rasto = &pvt->_rasto;
87
29.9k
    pvt->pub.rasta = &pvt->_rasta;
88
29.9k
    pvt->pub.jrasto = &pvt->_jrasto;
89
29.9k
    pvt->pub.jrasta = &pvt->_jrasta;
90
29.9k
    pvt->pub.init_ts = &pvt->_init_ts;
91
29.9k
    pvt->pub.destroy_ts = &pvt->_destroy_ts;
92
29.9k
    CALL_SMETHOD(pvt->pub.rcnt, attach, (rtpp_refcnt_dtor_t)&rtpp_acct_dtor,
93
29.9k
      pvt);
94
29.9k
    return ((&pvt->pub));
95
96
0
e0:
97
0
    return (NULL);
98
29.9k
}
99
100
static void
101
rtpp_acct_dtor(struct rtpp_acct_priv *pvt)
102
29.9k
{
103
104
    /*rtpp_acct_fin(&(pvt->pub));*/
105
29.9k
    if (pvt->pub.call_id != NULL)
106
29.9k
        free(pvt->pub.call_id);
107
29.9k
    if (pvt->pub.from_tag != NULL)
108
29.9k
        free(pvt->pub.from_tag);
109
29.9k
    if (pvt->pub.rtp.a.rem_addr != NULL)
110
29.9k
        RTPP_OBJ_DECREF(pvt->pub.rtp.a.rem_addr);
111
29.9k
    if (pvt->pub.rtp.o.rem_addr != NULL)
112
29.9k
        RTPP_OBJ_DECREF(pvt->pub.rtp.o.rem_addr);
113
29.9k
    if (pvt->pub.rtcp.a.rem_addr != NULL)
114
29.9k
        RTPP_OBJ_DECREF(pvt->pub.rtcp.a.rem_addr);
115
29.9k
    if (pvt->pub.rtcp.o.rem_addr != NULL)
116
29.9k
        RTPP_OBJ_DECREF(pvt->pub.rtcp.o.rem_addr);
117
29.9k
}