-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcue.go
49 lines (44 loc) · 1.02 KB
/
cue.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
41
42
43
44
45
46
47
48
49
package cuei
import (
"fmt"
)
// Cue a SCTE35 cue.
type Cue struct {
InfoSection
Command SpliceCommand
Descriptors []SpliceDescriptor `json:",omitempty"`
Packet PacketData `json:",omitempty"`
}
// Decode extracts bits for the Cue values.
func (cue *Cue) Decode(bites []byte) bool {
var bitn Bitn
bitn.Load(bites)
if !cue.InfoSection.Decode(&bitn) {
return false
}
cue.Command.Decoder(cue.InfoSection.SpliceCommandType, &bitn)
cue.InfoSection.DescriptorLoopLength = bitn.AsUInt64(16)
cue.dscptrLoop(&bitn)
return true
return false
}
// DscptrLoop loops over any splice descriptors
func (cue *Cue) dscptrLoop(bitn *Bitn) {
var i uint64
i = 0
l := cue.InfoSection.DescriptorLoopLength
for i < l {
tag := bitn.AsUInt8(8)
i++
length := bitn.AsUInt64(8)
i++
i += length
var sdr SpliceDescriptor
sdr.Decoder(bitn, tag, uint8(length))
cue.Descriptors = append(cue.Descriptors, sdr)
}
}
//Show display SCTE-35 data as JSON.
func (cue *Cue) Show() {
fmt.Println(MkJson(&cue))
}