mirror of https://bitbucket.org/ausocean/av.git
Still trying to debug
This commit is contained in:
parent
137d60bde6
commit
4c1892e36f
14
rtmp/rtmp.go
14
rtmp/rtmp.go
|
@ -89,7 +89,7 @@ func AVC(str string) C.AVal {
|
|||
}
|
||||
|
||||
// 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
|
||||
// constructor
|
||||
|
@ -113,8 +113,8 @@ func (s *session) Write(data []byte) (int, error) {
|
|||
if C.RTMP_IsConnected(s.rtmp) <= 0 {
|
||||
return 0, Err(1)
|
||||
}
|
||||
//if C.RTMP_Write(s.rtmp,(*C.char)(unsafe.Pointer(&data[0])),C.int(len(data))) <= 0 {
|
||||
if rtmpWrite(s.rtmp, 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 {
|
||||
return 0, Err(2)
|
||||
}
|
||||
return len(data), nil
|
||||
|
@ -186,10 +186,11 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
uintptr(pkt.m_nBodySize)))
|
||||
|
||||
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)) -
|
||||
uintptr(unsafe.Pointer(pkt.m_body)))))
|
||||
}
|
||||
|
||||
} else {
|
||||
enc = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(pkt.m_body)) +
|
||||
uintptr(pkt.m_nBytesRead)))
|
||||
|
@ -198,7 +199,10 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
if 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)
|
||||
s2 -= num
|
||||
buf = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(num)))
|
||||
|
|
Loading…
Reference in New Issue