mirror of https://bitbucket.org/ausocean/av.git
Just about to fix is I think
This commit is contained in:
parent
b1f470344d
commit
7b20e8f767
10
rtmp/rtmp.go
10
rtmp/rtmp.go
|
@ -47,6 +47,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
_"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -82,7 +83,7 @@ func NewSession(url string, connectTimeout uint) Session {
|
||||||
func AVC(str string) C.AVal {
|
func AVC(str string) C.AVal {
|
||||||
var aval C.AVal
|
var aval C.AVal
|
||||||
aval.av_val = C.CString(str)
|
aval.av_val = C.CString(str)
|
||||||
aval.av_len = C.int(len(str))
|
aval.av_len = C.int(unsafe.Sizeof(aval.av_val)-1)
|
||||||
return aval
|
return aval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ 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 rtmpWrite(s.rtmp, data) <= 0 {
|
if rtmpWrite(s.rtmp, data) <= 0 {
|
||||||
return 0, Err(2)
|
return 0, Err(2)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ func (s *session) Write(data []byte) (int, error) {
|
||||||
|
|
||||||
func rtmpWrite(r *C.RTMP, data []byte) int {
|
func rtmpWrite(r *C.RTMP, data []byte) int {
|
||||||
buf := (*C.char)(unsafe.Pointer(&data[0]))
|
buf := (*C.char)(unsafe.Pointer(&data[0]))
|
||||||
var pkt *C.RTMPPacket = &r.m_write
|
var pkt = &r.m_write
|
||||||
var pend, enc *C.char
|
var pend, enc *C.char
|
||||||
size := len(data)
|
size := len(data)
|
||||||
s2 := size
|
s2 := size
|
||||||
|
@ -127,15 +129,13 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
||||||
|
|
||||||
pkt.m_nChannel = 0x04
|
pkt.m_nChannel = 0x04
|
||||||
pkt.m_nInfoField2 = r.m_stream_id
|
pkt.m_nInfoField2 = r.m_stream_id
|
||||||
|
for s2 > 0 || s2 < 0{
|
||||||
for s2 > 0 {
|
|
||||||
if pkt.m_nBytesRead == 0 {
|
if pkt.m_nBytesRead == 0 {
|
||||||
if size < minDataSize {
|
if size < minDataSize {
|
||||||
log.Printf("size: %d\n", size)
|
log.Printf("size: %d\n", size)
|
||||||
log.Printf("too small \n")
|
log.Printf("too small \n")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
buf0 := *(*byte)(unsafe.Pointer(buf))
|
buf0 := *(*byte)(unsafe.Pointer(buf))
|
||||||
buf1 := *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(1)))
|
buf1 := *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(1)))
|
||||||
buf2 := *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(2)))
|
buf2 := *(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(buf)) + uintptr(2)))
|
||||||
|
|
Loading…
Reference in New Issue