Ported AMFProp_GetString to C_AMFProp_GetString - tested and working

This commit is contained in:
saxon 2018-08-15 02:47:40 +09:30
parent e1079dab98
commit 165a855d51
1 changed files with 18 additions and 8 deletions

View File

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