Wrote rtmp init func

This commit is contained in:
saxon 2018-07-19 17:30:30 +09:30
parent 8dc2b27bad
commit e04ae76dcf
1 changed files with 15 additions and 1 deletions

View File

@ -322,7 +322,7 @@ func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) {
url := C.CString(u) url := C.CString(u)
connect_timeout := C.int(timeout) connect_timeout := C.int(timeout)
rtmp = rtmpAlloc() rtmp = rtmpAlloc()
C.RTMP_Init(rtmp) rtmpInit(rtmp)
rtmp.Link.timeout = connect_timeout rtmp.Link.timeout = connect_timeout
if C.RTMP_SetupURL(rtmp, url) == 0 { if C.RTMP_SetupURL(rtmp, url) == 0 {
C.RTMP_Close(rtmp) C.RTMP_Close(rtmp)
@ -352,6 +352,20 @@ func rtmpAlloc() *C.RTMP {
return (*C.RTMP)(allocate(unsafe.Sizeof(r))) return (*C.RTMP)(allocate(unsafe.Sizeof(r)))
} }
func rtmpInit(r *C.RTMP) {
r.m_sb.sb_socket = -1
r.m_inChunkSize = RTMP_DEFAULT_CHUNKSIZE
r.m_outChunkSize = RTMP_DEFAULT_CHUNKSIZE
r.m_nBufferMS = 30000
r.m_nClientBW = 2500000
r.m_nClientBW2 = 2
r.m_nServerBW = 2500000
r.m_fAudioCodecs = 3191.0
r.m_fVideoCodecs = 252.0
r.Link.timeout = 30
r.Link.swfAge = 30
}
// Close terminates the rtmp connection // Close terminates the rtmp connection
func (s *session) Close() error { func (s *session) Close() error {
if s.rtmp == nil { if s.rtmp == nil {