mirror of https://bitbucket.org/ausocean/av.git
Wrote WriteN - still need to test
This commit is contained in:
parent
39ad3b6ac8
commit
abd5cc27de
51
rtmp/rtmp.go
51
rtmp/rtmp.go
|
@ -229,7 +229,7 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
}
|
||||
|
||||
func sendPacket(r *C.RTMP, pkt *C.RTMPPacket, queue int) int {
|
||||
const prevPacket *C.RTMPPacket
|
||||
var prevPacket *C.RTMPPacket
|
||||
last := 0
|
||||
var nSize, hSize, cSize, nChunkSize, tlen int
|
||||
var header, hptr, hend, buffer, tbuf, toff unsafe.Pointer
|
||||
|
@ -319,7 +319,7 @@ func sendPacket(r *C.RTMP, pkt *C.RTMPPacket, queue int) int {
|
|||
c |= byte(1)
|
||||
}
|
||||
|
||||
hptr* = tmp >> 8
|
||||
*(*byte)(hptr) = byte(tmp >> 8)
|
||||
hptr = incPtr(hptr,1)
|
||||
|
||||
if nSize > 1 {
|
||||
|
@ -442,7 +442,7 @@ func sendPacket(r *C.RTMP, pkt *C.RTMPPacket, queue int) int {
|
|||
// TODO: port the const
|
||||
if packet.m_packetType == C.RTMP_PACKET_TYPE_INVOKE {
|
||||
// TODO: port C.AVal
|
||||
var C.AVal method
|
||||
var method C.AVal
|
||||
var ptr unsafe.Pointer
|
||||
ptr = incPtr(unsafe.Pointer(packet.m_body),1)
|
||||
// TODO: port this
|
||||
|
@ -467,11 +467,54 @@ func sendPacket(r *C.RTMP, pkt *C.RTMPPacket, queue int) int {
|
|||
}
|
||||
|
||||
memmove(indxPtr(unsafe.Pointer(r.m_vecChannelsOut),packet.m_nChannel),
|
||||
unsafe.Pointer(packet), unsafe.Sizeof(C.RTMPPakcet))
|
||||
unsafe.Pointer(packet), unsafe.Sizeof(C.RTMPPacket))
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
||||
ptr := buffer
|
||||
for n > 0 {
|
||||
var nBytes int
|
||||
|
||||
if r.Link.protocol & C.RTMP_FEATURE_HTTP {
|
||||
// TODO: port HTTP_POST
|
||||
nbytes = int(C.HTTP_POST(r, C.RTMPT_SEND, (*C.char)(ptr), C.int(n))
|
||||
} else {
|
||||
// TODO: port this if necessary
|
||||
nBytes = RTMPSockBuf_Send(&r.m_sb, (*C.char)(ptr), C.int(n))
|
||||
}
|
||||
|
||||
if nBytes < 0 {
|
||||
// TODO: port this
|
||||
sockerr := int(C.GetSockError())
|
||||
|
||||
if debugMode {
|
||||
log.Printf("WriteN, RTMP send error %v (%v bytes)",sockerr, n)
|
||||
}
|
||||
|
||||
if sockerr == C.EINTR && RTMP_ctrlC == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: port this
|
||||
C.RTMP_Close(r)
|
||||
n = 1
|
||||
break
|
||||
}
|
||||
|
||||
if nBytes == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
n -= nBytes
|
||||
ptr = incPtr(ptr, nBytes)
|
||||
}
|
||||
|
||||
return n == 0
|
||||
}
|
||||
|
||||
|
||||
// memmove copies n bytes from "from" to "to".
|
||||
//go:linkname memmove runtime.memmove
|
||||
func memmove(to, from unsafe.Pointer, n uintptr)
|
||||
|
|
Loading…
Reference in New Issue