From 9f0cf39b3be989af4342d48eb3f8cf721e2e7644 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Tue, 15 Aug 2023 15:55:41 +0500 Subject: [PATCH] Process and check create stream command, store transaction id --- rtmp/amf/command.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rtmp/amf/command.go b/rtmp/amf/command.go index 31a1889..8cab681 100644 --- a/rtmp/amf/command.go +++ b/rtmp/amf/command.go @@ -33,6 +33,26 @@ func (amf_obj_root AMFObj) ProcessConnect() (err error) { return } +func (amf_obj_root AMFObj) ProcessCreateStream(trans_id *float64) (err error) { + err = errors.New("Bad AMF create stream") + if _, ok := amf_obj_root[0]; !ok { + return + } else if command_string, ok := amf_obj_root[0].(string); !ok || command_string != "createStream" { + return + } + + if _, ok := amf_obj_root[1]; !ok { + return + } + transac_id_float, ok := amf_obj_root[1].(float64) + if !ok { + return + } + *trans_id = transac_id_float + err = nil + return +} + func EncodeConnectResponse() ([]byte, error) { amf_root_obj := make(AMFObj) amf_root_obj[0] = "_result"