|
|
@ -16,18 +16,140 @@ import (
|
|
|
|
"github.com/q191201771/lal/pkg/mpegts"
|
|
|
|
"github.com/q191201771/lal/pkg/mpegts"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FixedFragmentHeader 每个TS文件都以固定的PAT,PMT开始
|
|
|
|
|
|
|
|
var FixedFragmentHeader = []byte{
|
|
|
|
|
|
|
|
/* TS */
|
|
|
|
|
|
|
|
0x47, 0x40, 0x00, 0x10, 0x00,
|
|
|
|
|
|
|
|
/* PSI */
|
|
|
|
|
|
|
|
0x00, 0xb0, 0x0d, 0x00, 0x01, 0xc1, 0x00, 0x00,
|
|
|
|
|
|
|
|
/* PAT */
|
|
|
|
|
|
|
|
0x00, 0x01, 0xf0, 0x01,
|
|
|
|
|
|
|
|
/* CRC */
|
|
|
|
|
|
|
|
0x2e, 0x70, 0x19, 0x05,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* stuffing 167 bytes */
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TS */
|
|
|
|
|
|
|
|
0x47, 0x50, 0x01, 0x10, 0x00,
|
|
|
|
|
|
|
|
/* PSI */
|
|
|
|
|
|
|
|
0x02, 0xb0, 0x17, 0x00, 0x01, 0xc1, 0x00, 0x00,
|
|
|
|
|
|
|
|
/* PMT */
|
|
|
|
|
|
|
|
0xe1, 0x00,
|
|
|
|
|
|
|
|
0xf0, 0x00,
|
|
|
|
|
|
|
|
0x1b, 0xe1, 0x00, 0xf0, 0x00, /* avc epid 256 */
|
|
|
|
|
|
|
|
0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac epid 257 */
|
|
|
|
|
|
|
|
/* CRC */
|
|
|
|
|
|
|
|
0x2f, 0x44, 0xb9, 0x9b, /* crc for aac */
|
|
|
|
|
|
|
|
/* stuffing 157 bytes */
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FixedFragmentHeaderHevc 每个TS文件都以固定的PAT,PMT开始
|
|
|
|
|
|
|
|
var FixedFragmentHeaderHevc = []byte{
|
|
|
|
|
|
|
|
/* TS */
|
|
|
|
|
|
|
|
0x47, 0x40, 0x00, 0x10, 0x00,
|
|
|
|
|
|
|
|
/* PSI */
|
|
|
|
|
|
|
|
0x00, 0xb0, 0x0d, 0x00, 0x01, 0xc1, 0x00, 0x00,
|
|
|
|
|
|
|
|
/* PAT */
|
|
|
|
|
|
|
|
0x00, 0x01, 0xf0, 0x01,
|
|
|
|
|
|
|
|
/* CRC */
|
|
|
|
|
|
|
|
0x2e, 0x70, 0x19, 0x05,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* stuffing 167 bytes */
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TS */
|
|
|
|
|
|
|
|
0x47, 0x50, 0x01, 0x10, 0x00,
|
|
|
|
|
|
|
|
/* PSI */
|
|
|
|
|
|
|
|
0x02, 0xb0, 0x17, 0x00, 0x01, 0xc1, 0x00, 0x00,
|
|
|
|
|
|
|
|
/* PMT */
|
|
|
|
|
|
|
|
0xe1, 0x00,
|
|
|
|
|
|
|
|
0xf0, 0x00,
|
|
|
|
|
|
|
|
//0x1b, 0xe1, 0x00, 0xf0, 0x00, /* avc epid 256 */
|
|
|
|
|
|
|
|
0x24, 0xe1, 0x00, 0xf0, 0x00,
|
|
|
|
|
|
|
|
0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac epid 257 */
|
|
|
|
|
|
|
|
/* CRC */
|
|
|
|
|
|
|
|
//0x2f, 0x44, 0xb9, 0x9b, /* crc for aac */
|
|
|
|
|
|
|
|
0xc7, 0x72, 0xb7, 0xcb,
|
|
|
|
|
|
|
|
/* stuffing 157 bytes */
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestMpegts(t *testing.T) {
|
|
|
|
func TestMpegts(t *testing.T) {
|
|
|
|
innertest.Entry(t)
|
|
|
|
innertest.Entry(t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestParseFixedTsPacket(t *testing.T) {
|
|
|
|
func TestParseFixedTsPacket(t *testing.T) {
|
|
|
|
h := mpegts.ParseTsPacketHeader(mpegts.FixedFragmentHeader)
|
|
|
|
h := mpegts.ParseTsPacketHeader(FixedFragmentHeader)
|
|
|
|
mpegts.Log.Debugf("%+v", h)
|
|
|
|
mpegts.Log.Debugf("%+v", h)
|
|
|
|
pat := mpegts.ParsePat(mpegts.FixedFragmentHeader[5:])
|
|
|
|
pat := mpegts.ParsePat(FixedFragmentHeader[5:])
|
|
|
|
mpegts.Log.Debugf("%+v", pat)
|
|
|
|
mpegts.Log.Debugf("%+v", pat)
|
|
|
|
|
|
|
|
|
|
|
|
h = mpegts.ParseTsPacketHeader(mpegts.FixedFragmentHeaderHevc[188:])
|
|
|
|
h = mpegts.ParseTsPacketHeader(FixedFragmentHeaderHevc[188:])
|
|
|
|
mpegts.Log.Debugf("%+v", h)
|
|
|
|
mpegts.Log.Debugf("%+v", h)
|
|
|
|
pmt := mpegts.ParsePmt(mpegts.FixedFragmentHeader[188+5:])
|
|
|
|
pmt := mpegts.ParsePmt(FixedFragmentHeader[188+5:])
|
|
|
|
mpegts.Log.Debugf("%+v", pmt)
|
|
|
|
mpegts.Log.Debugf("%+v", pmt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|