1
1
mirror of https://github.com/wader/fq.git synced 2024-12-02 12:45:53 +03:00
fq/format/mpeg/mpeg_ts.go
Mattias Wadman cae288e6be format,intepr: Refactor json, yaml, etc into formats also move out related functions
json, yaml, toml, xml, html, csv are now normal formats and most of them also particiate
in probing (not html and csv).

Also fixes a bunch of bugs in to/fromxml, to/fromjq etc.
2022-07-23 21:48:45 +02:00

34 lines
820 B
Go

package mpeg
import (
"github.com/wader/fq/format"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/interp"
"github.com/wader/fq/pkg/scalar"
)
func init() {
interp.RegisterFormat(decode.Format{
Name: format.MPEG_TS,
ProbeOrder: format.ProbeOrderBinFuzzy, // 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, _ any) any {
d.FieldU8("sync", d.AssertU(0x47), scalar.ActualHex)
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
}