Still trying to debug

This commit is contained in:
saxon 2018-07-13 05:21:17 +09:30
parent 137d60bde6
commit 4c1892e36f
1 changed files with 9 additions and 5 deletions

View File

@ -89,7 +89,7 @@ func AVC(str string) C.AVal {
} }
// av_setDataFrame is a static const global in rtmp.c // av_setDataFrame is a static const global in rtmp.c
var av_setDataFrame = AVC("@setDataFrame") var setDataFrame = AVC("@setDataFrame")
// Open establishes an rtmp connection with the url passed into the // Open establishes an rtmp connection with the url passed into the
// constructor // constructor
@ -113,8 +113,8 @@ func (s *session) Write(data []byte) (int, error) {
if C.RTMP_IsConnected(s.rtmp) <= 0 { if C.RTMP_IsConnected(s.rtmp) <= 0 {
return 0, Err(1) return 0, Err(1)
} }
//if C.RTMP_Write(s.rtmp,(*C.char)(unsafe.Pointer(&data[0])),C.int(len(data))) <= 0 { if C.RTMP_Write(s.rtmp,(*C.char)(unsafe.Pointer(&data[0])),C.int(len(data))) <= 0 {
if rtmpWrite(s.rtmp, data) <= 0 { //if rtmpWrite(s.rtmp, data) <= 0 {
return 0, Err(2) return 0, Err(2)
} }
return len(data), nil return len(data), nil
@ -186,10 +186,11 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
uintptr(pkt.m_nBodySize))) uintptr(pkt.m_nBodySize)))
if pkt.m_packetType == RTMP_PACKET_TYPE_INFO { if pkt.m_packetType == RTMP_PACKET_TYPE_INFO {
enc = C.AMF_EncodeString(enc, pend, &av_setDataFrame) enc = C.AMF_EncodeString(enc, pend, &setDataFrame)
pkt.m_nBytesRead = C.uint(math.Abs(float64(uintptr(unsafe.Pointer(enc)) - pkt.m_nBytesRead = C.uint(math.Abs(float64(uintptr(unsafe.Pointer(enc)) -
uintptr(unsafe.Pointer(pkt.m_body))))) uintptr(unsafe.Pointer(pkt.m_body)))))
} }
} else { } else {
enc = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(pkt.m_body)) + enc = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(pkt.m_body)) +
uintptr(pkt.m_nBytesRead))) uintptr(pkt.m_nBytesRead)))
@ -198,7 +199,10 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
if num > s2 { if num > s2 {
num = s2 num = s2
} }
C.memcpy(unsafe.Pointer(enc),unsafe.Pointer(buf),C.ulong(num)) for i := 0; i < num; i++ {
*(*byte)(unsafe.Pointer(enc)) = *(*byte)(unsafe.Pointer(buf))
}
//C.memcpy(unsafe.Pointer(enc),unsafe.Pointer(buf),C.ulong(num))
pkt.m_nBytesRead += C.uint(num) pkt.m_nBytesRead += C.uint(num)
s2 -= num s2 -= num
buf = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(num))) buf = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(num)))