Works when I don't use my amfEncodeString, clearly we need to work on that

This commit is contained in:
saxon 2018-07-29 09:31:19 +09:30
parent bb1f63d8bd
commit 76ced667b9
1 changed files with 14 additions and 29 deletions

View File

@ -783,8 +783,8 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
return 0
}
//if C.ReadN(r, (*C.char)(unsafe.Pointer(&typ)), 1) != 1 {
if readN(r, (*byte)(unsafe.Pointer(&typ)), 1) != 1 {
if C.ReadN(r, (*C.char)(unsafe.Pointer(&typ)), 1) != 1 {
//if readN(r, (*byte)(unsafe.Pointer(&typ)), 1) != 1 {
return 0
}
@ -795,8 +795,8 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
log.Println("handShake: type mismatch: client sent %v, server sent: %v",
clientbuf[0], typ)
}
if readN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
//if C.ReadN(r, (*C.char)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
//if readN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
if C.ReadN(r, (*C.char)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
return 0
}
@ -809,8 +809,8 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
return 0
}
if readN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
// if C.ReadN(r, (*C.char)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
//if readN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
if C.ReadN(r, (*C.char)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
return 0
}
@ -944,8 +944,8 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
var enc *byte
if cp != nil {
return rtmpSendPacket(r, cp, 1)
//return int(C.RTMP_SendPacket(r, cp, 1))
//return rtmpSendPacket(r, cp, 1)
return int(C.RTMP_SendPacket(r, cp, 1))
}
packet.m_nChannel = 0x03
@ -959,9 +959,9 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
enc = (*byte)(unsafe.Pointer(packet.m_body))
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
//(*C.char)(unsafe.Pointer(pend)), &av_connect)))
enc = amfEncodeString(enc, pend, &av_connect)
enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
(*C.char)(unsafe.Pointer(pend)), &av_connect)))
//enc = amfEncodeString(enc, pend, &av_connect)
r.m_numInvokes += 1
enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNumber((*C.char)(unsafe.Pointer(enc)),
(*C.char)(unsafe.Pointer(pend)), C.double(r.m_numInvokes))))
@ -1107,8 +1107,8 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
packet.m_nBodySize = C.uint32_t(int(uintptr(decBytePtr(unsafe.Pointer(enc),
int(uintptr(unsafe.Pointer(packet.m_body)))))))
//return int(C.RTMP_SendPacket(r, &packet, 1))
return rtmpSendPacket(r, &packet, 1)
return int(C.RTMP_SendPacket(r, &packet, 1))
//return rtmpSendPacket(r, &packet, 1)
}
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
@ -1261,7 +1261,7 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
var prevPacket *C.RTMPPacket
last := 0
var nSize, hSize, cSize, nChunkSize, tlen int
var nSize, hSize, cSize, nChunkSize int
var header, hptr, hend, buffer, tbuf, toff unsafe.Pointer
var goHbuf [RTMP_MAX_HEADER_SIZE]byte
var hbuf = unsafe.Pointer(&goHbuf[0])
@ -1407,21 +1407,6 @@ func rtmpSendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
log.Printf("rtmpSendPacket: fd=%v, size=%v", r.m_sb.sb_socket, nSize)
}
// send all chunks in one HTTP request
// TODO: port RTMP_FEATURE_HTTP
if int(r.Link.protocol&RTMP_FEATURE_HTTP) != 0 {
chunks := (nSize + nChunkSize - 1) / nChunkSize
if chunks > 1 {
tlen = chunks*(cSize+1) + nSize + hSize
// TODO: figure out how to do this in go
tbuf = allocate(uintptr(tlen))
if tbuf == nil {
return 0
}
toff = tbuf
}
}
for (nSize + hSize) != 0 {
var wrote int