mirror of https://bitbucket.org/ausocean/av.git
Finished making major change to how I increment pointers
This commit is contained in:
parent
9c67bc06a3
commit
4415d2c089
11
rtmp/rtmp.go
11
rtmp/rtmp.go
|
@ -109,6 +109,11 @@ func byteSliceToCArr(buf []byte) *C.char {
|
|||
return (*C.char)(unsafe.Pointer(&buf[0]))
|
||||
}
|
||||
|
||||
func cPtrInc(a *C.char, inc C.uint) *C.char {
|
||||
return (*C.char)(unsafe.Pointer( uintptr(unsafe.Pointer(a)) +
|
||||
( unsafe.Sizeof(C.char(0x00)) * (uintptr(inc)) ) ))
|
||||
}
|
||||
|
||||
func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||
var pkt *C.RTMPPacket = &r.m_write
|
||||
var pend, enc []byte
|
||||
|
@ -165,8 +170,7 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
|||
// Note this is pointer arithmatic
|
||||
enc = pkt.m_body
|
||||
// pend = enc + pkt.m_nBodySize
|
||||
pend = (*C.char)(unsafe.Pointer( uintptr(unsafe.Pointer(enc)) +
|
||||
( unsafe.Sizeof(C.char(0x00)) * (uintptr(pkt.m_nBodySize)) ) ))
|
||||
pend = cPtrInc(enc,pkt.m_nBodySize)
|
||||
|
||||
if pkt.m_packetType == C.RTMP_PACKET_TYPE_INFO {
|
||||
enc = C.AMF_EncodeString(enc, pend, &av_setDataFrame )
|
||||
|
@ -177,8 +181,7 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
|||
}
|
||||
} else {
|
||||
//C-code: enc = pkt.m_body + pkt.m_nBytesRead
|
||||
enc = (*C.char)(unsafe.Pointer( uintptr(unsafe.Pointer(pkt.m_body)) +
|
||||
( unsafe.Sizeof(C.char(0x00)) * (uintptr(pkt.m_nBytesRead)) ) ))
|
||||
enc = cPtrInc(pkt.m_body,pkt.m_nBytesRead)
|
||||
}
|
||||
|
||||
num = int(pkt.m_nBodySize - pkt.m_nBytesRead)
|
||||
|
|
Loading…
Reference in New Issue