mirror of https://bitbucket.org/ausocean/av.git
Ran go fmt
This commit is contained in:
parent
24eac36bbd
commit
46cff84322
22
rtmp/rtmp.go
22
rtmp/rtmp.go
|
@ -43,9 +43,9 @@ import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -62,7 +62,6 @@ type Session interface {
|
||||||
// session provides parameters required for an rtmp communication session.
|
// session provides parameters required for an rtmp communication session.
|
||||||
type session struct {
|
type session struct {
|
||||||
rtmp *C.RTMP
|
rtmp *C.RTMP
|
||||||
|
|
||||||
url string
|
url string
|
||||||
timeout uint
|
timeout uint
|
||||||
}
|
}
|
||||||
|
@ -126,7 +125,6 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf[0] == 'F' && buf[1] == 'L' && buf[2] == 'V' {
|
if buf[0] == 'F' && buf[1] == 'L' && buf[2] == 'V' {
|
||||||
// buf += 13
|
|
||||||
buf = buf[13:]
|
buf = buf[13:]
|
||||||
s2 -= 13
|
s2 -= 13
|
||||||
}
|
}
|
||||||
|
@ -138,7 +136,7 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
pkt.m_nTimeStamp = C.AMF_DecodeInt24(byteSliceToCArr(buf))
|
pkt.m_nTimeStamp = C.AMF_DecodeInt24(byteSliceToCArr(buf))
|
||||||
buf = buf[3:]
|
buf = buf[3:]
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
pkt.m_nTimeStamp |= C.uint( buf[0] << 24 )
|
pkt.m_nTimeStamp |= C.uint(buf[0] << 24)
|
||||||
buf = buf[3:]
|
buf = buf[3:]
|
||||||
s2 -= 11
|
s2 -= 11
|
||||||
|
|
||||||
|
@ -155,7 +153,7 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// C: if (!RTMPPacket_Alloc(pkt, pkt->m_nBodySize))
|
// C: if (!RTMPPacket_Alloc(pkt, pkt->m_nBodySize))
|
||||||
if int( C.RTMPPacket_Alloc(pkt, pkt.m_nBodySize)) == 0 {
|
if int(C.RTMPPacket_Alloc(pkt, pkt.m_nBodySize)) == 0 {
|
||||||
log.Println("Failed to allocated packet")
|
log.Println("Failed to allocated packet")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -168,11 +166,13 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
&av_setDataFrame))
|
&av_setDataFrame))
|
||||||
|
|
||||||
// C-code: pkt.m_nBytesRead enc - pkt.m_body
|
// C-code: pkt.m_nBytesRead enc - pkt.m_body
|
||||||
pkt.m_nBytesRead = (C.uint)(uintptr(enc)-uintptr(unsafe.Pointer(pkt.m_body)))
|
pkt.m_nBytesRead = (C.uint)(uintptr(enc) -
|
||||||
|
uintptr(unsafe.Pointer(pkt.m_body)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//C-code: enc = pkt.m_body + pkt.m_nBytesRead
|
//C-code: enc = pkt.m_body + pkt.m_nBytesRead
|
||||||
enc = unsafe.Pointer(uintptr(unsafe.Pointer(pkt.m_body)) + uintptr(pkt.m_nBytesRead))
|
enc = unsafe.Pointer(uintptr(unsafe.Pointer(pkt.m_body)) +
|
||||||
|
uintptr(pkt.m_nBytesRead))
|
||||||
}
|
}
|
||||||
|
|
||||||
num = int(pkt.m_nBodySize - pkt.m_nBytesRead)
|
num = int(pkt.m_nBodySize - pkt.m_nBytesRead)
|
||||||
|
@ -181,8 +181,8 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
num = s2
|
num = s2
|
||||||
}
|
}
|
||||||
|
|
||||||
encSlice := C.GoBytes(enc,C.int(num))
|
encSlice := C.GoBytes(enc, C.int(num))
|
||||||
copy(encSlice,buf)
|
copy(encSlice, buf)
|
||||||
|
|
||||||
pkt.m_nBytesRead += C.uint(num)
|
pkt.m_nBytesRead += C.uint(num)
|
||||||
s2 -= num
|
s2 -= num
|
||||||
|
@ -197,7 +197,6 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
// buf += 4
|
|
||||||
buf = buf[4:]
|
buf = buf[4:]
|
||||||
s2 -= 4
|
s2 -= 4
|
||||||
if s2 < 0 {
|
if s2 < 0 {
|
||||||
|
@ -205,10 +204,9 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return size+s2
|
return size + s2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *session) writeFrame(data []byte) uint {
|
func (s *session) writeFrame(data []byte) uint {
|
||||||
if C.RTMP_IsConnected(s.rtmp) <= 0 {
|
if C.RTMP_IsConnected(s.rtmp) <= 0 {
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in New Issue