mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-04 01:09:27 +02:00
Capture bandwidth switch (#14)
* Handle bitrate change by finding the stream with closest bitrate as peer * Convert video id into bitrate when creating peer or changing bitrate * Try to fix prometheus panic * Revert metrics label name change * minor fixes. * bitrate selector. * skip if moving to the same stream. * no closure for getting target bitrate. * fix: high res switch to lo video, stream bitrate out of range * revert dev config change. * white space. Co-authored-by: Aleksandar Sukovic <aleksandar.sukovic@gmail.com>
This commit is contained in:
parent
e0bee67e85
commit
6067367acd
10 changed files with 186 additions and 52 deletions
|
@ -27,7 +27,7 @@ type Track struct {
|
|||
onRtcp func(rtcp.Packet)
|
||||
onRtcpMu sync.RWMutex
|
||||
|
||||
videoIdChange func(string) error
|
||||
bitrateChange func(int) error
|
||||
}
|
||||
|
||||
func NewTrack(logger zerolog.Logger, codec codec.RTPCodec, connection *webrtc.PeerConnection) (*Track, error) {
|
||||
|
@ -140,14 +140,14 @@ func (t *Track) OnRTCP(f func(rtcp.Packet)) {
|
|||
t.onRtcp = f
|
||||
}
|
||||
|
||||
func (t *Track) SetVideoID(videoID string) error {
|
||||
if t.videoIdChange == nil {
|
||||
return fmt.Errorf("video id change not supported")
|
||||
func (t *Track) SetBitrate(bitrate int) error {
|
||||
if t.bitrateChange == nil {
|
||||
return fmt.Errorf("bitrate change not supported")
|
||||
}
|
||||
|
||||
return t.videoIdChange(videoID)
|
||||
return t.bitrateChange(bitrate)
|
||||
}
|
||||
|
||||
func (t *Track) OnVideoIdChange(f func(string) error) {
|
||||
t.videoIdChange = f
|
||||
func (t *Track) OnBitrateChange(f func(int) error) {
|
||||
t.bitrateChange = f
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue