mirror of https://bitbucket.org/ausocean/av.git
stream/mts/psi: modified way in which we add padding to psi - now we leave it up to the mts package to do this on creation of an ts packet. Also in the middle of writing AddDescriptor func, and finding issues, hence the mentioned change.
This commit is contained in:
parent
2145db71d4
commit
252e6680ed
|
@ -168,6 +168,10 @@ func TestProgramInfoLen(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSectionLen(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestDescriptors(t *testing.T) {
|
||||
// Try psi with descriptors
|
||||
p := PSIBytes(tstPsi1.Bytes())
|
||||
|
|
|
@ -26,12 +26,6 @@ LICENSE
|
|||
|
||||
package psi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/Comcast/gots/psi"
|
||||
)
|
||||
|
||||
const (
|
||||
PacketSize = 184 // packet size of a psi.
|
||||
)
|
||||
|
@ -170,7 +164,6 @@ func (p *PSI) Bytes() []byte {
|
|||
out[3] = byte(p.Sl)
|
||||
out = append(out, p.Tss.Bytes()...)
|
||||
out = addCrc(out)
|
||||
out = addPadding(out)
|
||||
return out
|
||||
}
|
||||
|
||||
|
@ -241,6 +234,7 @@ func asByte(b bool) byte {
|
|||
}
|
||||
|
||||
func (p *PSIBytes) AddDescriptor(tag int, data []byte) error {
|
||||
/*
|
||||
if psi.TableID(*p) != pmtID {
|
||||
return errors.New("trying to add descriptor, but not pmt")
|
||||
}
|
||||
|
@ -257,13 +251,14 @@ func (p *PSIBytes) AddDescriptor(tag int, data []byte) error {
|
|||
newDescLen := 2 + newDataLen
|
||||
|
||||
// Shift data
|
||||
copy(p[i+newDescLen:], data)
|
||||
// copy(p[i+newDescLen:], data)
|
||||
|
||||
deltaLen := desc.len() - oldDescLen
|
||||
newProgInfoLen := p.ProgramInfoLen() + deltaLen
|
||||
p.SetProgInfoLen(newProgInfoLen)
|
||||
newSectionLen := int(psi.SectionLength(*p)) + deltaLen
|
||||
p.SetSectionLen(newSectionLen)
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -302,6 +297,9 @@ func (p *PSIBytes) createDescriptor(tag int, data []byte) {
|
|||
newDescLen := dataLen + 2
|
||||
|
||||
// Copy data down from newDescIdx to create room for the new descriptor.
|
||||
tmp := make([]byte, len(*p)+newDescLen)
|
||||
copy(tmp, *p)
|
||||
*p = tmp
|
||||
copy((*p)[newDescIdx+newDescLen:], (*p)[newDescIdx:newDescIdx+newDescLen])
|
||||
|
||||
// Set the tag, data len and data of the new desriptor.
|
||||
|
|
Loading…
Reference in New Issue