mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-14 16:01:09 +02:00
added current timestamp to stat and on_update
This commit is contained in:
parent
67443c28b4
commit
940ff26009
|
@ -220,6 +220,7 @@ typedef struct {
|
|||
ngx_msec_t epoch;
|
||||
ngx_msec_t peer_epoch;
|
||||
ngx_msec_t base_time;
|
||||
uint32_t current_time;
|
||||
|
||||
/* ping */
|
||||
ngx_event_t ping_evt;
|
||||
|
|
|
@ -541,6 +541,8 @@ next:
|
|||
h.timestamp > end_timestamp ? h.timestamp - end_timestamp : 0,
|
||||
h.timestamp, end_timestamp, (ngx_int_t) buflen);
|
||||
|
||||
s->current_time = h.timestamp;
|
||||
|
||||
/* too much data sent; schedule timeout */
|
||||
if (h.timestamp > end_timestamp) {
|
||||
return h.timestamp - end_timestamp;
|
||||
|
|
|
@ -717,6 +717,8 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
"live: %s packet timestamp=%uD",
|
||||
type_s, h->timestamp);
|
||||
|
||||
s->current_time = h->timestamp;
|
||||
|
||||
peers = 0;
|
||||
apkt = NULL;
|
||||
aapkt = NULL;
|
||||
|
@ -916,6 +918,7 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
|
||||
cs->timestamp = lh.timestamp;
|
||||
cs->active = 1;
|
||||
ss->current_time = cs->timestamp;
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -937,6 +940,7 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
|
||||
cs->timestamp = ch.timestamp;
|
||||
cs->active = 1;
|
||||
ss->current_time = cs->timestamp;
|
||||
|
||||
++peers;
|
||||
|
||||
|
@ -970,6 +974,7 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
|||
|
||||
cs->timestamp += delta;
|
||||
++peers;
|
||||
ss->current_time = cs->timestamp;
|
||||
}
|
||||
|
||||
if (rpkt) {
|
||||
|
|
|
@ -2250,6 +2250,8 @@ ngx_rtmp_mp4_send(ngx_rtmp_session_t *s, ngx_file_t *f, ngx_uint_t *ts)
|
|||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
s->current_time = timestamp;
|
||||
|
||||
if (ngx_rtmp_mp4_next(s, t) != NGX_OK) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -694,6 +694,7 @@ ngx_rtmp_notify_update_create(ngx_rtmp_session_t *s, void *arg,
|
|||
b = ngx_create_temp_buf(pool,
|
||||
sizeof("&call=update") + sfx.len +
|
||||
sizeof("&time=") + NGX_TIME_T_LEN +
|
||||
sizeof("×tamp=") + NGX_INT32_LEN +
|
||||
sizeof("&name=") + name_len * 3 +
|
||||
1 + args_len);
|
||||
if (b == NULL) {
|
||||
|
@ -711,6 +712,10 @@ ngx_rtmp_notify_update_create(ngx_rtmp_session_t *s, void *arg,
|
|||
sizeof("&time=") - 1);
|
||||
b->last = ngx_sprintf(b->last, "%T", ngx_cached_time->sec - ctx->start);
|
||||
|
||||
b->last = ngx_cpymem(b->last, (u_char *) "×tamp=",
|
||||
sizeof("×tamp=") - 1);
|
||||
b->last = ngx_sprintf(b->last, "%D", s->current_time);
|
||||
|
||||
if (name_len) {
|
||||
b->last = ngx_cpymem(b->last, (u_char*) "&name=", sizeof("&name=") - 1);
|
||||
b->last = (u_char*) ngx_escape_uri(b->last, ctx->name, name_len,
|
||||
|
|
|
@ -421,6 +421,11 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
}
|
||||
NGX_RTMP_STAT_L("</avsync>");
|
||||
|
||||
NGX_RTMP_STAT_L("<timestamp>");
|
||||
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
|
||||
"%D", s->current_time) - bbuf);
|
||||
NGX_RTMP_STAT_L("</timestamp>");
|
||||
|
||||
if (ctx->publishing) {
|
||||
NGX_RTMP_STAT_L("<publishing/>");
|
||||
}
|
||||
|
@ -507,6 +512,7 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
ngx_rtmp_session_t *s;
|
||||
ngx_uint_t n, nclients, total_nclients;
|
||||
u_char buf[NGX_INT_T_LEN];
|
||||
u_char bbuf[NGX_INT32_LEN];
|
||||
ngx_rtmp_stat_loc_conf_t *slcf;
|
||||
|
||||
if (pacf->entries.nelts == 0) {
|
||||
|
@ -541,6 +547,11 @@ ngx_rtmp_stat_play(ngx_http_request_t *r, ngx_chain_t ***lll,
|
|||
|
||||
ngx_rtmp_stat_client(r, lll, s);
|
||||
|
||||
NGX_RTMP_STAT_L("<timestamp>");
|
||||
NGX_RTMP_STAT(bbuf, ngx_snprintf(bbuf, sizeof(bbuf),
|
||||
"%D", s->current_time) - bbuf);
|
||||
NGX_RTMP_STAT_L("</timestamp>");
|
||||
|
||||
NGX_RTMP_STAT_L("</client>\r\n");
|
||||
}
|
||||
}
|
||||
|
|
2
stat.xsl
2
stat.xsl
|
@ -189,6 +189,7 @@
|
|||
<th>Page URL</th>
|
||||
<th>SWF URL</th>
|
||||
<th>Dropped</th>
|
||||
<th>Timestamp</th>
|
||||
<th>A-V</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
|
@ -288,6 +289,7 @@
|
|||
</td>
|
||||
<td><xsl:value-of select="swfurl"/></td>
|
||||
<td><xsl:value-of select="dropped"/></td>
|
||||
<td><xsl:value-of select="timestamp"/></td>
|
||||
<td><xsl:value-of select="avsync"/></td>
|
||||
<td>
|
||||
<xsl:call-template name="showtime">
|
||||
|
|
Loading…
Reference in a new issue