diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 4cbd8ada..e5156468 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -190,6 +190,7 @@ const ( // av_setDataFrame is a static const global in rtmp.c var ( + AV_empty = AVC("") setDataFrame = AVC("@setDataFrame") av_connect = AVC("connect") av_app = AVC("app") @@ -1913,7 +1914,6 @@ func C_HandleChangeChunkSize(r *C.RTMP, packet *C.RTMPPacket) { // void HandleServerBW(RTMP* r, const RTMPPacket* packet); // rtmp.c +3508 func C_HandlServerBW(r *C.RTMP, packet *C.RTMPPacket) { - // TODO port AMF_DecodeInt32 r.m_nServerBW = C.int(C_AMF_DecodeInt32((*byte)(unsafe.Pointer(packet.m_body)))) //r.m_nServerBW = C.int(C.AMF_DecodeInt32((*C.char)(unsafe.Pointer(packet.m_body)))) // TODO use new logger here @@ -1939,11 +1939,9 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) { // int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize); // rtmp.c +2912 -// TODO port AMF_Dump (amf.c +1270) -// TODO port AMFPRop_GetString (amf.c +342) +// TODO port AMFProp_GetString (amf.c +342) // TODO port AMFProp_GetNumber (amf.c +330) // TODO port AMF_GetProp (amf.c +1249) -// TODO port AMF_Decode (amf.c +1180) // TODO port AV_erase (rtmp.c +2393) // TODO port SendReleaseStream (rtmp.c +1816) // TODO port SendFCPublish (rtmp.c +1846) @@ -1974,8 +1972,10 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { return 0 } - C.AMF_Dump(&obj) - C.AMFProp_GetString(C.AMF_GetProp(&obj, nil, 0), &method) + // NOTE we don't really need this ?? still functions without it + //C.AMF_Dump(&obj) + //C.AMFProp_GetString(C.AMF_GetProp(&obj, nil, 0), &method) + C_AMFProp_GetString(C.AMF_GetProp(&obj, nil, 0), &method) txn = float64(C.AMFProp_GetNumber(C.AMF_GetProp(&obj, nil, 1))) // TODO use new logger here // RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val); @@ -2141,8 +2141,8 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { var obj2 C.AMFObject var code, level C.AVal 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) + C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_code, -1), &code) + C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_level, -1), &level) // TODO use new logger // RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val); @@ -2248,6 +2248,16 @@ func C_AVMATCH(a1, a2 *C.AVal) int32 { } } +// void AMFProp_GetString(AMFObjectProperty* prop, AVal* str); +// amf.c +func C_AMFProp_GetString(prop *C.AMFObjectProperty, str *C.AVal) { + if prop.p_type == AMF_STRING { + *str = prop.p_vu.p_aval + } else { + *str = AV_empty + } +} + // void RTMPPacket_Free(RTMPPacket* p); // rtmp.c +203 func C_RTMPPacket_Free(p *C.RTMPPacket) {