From 48042f6813879cbfa74db68f9c738091d28ad5db Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 15 Aug 2018 02:54:41 +0930 Subject: [PATCH] Ported AMFProp_GetObject - tested and working --- rtmp/rtmp.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index e5156468..dc586c4d 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -240,6 +240,8 @@ var ( var packetSize = [...]int{12, 8, 4, 1} +var AMFObj_Invalid C.AMFObject + var RTMPProtocolStringsLower = [...]string{ "rtmp", "rtmpt", @@ -1939,7 +1941,7 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) { // int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize); // rtmp.c +2912 -// TODO port AMFProp_GetString (amf.c +342) +// TODO port AMFProp_GetObject (amf.c +342) // TODO port AMFProp_GetNumber (amf.c +330) // TODO port AMF_GetProp (amf.c +1249) // TODO port AV_erase (rtmp.c +2393) @@ -2140,7 +2142,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { log.Println("13") var obj2 C.AMFObject var code, level C.AVal - C.AMFProp_GetObject(C.AMF_GetProp(&obj, nil, 3), &obj2) + C_AMFProp_GetObject(C.AMF_GetProp(&obj, nil, 3), &obj2) C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_code, -1), &code) C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_level, -1), &level) @@ -2258,6 +2260,16 @@ func C_AMFProp_GetString(prop *C.AMFObjectProperty, str *C.AVal) { } } +// void AMFProp_GetObject(AMFObjectProperty *prop, AMFObject *obj); +// amf.c +351 +func C_AMFProp_GetObject(prop *C.AMFObjectProperty, obj *C.AMFObject) { + if prop.p_type == AMF_OBJECT { + *obj = prop.p_vu.p_object + } else { + *obj = AMFObj_Invalid + } +} + // void RTMPPacket_Free(RTMPPacket* p); // rtmp.c +203 func C_RTMPPacket_Free(p *C.RTMPPacket) {