mirror of
https://github.com/wader/fq.git
synced 2024-12-25 14:23:18 +03:00
2fc0a71a47
Move scalar into own package. Split scalar code into decode related scalar code (that reads etc) and scalar code that just transform the scalar value. Use a scalar.Mapper interface instead of just a function. Make mappers, assert and validat impement the interface.
34 lines
813 B
Go
34 lines
813 B
Go
package mpeg
|
|
|
|
import (
|
|
"github.com/wader/fq/format"
|
|
"github.com/wader/fq/format/registry"
|
|
"github.com/wader/fq/pkg/decode"
|
|
"github.com/wader/fq/pkg/scalar"
|
|
)
|
|
|
|
func init() {
|
|
registry.MustRegister(decode.Format{
|
|
Name: format.MPEG_TS,
|
|
ProbeOrder: 10, // make sure to be after gif, both start with 0x47
|
|
Description: "MPEG Transport Stream",
|
|
Groups: []string{format.PROBE},
|
|
DecodeFn: tsDecode,
|
|
})
|
|
}
|
|
|
|
// TODO: ts_packet
|
|
|
|
func tsDecode(d *decode.D, in interface{}) interface{} {
|
|
d.FieldU8("sync", d.AssertU(0x47), scalar.Hex)
|
|
d.FieldBool("transport_error_indicator")
|
|
d.FieldBool("payload_unit_start")
|
|
d.FieldBool("transport_priority")
|
|
d.FieldU13("pid")
|
|
d.FieldU2("transport_scrambling_control")
|
|
d.FieldU2("adaptation_field_control")
|
|
d.FieldU4("continuity_counter")
|
|
|
|
return nil
|
|
}
|