mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-31 09:57:08 +02:00
WebRTC congestion control (#26)
* Add congestion control * Improve stream matching, add manual stream selection, add metrics * Use a ticker for bitrate estimation and make bandwidth drops switch to lower streams more aggressively * Missing signal response, fix video auto bug * Remove redundant mutex * Bitrate history queue * Get bitrate fn support h264 & float64 --------- Co-authored-by: Aleksandar Sukovic <aleksandar.sukovic@gmail.com>
This commit is contained in:
parent
e80ae8019e
commit
2364facd60
15 changed files with 738 additions and 222 deletions
83
internal/capture/buckets/buckets_test.go
Normal file
83
internal/capture/buckets/buckets_test.go
Normal file
|
@ -0,0 +1,83 @@
|
|||
package buckets
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/demodesk/neko/pkg/types"
|
||||
"github.com/demodesk/neko/pkg/types/codec"
|
||||
)
|
||||
|
||||
func TestBucketsManagerCtx_FindNearestStream(t *testing.T) {
|
||||
type fields struct {
|
||||
codec codec.RTPCodec
|
||||
streams map[string]types.StreamSinkManager
|
||||
}
|
||||
type args struct {
|
||||
peerBitrate int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want types.StreamSinkManager
|
||||
}{
|
||||
{
|
||||
name: "findNearestStream",
|
||||
fields: fields{
|
||||
streams: map[string]types.StreamSinkManager{
|
||||
"1": mockStreamSink{
|
||||
id: "1",
|
||||
bitrate: 500,
|
||||
},
|
||||
"2": mockStreamSink{
|
||||
id: "2",
|
||||
bitrate: 750,
|
||||
},
|
||||
"3": mockStreamSink{
|
||||
id: "3",
|
||||
bitrate: 1000,
|
||||
},
|
||||
"4": mockStreamSink{
|
||||
id: "4",
|
||||
bitrate: 1250,
|
||||
},
|
||||
"5": mockStreamSink{
|
||||
id: "5",
|
||||
bitrate: 1700,
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
peerBitrate: 950,
|
||||
},
|
||||
want: mockStreamSink{
|
||||
id: "2",
|
||||
bitrate: 750,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
m := BucketsNew(tt.fields.codec, tt.fields.streams, []string{})
|
||||
|
||||
if got := m.findNearestStream(tt.args.peerBitrate); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("findNearestStream() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type mockStreamSink struct {
|
||||
id string
|
||||
bitrate int
|
||||
types.StreamSinkManager
|
||||
}
|
||||
|
||||
func (m mockStreamSink) ID() string {
|
||||
return m.id
|
||||
}
|
||||
|
||||
func (m mockStreamSink) Bitrate() int {
|
||||
return m.bitrate
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue