From 2dd7b344f870b96c74c273003cd1d28a28b1e43e Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 18 Jul 2018 12:21:31 +0930 Subject: [PATCH] Finished writing httpPost - need to build and test --- rtmp/rtmp.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 31c89b41..80bae0fa 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -52,7 +52,7 @@ import "C" import ( "errors" - _ "fmt" + "fmt" "log" "math" "reflect" @@ -605,6 +605,29 @@ func writeN(r *C.RTMP, buffer unsafe.Pointer, n int) int { return 0 } +func httpPost(r *C.RTMP, cmd RTMPTCmd, buf *byte, len int) int { + length := 512 + var hbuf [length]byte + fString := fmt.Sprintf("POST /%s%s/%d HTTP/1.1\r\n" + "Host: %.*s:%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], + r->m_clientID.av_val ? r->m_clientID.av_val : "", + r->m_msgCounter, r->Link.hostname.av_len, r->Link.hostname.av_val, + r->Link.port, len) + hlen := len(fString) + hbuf = (*byte)(unsafe.Pointer(&(([]byte{fString})[0]))) + // TODO: port this + C.RTMPSockBuf_Send(&r.m_sb, (*C.char)(hbuf), hlen) + hlen = c.RTMPSockBuf_Send(&r.m_sb, buf, len) + r.m_msgCounter++ + r.m_unackd++ + return hlen +} // TODO: port RTMP_METHOD func avQueue(vals **C.RTMP_METHOD, num *int, av *C.AVal, txn int ) {