mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-05 21:11:07 +02:00
added audio and video bw to stat
This commit is contained in:
parent
da0128a2fc
commit
6bb620f2fc
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Bandwidth update interval in seconds */
|
/* Bandwidth update interval in seconds */
|
||||||
#define NGX_RTMP_BANDWIDTH_INTERVAL 60
|
#define NGX_RTMP_BANDWIDTH_INTERVAL 10
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -1028,6 +1028,11 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||||
ngx_rtmp_update_bandwidth(&ctx->stream->bw_in, h->mlen);
|
ngx_rtmp_update_bandwidth(&ctx->stream->bw_in, h->mlen);
|
||||||
ngx_rtmp_update_bandwidth(&ctx->stream->bw_out, h->mlen * peers);
|
ngx_rtmp_update_bandwidth(&ctx->stream->bw_out, h->mlen * peers);
|
||||||
|
|
||||||
|
ngx_rtmp_update_bandwidth(h->type == NGX_RTMP_MSG_AUDIO ?
|
||||||
|
&ctx->stream->bw_in_audio :
|
||||||
|
&ctx->stream->bw_in_video,
|
||||||
|
h->mlen);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ struct ngx_rtmp_live_stream_s {
|
||||||
ngx_rtmp_live_stream_t *next;
|
ngx_rtmp_live_stream_t *next;
|
||||||
ngx_rtmp_live_ctx_t *ctx;
|
ngx_rtmp_live_ctx_t *ctx;
|
||||||
ngx_rtmp_bandwidth_t bw_in;
|
ngx_rtmp_bandwidth_t bw_in;
|
||||||
|
ngx_rtmp_bandwidth_t bw_in_audio;
|
||||||
|
ngx_rtmp_bandwidth_t bw_in_video;
|
||||||
ngx_rtmp_bandwidth_t bw_out;
|
ngx_rtmp_bandwidth_t bw_out;
|
||||||
ngx_msec_t epoch;
|
ngx_msec_t epoch;
|
||||||
unsigned active:1;
|
unsigned active:1;
|
||||||
|
|
|
@ -245,34 +245,39 @@ ngx_rtmp_stat_output(ngx_http_request_t *r, ngx_chain_t ***lll,
|
||||||
#define NGX_RTMP_STAT_ECS(s) NGX_RTMP_STAT_E((s), ngx_strlen(s))
|
#define NGX_RTMP_STAT_ECS(s) NGX_RTMP_STAT_E((s), ngx_strlen(s))
|
||||||
|
|
||||||
|
|
||||||
|
#define NGX_RTMP_STAT_BW 0x01
|
||||||
|
#define NGX_RTMP_STAT_BYTES 0x02
|
||||||
|
#define NGX_RTMP_STAT_BW_BYTES 0x03
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ngx_rtmp_stat_bw(ngx_http_request_t *r, ngx_chain_t ***lll,
|
ngx_rtmp_stat_bw(ngx_http_request_t *r, ngx_chain_t ***lll,
|
||||||
ngx_rtmp_bandwidth_t *bw_in, ngx_rtmp_bandwidth_t *bw_out)
|
ngx_rtmp_bandwidth_t *bw, char *name,
|
||||||
|
ngx_uint_t flags)
|
||||||
{
|
{
|
||||||
u_char buf[NGX_INT64_LEN + 1];
|
u_char buf[NGX_INT64_LEN + 1];
|
||||||
|
|
||||||
ngx_rtmp_update_bandwidth(bw_in, 0);
|
ngx_rtmp_update_bandwidth(bw, 0);
|
||||||
ngx_rtmp_update_bandwidth(bw_out, 0);
|
|
||||||
|
|
||||||
NGX_RTMP_STAT_L("<in>");
|
if (flags & NGX_RTMP_STAT_BW) {
|
||||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
NGX_RTMP_STAT_L("<bw_");
|
||||||
"%uL", bw_in->bytes) - buf);
|
NGX_RTMP_STAT_CS(name);
|
||||||
NGX_RTMP_STAT_L("</in>\r\n");
|
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf), ">%uL</bw_",
|
||||||
|
bw->bandwidth * 8)
|
||||||
|
- buf);
|
||||||
|
NGX_RTMP_STAT_CS(name);
|
||||||
|
NGX_RTMP_STAT_L(">\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
NGX_RTMP_STAT_L("<out>");
|
if (flags & NGX_RTMP_STAT_BYTES) {
|
||||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
NGX_RTMP_STAT_L("<bytes_");
|
||||||
"%uL", bw_out->bytes) - buf);
|
NGX_RTMP_STAT_CS(name);
|
||||||
NGX_RTMP_STAT_L("</out>\r\n");
|
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf), ">%uL</bytes_",
|
||||||
|
bw->bytes)
|
||||||
NGX_RTMP_STAT_L("<bwin>");
|
- buf);
|
||||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
NGX_RTMP_STAT_CS(name);
|
||||||
"%uL", bw_in->bandwidth * 8) - buf);
|
NGX_RTMP_STAT_L(">\r\n");
|
||||||
NGX_RTMP_STAT_L("</bwin>\r\n");
|
}
|
||||||
|
|
||||||
NGX_RTMP_STAT_L("<bwout>");
|
|
||||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
|
||||||
"%uL", bw_out->bandwidth * 8) - buf);
|
|
||||||
NGX_RTMP_STAT_L("</bwout>\r\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,7 +445,14 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
|
||||||
- buf);
|
- buf);
|
||||||
NGX_RTMP_STAT_L("</time>");
|
NGX_RTMP_STAT_L("</time>");
|
||||||
|
|
||||||
ngx_rtmp_stat_bw(r, lll, &stream->bw_in, &stream->bw_out);
|
ngx_rtmp_stat_bw(r, lll, &stream->bw_in, "in",
|
||||||
|
NGX_RTMP_STAT_BW_BYTES);
|
||||||
|
ngx_rtmp_stat_bw(r, lll, &stream->bw_out, "out",
|
||||||
|
NGX_RTMP_STAT_BW_BYTES);
|
||||||
|
ngx_rtmp_stat_bw(r, lll, &stream->bw_in_audio, "audio",
|
||||||
|
NGX_RTMP_STAT_BW);
|
||||||
|
ngx_rtmp_stat_bw(r, lll, &stream->bw_in_video, "video",
|
||||||
|
NGX_RTMP_STAT_BW);
|
||||||
|
|
||||||
nclients = 0;
|
nclients = 0;
|
||||||
codec = NULL;
|
codec = NULL;
|
||||||
|
@ -773,7 +785,8 @@ ngx_rtmp_stat_handler(ngx_http_request_t *r)
|
||||||
"%ui", ngx_rtmp_naccepted) - nbuf);
|
"%ui", ngx_rtmp_naccepted) - nbuf);
|
||||||
NGX_RTMP_STAT_L("</naccepted>\r\n");
|
NGX_RTMP_STAT_L("</naccepted>\r\n");
|
||||||
|
|
||||||
ngx_rtmp_stat_bw(r, lll, &ngx_rtmp_bw_in, &ngx_rtmp_bw_out);
|
ngx_rtmp_stat_bw(r, lll, &ngx_rtmp_bw_in, "in", NGX_RTMP_STAT_BW_BYTES);
|
||||||
|
ngx_rtmp_stat_bw(r, lll, &ngx_rtmp_bw_out, "out", NGX_RTMP_STAT_BW_BYTES);
|
||||||
|
|
||||||
cscf = cmcf->servers.elts;
|
cscf = cmcf->servers.elts;
|
||||||
for (n = 0; n < cmcf->servers.nelts; ++n, ++cscf) {
|
for (n = 0; n < cmcf->servers.nelts; ++n, ++cscf) {
|
||||||
|
|
40
stat.xsl
40
stat.xsl
|
@ -33,10 +33,10 @@
|
||||||
<th>#clients</th>
|
<th>#clients</th>
|
||||||
<th>In bytes</th>
|
<th>In bytes</th>
|
||||||
<th>Out bytes</th>
|
<th>Out bytes</th>
|
||||||
<th>Input bits/s</th>
|
<th>In bits/s</th>
|
||||||
<th>Output bits/s</th>
|
<th>Out bits/s</th>
|
||||||
<th colspan="3">Video</th>
|
<th colspan="4">Video</th>
|
||||||
<th colspan="3">Audio</th>
|
<th colspan="4">Audio</th>
|
||||||
<th>State</th>
|
<th>State</th>
|
||||||
<th>Time</th>
|
<th>Time</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -44,32 +44,34 @@
|
||||||
<td colspan="2">Accepted: <xsl:value-of select="naccepted"/></td>
|
<td colspan="2">Accepted: <xsl:value-of select="naccepted"/></td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="in"/>
|
<xsl:with-param name="size" select="bytes_in"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="out"/>
|
<xsl:with-param name="size" select="bytes_out"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="bwin"/>
|
<xsl:with-param name="size" select="bw_in"/>
|
||||||
<xsl:with-param name="bits" select="1"/>
|
<xsl:with-param name="bits" select="1"/>
|
||||||
<xsl:with-param name="persec" select="1"/>
|
<xsl:with-param name="persec" select="1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="bwout"/>
|
<xsl:with-param name="size" select="bw_out"/>
|
||||||
<xsl:with-param name="bits" select="1"/>
|
<xsl:with-param name="bits" select="1"/>
|
||||||
<xsl:with-param name="persec" select="1"/>
|
<xsl:with-param name="persec" select="1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<th bgcolor="#999999">codec</th>
|
<th bgcolor="#999999">codec</th>
|
||||||
|
<th bgcolor="#999999">bits/s</th>
|
||||||
<th bgcolor="#999999">size</th>
|
<th bgcolor="#999999">size</th>
|
||||||
<th bgcolor="#999999">fps</th>
|
<th bgcolor="#999999">fps</th>
|
||||||
<th bgcolor="#999999">codec</th>
|
<th bgcolor="#999999">codec</th>
|
||||||
|
<th bgcolor="#999999">bits/s</th>
|
||||||
<th bgcolor="#999999">freq</th>
|
<th bgcolor="#999999">freq</th>
|
||||||
<th bgcolor="#999999">chan</th>
|
<th bgcolor="#999999">chan</th>
|
||||||
<td/>
|
<td/>
|
||||||
|
@ -145,24 +147,24 @@
|
||||||
<td align="middle"> <xsl:value-of select="nclients"/> </td>
|
<td align="middle"> <xsl:value-of select="nclients"/> </td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="in"/>
|
<xsl:with-param name="size" select="bytes_in"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="out"/>
|
<xsl:with-param name="size" select="bytes_out"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="bwin"/>
|
<xsl:with-param name="size" select="bw_in"/>
|
||||||
<xsl:with-param name="bits" select="1"/>
|
<xsl:with-param name="bits" select="1"/>
|
||||||
<xsl:with-param name="persec" select="1"/>
|
<xsl:with-param name="persec" select="1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:call-template name="showsize">
|
<xsl:call-template name="showsize">
|
||||||
<xsl:with-param name="size" select="bwout"/>
|
<xsl:with-param name="size" select="bw_out"/>
|
||||||
<xsl:with-param name="bits" select="1"/>
|
<xsl:with-param name="bits" select="1"/>
|
||||||
<xsl:with-param name="persec" select="1"/>
|
<xsl:with-param name="persec" select="1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
|
@ -170,6 +172,13 @@
|
||||||
<td>
|
<td>
|
||||||
<xsl:value-of select="meta/video/codec"/> <xsl:value-of select="meta/video/profile"/> <xsl:value-of select="meta/video/level"/>
|
<xsl:value-of select="meta/video/codec"/> <xsl:value-of select="meta/video/profile"/> <xsl:value-of select="meta/video/level"/>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<xsl:call-template name="showsize">
|
||||||
|
<xsl:with-param name="size" select="bw_video"/>
|
||||||
|
<xsl:with-param name="bits" select="1"/>
|
||||||
|
<xsl:with-param name="persec" select="1"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:apply-templates select="meta/video/width"/>
|
<xsl:apply-templates select="meta/video/width"/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -179,6 +188,13 @@
|
||||||
<td>
|
<td>
|
||||||
<xsl:value-of select="meta/audio/codec"/> <xsl:value-of select="meta/audio/profile"/>
|
<xsl:value-of select="meta/audio/codec"/> <xsl:value-of select="meta/audio/profile"/>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<xsl:call-template name="showsize">
|
||||||
|
<xsl:with-param name="size" select="bw_audio"/>
|
||||||
|
<xsl:with-param name="bits" select="1"/>
|
||||||
|
<xsl:with-param name="persec" select="1"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<xsl:apply-templates select="meta/audio/sample_rate"/>
|
<xsl:apply-templates select="meta/audio/sample_rate"/>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue