removed unused code

This commit is contained in:
saxon 2018-08-18 12:54:40 +09:30
parent aef3cd3001
commit 3da48c15d3
1 changed files with 80 additions and 64 deletions

View File

@ -1991,7 +1991,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
var nRes int32 var nRes int32
if *body != 0x02 { if *body != 0x02 {
log.Println("here")
// TODO use new logger here // TODO use new logger here
//RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet", //RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
//__FUNCTION__); //__FUNCTION__);
@ -2000,7 +1999,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
nRes = C_AMF_Decode(&obj, body, int32(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)) //nRes = int32(C.AMF_Decode(&obj, (*C.char)(unsafe.Pointer(body)), C.int(nBodySize), 0))
if nRes < 0 { if nRes < 0 {
log.Println("here2")
// TODO use new logger here // TODO use new logger here
//RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__); //RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
return 0 return 0
@ -2017,13 +2015,11 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
switch { switch {
case C_AVMATCH(&method, &av__result) != 0: case C_AVMATCH(&method, &av__result) != 0:
{ {
log.Println("1")
var methodInvoked C.AVal var methodInvoked C.AVal
var i int32 var i int32
for i = 0; i < int32(r.m_numCalls); i++ { for i = 0; i < int32(r.m_numCalls); i++ {
if float64((*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i), if float64((*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).num) == txn { int(unsafe.Sizeof(*r.m_methodCalls))))).num) == txn {
log.Println("1.1")
methodInvoked = (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), methodInvoked = (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls),
int(i), int(unsafe.Sizeof(*r.m_methodCalls))))).name int(i), int(unsafe.Sizeof(*r.m_methodCalls))))).name
//C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 0) //C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 0)
@ -2032,7 +2028,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
} }
} }
if methodInvoked.av_val == nil { if methodInvoked.av_val == nil {
log.Println("1.2")
// TODO use new logger here // TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request", //RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request",
//__FUNCTION__, txn); //__FUNCTION__, txn);
@ -2044,7 +2039,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
switch { switch {
case C_AVMATCH(&methodInvoked, &av_connect) != 0: case C_AVMATCH(&methodInvoked, &av_connect) != 0:
{ {
log.Println("2")
/* NOTE This code doesn't run in our use case /* NOTE This code doesn't run in our use case
TODO port this eventually TODO port this eventually
if r.Link.token.av_len != 0 { if r.Link.token.av_len != 0 {
@ -2058,7 +2052,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
} }
*/ */
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 { if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
log.Println("2.3")
C_SendReleaseStream(r) C_SendReleaseStream(r)
C_SendFCPublish(r) C_SendFCPublish(r)
} /* NOTE This code doesn't run in our use case } /* NOTE This code doesn't run in our use case
@ -2095,11 +2088,9 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
} }
case C_AVMATCH(&methodInvoked, &av_createStream) != 0: case C_AVMATCH(&methodInvoked, &av_createStream) != 0:
{ {
log.Println("5")
r.m_stream_id = C.int(C_AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 3))) r.m_stream_id = C.int(C_AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 3)))
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 { if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
log.Println("5.1")
C_SendPublish(r) C_SendPublish(r)
} /* NOTE This code doesn't run in our use case } /* NOTE This code doesn't run in our use case
else { else {
@ -2126,9 +2117,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
} }
case C_AVMATCH(&method, &av_onBWDone) != 0: case C_AVMATCH(&method, &av_onBWDone) != 0:
{ {
log.Println("7")
if r.m_nBWCheckCounter == 0 { if r.m_nBWCheckCounter == 0 {
log.Println("7.1")
C_SendCheckBW(r) C_SendCheckBW(r)
} }
} }
@ -2172,7 +2161,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
*/ */
case C_AVMATCH(&method, &av_onStatus) != 0: case C_AVMATCH(&method, &av_onStatus) != 0:
{ {
log.Println("13")
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)
@ -2212,13 +2200,11 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
*/ */
case C_AVMATCH(&code, &av_NetStream_Publish_Start) != 0: case C_AVMATCH(&code, &av_NetStream_Publish_Start) != 0:
{ {
log.Println("16")
var i int32 var i int32
r.m_bPlaying = 1 r.m_bPlaying = 1
for i = 0; i < int32(r.m_numCalls); i++ { for i = 0; i < int32(r.m_numCalls); i++ {
if C_AVMATCH(&(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i), if C_AVMATCH(&(*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av_publish) != 0 { int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av_publish) != 0 {
log.Println("16.1")
//C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 1) //C.AV_erase(r.m_methodCalls, &r.m_numCalls, C.int(i), 1)
C_AV_erase(r.m_methodCalls, (*int32)(&r.m_numCalls), int32(i), 1) C_AV_erase(r.m_methodCalls, (*int32)(&r.m_numCalls), int32(i), 1)
break break
@ -2874,21 +2860,25 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
switch prop.p_type { switch prop.p_type {
case AMF_NUMBER: case AMF_NUMBER:
log.Println("1")
if nSize < 8 { if nSize < 8 {
return -1 return -1
} }
prop.p_vu.p_number = C.double(C_AMF_DecodeNumber(pBuffer)) prop.p_vu.p_number = C.double(C_AMF_DecodeNumber(pBuffer))
nSize -= 8 nSize -= 8
case AMF_BOOLEAN: /*
if nSize < 1 { case AMF_BOOLEAN:
return -1 log.Println("2")
} if nSize < 1 {
prop.p_vu.p_number = C.double(C_AMF_DecodeBoolean((*byte)(unsafe.Pointer(pBuffer)))) return -1
nSize-- }
prop.p_vu.p_number = C.double(C_AMF_DecodeBoolean((*byte)(unsafe.Pointer(pBuffer))))
nSize--
*/
case AMF_STRING: case AMF_STRING:
{ {
log.Println("3")
var nStringSize = C_AMF_DecodeInt16(pBuffer) var nStringSize = C_AMF_DecodeInt16(pBuffer)
if int64(nSize) < int64(nStringSize)+2 { if int64(nSize) < int64(nStringSize)+2 {
@ -2900,6 +2890,7 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_OBJECT: case AMF_OBJECT:
{ {
log.Println("4")
var nRes int32 = int32(C_AMF_Decode(&prop.p_vu.p_object, pBuffer, nSize, 1)) var nRes int32 = int32(C_AMF_Decode(&prop.p_vu.p_object, pBuffer, nSize, 1))
if nRes == -1 { if nRes == -1 {
return -1 return -1
@ -2910,6 +2901,7 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_MOVIECLIP: case AMF_MOVIECLIP:
{ {
log.Println("5")
// TODO use new logger here // TODO use new logger here
log.Println("AMFProp_Decode: MAF_MOVIECLIP reserved!") log.Println("AMFProp_Decode: MAF_MOVIECLIP reserved!")
//RTMP_Log(RTMP_LOGERROR, "AMF_MOVIECLIP reserved!"); //RTMP_Log(RTMP_LOGERROR, "AMF_MOVIECLIP reserved!");
@ -2917,12 +2909,16 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
} }
case AMF_NULL: case AMF_NULL:
log.Println("6")
case AMF_UNDEFINED: case AMF_UNDEFINED:
log.Println("7")
case AMF_UNSUPPORTED: case AMF_UNSUPPORTED:
log.Println("8")
prop.p_type = AMF_NULL prop.p_type = AMF_NULL
case AMF_REFERENCE: case AMF_REFERENCE:
{ {
log.Println("9")
// TODO use new logger here // TODO use new logger here
log.Println("AMFProp_Decode: AMF_REFERENCE not supported!") log.Println("AMFProp_Decode: AMF_REFERENCE not supported!")
//RTMP_Log(RTMP_LOGERROR, "AMF_REFERENCE not supported!"); //RTMP_Log(RTMP_LOGERROR, "AMF_REFERENCE not supported!");
@ -2931,6 +2927,7 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_ECMA_ARRAY: case AMF_ECMA_ARRAY:
{ {
log.Println("10")
nSize -= 4 nSize -= 4
// next comes the rest, mixed array has a final 0x000009 mark and names, so its an object // next comes the rest, mixed array has a final 0x000009 mark and names, so its an object
@ -2944,51 +2941,61 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_OBJECT_END: case AMF_OBJECT_END:
{ {
log.Println("11")
return -1 return -1
} }
case AMF_STRICT_ARRAY: /*
{ case AMF_STRICT_ARRAY:
nArrayLen := int32(C_AMF_DecodeInt32(pBuffer)) {
nSize -= 4 log.Println("12")
nArrayLen := int32(C_AMF_DecodeInt32(pBuffer))
nSize -= 4
nRes = C_AMF_DecodeArray(&prop.p_vu.p_object, (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 4)), nSize, int32(nArrayLen), FALSE) nRes = C_AMF_DecodeArray(&prop.p_vu.p_object, (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 4)), nSize, int32(nArrayLen), FALSE)
if nRes == -1 { if nRes == -1 {
return -1 return -1
}
nSize -= nRes
} }
nSize -= nRes */
} /*
case AMF_DATE:
{
log.Println("13")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "AMF_DATE");
case AMF_DATE: if nSize < 10 {
{ return -1
// TODO use new logger here }
//RTMP_Log(RTMP_LOGDEBUG, "AMF_DATE");
prop.p_vu.p_number = C.double(C_AMF_DecodeNumber(pBuffer))
prop.p_UTCoffset = C.int16_t(C_AMF_DecodeInt16((*byte)(incBytePtr(unsafe.Pointer(pBuffer), 8))))
nSize -= 10
if nSize < 10 {
return -1
} }
*/
prop.p_vu.p_number = C.double(C_AMF_DecodeNumber(pBuffer))
prop.p_UTCoffset = C.int16_t(C_AMF_DecodeInt16((*byte)(incBytePtr(unsafe.Pointer(pBuffer), 8))))
nSize -= 10
}
case AMF_LONG_STRING: case AMF_LONG_STRING:
case AMF_XML_DOC: log.Println("14")
{ /*
var nStringSize uint32 = C_AMF_DecodeInt32(pBuffer) case AMF_XML_DOC:
if int64(nSize) < int64(nStringSize)+4 { {
return -1 log.Println("15")
var nStringSize uint32 = C_AMF_DecodeInt32(pBuffer)
if int64(nSize) < int64(nStringSize)+4 {
return -1
}
C_AMF_DecodeLongString(pBuffer, &prop.p_vu.p_aval)
nSize -= int32(4 + nStringSize)
if prop.p_type == AMF_LONG_STRING {
prop.p_type = AMF_STRING
}
} }
C_AMF_DecodeLongString(pBuffer, &prop.p_vu.p_aval) */
nSize -= int32(4 + nStringSize)
if prop.p_type == AMF_LONG_STRING {
prop.p_type = AMF_STRING
}
}
case AMF_RECORDSET: case AMF_RECORDSET:
{ {
log.Println("16")
// TODO use new logger here // TODO use new logger here
log.Println("AMFProp_Decode: AMF_RECORDSET reserved!") log.Println("AMFProp_Decode: AMF_RECORDSET reserved!")
//RTMP_Log(RTMP_LOGERROR, "AMF_RECORDSET reserved!"); //RTMP_Log(RTMP_LOGERROR, "AMF_RECORDSET reserved!");
@ -2997,21 +3004,26 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
} }
case AMF_TYPED_OBJECT: case AMF_TYPED_OBJECT:
{ {
log.Println("17")
// TODO use new logger here // TODO use new logger here
// RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!") // RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!")
return -1 return -1
} }
case AMF_AVMPLUS: /*
{ case AMF_AVMPLUS:
nRes := int32(C.AMF3_Decode(&prop.p_vu.p_object, (*C.char)(unsafe.Pointer(pBuffer)), C.int(nSize), 1)) {
if nRes == -1 { log.Println("18")
return -1 nRes := int32(C.AMF3_Decode(&prop.p_vu.p_object, (*C.char)(unsafe.Pointer(pBuffer)), C.int(nSize), 1))
if nRes == -1 {
return -1
}
nSize -= nRes
prop.p_type = AMF_OBJECT
} }
nSize -= nRes */
prop.p_type = AMF_OBJECT
}
default: default:
log.Println("19")
// TODO use new logger here // TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @%p", __FUNCTION__, //RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @%p", __FUNCTION__,
//prop.p_type, pBuffer - 1); //prop.p_type, pBuffer - 1);
@ -3167,7 +3179,8 @@ func C_RTMP_Write(r *C.RTMP, data []byte) int {
// TODO: Port this // TODO: Port this
ret = C_RTMP_SendPacket(r, pkt, 0) ret = C_RTMP_SendPacket(r, pkt, 0)
// TODO: Port this // TODO: Port this
C.RTMPPacket_Free(pkt) //C.RTMPPacket_Free(pkt)
C_RTMPPacket_Free(pkt)
pkt.m_nBytesRead = 0 pkt.m_nBytesRead = 0
if ret == 0 { if ret == 0 {
return -1 return -1
@ -3510,6 +3523,7 @@ var RTMPT_cmds = []string{
// int RTMPSockBuf_Send(RTMPSockBuf* sb, const char* buf, int len); // int RTMPSockBuf_Send(RTMPSockBuf* sb, const char* buf, int len);
// rtmp.c +4297 // rtmp.c +4297
// TODO replace send with golang net connection send
func C_RTMPSockBuf_Send(sb *C.RTMPSockBuf, buf *byte, l int32) int32 { func C_RTMPSockBuf_Send(sb *C.RTMPSockBuf, buf *byte, l int32) int32 {
return int32(C.send(sb.sb_socket, unsafe.Pointer(buf), C.size_t(l), 0)) return int32(C.send(sb.sb_socket, unsafe.Pointer(buf), C.size_t(l), 0))
} }
@ -3575,6 +3589,7 @@ const (
// int AMF3ReadInteger(const char *data, int32_t *valp); // int AMF3ReadInteger(const char *data, int32_t *valp);
// amf.c +426 // amf.c +426
// TODO test
func C_AMF3ReadInteger(data *byte, valp *int32) int32 { func C_AMF3ReadInteger(data *byte, valp *int32) int32 {
var i int var i int
var val int32 var val int32
@ -3851,6 +3866,7 @@ func C_AMF_EncodeInt32(output *byte, outend *byte, nVal int32) *byte {
// void AMF3CD_AddProp(AMF3ClassDef *cd, AVal *prop); // void AMF3CD_AddProp(AMF3ClassDef *cd, AVal *prop);
// amf.c +1298 // amf.c +1298
// TODO test
func AMF3CD_AddProp(cd *C.AMF3ClassDef, prop *C.AVal) { func AMF3CD_AddProp(cd *C.AMF3ClassDef, prop *C.AVal) {
if cd.cd_num&0x0f == 0 { if cd.cd_num&0x0f == 0 {
cd.cd_props = (*C.AVal)(realloc(unsafe.Pointer(cd.cd_props), int(uintptr(cd.cd_num+16)*unsafe.Sizeof(C.AVal{})))) cd.cd_props = (*C.AVal)(realloc(unsafe.Pointer(cd.cd_props), int(uintptr(cd.cd_num+16)*unsafe.Sizeof(C.AVal{}))))