mirror of https://bitbucket.org/ausocean/av.git
rtmp: afmDecodeInt24 generated port from c2go
This commit is contained in:
parent
e51ec5b929
commit
b327c5772b
13
rtmp/rtmp.go
13
rtmp/rtmp.go
|
@ -341,9 +341,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(C.AMF_DecodeInt24((*C.char)(buf)))
|
||||
pkt.m_nBodySize = C.uint32_t(afmDecodeInt24((*byte)(buf)))
|
||||
buf = incBytePtr(buf, 3)
|
||||
pkt.m_nTimeStamp = C.uint32_t(C.AMF_DecodeInt24((*C.char)(buf)))
|
||||
pkt.m_nTimeStamp = C.uint32_t(afmDecodeInt24((*byte)(buf)))
|
||||
buf = incBytePtr(buf, 3)
|
||||
pkt.m_nTimeStamp |= C.uint32_t(*indxBytePtr(buf, 0)) << 24
|
||||
buf = incBytePtr(buf, 4)
|
||||
|
@ -410,9 +410,12 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
|
||||
// afmDecodeInt24 decodes data into an unsigned int
|
||||
func afmDecodeInt24(data *byte) uint32 {
|
||||
dataPtr := unsafe.Pointer(data)
|
||||
|
||||
return (uint32)(*data)<<16 | *(*uint32)(incBytePtr(dataPtr, 1))<<8 | *(*uint32)(incBytePtr(dataPtr, 2))
|
||||
// TODO Understand logic and simplify
|
||||
c := (*uint8)(unsafe.Pointer(data))
|
||||
dst := uint32(int32(*c) << 16)
|
||||
dst |= uint32(int32(*((*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + (uintptr)(int32(1))*unsafe.Sizeof(*c))))) << 8)
|
||||
dst |= uint32(int32(*((*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + (uintptr)(int32(2))*unsafe.Sizeof(*c))))))
|
||||
return dst
|
||||
}
|
||||
|
||||
func afmEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||
|
|
Loading…
Reference in New Issue