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
if *body != 0x02 {
log.Println("here")
// TODO use new logger here
//RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
//__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 = 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
//RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
return 0
@ -2017,13 +2015,11 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
switch {
case C_AVMATCH(&method, &av__result) != 0:
{
log.Println("1")
var methodInvoked C.AVal
var i int32
for i = 0; i < int32(r.m_numCalls); i++ {
if float64((*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).num) == txn {
log.Println("1.1")
methodInvoked = (*(*C.RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls),
int(i), int(unsafe.Sizeof(*r.m_methodCalls))))).name
//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 {
log.Println("1.2")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request",
//__FUNCTION__, txn);
@ -2044,7 +2039,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
switch {
case C_AVMATCH(&methodInvoked, &av_connect) != 0:
{
log.Println("2")
/* NOTE This code doesn't run in our use case
TODO port this eventually
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 {
log.Println("2.3")
C_SendReleaseStream(r)
C_SendFCPublish(r)
} /* 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:
{
log.Println("5")
r.m_stream_id = C.int(C_AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 3)))
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
log.Println("5.1")
C_SendPublish(r)
} /* NOTE This code doesn't run in our use case
else {
@ -2126,9 +2117,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
}
case C_AVMATCH(&method, &av_onBWDone) != 0:
{
log.Println("7")
if r.m_nBWCheckCounter == 0 {
log.Println("7.1")
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:
{
log.Println("13")
var obj2 C.AMFObject
var code, level C.AVal
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:
{
log.Println("16")
var i int32
r.m_bPlaying = 1
for i = 0; i < int32(r.m_numCalls); 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 {
log.Println("16.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)
break
@ -2874,21 +2860,25 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
switch prop.p_type {
case AMF_NUMBER:
log.Println("1")
if nSize < 8 {
return -1
}
prop.p_vu.p_number = C.double(C_AMF_DecodeNumber(pBuffer))
nSize -= 8
/*
case AMF_BOOLEAN:
log.Println("2")
if nSize < 1 {
return -1
}
prop.p_vu.p_number = C.double(C_AMF_DecodeBoolean((*byte)(unsafe.Pointer(pBuffer))))
nSize--
*/
case AMF_STRING:
{
log.Println("3")
var nStringSize = C_AMF_DecodeInt16(pBuffer)
if int64(nSize) < int64(nStringSize)+2 {
@ -2900,6 +2890,7 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_OBJECT:
{
log.Println("4")
var nRes int32 = int32(C_AMF_Decode(&prop.p_vu.p_object, pBuffer, nSize, 1))
if nRes == -1 {
return -1
@ -2910,6 +2901,7 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_MOVIECLIP:
{
log.Println("5")
// TODO use new logger here
log.Println("AMFProp_Decode: MAF_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:
log.Println("6")
case AMF_UNDEFINED:
log.Println("7")
case AMF_UNSUPPORTED:
log.Println("8")
prop.p_type = AMF_NULL
case AMF_REFERENCE:
{
log.Println("9")
// TODO use new logger here
log.Println("AMFProp_Decode: 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:
{
log.Println("10")
nSize -= 4
// next comes the rest, mixed array has a final 0x000009 mark and names, so its an object
@ -2944,10 +2941,13 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
case AMF_OBJECT_END:
{
log.Println("11")
return -1
}
/*
case AMF_STRICT_ARRAY:
{
log.Println("12")
nArrayLen := int32(C_AMF_DecodeInt32(pBuffer))
nSize -= 4
@ -2957,9 +2957,11 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
}
nSize -= nRes
}
*/
/*
case AMF_DATE:
{
log.Println("13")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "AMF_DATE");
@ -2973,9 +2975,13 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
nSize -= 10
}
*/
case AMF_LONG_STRING:
log.Println("14")
/*
case AMF_XML_DOC:
{
log.Println("15")
var nStringSize uint32 = C_AMF_DecodeInt32(pBuffer)
if int64(nSize) < int64(nStringSize)+4 {
return -1
@ -2986,9 +2992,10 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
prop.p_type = AMF_STRING
}
}
*/
case AMF_RECORDSET:
{
log.Println("16")
// TODO use new logger here
log.Println("AMFProp_Decode: AMF_RECORDSET reserved!")
//RTMP_Log(RTMP_LOGERROR, "AMF_RECORDSET reserved!");
@ -2997,13 +3004,16 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
}
case AMF_TYPED_OBJECT:
{
log.Println("17")
// TODO use new logger here
// RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!")
return -1
}
/*
case AMF_AVMPLUS:
{
log.Println("18")
nRes := int32(C.AMF3_Decode(&prop.p_vu.p_object, (*C.char)(unsafe.Pointer(pBuffer)), C.int(nSize), 1))
if nRes == -1 {
return -1
@ -3011,7 +3021,9 @@ func C_AMFProp_Decode(prop *C.AMFObjectProperty, pBuffer *byte, nSize, bDecodeNa
nSize -= nRes
prop.p_type = AMF_OBJECT
}
*/
default:
log.Println("19")
// TODO use new logger here
//RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @%p", __FUNCTION__,
//prop.p_type, pBuffer - 1);
@ -3167,7 +3179,8 @@ func C_RTMP_Write(r *C.RTMP, data []byte) int {
// TODO: Port this
ret = C_RTMP_SendPacket(r, pkt, 0)
// TODO: Port this
C.RTMPPacket_Free(pkt)
//C.RTMPPacket_Free(pkt)
C_RTMPPacket_Free(pkt)
pkt.m_nBytesRead = 0
if ret == 0 {
return -1
@ -3510,6 +3523,7 @@ var RTMPT_cmds = []string{
// int RTMPSockBuf_Send(RTMPSockBuf* sb, const char* buf, int len);
// rtmp.c +4297
// TODO replace send with golang net connection send
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))
}
@ -3575,6 +3589,7 @@ const (
// int AMF3ReadInteger(const char *data, int32_t *valp);
// amf.c +426
// TODO test
func C_AMF3ReadInteger(data *byte, valp *int32) int32 {
var i int
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);
// amf.c +1298
// TODO test
func AMF3CD_AddProp(cd *C.AMF3ClassDef, prop *C.AVal) {
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{}))))