mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-09 22:11:08 +02:00
improved sesion epoch storage; added live stream time field & added time field to statistics
This commit is contained in:
parent
ac93e06d65
commit
52f8295d5c
|
@ -200,8 +200,8 @@ typedef struct {
|
|||
ngx_uint_t hs_stage;
|
||||
|
||||
/* connection timestamps */
|
||||
uint32_t epoch;
|
||||
uint32_t peer_epoch;
|
||||
ngx_msec_t epoch;
|
||||
ngx_msec_t peer_epoch;
|
||||
|
||||
/* input stream 0 (reserved by RTMP spec)
|
||||
* is used as free chain link */
|
||||
|
|
|
@ -282,6 +282,7 @@ ngx_rtmp_handshake_parse_challenge(ngx_rtmp_session_t *s,
|
|||
return NGX_ERROR;
|
||||
}
|
||||
++b->pos;
|
||||
s->peer_epoch = 0;
|
||||
ngx_rtmp_rmemcpy(&s->peer_epoch, b->pos, 4);
|
||||
|
||||
p = b->pos + 4;
|
||||
|
@ -289,7 +290,7 @@ ngx_rtmp_handshake_parse_challenge(ngx_rtmp_session_t *s,
|
|||
"handshake: peer version=%i.%i.%i.%i epoch=%uD",
|
||||
(ngx_int_t)p[3], (ngx_int_t)p[2],
|
||||
(ngx_int_t)p[1], (ngx_int_t)p[0],
|
||||
s->peer_epoch);
|
||||
(uint32_t)s->peer_epoch);
|
||||
if (*(uint32_t *)p == 0) {
|
||||
s->hs_old = 1;
|
||||
return NGX_OK;
|
||||
|
|
|
@ -161,6 +161,7 @@ ngx_rtmp_live_get_stream(ngx_rtmp_session_t *s, u_char *name, int create)
|
|||
ngx_memzero(*stream, sizeof(ngx_rtmp_live_stream_t));
|
||||
ngx_memcpy((*stream)->name, name,
|
||||
ngx_min(sizeof((*stream)->name) - 1, len));
|
||||
(*stream)->epoch = ngx_current_msec;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ struct ngx_rtmp_live_stream_s {
|
|||
ngx_rtmp_bandwidth_t bw_in;
|
||||
ngx_rtmp_bandwidth_t bw_out;
|
||||
ngx_rtmp_live_meta_t meta;
|
||||
ngx_msec_t epoch;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1030,6 +1030,15 @@ ngx_rtmp_relay_disconnect(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
ngx_rtmp_relay_push(ctx-publish->session,
|
||||
&ctx->publish->name, &target);
|
||||
}*/
|
||||
#ifdef NGX_DEBUG
|
||||
{
|
||||
ngx_uint_t n = 0;
|
||||
for (cctx = &ctx->publish->play; *cctx; cctx = &(*cctx)->next, ++n);
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_RTMP, ctx->session->connection->log, 0,
|
||||
"relay: play left after disconnect app='%V' name='%V': %ui",
|
||||
&ctx->app, &ctx->name, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ctx->publish->play == NULL) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_RTMP,
|
||||
|
|
|
@ -227,6 +227,11 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
NGX_RTMP_STAT_ECS(stream->name);
|
||||
NGX_RTMP_STAT_L("</name>\r\n");
|
||||
|
||||
NGX_RTMP_STAT_L("<time>");
|
||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
||||
"%M", ngx_current_msec - stream->epoch) - buf);
|
||||
NGX_RTMP_STAT_L("</time>");
|
||||
|
||||
meta = &stream->meta;
|
||||
NGX_RTMP_STAT_L("<meta><width>");
|
||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
||||
|
@ -264,6 +269,11 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
NGX_RTMP_STAT_S(&s->connection->addr_text);
|
||||
NGX_RTMP_STAT_L("</address>");
|
||||
|
||||
NGX_RTMP_STAT_L("<time>");
|
||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
||||
"%M", ngx_current_msec - s->epoch) - buf);
|
||||
NGX_RTMP_STAT_L("</time>");
|
||||
|
||||
NGX_RTMP_STAT_L("<dropped>");
|
||||
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
|
||||
"%uz", ctx->dropped) - buf);
|
||||
|
|
48
stat.xsl
48
stat.xsl
|
@ -2,6 +2,7 @@
|
|||
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
|
@ -29,6 +30,7 @@
|
|||
<th>Video</th>
|
||||
<th>Audio</th>
|
||||
<th>State</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"/>
|
||||
|
@ -91,6 +93,11 @@
|
|||
<td><xsl:value-of select="meta/video"/></td>
|
||||
<td><xsl:value-of select="meta/audio"/></td>
|
||||
<td> <xsl:apply-templates select="publishing"/> </td>
|
||||
<td>
|
||||
<xsl:call-template name="showtime">
|
||||
<xsl:with-param name="time" select="time"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:none">
|
||||
<xsl:attribute name="id">
|
||||
|
@ -104,6 +111,7 @@
|
|||
<th>Flash version</th>
|
||||
<th>Page URL</th>
|
||||
<th>Dropped</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<xsl:apply-templates select="client"/>
|
||||
</table>
|
||||
|
@ -111,17 +119,34 @@
|
|||
</tr>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="showtime">
|
||||
<xsl:param name="time"/>
|
||||
|
||||
<xsl:variable name="sec">
|
||||
<xsl:value-of select="floor(time div 1000)"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test="$sec >= 86400">
|
||||
<xsl:value-of select="(floor($sec div 86400)) mod 60"/>d
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$sec >= 3600">
|
||||
<xsl:value-of select="(floor($sec div 3600)) mod 60"/>h
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$sec >= 60">
|
||||
<xsl:value-of select="(floor($sec div 60)) mod 60"/>m
|
||||
</xsl:if>
|
||||
|
||||
<xsl:value-of select="$sec mod 60"/>s
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="client">
|
||||
<tr bgcolor="#eeeeee">
|
||||
<td>
|
||||
<xsl:apply-templates select="publishing"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="address"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="flashver"/>
|
||||
</td>
|
||||
<td><xsl:apply-templates select="publishing"/></td>
|
||||
<td><xsl:value-of select="address"/></td>
|
||||
<td><xsl:value-of select="flashver"/></td>
|
||||
<td>
|
||||
<a target="_blank">
|
||||
<xsl:attribute name="href">
|
||||
|
@ -130,8 +155,11 @@
|
|||
<xsl:value-of select="pageurl"/>
|
||||
</a>
|
||||
</td>
|
||||
<td><xsl:value-of select="dropped"/></td>
|
||||
<td>
|
||||
<xsl:value-of select="dropped"/>
|
||||
<xsl:call-template name="showtime">
|
||||
<xsl:with-param name="time" select="time"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
|
|
Loading…
Reference in a new issue