From 2bc42d90f246b1ebe25453e373ed423f9cc4cb44 Mon Sep 17 00:00:00 2001 From: premultiply Date: Wed, 11 Nov 2015 15:31:05 +0100 Subject: [PATCH] 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 --- hls/ngx_rtmp_mpegts.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/hls/ngx_rtmp_mpegts.c b/hls/ngx_rtmp_mpegts.c index 9660807..0de52ec 100644 --- a/hls/ngx_rtmp_mpegts.c +++ b/hls/ngx_rtmp_mpegts.c @@ -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 */