Ran go fmt

This commit is contained in:
saxon 2018-07-12 00:50:18 +09:30
parent 24eac36bbd
commit 46cff84322
1 changed files with 15 additions and 17 deletions

View File

@ -43,9 +43,9 @@ import "C"
import (
"errors"
"log"
"strconv"
"unsafe"
"log"
)
const (
@ -61,8 +61,7 @@ type Session interface {
// session provides parameters required for an rtmp communication session.
type session struct {
rtmp *C.RTMP
rtmp *C.RTMP
url string
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' {
// buf += 13
buf = buf[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))
buf = buf[3:]
buf = buf[1:]
pkt.m_nTimeStamp |= C.uint( buf[0] << 24 )
pkt.m_nTimeStamp |= C.uint(buf[0] << 24)
buf = buf[3:]
s2 -= 11
@ -146,16 +144,16 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
pkt.m_packetType == C.RTMP_PACKET_TYPE_VIDEO) &&
pkt.m_nTimeStamp == 0) || pkt.m_packetType == C.RTMP_PACKET_TYPE_INFO {
pkt.m_headerType = C.RTMP_PACKET_SIZE_LARGE
if pkt.m_packetType == C.RTMP_PACKET_TYPE_INFO {
pkt.m_nBodySize += 16
}
pkt.m_headerType = C.RTMP_PACKET_SIZE_LARGE
if pkt.m_packetType == C.RTMP_PACKET_TYPE_INFO {
pkt.m_nBodySize += 16
}
} else {
pkt.m_headerType = C.RTMP_PACKET_SIZE_MEDIUM
}
// 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")
return 0
}
@ -168,11 +166,13 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
&av_setDataFrame))
// 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 {
//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)
@ -181,8 +181,8 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
num = s2
}
encSlice := C.GoBytes(enc,C.int(num))
copy(encSlice,buf)
encSlice := C.GoBytes(enc, C.int(num))
copy(encSlice, buf)
pkt.m_nBytesRead += C.uint(num)
s2 -= num
@ -197,7 +197,6 @@ func (s *session) rtmpWrite(r *C.RTMP, buf []byte) int {
if ret == 0 {
return -1
}
// buf += 4
buf = buf[4:]
s2 -= 4
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 {
if C.RTMP_IsConnected(s.rtmp) <= 0 {
return 1