Skip to content

Commit 9b4725a

Browse files
committed
fixed live timestamps in non-atc mode
1 parent b4ca0be commit 9b4725a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

ngx_rtmp_live_module.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
321321
size_t header_offset, last_offset;
322322
ngx_uint_t header_version, meta_version;
323323
ngx_int_t diff_timestamp;
324-
uint32_t *last;
324+
uint32_t *last, timestamp;
325325

326326
lacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_live_module);
327327
if (lacf == NULL) {
@@ -352,11 +352,16 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
352352
h->timestamp, h->timeshift);
353353

354354
cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);
355+
356+
timestamp = h->timestamp;
357+
if (lacf->atc == 0) {
358+
timestamp += h->timeshift;
359+
}
355360

356361
/* prepare output header */
357362
ngx_memzero(&ch, sizeof(ch));
358363
ngx_memzero(&lh, sizeof(lh));
359-
ch.timestamp = h->timestamp;
364+
ch.timestamp = timestamp;
360365
ch.msid = NGX_RTMP_LIVE_MSID;
361366
ch.type = h->type;
362367
lh.msid = ch.msid;
@@ -420,20 +425,20 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
420425
ss = pctx->session;
421426
last = (uint32_t *)((u_char *)pctx + last_offset);
422427

423-
ch.timestamp = lacf->atc ? h->timestamp :
424-
h->timeshift + h->timestamp - (uint32_t)ss->epoch;
428+
ch.timestamp = timestamp;
429+
if (lacf->atc == 0) {
430+
ch.timestamp -= (uint32_t)ss->epoch;
431+
}
425432

426433
/* send absolute frame */
427434
if ((pctx->msg_mask & (1 << h->type)) == 0) {
428435

429436
/* packet from the past for the peer */
430-
if (lacf->atc == 0 &&
431-
h->timeshift + h->timestamp < (uint32_t)ss->epoch)
432-
{
437+
if (lacf->atc == 0 && timestamp < (uint32_t)ss->epoch) {
433438
ngx_log_debug3(NGX_LOG_DEBUG_RTMP, ss->connection->log, 0,
434439
"live: av: %s packet from the past %uD < %uD",
435440
h->type == NGX_RTMP_MSG_VIDEO ? "video" : "audio",
436-
h->timeshift + h->timestamp, (uint32_t)ss->epoch);
441+
timestamp, (uint32_t)ss->epoch);
437442
continue;
438443
}
439444

0 commit comments

Comments
 (0)