mirror of https://bitbucket.org/ausocean/av.git
rtmp: clean up C_HandShake
This commit is contained in:
parent
cb47db73c8
commit
29f7d24623
28
rtmp/rtmp.go
28
rtmp/rtmp.go
|
@ -1391,30 +1391,25 @@ func C_RTMP_ReadPacket(r *C_RTMP, packet *C_RTMPPacket) (ok bool) {
|
||||||
// int HandShake(RTMP* r, int FP9HandShake);
|
// int HandShake(RTMP* r, int FP9HandShake);
|
||||||
// rtmp.c +3744
|
// rtmp.c +3744
|
||||||
func C_HandShake(r *C_RTMP, FP9HandShake int32) (ok bool) {
|
func C_HandShake(r *C_RTMP, FP9HandShake int32) (ok bool) {
|
||||||
var uptime, suptime uint32
|
|
||||||
var typ [1]byte
|
|
||||||
//clientbuf := make([]byte, RTMP_SIG_SIZE+1)
|
|
||||||
var clientbuf [RTMP_SIG_SIZE + 1]byte
|
var clientbuf [RTMP_SIG_SIZE + 1]byte
|
||||||
clientsig := (*byte)(incBytePtr(unsafe.Pointer(&clientbuf[0]), 1))
|
clientsig := clientbuf[1:]
|
||||||
//serversig := make([]byte, RTMP_SIG_SIZE)
|
|
||||||
var serversig [RTMP_SIG_SIZE]byte
|
var serversig [RTMP_SIG_SIZE]byte
|
||||||
|
|
||||||
clientbuf[0] = 0x03 // not encrypted
|
clientbuf[0] = 0x03 // not encrypted
|
||||||
|
|
||||||
// TODO: port rtmp_getTime
|
binary.BigEndian.PutUint32(clientsig, uint32(C_RTMP_GetTime()))
|
||||||
uptime = inet.Htonl(uint32(C_RTMP_GetTime()))
|
copy(clientsig[4:8], []byte{0, 0, 0, 0})
|
||||||
memmove(unsafe.Pointer(clientsig), unsafe.Pointer(&uptime), 4)
|
|
||||||
|
|
||||||
memset((*byte)(sliceToPtr((*[_Gi]byte)(unsafe.Pointer(clientsig))[4:])), 0, 4)
|
|
||||||
|
|
||||||
for i := 8; i < RTMP_SIG_SIZE; i++ {
|
for i := 8; i < RTMP_SIG_SIZE; i++ {
|
||||||
(*[_Gi]byte)(unsafe.Pointer(clientsig))[i] = byte(rand.Intn(256))
|
clientsig[i] = byte(rand.Intn(256))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !C_WriteN(r, pl2b(&clientbuf[0], RTMP_SIG_SIZE+1)) {
|
if !C_WriteN(r, clientbuf[:]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var typ [1]byte
|
||||||
if C_ReadN(r, typ[:]) != 1 {
|
if C_ReadN(r, typ[:]) != 1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1431,11 +1426,14 @@ func C_HandShake(r *C_RTMP, FP9HandShake int32) (ok bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode server response
|
// decode server response
|
||||||
memmove(unsafe.Pointer(&suptime), unsafe.Pointer(&serversig[0]), 4)
|
suptime := binary.BigEndian.Uint32(serversig[:4])
|
||||||
suptime = inet.Ntohl(suptime)
|
_ = suptime
|
||||||
|
// RTMP_Log(RTMP_LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, suptime)
|
||||||
|
// RTMP_Log(RTMP_LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__,
|
||||||
|
// serversig[4], serversig[5], serversig[6], serversig[7])
|
||||||
|
|
||||||
// 2nd part of handshake
|
// 2nd part of handshake
|
||||||
if !C_WriteN(r, pl2b(&serversig[0], RTMP_SIG_SIZE)) {
|
if !C_WriteN(r, serversig[:]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue