MPEG TS improvements

- Changed PMT PID to widely used 0x0FFF (4095)
- Write PCR on every frames (for hardware decoders and other DVB compatible decoders)
- Recalculated PAT CRC32

TODO: Recalculate PMT CRC32
This commit is contained in:
premultiply 2015-11-11 15:31:05 +01:00
parent cd416d5fd2
commit 2bc42d90f2

View file

@ -17,9 +17,9 @@ static u_char ngx_rtmp_mpegts_header[] = {
/* PSI */
0x00, 0xb0, 0x0d, 0x00, 0x01, 0xc1, 0x00, 0x00,
/* PAT */
0x00, 0x01, 0xf0, 0x01,
0x00, 0x01, 0xef, 0xff,
/* CRC */
0x2e, 0x70, 0x19, 0x05,
0x36, 0x90, 0xe2, 0x3d,
/* stuffing 167 bytes */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -40,7 +40,7 @@ static u_char ngx_rtmp_mpegts_header[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
/* TS */
0x47, 0x50, 0x01, 0x10, 0x00,
0x47, 0x4f, 0xff, 0x10, 0x00,
/* PSI */
0x02, 0xb0, 0x17, 0x00, 0x01, 0xc1, 0x00, 0x00,
/* PMT */
@ -250,14 +250,12 @@ ngx_rtmp_mpegts_write_frame(ngx_rtmp_mpegts_file_t *file,
if (first) {
if (f->key) {
packet[3] |= 0x20; /* adaptation */
packet[3] |= 0x20; /* adaptation */
*p++ = 7; /* size */
*p++ = 0x50; /* random access + PCR */
*p++ = 7; /* size */
*p++ = 0x50; /* random access + PCR */
p = ngx_rtmp_mpegts_write_pcr(p, f->dts - NGX_RTMP_HLS_DELAY);
}
p = ngx_rtmp_mpegts_write_pcr(p, f->dts - NGX_RTMP_HLS_DELAY);
/* PES header */