Skip to content

Commit f39d3f6

Browse files
committed
added more data to stat
1 parent 0a5b066 commit f39d3f6

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

ngx_rtmp_stat_module.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,20 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
486486
total_nclients += nclients;
487487

488488
if (codec) {
489-
NGX_RTMP_STAT_L("<meta><width>");
489+
NGX_RTMP_STAT_L("<meta>");
490+
491+
NGX_RTMP_STAT_L("<video>");
492+
NGX_RTMP_STAT_L("<width>");
490493
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
491494
"%ui", codec->width) - buf);
492495
NGX_RTMP_STAT_L("</width><height>");
493496
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
494497
"%ui", codec->height) - buf);
495-
NGX_RTMP_STAT_L("</height><framerate>");
498+
NGX_RTMP_STAT_L("</height><frame_rate>");
496499
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
497500
"%ui", codec->frame_rate) - buf);
498-
NGX_RTMP_STAT_L("</framerate>");
501+
NGX_RTMP_STAT_L("</frame_rate>");
499502

500-
NGX_RTMP_STAT_L("<video>");
501503
cname = ngx_rtmp_get_video_codec_name(codec->video_codec_id);
502504
if (*cname) {
503505
NGX_RTMP_STAT_L("<codec>");
@@ -544,6 +546,17 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
544546
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
545547
"%ui", codec->aac_chan_conf) - buf);
546548
NGX_RTMP_STAT_L("</channels>");
549+
} else if (codec->audio_channels) {
550+
NGX_RTMP_STAT_L("<channels>");
551+
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
552+
"%ui", codec->audio_channels) - buf);
553+
NGX_RTMP_STAT_L("</channels>");
554+
}
555+
if (codec->sample_rate) {
556+
NGX_RTMP_STAT_L("<sample_rate>");
557+
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
558+
"%ui", codec->sample_rate) - buf);
559+
NGX_RTMP_STAT_L("</sample_rate>");
547560
}
548561
NGX_RTMP_STAT_L("</audio>");
549562

stat.xsl

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
<th>Out bytes</th>
3636
<th>Input bits/s</th>
3737
<th>Output bits/s</th>
38-
<th>Size</th>
39-
<th>Frame Rate</th>
40-
<th>Video</th>
41-
<th>Audio</th>
38+
<th colspan="3">Video</th>
39+
<th colspan="3">Audio</th>
4240
<th>State</th>
4341
<th>Time</th>
4442
</tr>
@@ -68,7 +66,13 @@
6866
<xsl:with-param name="persec" select="1"/>
6967
</xsl:call-template>
7068
</td>
71-
<td colspan="5"/>
69+
<th bgcolor="#999999">codec</th>
70+
<th bgcolor="#999999">size</th>
71+
<th bgcolor="#999999">fps</th>
72+
<th bgcolor="#999999">codec</th>
73+
<th bgcolor="#999999">freq</th>
74+
<th bgcolor="#999999">chan</th>
75+
<td/>
7276
<td>
7377
<xsl:call-template name="showtime">
7478
<xsl:with-param name="time" select="/rtmp/uptime * 1000"/>
@@ -164,17 +168,22 @@
164168
</xsl:call-template>
165169
</td>
166170
<td>
167-
<xsl:if test="meta/width &gt; 0">
168-
<xsl:value-of select="meta/width"/>x<xsl:value-of select="meta/height"/>
169-
</xsl:if>
171+
<xsl:value-of select="meta/video/codec"/>&#160;<xsl:value-of select="meta/video/profile"/>&#160;<xsl:value-of select="meta/video/level"/>
170172
</td>
171-
<td align="middle"><xsl:value-of select="meta/framerate"/></td>
172173
<td>
173-
<xsl:value-of select="meta/video/codec"/>&#160;<xsl:value-of select="meta/video/profile"/>&#160;<xsl:value-of select="meta/video/level"/>
174+
<xsl:apply-templates select="meta/video/width"/>
175+
</td>
176+
<td>
177+
<xsl:value-of select="meta/video/frame_rate"/>
174178
</td>
175179
<td>
176180
<xsl:value-of select="meta/audio/codec"/>&#160;<xsl:value-of select="meta/audio/profile"/>
177-
<xsl:apply-templates select="meta/audio/channels"/>
181+
</td>
182+
<td>
183+
<xsl:apply-templates select="meta/audio/sample_rate"/>
184+
</td>
185+
<td>
186+
<xsl:value-of select="meta/audio/channels"/>
178187
</td>
179188
<td><xsl:call-template name="streamstate"/></td>
180189
<td>
@@ -323,8 +332,8 @@
323332
active
324333
</xsl:template>
325334

326-
<xsl:template match="channels">
327-
x<xsl:value-of select="."/>
335+
<xsl:template match="width">
336+
<xsl:value-of select="."/>x<xsl:value-of select="../height"/>
328337
</xsl:template>
329338

330339
</xsl:stylesheet>

0 commit comments

Comments
 (0)