set default read and write timeout to 10 secs

This commit is contained in:
aler9
2020-11-01 16:57:39 +01:00
parent e4e66789e9
commit 5945937a5f
4 changed files with 9 additions and 9 deletions

View File

@@ -102,11 +102,11 @@ type ConnClient struct {
// NewConnClient allocates a ConnClient. See ConnClientConf for the options.
func NewConnClient(conf ConnClientConf) (*ConnClient, error) {
if conf.ReadTimeout == time.Duration(0) {
if conf.ReadTimeout == 0 {
conf.ReadTimeout = 10 * time.Second
}
if conf.WriteTimeout == time.Duration(0) {
conf.WriteTimeout = 5 * time.Second
if conf.WriteTimeout == 0 {
conf.WriteTimeout = 10 * time.Second
}
if conf.ReadBufferCount == 0 {
conf.ReadBufferCount = 1

View File

@@ -46,11 +46,11 @@ type ConnServer struct {
// NewConnServer allocates a ConnServer.
func NewConnServer(conf ConnServerConf) *ConnServer {
if conf.ReadTimeout == time.Duration(0) {
conf.ReadTimeout = 5 * time.Second
if conf.ReadTimeout == 0 {
conf.ReadTimeout = 10 * time.Second
}
if conf.WriteTimeout == time.Duration(0) {
conf.WriteTimeout = 5 * time.Second
if conf.WriteTimeout == 0 {
conf.WriteTimeout = 10 * time.Second
}
if conf.ReadBufferCount == 0 {
conf.ReadBufferCount = 1

View File

@@ -44,7 +44,7 @@ func NewEncoder(relativeType uint8, config []byte) (*Encoder, error) {
// Write encodes an AAC frame into RTP/AAC packets.
func (e *Encoder) Write(data []byte, timestamp time.Duration) ([][]byte, error) {
if e.started == time.Duration(0) {
if e.started == 0 {
e.started = timestamp
}

View File

@@ -33,7 +33,7 @@ func NewEncoder(relativeType uint8) (*Encoder, error) {
// Write encodes NALUs into RTP/H264 packets.
func (e *Encoder) Write(nalus [][]byte, timestamp time.Duration) ([][]byte, error) {
if e.started == time.Duration(0) {
if e.started == 0 {
e.started = timestamp
}