mirror of https://bitbucket.org/ausocean/av.git
psi: start writing testing file
This commit is contained in:
parent
94cefe848a
commit
8fe430f5f5
|
@ -1,6 +1,7 @@
|
||||||
package psi
|
package psi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
)
|
)
|
||||||
|
@ -63,7 +64,7 @@ type PMT struct {
|
||||||
Pcrpid uint16 // Program clock reference pid
|
Pcrpid uint16 // Program clock reference pid
|
||||||
Pil uint16 // Program info length
|
Pil uint16 // Program info length
|
||||||
Pd []Desc // Program descriptors
|
Pd []Desc // Program descriptors
|
||||||
Essd ESSD // Elementary stream specific data
|
Essd *ESSD // Elementary stream specific data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elementary stream specific data
|
// Elementary stream specific data
|
||||||
|
@ -177,6 +178,13 @@ func readEssd(data []byte) *ESSD {
|
||||||
essd := ESSD{}
|
essd := ESSD{}
|
||||||
pos := 0
|
pos := 0
|
||||||
essd.St = data[pos]
|
essd.St = data[pos]
|
||||||
|
pos++
|
||||||
|
essd.Epid = uint16(data[pos]&0x1f)<<8 | uint16(data[pos+1])
|
||||||
|
pos += 2
|
||||||
|
essd.Esil = uint16(data[pos]&0x03)<<8 | uint16(data[pos+1])
|
||||||
|
pos += 2
|
||||||
|
essd.Esd = readDescs(data[pos:], int(essd.Esil))
|
||||||
|
return &essd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bytes outputs a byte slice representation of the PSI
|
// Bytes outputs a byte slice representation of the PSI
|
||||||
|
@ -295,3 +303,12 @@ func crc32_Update(crc uint32, tab *crc32.Table, p []byte) uint32 {
|
||||||
}
|
}
|
||||||
return crc
|
return crc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateTimestamp
|
||||||
|
func UpdateTimestamp(data []byte, t int) error {
|
||||||
|
psi := ReadPSI(data)
|
||||||
|
if psi.Tid != PATTableID {
|
||||||
|
return errors.New("Timestamp update failed because psi is not a PMT")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package psi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestReadPSI1(t *testing.T) {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue