mirror of https://bitbucket.org/ausocean/av.git
Finally found value for av_connect
This commit is contained in:
parent
7088a88fe9
commit
46673e0309
37
rtmp/rtmp.go
37
rtmp/rtmp.go
|
@ -149,11 +149,12 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func memmove(to, from unsafe.Pointer, n uintptr) {
|
func memmove(to, from unsafe.Pointer, n uintptr) {
|
||||||
copy(ptrToSlice(to, int(n)), ptrToSlice(from,int(n)))
|
copy(ptrToSlice(to, int(n)), ptrToSlice(from, int(n)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// av_setDataFrame is a static const global in rtmp.c
|
// av_setDataFrame is a static const global in rtmp.c
|
||||||
var setDataFrame = AVC("@setDataFrame")
|
var setDataFrame = AVC("@setDataFrame")
|
||||||
|
var av_connect = AVC("connect")
|
||||||
|
|
||||||
var packetSize = [...]int{12, 8, 4, 1}
|
var packetSize = [...]int{12, 8, 4, 1}
|
||||||
|
|
||||||
|
@ -694,7 +695,7 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
log.Println("... connected, handshaking...")
|
log.Println("... connected, handshaking...")
|
||||||
}
|
}
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
if C.HandShake(r, 1) == 0 {
|
if handShake(r, 1) == 0 {
|
||||||
log.Println("rtmpConnect1: handshake failed!")
|
log.Println("rtmpConnect1: handshake failed!")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -703,7 +704,7 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
if C.SendConnectPacket(r, cp) == 0 {
|
if sendConnectPacket(r, cp) == 0 {
|
||||||
log.Println("RTMP connect failed!")
|
log.Println("RTMP connect failed!")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -778,12 +779,38 @@ func handShake(r *C.RTMP, FP9HandShake int32) int {
|
||||||
bMatch = 1
|
bMatch = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if bMatch != 0 {
|
if bMatch == 0 {
|
||||||
log.Println("Client signature does not match!")
|
log.Println("Client signature does not match!")
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
|
var packet C.RTMPPacket
|
||||||
|
var pbuf [4096]byte
|
||||||
|
pend := incBytePtr(unsafe.Pointer(&pbuf[0]), int(unsafe.Sizeof(pbuf)))
|
||||||
|
var enc *byte
|
||||||
|
|
||||||
|
if cp != nil {
|
||||||
|
return sendPacket(r, cp, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.m_nChannel = 0x03
|
||||||
|
packet.m_headerType = RTMP_PACKET_SIZE_LARGE
|
||||||
|
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
||||||
|
packet.m_nTimeStamp = 0
|
||||||
|
packet.m_nInfoField2 = 0
|
||||||
|
packet.m_hasAbsTimestamp = 0
|
||||||
|
packet.m_body = (*C.char)(incBytePtr(unsafe.Pointer(&pbuf[0]),
|
||||||
|
RTMP_MAX_HEADER_SIZE))
|
||||||
|
|
||||||
|
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
||||||
|
enc = afmEncodeString(enc, (*byte)(pend), &av_connect)
|
||||||
|
r.m_numInvokes += 1
|
||||||
|
enc = afmEncodeString(unsafe.Pointer(enc), unsafe.Pointer(pend), r.m_numInvokes)
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
var packet C.RTMPPacket
|
var packet C.RTMPPacket
|
||||||
|
|
||||||
|
@ -906,7 +933,7 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
||||||
num = s2
|
num = s2
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(enc,buf,uintptr(num))
|
memmove(enc, buf, uintptr(num))
|
||||||
pkt.m_nBytesRead += C.uint32_t(num)
|
pkt.m_nBytesRead += C.uint32_t(num)
|
||||||
s2 -= num
|
s2 -= num
|
||||||
buf = incBytePtr(buf, num)
|
buf = incBytePtr(buf, num)
|
||||||
|
|
Loading…
Reference in New Issue