mirror of https://bitbucket.org/ausocean/av.git
Merge branch 'librtmpPorting' of http://bitbucket.org/ausocean/av into librtmpPorting
This commit is contained in:
commit
e0f07b9bca
28
rtmp/rtmp.go
28
rtmp/rtmp.go
|
@ -794,12 +794,11 @@ func sendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
|||
if t > 0xffffff {
|
||||
res = 0xffffff
|
||||
}
|
||||
hptr = unsafe.Pointer(C.AMF_EncodeInt24((*C.char)(hptr), (*C.char)(hend), C.int(res)))
|
||||
hptr = unsafe.Pointer(afmEncodeInt24((*byte)(hptr), (*byte)(hend), res))
|
||||
}
|
||||
|
||||
if nSize > 4 {
|
||||
hptr = unsafe.Pointer(C.AMF_EncodeInt24((*C.char)(hptr), (*C.char)(hend),
|
||||
C.int(packet.m_nBodySize)))
|
||||
hptr = unsafe.Pointer(afmEncodeInt24((*byte)(hptr), (*byte)(hend), (int32(packet.m_nBodySize))))
|
||||
*(*byte)(hptr) = byte(packet.m_packetType)
|
||||
hptr = incBytePtr(hptr, 1)
|
||||
}
|
||||
|
@ -963,6 +962,29 @@ func afmDecodeInt16(data *byte) uint16 {
|
|||
return (uint16(*(*uint8)(c)) << 8) | *(*uint16)(incBytePtr(c, 1))
|
||||
}
|
||||
|
||||
// afmEncodeInt24 encodes a int24 into data
|
||||
func afmEncodeInt24(output *byte, outend *byte, nVal int32) *byte {
|
||||
outputPtr := unsafe.Pointer(output)
|
||||
outendPtr := unsafe.Pointer(outend)
|
||||
if uintptr(outputPtr)+3 > uintptr(outendPtr) {
|
||||
// length < 3
|
||||
return nil
|
||||
}
|
||||
|
||||
// Assign output[2]
|
||||
third := (*byte)(incBytePtr(outputPtr, 2))
|
||||
*third = (byte)(nVal & 0xff)
|
||||
|
||||
// Assign output[1]
|
||||
second := (*byte)(incBytePtr(outputPtr, 1))
|
||||
*second = (byte)(nVal >> 8)
|
||||
|
||||
// Assign output[0]
|
||||
*output = (byte)(nVal >> 16)
|
||||
|
||||
return (*byte)(incBytePtr(outputPtr, 3))
|
||||
}
|
||||
|
||||
func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
||||
ptr := buffer
|
||||
for n > 0 {
|
||||
|
|
Loading…
Reference in New Issue