Merge branch 'peer-timestamp'

This commit is contained in:
Roman Arutyunyan 2013-11-03 23:37:38 +04:00
commit b564a096fd
7 changed files with 28 additions and 0 deletions

View file

@ -221,6 +221,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;

View file

@ -542,6 +542,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;

View file

@ -718,6 +718,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;
@ -917,6 +919,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 {
@ -938,6 +941,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;
@ -971,6 +975,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) {

View file

@ -2271,6 +2271,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;
}

View file

@ -695,6 +695,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("&timestamp=") + NGX_INT32_LEN +
sizeof("&name=") + name_len * 3 +
1 + args_len);
if (b == NULL) {
@ -712,6 +713,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 *) "&timestamp=",
sizeof("&timestamp=") - 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,

View file

@ -424,6 +424,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/>");
}
@ -510,6 +515,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) {
@ -544,6 +550,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");
}
}

View file

@ -196,6 +196,7 @@
<th>Page URL</th>
<th>SWF URL</th>
<th>Dropped</th>
<th>Timestamp</th>
<th>A-V</th>
<th>Time</th>
</tr>
@ -295,6 +296,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">