mirror of https://bitbucket.org/ausocean/av.git
Added some test cases for helper functions
This commit is contained in:
parent
cf8568bf40
commit
1d1ff01681
36
rtmp/rtmp.go
36
rtmp/rtmp.go
|
@ -991,13 +991,8 @@ func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
|||
for n > 0 {
|
||||
var nBytes int
|
||||
|
||||
if (r.Link.protocol & RTMP_FEATURE_HTTP) != 0 {
|
||||
// TODO: port HTTP_POST
|
||||
nBytes = httpPost(r, RTMPT_SEND, (*byte)(ptr), n)
|
||||
} else {
|
||||
// TODO: port this if necessary
|
||||
nBytes = int(sockBufSend(&r.m_sb, (*byte)(ptr), int32(n)))
|
||||
}
|
||||
// TODO: port this if necessary
|
||||
nBytes = int(sockBufSend(&r.m_sb, (*byte)(ptr), int32(n)))
|
||||
|
||||
if nBytes < 0 {
|
||||
if debugMode {
|
||||
|
@ -1033,31 +1028,6 @@ var RTMPT_cmds = []string{
|
|||
"close",
|
||||
}
|
||||
|
||||
func httpPost(r *C.RTMP, cmd C.RTMPTCmd, buf *byte, l int) int {
|
||||
res := ""
|
||||
if r.m_clientID.av_val != nil {
|
||||
res = string(ptrToSlice(unsafe.Pointer(r.m_clientID.av_val),
|
||||
int(r.m_clientID.av_len)))
|
||||
}
|
||||
fString := fmt.Sprintf("POST /%s%s/%d HTTP/1.1\r\n"+
|
||||
"Host: %v:%d\r\n"+
|
||||
"Accept: */*\r\n"+
|
||||
"User-Agent: Shockwave Flash\r\n"+
|
||||
"Connection: Keep-Alive\r\n"+
|
||||
"Cache-Control: no-cache\r\n"+
|
||||
"Content-type: application/x-fcs\r\n"+
|
||||
"Content-length: %d\r\n\r\n", RTMPT_cmds[cmd], res, r.m_msgCounter,
|
||||
r.Link.hostname.av_len, r.Link.hostname.av_val, r.Link.port, l)
|
||||
hlen := len(fString)
|
||||
hbuf := (*byte)(unsafe.Pointer(&(([]byte(fString))[0])))
|
||||
// TODO: port this
|
||||
sockBufSend(&r.m_sb, (*byte)(unsafe.Pointer(hbuf)), int32(hlen))
|
||||
hlen = int(sockBufSend(&r.m_sb, (*byte)(unsafe.Pointer(buf)), int32(l)))
|
||||
r.m_msgCounter++
|
||||
r.m_unackd++
|
||||
return hlen
|
||||
}
|
||||
|
||||
func sockBufSend(sb *C.RTMPSockBuf, buf *byte, l int32) int32 {
|
||||
return int32(C.send(sb.sb_socket, unsafe.Pointer(buf), C.size_t(l), 0))
|
||||
}
|
||||
|
@ -1091,7 +1061,7 @@ func sToUP(b []byte) unsafe.Pointer {
|
|||
return unsafe.Pointer(&b[0])
|
||||
}
|
||||
|
||||
// Creates a new C string from a go string
|
||||
// Creates a new C style string from a go string
|
||||
func goStrToCStr(str string) *byte {
|
||||
l := len(str)
|
||||
slice := make([]byte, l+1)
|
||||
|
|
Loading…
Reference in New Issue