Update FLV muxer

This commit is contained in:
Alex X
2023-09-17 14:07:55 +03:00
parent 9f1e33e0c6
commit 4dffceaf7e
2 changed files with 32 additions and 13 deletions
+23
View File
@@ -199,6 +199,8 @@ func (a *AMF) writeKV(obj map[string]any) {
a.WriteString(v)
case int:
a.WriteNumber(float64(v))
case uint16:
a.WriteNumber(float64(v))
case uint32:
a.WriteNumber(float64(v))
case float64:
@@ -214,3 +216,24 @@ func (a *AMF) writeKV(obj map[string]any) {
func (a *AMF) WriteNull() {
a.buf = append(a.buf, TypeNull)
}
func EncodeItems(items ...any) []byte {
a := &AMF{}
for _, item := range items {
switch v := item.(type) {
case float64:
a.WriteNumber(v)
case int:
a.WriteNumber(float64(v))
case string:
a.WriteString(v)
case map[string]any:
a.WriteObject(v)
case nil:
a.WriteNull()
default:
panic(v)
}
}
return a.Bytes()
}