diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-05-20 23:47:28 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-05-20 23:47:28 +0200 |
commit | bbc2959d86e93fc73fcaacede130daa06e7c9cc2 (patch) | |
tree | e6ea22b00de0204e272a5121a9b4321bf10a7d56 | |
parent | 17d3ade17d91be83628b5e2f532232b4e1771fc2 (diff) |
rtpstat: fixup some formatting
-rw-r--r-- | src/audio.c | 82 | ||||
-rw-r--r-- | src/call.c | 37 | ||||
-rw-r--r-- | src/core.h | 4 |
3 files changed, 59 insertions, 64 deletions
diff --git a/src/audio.c b/src/audio.c index cd576e0..36f9c6a 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1398,66 +1398,62 @@ void audio_set_devicename(struct audio *a, const char *src, const char *play) * * https://www.avm.de/de/Extern/files/x-rtp/xrtpv32.pdf */ -int stream_rtpstat(struct re_printf *pf, const struct stream *s) +int audio_print_rtpstat(struct re_printf *pf, const struct audio *a) { - const struct rtcp_stats *rtcp; - const struct call *call = s->call; - const struct audio *a = call_audio(call); + const struct stream *s; + const struct rtcp_stats *rtcp; int srate_tx = 8000; int srate_rx = 8000; - int err; + int err; - if (!s) - return 1; + if (!a) + return 1; - rtcp = &s->rtcp_stats; + s = a->strm; + rtcp = &s->rtcp_stats; - if (!rtcp->tx.sent) { - info("\n\nNo RTCP data available.\n"); - return 1; - } + if (!rtcp->tx.sent) + return 1; if (a->tx.ac) srate_tx = get_srate(a->tx.ac); if (a->rx.ac) srate_rx = get_srate(a->rx.ac); - err = re_hprintf(pf, - "EX=BareSip;" /* Reporter Identifier */ - "CS=%d;" /* Call Setup in milliseconds */ - "CD=%d;" /* Call Duration in seconds */ - "PR=%u;PS=%u;" /* Packets RX, TX */ - "PL=%d,%d;" /* Packets Lost RX, TX */ - "PD=%d,%d;" /* Packets Discarded, RX, TX */ - "JI=%.1f,%.1f;" /* Jitter RX, TX in timestamp units */ - "IP=%J,%J" /* Local, Remote IPs */ - , - call_setup_duration(s->call) * 1000, - call_duration(s->call), + err = re_hprintf(pf, + "EX=BareSip;" /* Reporter Identifier */ + "CS=%d;" /* Call Setup in milliseconds */ + "CD=%d;" /* Call Duration in seconds */ + "PR=%u;PS=%u;" /* Packets RX, TX */ + "PL=%d,%d;" /* Packets Lost RX, TX */ + "PD=%d,%d;" /* Packets Discarded, RX, TX */ + "JI=%.1f,%.1f;" /* Jitter RX, TX in timestamp units */ + "IP=%J,%J" /* Local, Remote IPs */ + , + call_setup_duration(s->call) * 1000, + call_duration(s->call), - s->metric_rx.n_packets, - s->metric_tx.n_packets, + s->metric_rx.n_packets, + s->metric_tx.n_packets, - rtcp->rx.lost, rtcp->tx.lost, + rtcp->rx.lost, rtcp->tx.lost, - s->metric_rx.n_err, s->metric_tx.n_err, + s->metric_rx.n_err, s->metric_tx.n_err, - // timestamp units (ie: 8 ts units = 1 ms @ 8KHZ) - 1.0 * rtcp->rx.jit/1000 * (srate_rx/1000), - 1.0 * rtcp->tx.jit/1000 * (srate_rx/1000), + /* timestamp units (ie: 8 ts units = 1 ms @ 8KHZ) */ + 1.0 * rtcp->rx.jit/1000 * (srate_rx/1000), + 1.0 * rtcp->tx.jit/1000 * (srate_tx/1000), - sdp_media_laddr(s->sdp), - sdp_media_raddr(s->sdp) + sdp_media_laddr(s->sdp), + sdp_media_raddr(s->sdp) + ); - ); - - if (a->tx.ac) { - err |= re_hprintf(pf, ";EN=%s/%d", a->tx.ac->name, srate_tx ); - } - if (a->rx.ac) { - err |= re_hprintf(pf, ";DE=%s/%d", a->rx.ac->name, srate_rx ); - } + if (a->tx.ac) { + err |= re_hprintf(pf, ";EN=%s/%d", a->tx.ac->name, srate_tx ); + } + if (a->rx.ac) { + err |= re_hprintf(pf, ";DE=%s/%d", a->rx.ac->name, srate_rx ); + } - return err; + return err; } - @@ -73,8 +73,8 @@ struct call { call_event_h *eh; /**< Event handler */ call_dtmf_h *dtmfh; /**< DTMF handler */ void *arg; /**< Handler argument */ -
- struct config_avt config_avt;
+ + struct config_avt config_avt; }; @@ -442,8 +442,8 @@ int call_alloc(struct call **callp, const struct config *cfg, struct list *lst, MAGIC_INIT(call); - call->config_avt = cfg->avt;
-
+ call->config_avt = cfg->avt; + tmr_init(&call->tmr_inv); call->acc = mem_ref(acc); @@ -623,9 +623,9 @@ int call_hangup(struct call *call, uint16_t scode, const char *reason) if (!call) return EINVAL; - if (call->config_avt.rtp_stats)
- call_set_xrtpstat(call);
-
+ if (call->config_avt.rtp_stats) + call_set_xrtpstat(call); + switch (call->state) { case STATE_INCOMING: @@ -1626,15 +1626,14 @@ void call_set_handlers(struct call *call, call_event_h *eh, if (arg) call->arg = arg; } -
-
-void call_set_xrtpstat(struct call *call)
-{
- if (!call)
- return;
-
- sipsess_set_close_headers(call->sess,
- "X-RTP-Stat: %H\r\n",
- stream_rtpstat,
- audio_strm(call->audio));
-}
+ + +void call_set_xrtpstat(struct call *call) +{ + if (!call) + return; + + sipsess_set_close_headers(call->sess, + "X-RTP-Stat: %H\r\n", + audio_print_rtpstat, call->audio); +} @@ -124,6 +124,7 @@ int audio_decoder_set(struct audio *a, const struct aucodec *ac, struct stream *audio_strm(const struct audio *a); int audio_send_digit(struct audio *a, char key); void audio_sdp_attr_decode(struct audio *a); +int audio_print_rtpstat(struct re_printf *pf, const struct audio *au); /* @@ -168,7 +169,7 @@ int call_reset_transp(struct call *call); int call_notify_sipfrag(struct call *call, uint16_t scode, const char *reason, ...); int call_af(const struct call *call); -void call_set_xrtpstat(struct call *call);
+void call_set_xrtpstat(struct call *call); /* @@ -348,7 +349,6 @@ void stream_reset(struct stream *s); void stream_set_bw(struct stream *s, uint32_t bps); int stream_debug(struct re_printf *pf, const struct stream *s); int stream_print(struct re_printf *pf, const struct stream *s); -int stream_rtpstat(struct re_printf *pf, const struct stream *s);
/* |