From fa0498bc52b5a88efce87a5006893c4b95d9ab66 Mon Sep 17 00:00:00 2001 From: saxon Date: Thu, 6 Dec 2018 00:41:53 +1030 Subject: [PATCH] psi: wrote bytes() for pat --- stream/mts/psi/psi.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/stream/mts/psi/psi.go b/stream/mts/psi/psi.go index ec56e8aa..3047106f 100644 --- a/stream/mts/psi/psi.go +++ b/stream/mts/psi/psi.go @@ -1,9 +1,10 @@ package psi const ( - ESSDHeadLen = 5 - DescHeadLen = 2 - PMTHeadLen = 2 + ESSDDefLen = 5 + DescDefLen = 2 + PMTDefLen = 4 + PATLen = 4 ) // Program specific information @@ -73,11 +74,17 @@ func (p *PSI) Bytes() (out []byte) { func (t *TSS) Fill(s []byte) { } -func (p *PAT) Fill(s []byte) { +func (p *PAT) Bytes() []byte { + out := make([]byte, PATLen) + out[0] = byte(p.pn >> 8) + out[1] = byte(p.pn) + out[2] = 0xe0 | (0x1f & byte(p.pmpid>>8)) + out[3] = byte(p.pmpid) + return out } func (p *PMT) Bytes() []byte { - out := make([]byte, PMTHeadLen) + out := make([]byte, PMTDefLen) out[0] = 0xe0 | (0x1f & byte(p.pcrpid>>8)) out[1] = byte(p.pcrpid) out[2] = 0xf0 | (0x03 & byte(p.pil>>8)) @@ -92,7 +99,7 @@ func (p *PMT) Bytes() []byte { } func (d *Desc) Bytes() []byte { - out := make([]byte, DescHeadLen) + out := make([]byte, DescDefLen) out[0] = d.dt out[1] = d.dl out = append(out, d.dd...) @@ -100,7 +107,7 @@ func (d *Desc) Bytes() []byte { } func (e *ESSD) Bytes() []byte { - out := make([]byte, ESSDHeadLen) + out := make([]byte, ESSDDefLen) out[0] = e.st out[1] = 0xe0 | (0x1f & byte(e.epid>>8)) out[2] = byte(e.epid)