From d10723122444e74e5201837c65477d99402fc74d Mon Sep 17 00:00:00 2001 From: saxon Date: Sat, 26 Jan 2019 18:04:21 +1030 Subject: [PATCH] stream/mts: starting to work out meta logistics in encoder.go and added incomplete AddDescriptor function in psi package --- stream/mts/encoder.go | 60 ++++++++++--------------------------------- stream/mts/psi/psi.go | 8 ++++++ 2 files changed, 21 insertions(+), 47 deletions(-) diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 53342624..d4c2ecd6 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -82,43 +82,6 @@ var ( }, }, } - - // standardPmtTimeLocation is a standard PMT with time and location - // descriptors, but time and location fields zeroed out. - standardPmtTimeLocation = psi.PSI{ - Pf: 0x00, - Tid: 0x02, - Ssi: true, - Sl: 0x3e, - Tss: &psi.TSS{ - Tide: 0x01, - V: 0, - Cni: true, - Sn: 0, - Lsn: 0, - Sd: &psi.PMT{ - Pcrpid: 0x0100, - Pil: psi.PmtTimeLocationPil, - Pd: []psi.Desc{ - { - Dt: psi.TimeDescTag, - Dl: psi.TimeDataSize, - Dd: make([]byte, psi.TimeDataSize), - }, - { - Dt: psi.LocationDescTag, - Dl: psi.LocationDataSize, - Dd: make([]byte, psi.LocationDataSize), - }, - }, - Essd: &psi.ESSD{ - St: 0x1b, - Epid: 0x0100, - Esil: 0x00, - }, - }, - }, - } ) const ( @@ -162,13 +125,24 @@ func (tl *timeLocation) Location() string { return l } +func updateMeta(b []byte) error { + var p psi.PSIBytes + p = b + // TODO: get length of meta data and format appropriately + metaLen := 0 + metaData := "" + + p.AddDescriptor(psi.MetadataTag, metaLen, metaData) + return nil +} + // MetData will hold time and location data which may be set externally if // this data is available. It is then inserted into mpegts packets outputted. var MetaData timeLocation var ( patTable = standardPat.Bytes() - pmtTable = standardPmtTimeLocation.Bytes() + pmtTable = standardPmt.Bytes() ) // Time related constants. @@ -283,15 +257,7 @@ func (e *Encoder) writePSI() error { return err } - // Update pmt table time and location. - err = psi.UpdateTime(pmtTable, MetaData.TimeStamp()) - if err != nil { - return err - } - err = psi.UpdateLocation(pmtTable, MetaData.Location()) - if err != nil { - return nil - } + updateMeta(pmtTable) // Create mts packet from pmt table. pmtPkt := Packet{ diff --git a/stream/mts/psi/psi.go b/stream/mts/psi/psi.go index 09028ba6..34063d0c 100644 --- a/stream/mts/psi/psi.go +++ b/stream/mts/psi/psi.go @@ -68,6 +68,14 @@ const ( crcSize = 4 ) +const MetadataTag = 0x26 + +type PSIBytes []byte + +func (p *PSIBytes) AddDescriptor(tag, len int, data string) { + +} + // Program specific information type PSI struct { Pf byte // Point field