diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 70f08380..66f0fa07 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -928,7 +928,7 @@ func C_SendBytesReceived(r *C.RTMP) int { packet.m_nBodySize = 4 - amfEncodeInt32((*byte)(unsafe.Pointer(packet.m_body)), pend, int32(r.m_nBytesIn)) + C_AMFEncodeInt32((*byte)(unsafe.Pointer(packet.m_body)), pend, int32(r.m_nBytesIn)) // C.AMF_EncodeInt32(packet.m_body, (*C.char)(unsafe.Pointer(pend)), r.m_nBytesIn) r.m_nBytesInSent = r.m_nBytesIn @@ -962,11 +962,11 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)), //(*C.char)(unsafe.Pointer(pend)), &av_connect))) - enc = amfEncodeString(enc, pend, &av_connect) + enc = C_AMFEncodeString(enc, pend, &av_connect) r.m_numInvokes += 1 //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNumber((*C.char)(unsafe.Pointer(enc)), //(*C.char)(unsafe.Pointer(pend)), C.double(r.m_numInvokes)))) - enc = amfEncodeNumber(enc, pend, float64(r.m_numInvokes)) + enc = C_AMFEncodeNumber(enc, pend, float64(r.m_numInvokes)) *indxBytePtr(unsafe.Pointer(enc), 0) = AMF_OBJECT @@ -974,14 +974,14 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_app, &r.Link.app))) - enc = amfEncodeNamedString(enc, pend, &av_app, &r.Link.app) + enc = C_AMFEncodeNamedString(enc, pend, &av_app, &r.Link.app) if enc == nil { return 0 } if r.Link.protocol&RTMP_FEATURE_WRITE != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_type, &av_nonprivate))) - enc = amfEncodeNamedString(enc, pend, &av_type, &av_nonprivate) + enc = C_AMFEncodeNamedString(enc, pend, &av_type, &av_nonprivate) if enc == nil { return 0 @@ -991,7 +991,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.Link.flashVer.av_len != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_flashVer, &r.Link.flashVer))) - enc = amfEncodeNamedString(enc, pend, &av_flashVer, &r.Link.flashVer) + enc = C_AMFEncodeNamedString(enc, pend, &av_flashVer, &r.Link.flashVer) if enc == nil { return 0 } @@ -999,7 +999,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.Link.swfUrl.av_len != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( // unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_swfUrl, &r.Link.swfUrl))) - enc = amfEncodeNamedString(enc, pend, &av_swfUrl, &r.Link.swfUrl) + enc = C_AMFEncodeNamedString(enc, pend, &av_swfUrl, &r.Link.swfUrl) if enc == nil { return 0 } @@ -1008,7 +1008,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.Link.tcUrl.av_len != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_tcUrl, &r.Link.tcUrl))) - enc = amfEncodeNamedString(enc, pend, &av_tcUrl, &r.Link.tcUrl) + enc = C_AMFEncodeNamedString(enc, pend, &av_tcUrl, &r.Link.tcUrl) if enc == nil { return 0 } @@ -1017,38 +1017,38 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.Link.protocol&RTMP_FEATURE_WRITE == 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedBoolean((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_fpad, 0))) - enc = amfEncodeNamedBoolean(enc, pend, &av_fpad, 0) + enc = C_AMFEncodeNamedBoolean(enc, pend, &av_fpad, 0) if enc == nil { return 0 } //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_capabilities, 15.0))) - enc = amfEncodeNamedNumber(enc, pend, &av_capabilities, 15.0) + enc = C_AMFEncodeNamedNumber(enc, pend, &av_capabilities, 15.0) if enc == nil { return 0 } //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)( // unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_audioCodecs, r.m_fAudioCodecs))) - enc = amfEncodeNamedNumber(enc, pend, &av_audioCodecs, float64(r.m_fAudioCodecs)) + enc = C_AMFEncodeNamedNumber(enc, pend, &av_audioCodecs, float64(r.m_fAudioCodecs)) if enc == nil { return 0 } //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoCodecs, r.m_fVideoCodecs))) - enc = amfEncodeNamedNumber(enc, pend, &av_videoCodecs, float64(r.m_fVideoCodecs)) + enc = C_AMFEncodeNamedNumber(enc, pend, &av_videoCodecs, float64(r.m_fVideoCodecs)) if enc == nil { return 0 } //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)( // unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoFunction, 1.0))) - enc = amfEncodeNamedNumber(enc, pend, &av_videoFunction, 1.0) + enc = C_AMFEncodeNamedNumber(enc, pend, &av_videoFunction, 1.0) if enc == nil { return 0 } if r.Link.pageUrl.av_len != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_pageUrl, &r.Link.pageUrl))) - enc = amfEncodeNamedString(enc, pend, &av_pageUrl, &r.Link.pageUrl) + enc = C_AMFEncodeNamedString(enc, pend, &av_pageUrl, &r.Link.pageUrl) if enc == nil { return 0 } @@ -1058,7 +1058,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.m_fEncoding != 0.0 || r.m_bSendEncoding != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)( //unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_objectEncoding, r.m_fEncoding))) - enc = amfEncodeNamedNumber(enc, pend, &av_objectEncoding, float64(r.m_fEncoding)) + enc = C_AMFEncodeNamedNumber(enc, pend, &av_objectEncoding, float64(r.m_fEncoding)) if enc == nil { return 0 } @@ -1080,13 +1080,13 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int { if r.Link.auth.av_len != 0 { //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeBoolean((*C.char)( // unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), r.Link.lFlags&RTMP_LF_AUTH))) - enc = amfEncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH)) + enc = C_AMFEncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH)) if enc == nil { return 0 } //enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)), //(*C.char)(unsafe.Pointer(pend)), &r.Link.auth))) - enc = amfEncodeString(enc, (*byte)(pend), &r.Link.auth) + enc = C_AMFEncodeString(enc, (*byte)(pend), &r.Link.auth) if enc == nil { return 0 } @@ -1138,15 +1138,15 @@ func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte switch p.p_type { case AMF_NUMBER: - pBuffer = amfEncodeNumber(pBuffer, pBufEnd, float64(p.p_vu.p_number)) + pBuffer = C_AMFEncodeNumber(pBuffer, pBufEnd, float64(p.p_vu.p_number)) case AMF_BOOLEAN: val := 0 if p.p_vu.p_number != 0 { val = 1 } - pBuffer = amfEncodeBoolean(pBuffer, pBufEnd, val) + pBuffer = C_AMFEncodeBoolean(pBuffer, pBufEnd, val) case AMF_STRING: - pBuffer = amfEncodeString(pBuffer, pBufEnd, &p.p_vu.p_aval) + pBuffer = C_AMFEncodeString(pBuffer, pBufEnd, &p.p_vu.p_aval) case AMF_NULL: if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 1)) >= uintptr(unsafe.Pointer( pBufEnd)) { @@ -1155,15 +1155,15 @@ func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte *(*byte)(unsafe.Pointer(pBuffer)) = AMF_NULL pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1)) case AMF_OBJECT: - pBuffer = amfEncode(&p.p_vu.p_object, pBuffer, pBufEnd) + pBuffer = C_AMFEncode(&p.p_vu.p_object, pBuffer, pBufEnd) //pBuffer = (*byte)(unsafe.Pointer(C.AMF_Encode(&p.p_vu.p_object, (*C.char)( //unsafe.Pointer(pBuffer)), (*C.char)(unsafe.Pointer(pBufEnd))))) case AMF_ECMA_ARRAY: - pBuffer = amfEncodeEcmaArray(&p.p_vu.p_object, pBuffer, pBufEnd) + pBuffer = C_AMFEncodeEcmaArray(&p.p_vu.p_object, pBuffer, pBufEnd) //pBuffer = (*byte)(unsafe.Pointer(C.AMF_EncodeEcmaArray(&p.p_vu.p_object, (*C.char)(unsafe.Pointer(pBuffer)), (*C.char)(unsafe.Pointer(pBufEnd))))) case AMF_STRICT_ARRAY: //pBuffer = (*byte)(unsafe.Pointer(C.AMF_EncodeArray(&p.p_vu.p_object, (*C.char)(unsafe.Pointer(pBuffer)), (*C.char)(unsafe.Pointer(pBufEnd))))) - pBuffer = amfEncodeArray(&p.p_vu.p_object, pBuffer, pBufEnd) + pBuffer = C_AMFEncodeArray(&p.p_vu.p_object, pBuffer, pBufEnd) default: log.Println("C_AMFPropEncode: invalid type!") pBuffer = nil @@ -1171,7 +1171,7 @@ func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte return pBuffer } -func amfEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { +func C_AMFEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { if uintptr(unsafe.Pointer(pBuffer))+uintptr(4) >= uintptr(unsafe.Pointer(pBufEnd)) { return nil } @@ -1183,7 +1183,7 @@ func amfEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer( obj.o_props), i, int(unsafe.Sizeof(*obj.o_props)))), pBuffer, pBufEnd) if res == nil { - log.Println("amfEncode: failed to encode property in index") + log.Println("C_AMFEncode: failed to encode property in index") break } else { pBuffer = res @@ -1194,12 +1194,12 @@ func amfEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { return nil } - pBuffer = amfEncodeInt24(pBuffer, pBufEnd, int32(AMF_OBJECT_END)) + pBuffer = C_AMFEncodeInt24(pBuffer, pBufEnd, int32(AMF_OBJECT_END)) return pBuffer } -func amfEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { +func C_AMFEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) { return nil } @@ -1207,13 +1207,13 @@ func amfEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { *pBuffer = AMF_ECMA_ARRAY pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1)) - pBuffer = amfEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num)) + pBuffer = C_AMFEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num)) for i := 0; i < int(obj.o_num); i++ { res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer( obj.o_props), i, int(unsafe.Sizeof(*obj.o_props)))), pBuffer, pBufEnd) if res == nil { - log.Println("amfEncodeEcmaArray: failed to encode property!") + log.Println("C_AMFEncodeEcmaArray: failed to encode property!") break } else { pBuffer = res @@ -1224,12 +1224,12 @@ func amfEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { return nil } - pBuffer = amfEncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END) + pBuffer = C_AMFEncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END) return pBuffer } -func amfEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { +func C_AMFEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) { return nil } @@ -1237,13 +1237,13 @@ func amfEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte { *pBuffer = AMF_STRICT_ARRAY pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1)) - pBuffer = amfEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num)) + pBuffer = C_AMFEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num)) for i := 0; i < int(obj.o_num); i++ { res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer( obj.o_props), i, int(unsafe.Sizeof(*obj.o_props)))), pBuffer, pBufEnd) if res == nil { - log.Println("amfEncodeEcmaArray: failed to encode property!") + log.Println("C_AMFEncodeEcmaArray: failed to encode property!") break } else { pBuffer = res @@ -1390,10 +1390,10 @@ func rtmpReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 { unsafe.Pointer(&hbuf[0])))), int(nSize)))) if nSize >= 3 { - packet.m_nTimeStamp = C.uint32_t(amfDecodeInt24(header)) + packet.m_nTimeStamp = C.uint32_t(C_AMFDecodeInt24(header)) if nSize >= 6 { - packet.m_nBodySize = C.uint32_t(amfDecodeInt24((*byte)(incBytePtr( + packet.m_nBodySize = C.uint32_t(C_AMFDecodeInt24((*byte)(incBytePtr( unsafe.Pointer(header), 3)))) packet.m_nBytesRead = 0 @@ -1542,9 +1542,9 @@ func rtmpWrite(r *C.RTMP, data []byte) int { pkt.m_packetType = C.uint8_t(*indxBytePtr(buf, 0)) buf = incBytePtr(buf, 1) - pkt.m_nBodySize = C.uint32_t(amfDecodeInt24((*byte)(buf))) + pkt.m_nBodySize = C.uint32_t(C_AMFDecodeInt24((*byte)(buf))) buf = incBytePtr(buf, 3) - pkt.m_nTimeStamp = C.uint32_t(amfDecodeInt24((*byte)(buf))) + pkt.m_nTimeStamp = C.uint32_t(C_AMFDecodeInt24((*byte)(buf))) buf = incBytePtr(buf, 3) pkt.m_nTimeStamp |= C.uint32_t(*indxBytePtr(buf, 0)) << 24 buf = incBytePtr(buf, 4) @@ -1572,7 +1572,7 @@ func rtmpWrite(r *C.RTMP, data []byte) int { pend = incBytePtr(enc, int(pkt.m_nBodySize)) if pkt.m_packetType == RTMP_PACKET_TYPE_INFO { - enc = unsafe.Pointer(amfEncodeString((*byte)(enc), (*byte)(pend), &setDataFrame)) + enc = unsafe.Pointer(C_AMFEncodeString((*byte)(enc), (*byte)(pend), &setDataFrame)) pkt.m_nBytesRead = C.uint32_t(math.Abs(float64(uintptr(enc) - uintptr(unsafe.Pointer(pkt.m_body))))) } @@ -1732,11 +1732,11 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { if t > 0xffffff { res = 0xffffff } - hptr = unsafe.Pointer(amfEncodeInt24((*byte)(hptr), (*byte)(hend), res)) + hptr = unsafe.Pointer(C_AMFEncodeInt24((*byte)(hptr), (*byte)(hend), res)) } if nSize > 4 { - hptr = unsafe.Pointer(amfEncodeInt24((*byte)(hptr), (*byte)(hend), (int32(packet.m_nBodySize)))) + hptr = unsafe.Pointer(C_AMFEncodeInt24((*byte)(hptr), (*byte)(hend), (int32(packet.m_nBodySize)))) *(*byte)(hptr) = byte(packet.m_packetType) hptr = incBytePtr(hptr, 1) } @@ -1748,7 +1748,7 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { } if t >= 0xffffff { - hptr = unsafe.Pointer(amfEncodeInt32((*byte)(hptr), (*byte)(hend), (int32)(t))) + hptr = unsafe.Pointer(C_AMFEncodeInt32((*byte)(hptr), (*byte)(hend), (int32)(t))) } nSize = int(packet.m_nBodySize) @@ -1810,7 +1810,7 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { } if t >= 0xffffff { extendedTimestamp := incBytePtr(header, 1+cSize) - amfEncodeInt32((*byte)(extendedTimestamp), + C_AMFEncodeInt32((*byte)(extendedTimestamp), (*byte)(incBytePtr(extendedTimestamp, 4)), (int32)(t)) } } @@ -1835,7 +1835,7 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { var ptr unsafe.Pointer ptr = incBytePtr(unsafe.Pointer(packet.m_body), 1) //C.AMF_DecodeString((*C.char)(ptr), &method) - amfDecodeString((*byte)(ptr), &method) + C_AMFDecodeString((*byte)(ptr), &method) if debugMode { log.Printf("Invoking %v", method.av_val) @@ -1845,7 +1845,7 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int { var txn int ptr = incBytePtr(ptr, 3+int(method.av_len)) //txn = int(C.AMF_DecodeNumber((*C.char)(ptr))) - txn = int(amfDecodeNumber((*byte)(ptr))) + txn = int(C_AMFDecodeNumber((*byte)(ptr))) avQueue(&r.m_methodCalls, (*int32)(unsafe.Pointer(&r.m_numCalls)), &method, int32(txn)) //C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method, @@ -1936,27 +1936,27 @@ func avQueue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) { (*num)++ } -func amfEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte { +func C_AMFEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte { if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) { return nil } - output = amfEncodeInt16(output, outend, int16(strName.av_len)) + output = C_AMFEncodeInt16(output, outend, int16(strName.av_len)) memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len)) output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len))) - return amfEncodeNumber(output, outend, dVal) + return C_AMFEncodeNumber(output, outend, dVal) } -func amfEncodeNamedBoolean(output *byte, outend *byte, strName *C.AVal, bVal int) *byte { +func C_AMFEncodeNamedBoolean(output *byte, outend *byte, strName *C.AVal, bVal int) *byte { if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) { return nil } - output = amfEncodeInt16(output, outend, int16(strName.av_len)) + output = C_AMFEncodeInt16(output, outend, int16(strName.av_len)) memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len)) output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len))) - return amfEncodeBoolean(output, outend, bVal) + return C_AMFEncodeBoolean(output, outend, bVal) } -func amfEncodeBoolean(output *byte, outend *byte, bVal int) *byte { +func C_AMFEncodeBoolean(output *byte, outend *byte, bVal int) *byte { if int(uintptr(unsafe.Pointer(output)))+2 > int(uintptr(unsafe.Pointer(outend))) { return nil } @@ -1971,7 +1971,7 @@ func amfEncodeBoolean(output *byte, outend *byte, bVal int) *byte { return output } -func amfEncodeNumber(output *byte, outend *byte, dVal float64) *byte { +func C_AMFEncodeNumber(output *byte, outend *byte, dVal float64) *byte { if int(uintptr(unsafe.Pointer(output)))+1+8 > int(uintptr(unsafe.Pointer(outend))) { return nil } @@ -1989,7 +1989,7 @@ func amfEncodeNumber(output *byte, outend *byte, dVal float64) *byte { return (*byte)(incBytePtr(unsafe.Pointer(output), 8)) } -func amfDecodeNumber(data *byte) float64 { +func C_AMFDecodeNumber(data *byte) float64 { var dVal float64 var ci, co *uint8 ci = (*uint8)(unsafe.Pointer(data)) @@ -2000,21 +2000,21 @@ func amfDecodeNumber(data *byte) float64 { return dVal } -func amfEncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte { +func C_AMFEncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte { if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) { return nil } - output = amfEncodeInt16(output, outend, int16(strName.av_len)) + output = C_AMFEncodeInt16(output, outend, int16(strName.av_len)) memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len)) output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len))) - return amfEncodeString(output, outend, strValue) + return C_AMFEncodeString(output, outend, strValue) } -// amfDecodeString decodes data into a string inside a AVal -func amfDecodeString(data *byte, bv *C.AVal) { +// C_AMFDecodeString decodes data into a string inside a AVal +func C_AMFDecodeString(data *byte, bv *C.AVal) { dataPtr := unsafe.Pointer(data) //bv.av_len = C.int(C.AMF_DecodeInt16((*C.char)(dataPtr))) - bv.av_len = C.int(amfDecodeInt16((*byte)(dataPtr))) + bv.av_len = C.int(C_AMFDecodeInt16((*byte)(dataPtr))) if bv.av_len > 0 { bv.av_val = (*C.char)(incBytePtr(dataPtr, 2)) } else { @@ -2022,14 +2022,14 @@ func amfDecodeString(data *byte, bv *C.AVal) { } } -// amfDecodeInt16 decodes data into a 16 bit number -func amfDecodeInt16(data *byte) uint16 { +// C_AMFDecodeInt16 decodes data into a 16 bit number +func C_AMFDecodeInt16(data *byte) uint16 { c := unsafe.Pointer(data) return uint16(*(*uint8)(c)<<8 | *(*byte)(incBytePtr(c, 1))) } -// amfEncodeInt24 encodes a int24 into data -func amfEncodeInt24(output *byte, outend *byte, nVal int32) *byte { +// C_AMFEncodeInt24 encodes a int24 into data +func C_AMFEncodeInt24(output *byte, outend *byte, nVal int32) *byte { outputPtr := unsafe.Pointer(output) outendPtr := unsafe.Pointer(outend) if uintptr(outputPtr)+3 > uintptr(outendPtr) { @@ -2047,8 +2047,8 @@ func amfEncodeInt24(output *byte, outend *byte, nVal int32) *byte { return (*byte)(incBytePtr(outputPtr, 3)) } -// amfDecodeInt24 decodes data into an unsigned int -func amfDecodeInt24(data *byte) uint32 { +// C_AMFDecodeInt24 decodes data into an unsigned int +func C_AMFDecodeInt24(data *byte) uint32 { // TODO Understand logic and simplify c := (*uint8)(unsafe.Pointer(data)) dst := uint32(int32(*c) << 16) @@ -2059,7 +2059,7 @@ func amfDecodeInt24(data *byte) uint32 { return dst } -func amfEncodeString(output *byte, outend *byte, bv *C.AVal) *byte { +func C_AMFEncodeString(output *byte, outend *byte, bv *C.AVal) *byte { outputPtr := unsafe.Pointer(output) outendPtr := unsafe.Pointer(outend) if (bv.av_len < 65536 && uintptr(incBytePtr(outputPtr, 1+2+int(bv.av_len))) > @@ -2072,14 +2072,14 @@ func amfEncodeString(output *byte, outend *byte, bv *C.AVal) *byte { outputPtr = incBytePtr(outputPtr, 1) outputPtr = unsafe.Pointer(C.AMF_EncodeInt16((*C.char)(outputPtr), (*C.char)( outendPtr), C.short(bv.av_len))) - //outputPtr = unsafe.Pointer(amfEncodeInt16((*byte)(outputPtr), + //outputPtr = unsafe.Pointer(C_AMFEncodeInt16((*byte)(outputPtr), //(*byte)(outendPtr), (int16)(bv.av_len))) } else { *(*byte)(outputPtr) = AMF_LONG_STRING outputPtr = incBytePtr(outputPtr, 1) outputPtr = unsafe.Pointer(C.AMF_EncodeInt32((*C.char)(outputPtr), (*C.char)( outendPtr), C.int(bv.av_len))) - //outputPtr = unsafe.Pointer(amfEncodeInt32((*byte)(outputPtr), + //outputPtr = unsafe.Pointer(C_AMFEncodeInt32((*byte)(outputPtr), //(*byte)(outendPtr), (int32)(bv.av_len))) } memmove(unsafe.Pointer(outputPtr), unsafe.Pointer(bv.av_val), uintptr(bv.av_len)) @@ -2088,8 +2088,8 @@ func amfEncodeString(output *byte, outend *byte, bv *C.AVal) *byte { return (*byte)(outputPtr) } -// amfEncodeInt16 encodes a int16 into data -func amfEncodeInt16(output *byte, outend *byte, nVal int16) *byte { +// C_AMFEncodeInt16 encodes a int16 into data +func C_AMFEncodeInt16(output *byte, outend *byte, nVal int16) *byte { outputPtr := unsafe.Pointer(output) outendPtr := unsafe.Pointer(outend) if uintptr(outputPtr)+2 > uintptr(outendPtr) { @@ -2104,8 +2104,8 @@ func amfEncodeInt16(output *byte, outend *byte, nVal int16) *byte { return (*byte)(incBytePtr(outputPtr, 2)) } -// amfEncodeInt32 encodes a int32 into data -func amfEncodeInt32(output *byte, outend *byte, nVal int32) *byte { +// C_AMFEncodeInt32 encodes a int32 into data +func C_AMFEncodeInt32(output *byte, outend *byte, nVal int32) *byte { outputPtr := unsafe.Pointer(output) outendPtr := unsafe.Pointer(outend) if uintptr(outputPtr)+4 > uintptr(outendPtr) {