mirror of https://bitbucket.org/ausocean/av.git
rtmp: Implemented afmDecodeInt24 and afmDecodeString
This commit is contained in:
parent
daf219c937
commit
a00550b638
30
rtmp/rtmp.go
30
rtmp/rtmp.go
|
@ -8,6 +8,7 @@ DESCRIPTION
|
|||
AUTHOR
|
||||
Saxon Nelson-Milton <saxon@ausocean.org>
|
||||
Dan Kortschak <dan@ausocean.org>
|
||||
Jake Lane <jake@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
rtmp.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
||||
|
@ -199,11 +200,9 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
|
||||
pkt.m_packetType = C.uint8_t(*indxBytePtr(buf, 0))
|
||||
buf = incBytePtr(buf, 1)
|
||||
// TODO: port this
|
||||
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)
|
||||
// TODO: replace with ported version
|
||||
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)
|
||||
|
@ -231,7 +230,6 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
pend = incBytePtr(enc, int(pkt.m_nBodySize))
|
||||
|
||||
if pkt.m_packetType == RTMP_PACKET_TYPE_INFO {
|
||||
// TODO: Port this
|
||||
enc = unsafe.Pointer(afmEncodeString((*byte)(enc), (*byte)(pend), &setDataFrame))
|
||||
pkt.m_nBytesRead = C.uint32_t(math.Abs(float64(uintptr(enc) -
|
||||
uintptr(unsafe.Pointer(pkt.m_body)))))
|
||||
|
@ -269,6 +267,13 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
return size + s2
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
||||
func afmEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||
outputPtr := unsafe.Pointer(output)
|
||||
outendPtr := unsafe.Pointer(outend)
|
||||
|
@ -533,8 +538,7 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
|||
var method C.AVal
|
||||
var ptr unsafe.Pointer
|
||||
ptr = incBytePtr(unsafe.Pointer(packet.m_body), 1)
|
||||
// TODO: port this
|
||||
C.AMF_DecodeString((*C.char)(ptr), &method)
|
||||
afmDecodeString((*byte)(ptr), &method)
|
||||
|
||||
if debugMode {
|
||||
log.Printf("Invoking %v", method.av_val)
|
||||
|
@ -566,6 +570,18 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// afmDecodeString decodes data into a string inside a AVal
|
||||
func afmDecodeString(data *byte, bv *C.AVal) {
|
||||
dataPtr := unsafe.Pointer(data)
|
||||
bv.av_len = C.int(C.AMF_DecodeInt16((*C.char)(dataPtr)))
|
||||
|
||||
if bv.av_len > 0 {
|
||||
bv.av_val = (*C.char)(incBytePtr(dataPtr, 2))
|
||||
} else {
|
||||
bv.av_val = nil
|
||||
}
|
||||
}
|
||||
|
||||
func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
||||
ptr := buffer
|
||||
for n > 0 {
|
||||
|
|
Loading…
Reference in New Issue