Merge init into NewSession.

This commit is contained in:
scruzin 2019-01-09 22:05:04 +10:30
parent d1958ff75d
commit c8ec317823
1 changed files with 13 additions and 18 deletions

View File

@ -79,8 +79,18 @@ const (
func NewSession(url string, timeout uint, log Log) *Session { func NewSession(url string, timeout uint, log Log) *Session {
return &Session{ return &Session{
url: url, url: url,
timeout: timeout, inChunkSize: 128,
outChunkSize: 128,
clientBW: 2500000,
clientBW2: 2,
serverBW: 2500000,
audioCodecs: 3191.0,
videoCodecs: 252.0,
log: log, log: log,
link: link{
timeout: timeout,
swfAge: 30,
},
} }
} }
@ -99,7 +109,6 @@ func (s *Session) Open() error {
// start does the heavylifting for Open(). // start does the heavylifting for Open().
func (s *Session) start() error { func (s *Session) start() error {
s.log(DebugLevel, pkg+"Session.start") s.log(DebugLevel, pkg+"Session.start")
s.init()
err := setupURL(s, s.url) err := setupURL(s, s.url)
if err != nil { if err != nil {
s.close() s.close()
@ -121,20 +130,6 @@ func (s *Session) start() error {
return nil return nil
} }
// init initializes various RTMP defauls.
// ToDo: define consts for the magic numbers.
func (s *Session) init() {
s.inChunkSize = RTMP_DEFAULT_CHUNKSIZE
s.outChunkSize = RTMP_DEFAULT_CHUNKSIZE
s.clientBW = 2500000
s.clientBW2 = 2
s.serverBW = 2500000
s.audioCodecs = 3191.0
s.videoCodecs = 252.0
s.link.timeout = s.timeout
s.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.isConnected() { if !s.isConnected() {