mirror of https://bitbucket.org/ausocean/av.git
Ported SocksSetup and tested
This commit is contained in:
parent
6cc807f56f
commit
aaa7cdbdab
41
rtmp/rtmp.go
41
rtmp/rtmp.go
|
@ -354,7 +354,7 @@ func (s *session) Write(data []byte) (int, error) {
|
|||
if s.rtmp == nil {
|
||||
return 0, Err(3)
|
||||
}
|
||||
// TODO: port this
|
||||
|
||||
if rtmpIsConnected(s.rtmp) == 0 {
|
||||
return 0, Err(1)
|
||||
}
|
||||
|
@ -472,8 +472,8 @@ func rtmpSetupUrl(r *C.RTMP, u string) int32 {
|
|||
r.Link.tcUrl.av_len = C.int(strlen(url))
|
||||
}
|
||||
}
|
||||
// TODO: port this
|
||||
C.SocksSetup(r, &r.Link.sockshost)
|
||||
|
||||
socksSetup(r, &r.Link.sockshost)
|
||||
|
||||
if r.Link.port == 0 {
|
||||
switch {
|
||||
|
@ -488,6 +488,32 @@ func rtmpSetupUrl(r *C.RTMP, u string) int32 {
|
|||
return 1
|
||||
}
|
||||
|
||||
func socksSetup(r *C.RTMP, sockshost *C.AVal) {
|
||||
if sockshost.av_len != 0 {
|
||||
socksport := strchr((*byte)(unsafe.Pointer(sockshost.av_val)), ':')
|
||||
hostname := strdup((*byte)(unsafe.Pointer(sockshost.av_val)))
|
||||
|
||||
if uintptr(unsafe.Pointer(socksport)) != 0 {
|
||||
*indxBytePtr(unsafe.Pointer(hostname),
|
||||
int(uintptr(decBytePtr(unsafe.Pointer(socksport),
|
||||
int(uintptr(unsafe.Pointer(sockshost.av_val))))))) = '\000'
|
||||
r.Link.sockshost.av_val = (*C.char)(unsafe.Pointer(hostname))
|
||||
r.Link.sockshost.av_len = C.int(strlen(hostname))
|
||||
|
||||
value, err := strconv.Atoi(string(ptrToSlice(unsafe.Pointer(uintptr(
|
||||
unsafe.Pointer(socksport))+uintptr(1)), int(strlen((*byte)(unsafe.Pointer(
|
||||
uintptr(unsafe.Pointer(socksport))+uintptr(1)))))+1)))
|
||||
if err != nil {
|
||||
log.Println("socksSetup: bad string conversion!")
|
||||
}
|
||||
if uintptr(unsafe.Pointer(socksport)) == 0 {
|
||||
value = 1080
|
||||
}
|
||||
r.Link.socksport = C.ushort(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func rtmpClose(r *C.RTMP) {
|
||||
closeInternal(r, 0)
|
||||
|
@ -679,15 +705,6 @@ func rtmpConnect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
/*
|
||||
func socksSetup(r *RTMP, sockshost *AVal) {
|
||||
if sockshost.av_len != 0 {
|
||||
socksport := strchr((*byte)(unsafe.Pointer(sockshost.av_val)), ':')
|
||||
hostname := strdup((*byte)(unsafe.Pointer(sockshost.av_val)))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
||||
var packet C.RTMPPacket
|
||||
|
||||
|
|
Loading…
Reference in New Issue