mirror of https://bitbucket.org/ausocean/av.git
psi: wrote bytes() for pmt
This commit is contained in:
parent
e2a5e6a16a
commit
1fd9bed1e4
|
@ -3,6 +3,7 @@ package psi
|
|||
const (
|
||||
ESSDHeadLen = 5
|
||||
DescHeadLen = 2
|
||||
PMTHeadLen = 2
|
||||
)
|
||||
|
||||
// Program specific information
|
||||
|
@ -49,7 +50,7 @@ type PMT struct {
|
|||
// Elementary stream specific data
|
||||
type ESSD struct {
|
||||
st byte // Stream type
|
||||
epid byte // Elementary pid
|
||||
epid uint16 // Elementary pid
|
||||
esil uint16 // Elementary stream
|
||||
esd []Desc // Elementary stream desriptors
|
||||
}
|
||||
|
@ -75,27 +76,38 @@ func (t *TSS) Fill(s []byte) {
|
|||
func (p *PAT) Fill(s []byte) {
|
||||
}
|
||||
|
||||
func (p *PMT) Bytes() (out []byte) {
|
||||
return nil
|
||||
func (p *PMT) Bytes() []byte {
|
||||
out := make([]byte, PMTHeadLen)
|
||||
out[0] = 0xe0 | (0x1f & byte(p.pcrpid>>8))
|
||||
out[1] = byte(p.pcrpid)
|
||||
out[2] = 0xf0 | (0x03 & byte(p.pil>>8))
|
||||
out[3] = byte(p.pil)
|
||||
for _, d := range p.pd {
|
||||
out = append(out, d.Bytes()...)
|
||||
}
|
||||
for _, e := range p.essd {
|
||||
out = append(out, e.Bytes()...)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (d *Desc) Bytes() (out []byte) {
|
||||
out = make([]byte, DescHeadLen)
|
||||
func (d *Desc) Bytes() []byte {
|
||||
out := make([]byte, DescHeadLen)
|
||||
out[0] = d.dt
|
||||
out[1] = d.dl
|
||||
out = append(out, d.dd...)
|
||||
return
|
||||
return out
|
||||
}
|
||||
|
||||
func (e *ESSD) Bytes() (out []byte) {
|
||||
out = make([]byte, ESSDHeadLen)
|
||||
func (e *ESSD) Bytes() []byte {
|
||||
out := make([]byte, ESSDHeadLen)
|
||||
out[0] = e.st
|
||||
out[1] = 0xe0 | e.epid>>3
|
||||
out[2] = e.epid
|
||||
out[3] = 0xf0 | byte(e.esil>>6)
|
||||
out[1] = 0xe0 | (0x1f & byte(e.epid>>8))
|
||||
out[2] = byte(e.epid)
|
||||
out[3] = 0xf0 | (0x03 & byte(e.esil>>8))
|
||||
out[4] = byte(e.esil)
|
||||
for _, d := range e.esd {
|
||||
out = append(out, d.Bytes()...)
|
||||
}
|
||||
return
|
||||
return out
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue