2020-06-08 03:29:51 +03:00
|
|
|
package protobuf
|
|
|
|
|
|
|
|
// TODO: move? make collection on known protobuf messages?
|
|
|
|
|
|
|
|
import (
|
2021-08-17 13:06:32 +03:00
|
|
|
"github.com/wader/fq/format"
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-07-16 19:39:57 +03:00
|
|
|
"github.com/wader/fq/pkg/interp"
|
2021-12-02 00:48:25 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
|
2023-03-29 01:36:55 +03:00
|
|
|
var widevineProtoBufGroup decode.Group
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
func init() {
|
2023-03-29 01:36:55 +03:00
|
|
|
interp.RegisterFormat(
|
|
|
|
format.ProtobufWidevine,
|
|
|
|
&decode.Format{
|
|
|
|
Description: "Widevine protobuf",
|
|
|
|
DecodeFn: widevineDecode,
|
|
|
|
Dependencies: []decode.Dependency{
|
|
|
|
{Groups: []*decode.Group{format.Protobuf}, Out: &widevineProtoBufGroup},
|
|
|
|
},
|
|
|
|
})
|
2020-06-08 03:29:51 +03:00
|
|
|
}
|
|
|
|
|
2023-02-18 23:10:48 +03:00
|
|
|
func widevineDecode(d *decode.D) any {
|
2020-06-08 03:29:51 +03:00
|
|
|
widewinePb := format.ProtoBufMessage{
|
2022-09-30 14:58:23 +03:00
|
|
|
1: {Type: format.ProtoBufTypeEnum, Name: "algorithm", Enums: scalar.UintMapSymStr{
|
2022-04-05 14:57:55 +03:00
|
|
|
0: "unencrypted",
|
|
|
|
1: "aesctr",
|
2020-06-08 03:29:51 +03:00
|
|
|
}},
|
|
|
|
2: {Type: format.ProtoBufTypeBytes, Name: "key_id"},
|
|
|
|
3: {Type: format.ProtoBufTypeString, Name: "provider"},
|
|
|
|
4: {Type: format.ProtoBufTypeBytes, Name: "content_id"},
|
|
|
|
6: {Type: format.ProtoBufTypeString, Name: "policy"},
|
|
|
|
7: {Type: format.ProtoBufTypeUInt32, Name: "crypto_period_index"},
|
|
|
|
8: {Type: format.ProtoBufTypeBytes, Name: "grouped_license"},
|
2022-09-30 14:58:23 +03:00
|
|
|
9: {Type: format.ProtoBufTypeUInt32, Name: "protection_scheme", Enums: scalar.UintMapSymStr{
|
2023-08-18 12:24:27 +03:00
|
|
|
// FourCC
|
|
|
|
0x63_65_6e_63: "cenc",
|
|
|
|
0x63_62_63_31: "cbc1",
|
|
|
|
0x63_65_6e_73: "cens",
|
|
|
|
0x63_62_63_73: "cbcs",
|
2020-06-08 03:29:51 +03:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
2023-05-01 14:19:04 +03:00
|
|
|
d.Format(&widevineProtoBufGroup, format.Protobuf_In{Message: widewinePb})
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|