mirror of https://bitbucket.org/ausocean/av.git
Ported C_AMF_Decode - tested and working
This commit is contained in:
parent
11798bb9ff
commit
e1079dab98
56
rtmp/rtmp.go
56
rtmp/rtmp.go
|
@ -1965,9 +1965,8 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
//__FUNCTION__);
|
||||
return 0
|
||||
}
|
||||
|
||||
nRes = int32(C.AMF_Decode(&obj, (*C.char)(unsafe.Pointer(body)), C.int(nBodySize), 0))
|
||||
// nRes = C_AMF_Decode(&obj, body, nBodySize, 0)
|
||||
nRes = C_AMF_Decode(&obj, body, int32(nBodySize), 0)
|
||||
//nRes = int32(C.AMF_Decode(&obj, (*C.char)(unsafe.Pointer(body)), C.int(nBodySize), 0))
|
||||
if nRes < 0 {
|
||||
log.Println("here2")
|
||||
// TODO use new logger here
|
||||
|
@ -2472,6 +2471,57 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
|||
return 1
|
||||
}
|
||||
|
||||
// int AMF_Decode(AMFObject *obj, const char* pBuffer, int nSize, int bDecodeName);
|
||||
// amf.c +1180
|
||||
func C_AMF_Decode(obj *C.AMFObject, pBuffer *byte, nSize int32, bDecodeName int32) int32 {
|
||||
var nOriginalSize int32 = nSize
|
||||
var bError int32 = 0
|
||||
|
||||
obj.o_num = 0
|
||||
obj.o_props = nil
|
||||
|
||||
for nSize > 0 {
|
||||
var prop C.AMFObjectProperty
|
||||
var nRes int32
|
||||
|
||||
if nSize >= 3 && C_AMF_DecodeInt24(pBuffer) == C.AMF_OBJECT_END {
|
||||
nSize -= 3
|
||||
bError = 0
|
||||
break
|
||||
}
|
||||
|
||||
if bError != 0 {
|
||||
// TODO use new logger here
|
||||
log.Println("AMF_Decode: decoding error, ignoring bytes until next known pattern!")
|
||||
nSize--
|
||||
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
||||
continue
|
||||
}
|
||||
// TODO port AMFProp_Decode
|
||||
nRes = int32(C.AMFProp_Decode(&prop, (*C.char)(unsafe.Pointer(pBuffer)),
|
||||
C.int(nSize), C.int(bDecodeName)))
|
||||
if nRes == -1 {
|
||||
bError = 1
|
||||
break
|
||||
} else {
|
||||
nSize -= nRes
|
||||
if nSize < 0 {
|
||||
bError = 1
|
||||
break
|
||||
}
|
||||
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), int(nRes)))
|
||||
// TODO port
|
||||
C.AMF_AddProp(obj, &prop)
|
||||
}
|
||||
}
|
||||
|
||||
if bError != 0 {
|
||||
return -1
|
||||
}
|
||||
|
||||
return nOriginalSize - nSize
|
||||
}
|
||||
|
||||
// static int DecodeInt32LE(const char* data);
|
||||
// rtmp.c +3527
|
||||
func C_DecodeInt32LE(data *byte) int32 {
|
||||
|
|
Loading…
Reference in New Issue