mirror of https://bitbucket.org/ausocean/av.git
Started writing handshake function - program currently still buildable
This commit is contained in:
parent
aaa7cdbdab
commit
4eff566a73
35
rtmp/rtmp.go
35
rtmp/rtmp.go
|
@ -130,6 +130,8 @@ const (
|
||||||
RTMP_BUFFER_CACHE_SIZE = (16 * 1024)
|
RTMP_BUFFER_CACHE_SIZE = (16 * 1024)
|
||||||
RTMP_CHANNELS = 65600
|
RTMP_CHANNELS = 65600
|
||||||
RTMP_SWF_HASHLEN = 32
|
RTMP_SWF_HASHLEN = 32
|
||||||
|
RTMP_SIG_SIZE = 1536
|
||||||
|
RTMP_LARGE_HEADER_SIZE = 12
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -632,14 +634,12 @@ func rtmpConnect(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: port this
|
|
||||||
if rtmpConnect0(r, (*C.sockaddr)(unsafe.Pointer(&service))) == 0 {
|
if rtmpConnect0(r, (*C.sockaddr)(unsafe.Pointer(&service))) == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
r.m_bSendCounter = 1
|
r.m_bSendCounter = 1
|
||||||
|
|
||||||
// TODO: port this
|
|
||||||
return int(rtmpConnect1(r, cp))
|
return int(rtmpConnect1(r, cp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,6 +690,7 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if debugMode {
|
if debugMode {
|
||||||
log.Println("... connected, handshaking...")
|
log.Println("... connected, handshaking...")
|
||||||
}
|
}
|
||||||
|
// TODO: port this
|
||||||
if C.HandShake(r, 1) == 0 {
|
if C.HandShake(r, 1) == 0 {
|
||||||
log.Println("rtmpConnect1: handshake failed!")
|
log.Println("rtmpConnect1: handshake failed!")
|
||||||
return 0
|
return 0
|
||||||
|
@ -698,6 +699,7 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
log.Println("... handshaked...")
|
log.Println("... handshaked...")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: port this
|
||||||
if C.SendConnectPacket(r, cp) == 0 {
|
if C.SendConnectPacket(r, cp) == 0 {
|
||||||
log.Println("RTMP connect failed!")
|
log.Println("RTMP connect failed!")
|
||||||
return 0
|
return 0
|
||||||
|
@ -705,6 +707,35 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: complete this
|
||||||
|
|
||||||
|
/*
|
||||||
|
func handShake(r *C.RTMP, FP9HandShake int32) int {
|
||||||
|
var i, bMatch int
|
||||||
|
var uptime, suptime uint32
|
||||||
|
var typ byte
|
||||||
|
// TODO: port this const
|
||||||
|
var clientbuf [RTMP_SIG_SIZE + 1]byte
|
||||||
|
clientsig := (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&clientbuf[0])) +
|
||||||
|
uintptr(1)))
|
||||||
|
var serversig [RTMP_SIG_SIZE]byte
|
||||||
|
|
||||||
|
clientbuf[0] = 0x03 // not encrypted
|
||||||
|
|
||||||
|
// TODO: port rtmp_getTime
|
||||||
|
uptime = inet.Htonl(uint32(C.RTMP_GetTime()))
|
||||||
|
memmove(unsafe.Pointer(clientsig), unsafe.Pointer(&uptime), 4)
|
||||||
|
|
||||||
|
memset(indxBytePtr(unsafe.Pointer(clientsig), 4), 0, 4)
|
||||||
|
|
||||||
|
for i := 8; i < RTMP_SIG_SIZE; i++ {
|
||||||
|
*indxBytePtr(unsafe.Pointer(clientsig), i) = byte(rand.Intn(256))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
var packet C.RTMPPacket
|
var packet C.RTMPPacket
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue