Skip to content

Commit 5e0b44e

Browse files
committed
[dev] fixed an endian bug in http-flv (tested by qemu-system-mips64).
1 parent fd54989 commit 5e0b44e

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

hls/ngx_rtmp_mpegts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static u_char ngx_rtmp_mpegts_header[] = {
5050
0xff, 0xff, 0xff, 0xff, 0xff, /* video, filled dynamically */
5151
0xff, 0xff, 0xff, 0xff, 0xff, /* audio, filled dynamically */
5252
/* CRC */
53-
0xff, 0xff, 0xff, 0xff, /* calculate dynamically */
53+
0xff, 0xff, 0xff, 0xff, /* calculated dynamically */
5454
/* stuffing 157 bytes */
5555
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5656
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,

ngx_http_flv_live_module.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ ngx_http_flv_live_correct_timestamp(ngx_rtmp_session_t *s, ngx_flag_t correct)
16301630
{
16311631
uint8_t type;
16321632
uint32_t timestamp;
1633-
u_char *p, *pt;
1633+
u_char *p;
16341634
ngx_chain_t *cl;
16351635
ngx_buf_t *b;
16361636

@@ -1651,14 +1651,9 @@ ngx_http_flv_live_correct_timestamp(ngx_rtmp_session_t *s, ngx_flag_t correct)
16511651
return;
16521652
}
16531653

1654-
timestamp = 0;
1655-
pt = (u_char *) &timestamp;
1656-
16571654
p = b->pos + 4;
1658-
pt[2] = *p++;
1659-
pt[1] = *p++;
1660-
pt[0] = *p++;
1661-
pt[3] = *p++;
1655+
timestamp = ngx_rtmp_n3_to_h4(p);
1656+
timestamp |= ((uint32_t) p[3] << 24);
16621657

16631658
if (correct) {
16641659
timestamp -= s->offset_timestamp;
@@ -1671,10 +1666,9 @@ ngx_http_flv_live_correct_timestamp(ngx_rtmp_session_t *s, ngx_flag_t correct)
16711666
}
16721667

16731668
p = b->pos + 4;
1674-
p[2] = *pt++;
1675-
p[1] = *pt++;
1676-
p[0] = *pt++;
1677-
p[3] = *pt++;
1669+
ngx_rtmp_h4_to_n3(p, timestamp);
1670+
p += 3;
1671+
*p++ = (u_char) (timestamp >> 24);
16781672
}
16791673
}
16801674

0 commit comments

Comments
 (0)