Skip to content

Commit 8baf9a8

Browse files
committed
[fix] fix #115 committed in '[dev] the timestamp of stream starts at 0'.
1 parent c09ffa9 commit 8baf9a8

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

ngx_http_flv_live_module.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,19 +1576,39 @@ ngx_http_flv_live_write_handler(ngx_event_t *wev)
15761576
static void
15771577
ngx_http_flv_live_correct_timestamp(ngx_rtmp_session_t *s, ngx_flag_t correct)
15781578
{
1579-
uint8_t type;
1580-
uint32_t timestamp;
1581-
u_char *p, *pt;
1582-
ngx_buf_t *b;
1579+
uint8_t type;
1580+
uint32_t timestamp;
1581+
u_char *p, *pt;
1582+
ngx_chain_t *cl;
1583+
ngx_buf_t *b;
1584+
ngx_http_request_t *r;
1585+
1586+
cl = s->out_chain;
1587+
if (cl == NULL) {
1588+
return;
1589+
}
15831590

1584-
if (s->out_chain == NULL) {
1591+
if (cl != s->out[s->out_pos]) {
15851592
return;
15861593
}
15871594

1588-
b = s->out_chain->buf;
1595+
r = s->data;
1596+
if (r->chunked) {
1597+
cl = cl->next;
1598+
if (cl == NULL) {
1599+
return;
1600+
}
1601+
}
15891602

1603+
b = cl->buf;
15901604
if (b->start + NGX_RTMP_MAX_CHUNK_HEADER != b->pos) {
15911605
type = b->pos[0] & 0x1f;
1606+
1607+
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, s->connection->log, 0,
1608+
"flv live: type=%uD, chunked=%uD, "
1609+
"correct=%uD, offset_timestamp=%uD",
1610+
type, r->chunked, correct, s->offset_timestamp);
1611+
15921612
if (type != NGX_RTMP_MSG_VIDEO && type != NGX_RTMP_MSG_AUDIO) {
15931613
return;
15941614
}
@@ -1602,9 +1622,6 @@ ngx_http_flv_live_correct_timestamp(ngx_rtmp_session_t *s, ngx_flag_t correct)
16021622
pt[0] = *p++;
16031623
pt[3] = *p++;
16041624

1605-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, s->connection->log, 0,
1606-
"flv live: offset_timestamp=%uD", s->offset_timestamp);
1607-
16081625
if (correct) {
16091626
timestamp -= s->offset_timestamp;
16101627
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, s->connection->log, 0,
@@ -2171,8 +2188,8 @@ ngx_http_flv_live_append_message(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
21712188
}
21722189

21732190
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, s->connection->log, 0,
2174-
"flv live: timestamp=%uD, offset_timestamp=%uD",
2175-
h->timestamp, s->offset_timestamp);
2191+
"flv live: timestamp=%uD, offset_timestamp=%uD",
2192+
h->timestamp, s->offset_timestamp);
21762193
}
21772194

21782195
return ngx_http_flv_live_append_shared_bufs(cscf, h, in, r->chunked);

0 commit comments

Comments
 (0)