mirror of
https://github.com/wader/fq.git
synced 2024-12-02 12:45:53 +03:00
1ddea1ada3
Move registry to interp and add support for functions and filesystems. This will be used later for allow formats to add own functions and fq code. Add gojqextra function helpers to have more comfortable API to add functions. Takes care of argument type casting and JQValue:s and some more things. Refactor interp package to use new function helper and registry. Probably fixes a bunch of JQValue bugs and other type errors. Refactor out some mpeg nal things to mpeg format. Refactor interp jq code into display.q and init.jq. Remove undocumented aes_ctr funciton, was a test. Hopefully will add more crypto things laster.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package mp4
|
|
|
|
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.PSSH_PLAYREADY,
|
|
Description: "PlayReady PSSH",
|
|
DecodeFn: playreadyPsshDecode,
|
|
})
|
|
}
|
|
|
|
const (
|
|
recordTypeRightsManagementHeader = 1
|
|
recordTypeLicenseStore = 2
|
|
)
|
|
|
|
var recordTypeNames = scalar.UToSymStr{
|
|
recordTypeRightsManagementHeader: "Rights management header",
|
|
recordTypeLicenseStore: "License store",
|
|
}
|
|
|
|
func playreadyPsshDecode(d *decode.D, in any) any {
|
|
d.Endian = decode.LittleEndian
|
|
|
|
d.FieldU32("size")
|
|
count := d.FieldU16("count")
|
|
i := uint64(0)
|
|
d.FieldStructArrayLoop("records", "record", func() bool { return i < count }, func(d *decode.D) {
|
|
recordType := d.FieldU16("type", recordTypeNames)
|
|
recordLen := d.FieldU16("len")
|
|
switch recordType {
|
|
case recordTypeRightsManagementHeader, recordTypeLicenseStore:
|
|
d.FieldUTF16LE("xml", int(recordLen))
|
|
default:
|
|
d.FieldRawLen("data", int64(recordLen)*8)
|
|
}
|
|
i++
|
|
})
|
|
|
|
return nil
|
|
}
|