mirror of https://bitbucket.org/ausocean/av.git
stream/mts: added some consts to describe indexes and masks, and fixed some syntax errors, so now it all builds
This commit is contained in:
parent
1be7e08b9e
commit
46b2bc4520
|
@ -83,6 +83,16 @@ const (
|
|||
SectionLenMask1 = 0x03
|
||||
)
|
||||
|
||||
const (
|
||||
ProgramInfoLenIdx1 = 11
|
||||
ProgramInfoLenIdx2 = 12
|
||||
ProgramInfoLenMask1 = 0x03
|
||||
)
|
||||
|
||||
const (
|
||||
DescriptorsIdx = ProgramInfoLenIdx2 + 1
|
||||
)
|
||||
|
||||
const MetadataTag = 0x26
|
||||
|
||||
type (
|
||||
|
@ -246,49 +256,49 @@ func (p *PSIBytes) ProgramInfoLen() int {
|
|||
return int((((*p)[ProgramInfoLenIdx1] & ProgramInfoLenMask1) << 8) | (*p)[ProgramInfoLenIdx2])
|
||||
}
|
||||
|
||||
func (p *PSIBytes) HasDescriptor(int tag) Descriptor {
|
||||
func (p *PSIBytes) HasDescriptor(tag int) Descriptor {
|
||||
descs := p.descriptors()
|
||||
if descs == nil {
|
||||
return nil
|
||||
}
|
||||
for i := 0; i < len(descs); {
|
||||
t := descs[i]
|
||||
t := int(descs[i])
|
||||
if t == tag {
|
||||
return esc[i : i+int(descs[i+1])]
|
||||
return descs[i : i+int(descs[i+1])]
|
||||
}
|
||||
i += 1 + desc[i+1]
|
||||
i += 1 + int(descs[i+1])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PSIBytes) descriptors() []byte {
|
||||
return p[DescriptorsIdx : DescriptorsIdx+p.ProgramInfoLen()]
|
||||
return (*p)[DescriptorsIdx : DescriptorsIdx+p.ProgramInfoLen()]
|
||||
}
|
||||
|
||||
func (p *PSIBytes) createDescriptor(tag, data) {
|
||||
func (p *PSIBytes) createDescriptor(tag int, data []byte) {
|
||||
curProgLen := p.ProgramInfoLen()
|
||||
dataLen := len(data)
|
||||
|
||||
// Calculate the new descriptors index and length.
|
||||
newDescIdx := DescriptorsIdx + curProgLen
|
||||
newDescLen := dLen + 2
|
||||
newDescLen := dataLen + 2
|
||||
|
||||
// Copy data down from newDescIdx to create room for the new descriptor.
|
||||
copy(p[newDescIdx+newDescLen:], p[newDescIdx:dataLen-newDescLen])
|
||||
copy((*p)[newDescIdx+newDescLen:], (*p)[newDescIdx:dataLen-newDescLen])
|
||||
|
||||
// Set the tag, data len and data of the new desriptor.
|
||||
p[newDescIdx] = tag
|
||||
p[newDescIdx+1] = dataLen
|
||||
copy(p[newDescIdx+2:newDescIdx+2+dataLen], data)
|
||||
(*p)[newDescIdx] = byte(tag)
|
||||
(*p)[newDescIdx+1] = byte(dataLen)
|
||||
copy((*p)[newDescIdx+2:newDescIdx+2+dataLen], data)
|
||||
|
||||
// Update the program info length to account for the new descriptor.
|
||||
newProgInfoLen := curProgLen + dataLen
|
||||
p[ProgramInfoLenIdx1] = newProgInfoLen >> 8
|
||||
p[ProgramInfoLenIdx2] = byte(newProgInfoLen)
|
||||
(*p)[ProgramInfoLenIdx1] = byte(newProgInfoLen >> 8)
|
||||
(*p)[ProgramInfoLenIdx2] = byte(newProgInfoLen)
|
||||
}
|
||||
|
||||
func (d *Descriptor) update(data) {
|
||||
if len(data) > d[1] {
|
||||
func (d *Descriptor) update(data []byte) {
|
||||
if len(data) > int((*d)[1]) {
|
||||
// TODO: implement resizing of descriptor
|
||||
panic("Can't resize descriptor data")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue