av/protocol/rtmp/options.go

72 lines
1.9 KiB
Go
Raw Permalink Normal View History

2022-05-31 08:17:06 +03:00
/*
DESCRIPTION
options.go provides RTMP connection option functions used to change
configuration parameters such as timeouts and bandwidths.
AUTHORS
Saxon Nelson-Milton <saxon@ausocean.org>
LICENSE
Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package rtmp
import "errors"
// Option parameter errors.
var (
ErrClientBandwidth = errors.New("bad client bandwidth")
ErrServerBandwidth = errors.New("bad server bandwidth")
ErrLinkTimeout = errors.New("bad link timeout")
)
// ClientBandwidth changes the Conn's clientBW parameter to the given value.
// See default value under conn.go.
func ClientBandwidth(b int) func(*Conn) error {
return func(c *Conn) error {
if b <= 0 {
return ErrClientBandwidth
}
c.clientBW = uint32(b)
return nil
}
}
// ServerBandwidth changes the Conn's serverBW parameter to the given value.
// See default value under conn.go.
func ServerBandwidth(b int) func(*Conn) error {
return func(c *Conn) error {
if b <= 0 {
return ErrServerBandwidth
}
c.serverBW = uint32(b)
return nil
}
}
// LinkTimeout changes the Conn.link's timeout parameter to the given value.
// See default value under conn.go.
func LinkTimeout(t uint) func(*Conn) error {
return func(c *Conn) error {
if t <= 0 {
return ErrLinkTimeout
}
c.link.timeout = t
return nil
}
}