stream/mts/psi.go: added more to AddDescriptor and added signature for edistDesc

This commit is contained in:
saxon 2019-01-26 23:35:31 +10:30
parent ecf7263bc1
commit 6f421ab706
2 changed files with 35 additions and 2 deletions

View File

@ -252,7 +252,6 @@ func (e *Encoder) ccFor(pid int) byte {
func updateMeta(b []byte) error { func updateMeta(b []byte) error {
var p psi.PSIBytes var p psi.PSIBytes
p = b p = b
// TODO: get length of meta data and format appropriately
m := meta.Format() m := meta.Format()
p.AddDescriptor(psi.MetadataTag, len(m), m) p.AddDescriptor(psi.MetadataTag, len(m), m)
return nil return nil

View File

@ -26,6 +26,12 @@ LICENSE
package psi package psi
import (
"errors"
"github.com/Comcast/gots/psi"
)
const ( const (
PacketSize = 184 // packet size of a psi. PacketSize = 184 // packet size of a psi.
) )
@ -68,11 +74,39 @@ const (
crcSize = 4 crcSize = 4
) )
const (
SectionLenIdx1 = 2
SectionLenIdx2 = 3
)
const (
SectionLenMask1 = 0x03
)
const MetadataTag = 0x26 const MetadataTag = 0x26
type PSIBytes []byte type PSIBytes []byte
func (p *PSIBytes) AddDescriptor(tag, len int, data []byte) { func (p *PSIBytes) AddDescriptor(tag int, data []byte) error {
// first check that we actually have table syntax section
// NB: if table syntax section doesn't exist (unlikely I think) then we could
// just add it
// Check that this is actually a PMT
if psi.TableID(*p) != pmtID {
return errors.New("trying to add descriptor, but not pmt")
}
if !p.editDesc(tag, data) {
}
// if exists update
// otherwise add
return nil
}
func (p *PSIBytes) editDesc(tag int, data []byte) bool {
return true
} }
// Program specific information // Program specific information