forked from asticode/go-astits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_pmt_test.go
40 lines (35 loc) · 1.13 KB
/
data_pmt_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package astits
import (
"testing"
"github.com/asticode/go-astitools/binary"
"github.com/stretchr/testify/assert"
)
var pmt = &PMTData{
ElementaryStreams: []*PMTElementaryStream{{
ElementaryPID: 2730,
ElementaryStreamDescriptors: descriptors,
StreamType: StreamTypeMPEG1Audio,
}},
PCRPID: 5461,
ProgramDescriptors: descriptors,
ProgramNumber: 1,
}
func pmtBytes() []byte {
w := astibinary.New()
w.Write("111") // Reserved bits
w.Write("1010101010101") // PCR PID
w.Write("1111") // Reserved
descriptorsBytes(w) // Program descriptors
w.Write(uint8(StreamTypeMPEG1Audio)) // Stream #1 stream type
w.Write("111") // Stream #1 reserved
w.Write("0101010101010") // Stream #1 PID
w.Write("1111") // Stream #1 reserved
descriptorsBytes(w) // Stream #1 descriptors
return w.Bytes()
}
func TestParsePMTSection(t *testing.T) {
var offset int
var b = pmtBytes()
d := parsePMTSection(b, &offset, len(b), uint16(1))
assert.Equal(t, d, pmt)
}