rtmp: remove C_AVal from P_vu

This commit is contained in:
Dan Kortschak 2018-09-06 16:10:15 +09:30
parent ed40f36ffe
commit c4800034a6
3 changed files with 35 additions and 36 deletions

View File

@ -308,12 +308,11 @@ func C_AMFProp_GetNumber(prop *C_AMFObjectProperty) float64 {
// void AMFProp_GetString(AMFObjectProperty* prop, AVal* str); // void AMFProp_GetString(AMFObjectProperty* prop, AVal* str);
// amf.c +341 // amf.c +341
func C_AMFProp_GetString(prop *C_AMFObjectProperty, str *C_AVal) { func C_AMFProp_GetString(prop *C_AMFObjectProperty) string {
if prop.p_type == AMF_STRING { if prop.p_type == AMF_STRING {
*str = prop.p_vu.p_aval return prop.p_vu.p_aval
} else {
*str = AV_empty
} }
return ""
} }
// void AMFProp_GetObject(AMFObjectProperty *prop, AMFObject *obj); // void AMFProp_GetObject(AMFObjectProperty *prop, AMFObject *obj);
@ -355,7 +354,7 @@ func C_AMF_PropEncode(p *C_AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byt
case AMF_BOOLEAN: case AMF_BOOLEAN:
pBuffer = C_AMF_EncodeBoolean(pBuffer, pBufEnd, p.p_vu.p_number != 0) pBuffer = C_AMF_EncodeBoolean(pBuffer, pBufEnd, p.p_vu.p_number != 0)
case AMF_STRING: case AMF_STRING:
pBuffer = C_AMF_EncodeString(pBuffer, pBufEnd, CAV(&p.p_vu.p_aval)) pBuffer = C_AMF_EncodeString(pBuffer, pBufEnd, p.p_vu.p_aval)
case AMF_NULL: case AMF_NULL:
if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 1)) >= uintptr(unsafe.Pointer( if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 1)) >= uintptr(unsafe.Pointer(
pBufEnd)) { pBufEnd)) {
@ -510,7 +509,7 @@ func C_AMFProp_Decode(prop *C_AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
if int64(nSize) < int64(nStringSize)+2 { if int64(nSize) < int64(nStringSize)+2 {
return -1 return -1
} }
prop.p_vu.p_aval = AVC(C_AMF_DecodeString(pBuffer)) prop.p_vu.p_aval = C_AMF_DecodeString(pBuffer)
nSize -= int32(2 + nStringSize) nSize -= int32(2 + nStringSize)
case AMF_OBJECT: case AMF_OBJECT:
@ -593,8 +592,7 @@ func C_AMFProp_Reset(prop *C_AMFObjectProperty) {
prop.p_type == AMF_STRICT_ARRAY { prop.p_type == AMF_STRICT_ARRAY {
C_AMF_Reset(&prop.p_vu.p_object) C_AMF_Reset(&prop.p_vu.p_object)
} else { } else {
prop.p_vu.p_aval.av_len = 0 prop.p_vu.p_aval = ""
prop.p_vu.p_aval.av_val = nil
} }
prop.p_type = AMF_INVALID prop.p_type = AMF_INVALID
} }

View File

@ -107,7 +107,7 @@ type C_AMFObject struct {
// amf.h +73 // amf.h +73
type P_vu struct { type P_vu struct {
p_number float64 p_number float64
p_aval C_AVal p_aval string
p_object C_AMFObject p_object C_AMFObject
} }

View File

@ -1155,7 +1155,6 @@ func C_AV_queue(vals **C_RTMP_METHOD, num *int32, av string, txn int32) {
// rtmp.c +2912 // rtmp.c +2912
func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) { func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
var obj C_AMFObject var obj C_AMFObject
var method C_AVal
var txn float64 var txn float64
var nRes int32 var nRes int32
@ -1175,13 +1174,13 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
// NOTE we don't really need this ?? still functions without it // NOTE we don't really need this ?? still functions without it
//C.AMF_Dump(&obj) //C.AMF_Dump(&obj)
//C.AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0), &method) //C.AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0), &method)
C_AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0), &method) method := C_AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0))
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);
avmethod := AVC(method)
switch { switch {
case C_AVMATCH(&method, &av__result) != 0: case C_AVMATCH(&avmethod, &av__result) != 0:
{ {
var methodInvoked C_AVal var methodInvoked C_AVal
var i int32 var i int32
@ -1236,47 +1235,49 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
} }
//C.free(unsafe.Pointer(methodInvoked.av_val)) //C.free(unsafe.Pointer(methodInvoked.av_val))
} }
case C_AVMATCH(&method, &av_onBWDone) != 0: case C_AVMATCH(&avmethod, &av_onBWDone) != 0:
if r.m_nBWCheckCounter == 0 { if r.m_nBWCheckCounter == 0 {
C_SendCheckBW(r) C_SendCheckBW(r)
} }
case C_AVMATCH(&method, &av_onFCUnsubscribe) != 0 || C_AVMATCH(&method, &av_onFCSubscribe) != 0: case C_AVMATCH(&avmethod, &av_onFCUnsubscribe) != 0 || C_AVMATCH(&avmethod, &av_onFCSubscribe) != 0:
panic("Unsupported method av_onFCUnsubscribe/av_onFCSubscribe") panic("Unsupported method av_onFCUnsubscribe/av_onFCSubscribe")
case C_AVMATCH(&method, &av_ping) != 0: case C_AVMATCH(&avmethod, &av_ping) != 0:
panic("Unsupported method av_ping") panic("Unsupported method av_ping")
case C_AVMATCH(&method, &av__onbwcheck) != 0: case C_AVMATCH(&avmethod, &av__onbwcheck) != 0:
panic("Unsupported method av_onbwcheck") panic("Unsupported method av_onbwcheck")
case C_AVMATCH(&method, &av__onbwdone) != 0: case C_AVMATCH(&avmethod, &av__onbwdone) != 0:
panic("Unsupported method av_onbwdone") panic("Unsupported method av_onbwdone")
case C_AVMATCH(&method, &av_close) != 0: case C_AVMATCH(&avmethod, &av_close) != 0:
panic("Unsupported method av_close") panic("Unsupported method av_close")
case C_AVMATCH(&method, &av_onStatus) != 0: case C_AVMATCH(&avmethod, &av_onStatus) != 0:
var obj2 C_AMFObject 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) code := C_AMFProp_GetString(C_AMF_GetProp(&obj2, &av_code, -1))
C_AMFProp_GetString(C_AMF_GetProp(&obj2, &av_level, -1), &level)
level := C_AMFProp_GetString(C_AMF_GetProp(&obj2, &av_level, -1)) // Not used.
_ = 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);
avcode := AVC(code)
switch { switch {
case C_AVMATCH(&code, &av_NetStream_Failed) != 0 || case C_AVMATCH(&avcode, &av_NetStream_Failed) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_Failed) != 0 || C_AVMATCH(&avcode, &av_NetStream_Play_Failed) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_StreamNotFound) != 0 || C_AVMATCH(&avcode, &av_NetStream_Play_StreamNotFound) != 0 ||
C_AVMATCH(&code, &av_NetConnection_Connect_InvalidApp) != 0: C_AVMATCH(&avcode, &av_NetConnection_Connect_InvalidApp) != 0:
panic("Unsupported method av_NetStream/av_NetStream_Play_Failed/av_netSTream_Play_StreamNotFound/av_netConnection_Connect_invalidApp") panic("Unsupported method av_NetStream/av_NetStream_Play_Failed/av_netSTream_Play_StreamNotFound/av_netConnection_Connect_invalidApp")
case C_AVMATCH(&code, &av_NetStream_Play_Start) != 0 || case C_AVMATCH(&avcode, &av_NetStream_Play_Start) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_PublishNotify) != 0: C_AVMATCH(&avcode, &av_NetStream_Play_PublishNotify) != 0:
panic("Unsupported method av_NetStream_Play_Start/av_NetStream_Play_PublishNotify") panic("Unsupported method av_NetStream_Play_Start/av_NetStream_Play_PublishNotify")
case C_AVMATCH(&code, &av_NetStream_Publish_Start) != 0: case C_AVMATCH(&avcode, &av_NetStream_Publish_Start) != 0:
var i int32 var i int32
r.m_bPlaying = true r.m_bPlaying = true
@ -1288,19 +1289,19 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
} }
} }
case C_AVMATCH(&code, &av_NetStream_Play_Complete) != 0 || case C_AVMATCH(&avcode, &av_NetStream_Play_Complete) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_Stop) != 0 || C_AVMATCH(&avcode, &av_NetStream_Play_Stop) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_UnpublishNotify) != 0: C_AVMATCH(&avcode, &av_NetStream_Play_UnpublishNotify) != 0:
panic("Unsupported method av_NetStream_Play_Complete/av_NetStream_Play_Stop/av_NetStream_Play_UnpublishNotify") panic("Unsupported method av_NetStream_Play_Complete/av_NetStream_Play_Stop/av_NetStream_Play_UnpublishNotify")
case C_AVMATCH(&code, &av_NetStream_Seek_Notify) != 0: case C_AVMATCH(&avcode, &av_NetStream_Seek_Notify) != 0:
panic("Unsupported method av_netStream_Seek_Notify") panic("Unsupported method av_netStream_Seek_Notify")
case C_AVMATCH(&code, &av_NetStream_Pause_Notify) != 0: case C_AVMATCH(&avcode, &av_NetStream_Pause_Notify) != 0:
panic("Unsupported method av_NetStream_Pause_Notify") panic("Unsupported method av_NetStream_Pause_Notify")
} }
case C_AVMATCH(&method, &av_playlist_ready) != 0: case C_AVMATCH(&avmethod, &av_playlist_ready) != 0:
panic("Unsupported method av_playlist_ready") panic("Unsupported method av_playlist_ready")
default: default: