From 351843578381ff93f52839e6853338c4cc3bc1f0 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 22 Dec 2020 17:26:26 -0800 Subject: [PATCH] using counterfeiter instead of gomocks, much simpler --- .gitignore | 2 +- go.mod | 4 +- go.sum | 21 +- magefile.go | 54 +- pkg/rtc/datatrack.go | 2 +- pkg/rtc/interfaces.go | 14 +- pkg/rtc/mediatrack.go | 10 +- pkg/rtc/mock_helper_test.go | 36 +- pkg/rtc/mock_test.go | 809 ------------ pkg/rtc/participant.go | 6 +- pkg/rtc/room.go | 7 + pkg/rtc/room_test.go | 60 +- pkg/rtc/rtcfakes/fake_participant.go | 1309 ++++++++++++++++++++ pkg/rtc/rtcfakes/fake_peer_connection.go | 1059 ++++++++++++++++ pkg/rtc/rtcfakes/fake_published_track.go | 406 ++++++ pkg/rtc/rtcfakes/fake_signal_connection.go | 182 +++ pkg/rtc/rtcfakes/fake_websocket_client.go | 277 +++++ tools/tools.go | 7 + 18 files changed, 3352 insertions(+), 913 deletions(-) delete mode 100644 pkg/rtc/mock_test.go create mode 100644 pkg/rtc/rtcfakes/fake_participant.go create mode 100644 pkg/rtc/rtcfakes/fake_peer_connection.go create mode 100644 pkg/rtc/rtcfakes/fake_published_track.go create mode 100644 pkg/rtc/rtcfakes/fake_signal_connection.go create mode 100644 pkg/rtc/rtcfakes/fake_websocket_client.go create mode 100644 tools/tools.go diff --git a/.gitignore b/.gitignore index 36f9183f8..c0a0548a2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ # Test binary, built with `go test -c` *.test -# checksums of file modification time +# checksums of file tree .checksumgo proto/.checksumproto diff --git a/go.mod b/go.mod index 57e9f61ad..600f0416d 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,7 @@ module github.com/livekit/livekit-server go 1.15 require ( - github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.4.3 - github.com/google/subcommands v1.2.0 // indirect github.com/google/uuid v1.1.2 github.com/google/wire v0.4.0 github.com/gorilla/websocket v1.4.2 @@ -14,6 +12,7 @@ require ( github.com/magefile/mage v1.10.0 github.com/magiconair/properties v1.8.1 github.com/manifoldco/promptui v0.8.0 + github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 github.com/pion/interceptor v0.0.5 github.com/pion/ion-log v1.0.0 github.com/pion/ion-sfu v1.6.5 @@ -24,6 +23,7 @@ require ( github.com/pion/webrtc/v3 v3.0.0-beta.16 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.6.1 + github.com/thoas/go-funk v0.7.0 github.com/twitchtv/twirp v7.1.0+incompatible github.com/urfave/cli/v2 v2.2.0 github.com/urfave/negroni v1.0.0 diff --git a/go.sum b/go.sum index 5381f1004..ff3097fe5 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,6 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -145,8 +143,6 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.0.1 h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k= github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -241,6 +237,8 @@ github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 h1:8E6DrFvII6QR4eJ3PkFvV+lc03P+2qwqTPLm1ax7694= +github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0/go.mod h1:fcEyUyXZXoV4Abw8DX0t7wyL8mCDxXyU4iAFZfT3IHw= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -262,6 +260,8 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= @@ -271,11 +271,13 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -391,6 +393,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= +github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= +github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -422,6 +426,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y= +github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/twitchtv/twirp v7.1.0+incompatible h1:3fNSDoSPyq+fTrifIvGue9XM/tptzuhiGY83rxPVNUg= @@ -434,7 +440,6 @@ github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2 github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -518,6 +523,7 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201026091529-146b70c837a4/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTiq8voBeTuweGVkY6Puw= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7 h1:3uJsdck53FDIpWwLeAXlia9p4C8j0BO2xZrqzKpL0D8= @@ -606,8 +612,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200815165600-90abf76919f3 h1:0aScV/0rLmANzEYIhjCOi2pTvDyhZNduBUMD2q3iqs4= -golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201222163215-f2e330f49058 h1:zSPRinxiz6krIAZie/STjID5lW/bkAvl+xz2cquNQEA= golang.org/x/tools v0.0.0-20201222163215-f2e330f49058/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -672,6 +677,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/magefile.go b/magefile.go index bf2aee69e..559aaef31 100644 --- a/magefile.go +++ b/magefile.go @@ -28,9 +28,9 @@ var Default = Build var checksummer = NewChecksummer(".", goChecksumFile, ".go") func init() { - checksummer.IgnoredFiles = []string{ + checksummer.IgnoredPaths = []string{ "cmd/server/wire_gen.go", - "pkg/rtc/mock_test.go", + "pkg/rtc/rtcfakes", } } @@ -96,7 +96,7 @@ func Proto() error { // builds LiveKit server and cli func Build() error { - mg.Deps(Proto, generate) + mg.Deps(Proto, generateCmd) if !checksummer.IsChanged() { fmt.Println("up to date") return nil @@ -125,7 +125,7 @@ func Build() error { } func Test() error { - mg.Deps(Proto, generate) + mg.Deps(Proto, generateTest) cmd := exec.Command("go", "test", "./...") connectStd(cmd) return cmd.Run() @@ -140,38 +140,28 @@ func Clean() { } // code generation -func generate() error { +func generateCmd() error { mg.Deps(installDeps) if !checksummer.IsChanged() { return nil } - fmt.Println("wiring...") - wire, err := getToolPath("wire") - if err != nil { - return err - } - cmd := exec.Command(wire) - cmd.Dir = "cmd/server" + fmt.Println("generating...") + + cmd := exec.Command("go", "generate", "./cmd/...") connectStd(cmd) - if err := cmd.Run(); err != nil { - return err + return cmd.Run() +} + +func generateTest() error { + mg.Deps(installDeps) + if !checksummer.IsChanged() { + return nil } - //cmd = exec.Command(wire) - //cmd.Dir = "cmd/cli" - //connectStd(cmd) - //if err := cmd.Run(); err != nil { - // return err - //} + fmt.Println("generating for tests...") - fmt.Println("updating mocks...") - mockgen, err := getToolPath("mockgen") - if err != nil { - return err - } - - cmd = exec.Command(mockgen, "-source", "pkg/rtc/interfaces.go", "-destination", "pkg/rtc/mock_test.go", "-package", "rtc") + cmd := exec.Command("go", "generate", "./pkg/...") connectStd(cmd) return cmd.Run() } @@ -253,7 +243,7 @@ type Checksummer struct { checksum string allExts bool extMap map[string]bool - IgnoredFiles []string + IgnoredPaths []string } func NewChecksummer(dir string, checksumfile string, exts ...string) *Checksummer { @@ -311,14 +301,14 @@ func (c *Checksummer) computeChecksum() error { entries := make([]string, 0) ignoredMap := make(map[string]bool) - for _, f := range c.IgnoredFiles { + for _, f := range c.IgnoredPaths { ignoredMap[f] = true } err := filepath.Walk(c.dir, func(path string, info os.FileInfo, err error) error { if path == c.dir { return nil } - if strings.HasPrefix(info.Name(), ".") { + if strings.HasPrefix(info.Name(), ".") || ignoredMap[path] { if info.IsDir() { return filepath.SkipDir } else { @@ -326,8 +316,8 @@ func (c *Checksummer) computeChecksum() error { } } if info.IsDir() { - entries = append(entries, fmt.Sprintf("%s %s", path, info.ModTime().String())) - } else if !ignoredMap[path] && (c.allExts || c.extMap[filepath.Ext(info.Name())]) { + entries = append(entries, fmt.Sprintf("%s %d", path, info.ModTime().Unix())) + } else if c.allExts || c.extMap[filepath.Ext(info.Name())] { entries = append(entries, fmt.Sprintf("%s %d %d", path, info.Size(), info.ModTime().Unix())) } return nil diff --git a/pkg/rtc/datatrack.go b/pkg/rtc/datatrack.go index 3f107cdc4..080d2457a 100644 --- a/pkg/rtc/datatrack.go +++ b/pkg/rtc/datatrack.go @@ -67,7 +67,7 @@ func (t *DataTrack) StreamID() string { func (t *DataTrack) AddSubscriber(participant Participant) error { label := PackDataTrackLabel(t.participantId, t.ID(), t.dataChannel.Label()) - downChannel, err := participant.peerConnection().CreateDataChannel(label, t.dataChannelOptions()) + downChannel, err := participant.PeerConnection().CreateDataChannel(label, t.dataChannelOptions()) if err != nil { return err } diff --git a/pkg/rtc/interfaces.go b/pkg/rtc/interfaces.go index 15d876b14..297c9674e 100644 --- a/pkg/rtc/interfaces.go +++ b/pkg/rtc/interfaces.go @@ -10,18 +10,22 @@ import ( "github.com/livekit/livekit-server/proto/livekit" ) +//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate + +//counterfeiter:generate . WebsocketClient type WebsocketClient interface { ReadMessage() (messageType int, p []byte, err error) WriteMessage(messageType int, data []byte) error WriteControl(messageType int, data []byte, deadline time.Time) error } +//counterfeiter:generate . SignalConnection type SignalConnection interface { ReadRequest() (*livekit.SignalRequest, error) WriteResponse(*livekit.SignalResponse) error } -// use interface to make it easier to mock +//counterfeiter:generate . PeerConnection type PeerConnection interface { OnICECandidate(f func(*webrtc.ICECandidate)) OnICEConnectionStateChange(func(webrtc.ICEConnectionState)) @@ -43,6 +47,7 @@ type PeerConnection interface { RemoveTrack(sender *webrtc.RTPSender) error } +//counterfeiter:generate . Participant type Participant interface { ID() string Name() string @@ -69,13 +74,14 @@ type Participant interface { OnClose(func(Participant)) // package methods - addDownTrack(streamId string, dt *sfu.DownTrack) - removeDownTrack(streamId string, dt *sfu.DownTrack) - peerConnection() PeerConnection + AddDownTrack(streamId string, dt *sfu.DownTrack) + RemoveDownTrack(streamId string, dt *sfu.DownTrack) + PeerConnection() PeerConnection } // PublishedTrack is the main interface representing a track published to the room // it's responsible for managing subscribers and forwarding data from the input track to all subscribers +//counterfeiter:generate . PublishedTrack type PublishedTrack interface { Start() ID() string diff --git a/pkg/rtc/mediatrack.go b/pkg/rtc/mediatrack.go index 59d3ebd24..788a40407 100644 --- a/pkg/rtc/mediatrack.go +++ b/pkg/rtc/mediatrack.go @@ -101,7 +101,7 @@ func (t *MediaTrack) AddSubscriber(participant Participant) error { return err } - transceiver, err := participant.peerConnection().AddTransceiverFromTrack(outTrack, webrtc.RTPTransceiverInit{ + transceiver, err := participant.PeerConnection().AddTransceiverFromTrack(outTrack, webrtc.RTPTransceiverInit{ Direction: webrtc.RTPTransceiverDirectionSendonly, }) if err != nil { @@ -113,7 +113,7 @@ func (t *MediaTrack) AddSubscriber(participant Participant) error { //outTrack.OnBind(func() { // go sub.sendStreamDownTracksReports(recv.StreamID()) //}) - participant.addDownTrack(t.StreamID(), outTrack) + participant.AddDownTrack(t.StreamID(), outTrack) forwarder := NewSimpleForwarder(t.ctx, t.rtcpCh, outTrack, t.receiver) forwarder.OnClose(func(f Forwarder) { @@ -121,12 +121,12 @@ func (t *MediaTrack) AddSubscriber(participant Participant) error { delete(t.forwarders, participant.ID()) t.lock.Unlock() - if participant.peerConnection().ConnectionState() == webrtc.PeerConnectionStateClosed { + if participant.PeerConnection().ConnectionState() == webrtc.PeerConnectionStateClosed { return } sender := transceiver.Sender() if sender != nil { - if err := participant.peerConnection().RemoveTrack(sender); err != nil { + if err := participant.PeerConnection().RemoveTrack(sender); err != nil { if _, ok := err.(*rtcerr.InvalidStateError); !ok { logger.GetLogger().Warnw("could not remove remoteTrack from forwarder", "participant", participant.ID(), @@ -135,7 +135,7 @@ func (t *MediaTrack) AddSubscriber(participant Participant) error { } } - participant.removeDownTrack(t.StreamID(), outTrack) + participant.RemoveDownTrack(t.StreamID(), outTrack) }) t.lock.Lock() diff --git a/pkg/rtc/mock_helper_test.go b/pkg/rtc/mock_helper_test.go index 4685cb1ab..89a92fd6f 100644 --- a/pkg/rtc/mock_helper_test.go +++ b/pkg/rtc/mock_helper_test.go @@ -1,38 +1,16 @@ -package rtc +package rtc_test import ( - "github.com/golang/mock/gomock" - + "github.com/livekit/livekit-server/pkg/rtc/rtcfakes" "github.com/livekit/livekit-server/pkg/utils" "github.com/livekit/livekit-server/proto/livekit" ) -func newMockPeerConnection(mockCtrl *gomock.Controller) *MockPeerConnection { - pc := NewMockPeerConnection(mockCtrl) - pc.EXPECT().OnDataChannel(gomock.Any()).AnyTimes() - pc.EXPECT().OnICECandidate(gomock.Any()).AnyTimes() - pc.EXPECT().OnICEConnectionStateChange(gomock.Any()).AnyTimes() - pc.EXPECT().OnNegotiationNeeded(gomock.Any()).AnyTimes() - pc.EXPECT().OnTrack(gomock.Any()).AnyTimes() - return pc -} +func newMockParticipant(name string) *rtcfakes.FakeParticipant { + p := &rtcfakes.FakeParticipant{} + p.IDReturns(utils.NewGuid(utils.ParticipantPrefix)) + p.NameReturns(name) + p.StateReturns(livekit.ParticipantInfo_JOINED) -func newMockSignalConnection(mockCtrl *gomock.Controller) *MockSignalConnection { - sc := NewMockSignalConnection(mockCtrl) - return sc -} - -func newMockParticipant(mockCtrl *gomock.Controller) *MockParticipant { - p := NewMockParticipant(mockCtrl) - p.EXPECT().ID().Return(utils.NewGuid(utils.ParticipantPrefix)).AnyTimes() - p.EXPECT().Name().Return("tester").AnyTimes() - p.EXPECT().State().Return(livekit.ParticipantInfo_JOINED).AnyTimes() - - // default callbacks - p.EXPECT().OnICECandidate(gomock.Any()).AnyTimes() - p.EXPECT().OnClose(gomock.Any()).AnyTimes() - p.EXPECT().OnOffer(gomock.Any()).AnyTimes() - p.EXPECT().OnStateChange(gomock.Any()).AnyTimes() - p.EXPECT().OnTrackPublished(gomock.Any()).AnyTimes() return p } diff --git a/pkg/rtc/mock_test.go b/pkg/rtc/mock_test.go deleted file mode 100644 index fd71521ee..000000000 --- a/pkg/rtc/mock_test.go +++ /dev/null @@ -1,809 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: pkg/rtc/interfaces.go - -// Package rtc is a generated GoMock package. -package rtc - -import ( - gomock "github.com/golang/mock/gomock" - sfu "github.com/livekit/livekit-server/pkg/sfu" - livekit "github.com/livekit/livekit-server/proto/livekit" - rtcp "github.com/pion/rtcp" - v3 "github.com/pion/webrtc/v3" - reflect "reflect" - time "time" -) - -// MockWebsocketClient is a mock of WebsocketClient interface -type MockWebsocketClient struct { - ctrl *gomock.Controller - recorder *MockWebsocketClientMockRecorder -} - -// MockWebsocketClientMockRecorder is the mock recorder for MockWebsocketClient -type MockWebsocketClientMockRecorder struct { - mock *MockWebsocketClient -} - -// NewMockWebsocketClient creates a new mock instance -func NewMockWebsocketClient(ctrl *gomock.Controller) *MockWebsocketClient { - mock := &MockWebsocketClient{ctrl: ctrl} - mock.recorder = &MockWebsocketClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockWebsocketClient) EXPECT() *MockWebsocketClientMockRecorder { - return m.recorder -} - -// ReadMessage mocks base method -func (m *MockWebsocketClient) ReadMessage() (int, []byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReadMessage") - ret0, _ := ret[0].(int) - ret1, _ := ret[1].([]byte) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// ReadMessage indicates an expected call of ReadMessage -func (mr *MockWebsocketClientMockRecorder) ReadMessage() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadMessage", reflect.TypeOf((*MockWebsocketClient)(nil).ReadMessage)) -} - -// WriteMessage mocks base method -func (m *MockWebsocketClient) WriteMessage(messageType int, data []byte) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteMessage", messageType, data) - ret0, _ := ret[0].(error) - return ret0 -} - -// WriteMessage indicates an expected call of WriteMessage -func (mr *MockWebsocketClientMockRecorder) WriteMessage(messageType, data interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteMessage", reflect.TypeOf((*MockWebsocketClient)(nil).WriteMessage), messageType, data) -} - -// WriteControl mocks base method -func (m *MockWebsocketClient) WriteControl(messageType int, data []byte, deadline time.Time) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteControl", messageType, data, deadline) - ret0, _ := ret[0].(error) - return ret0 -} - -// WriteControl indicates an expected call of WriteControl -func (mr *MockWebsocketClientMockRecorder) WriteControl(messageType, data, deadline interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteControl", reflect.TypeOf((*MockWebsocketClient)(nil).WriteControl), messageType, data, deadline) -} - -// MockSignalConnection is a mock of SignalConnection interface -type MockSignalConnection struct { - ctrl *gomock.Controller - recorder *MockSignalConnectionMockRecorder -} - -// MockSignalConnectionMockRecorder is the mock recorder for MockSignalConnection -type MockSignalConnectionMockRecorder struct { - mock *MockSignalConnection -} - -// NewMockSignalConnection creates a new mock instance -func NewMockSignalConnection(ctrl *gomock.Controller) *MockSignalConnection { - mock := &MockSignalConnection{ctrl: ctrl} - mock.recorder = &MockSignalConnectionMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockSignalConnection) EXPECT() *MockSignalConnectionMockRecorder { - return m.recorder -} - -// ReadRequest mocks base method -func (m *MockSignalConnection) ReadRequest() (*livekit.SignalRequest, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReadRequest") - ret0, _ := ret[0].(*livekit.SignalRequest) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ReadRequest indicates an expected call of ReadRequest -func (mr *MockSignalConnectionMockRecorder) ReadRequest() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadRequest", reflect.TypeOf((*MockSignalConnection)(nil).ReadRequest)) -} - -// WriteResponse mocks base method -func (m *MockSignalConnection) WriteResponse(arg0 *livekit.SignalResponse) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteResponse", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// WriteResponse indicates an expected call of WriteResponse -func (mr *MockSignalConnectionMockRecorder) WriteResponse(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteResponse", reflect.TypeOf((*MockSignalConnection)(nil).WriteResponse), arg0) -} - -// MockPeerConnection is a mock of PeerConnection interface -type MockPeerConnection struct { - ctrl *gomock.Controller - recorder *MockPeerConnectionMockRecorder -} - -// MockPeerConnectionMockRecorder is the mock recorder for MockPeerConnection -type MockPeerConnectionMockRecorder struct { - mock *MockPeerConnection -} - -// NewMockPeerConnection creates a new mock instance -func NewMockPeerConnection(ctrl *gomock.Controller) *MockPeerConnection { - mock := &MockPeerConnection{ctrl: ctrl} - mock.recorder = &MockPeerConnectionMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPeerConnection) EXPECT() *MockPeerConnectionMockRecorder { - return m.recorder -} - -// OnICECandidate mocks base method -func (m *MockPeerConnection) OnICECandidate(f func(*v3.ICECandidate)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnICECandidate", f) -} - -// OnICECandidate indicates an expected call of OnICECandidate -func (mr *MockPeerConnectionMockRecorder) OnICECandidate(f interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnICECandidate", reflect.TypeOf((*MockPeerConnection)(nil).OnICECandidate), f) -} - -// OnICEConnectionStateChange mocks base method -func (m *MockPeerConnection) OnICEConnectionStateChange(arg0 func(v3.ICEConnectionState)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnICEConnectionStateChange", arg0) -} - -// OnICEConnectionStateChange indicates an expected call of OnICEConnectionStateChange -func (mr *MockPeerConnectionMockRecorder) OnICEConnectionStateChange(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnICEConnectionStateChange", reflect.TypeOf((*MockPeerConnection)(nil).OnICEConnectionStateChange), arg0) -} - -// OnTrack mocks base method -func (m *MockPeerConnection) OnTrack(f func(*v3.TrackRemote, *v3.RTPReceiver)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnTrack", f) -} - -// OnTrack indicates an expected call of OnTrack -func (mr *MockPeerConnectionMockRecorder) OnTrack(f interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnTrack", reflect.TypeOf((*MockPeerConnection)(nil).OnTrack), f) -} - -// OnDataChannel mocks base method -func (m *MockPeerConnection) OnDataChannel(arg0 func(*v3.DataChannel)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnDataChannel", arg0) -} - -// OnDataChannel indicates an expected call of OnDataChannel -func (mr *MockPeerConnectionMockRecorder) OnDataChannel(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnDataChannel", reflect.TypeOf((*MockPeerConnection)(nil).OnDataChannel), arg0) -} - -// OnNegotiationNeeded mocks base method -func (m *MockPeerConnection) OnNegotiationNeeded(f func()) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnNegotiationNeeded", f) -} - -// OnNegotiationNeeded indicates an expected call of OnNegotiationNeeded -func (mr *MockPeerConnectionMockRecorder) OnNegotiationNeeded(f interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnNegotiationNeeded", reflect.TypeOf((*MockPeerConnection)(nil).OnNegotiationNeeded), f) -} - -// Close mocks base method -func (m *MockPeerConnection) Close() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close") - ret0, _ := ret[0].(error) - return ret0 -} - -// Close indicates an expected call of Close -func (mr *MockPeerConnectionMockRecorder) Close() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPeerConnection)(nil).Close)) -} - -// SetRemoteDescription mocks base method -func (m *MockPeerConnection) SetRemoteDescription(desc v3.SessionDescription) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetRemoteDescription", desc) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetRemoteDescription indicates an expected call of SetRemoteDescription -func (mr *MockPeerConnectionMockRecorder) SetRemoteDescription(desc interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRemoteDescription", reflect.TypeOf((*MockPeerConnection)(nil).SetRemoteDescription), desc) -} - -// SetLocalDescription mocks base method -func (m *MockPeerConnection) SetLocalDescription(desc v3.SessionDescription) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetLocalDescription", desc) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetLocalDescription indicates an expected call of SetLocalDescription -func (mr *MockPeerConnectionMockRecorder) SetLocalDescription(desc interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLocalDescription", reflect.TypeOf((*MockPeerConnection)(nil).SetLocalDescription), desc) -} - -// CreateOffer mocks base method -func (m *MockPeerConnection) CreateOffer(options *v3.OfferOptions) (v3.SessionDescription, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOffer", options) - ret0, _ := ret[0].(v3.SessionDescription) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateOffer indicates an expected call of CreateOffer -func (mr *MockPeerConnectionMockRecorder) CreateOffer(options interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOffer", reflect.TypeOf((*MockPeerConnection)(nil).CreateOffer), options) -} - -// CreateAnswer mocks base method -func (m *MockPeerConnection) CreateAnswer(options *v3.AnswerOptions) (v3.SessionDescription, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateAnswer", options) - ret0, _ := ret[0].(v3.SessionDescription) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateAnswer indicates an expected call of CreateAnswer -func (mr *MockPeerConnectionMockRecorder) CreateAnswer(options interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAnswer", reflect.TypeOf((*MockPeerConnection)(nil).CreateAnswer), options) -} - -// AddICECandidate mocks base method -func (m *MockPeerConnection) AddICECandidate(candidate v3.ICECandidateInit) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddICECandidate", candidate) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddICECandidate indicates an expected call of AddICECandidate -func (mr *MockPeerConnectionMockRecorder) AddICECandidate(candidate interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddICECandidate", reflect.TypeOf((*MockPeerConnection)(nil).AddICECandidate), candidate) -} - -// WriteRTCP mocks base method -func (m *MockPeerConnection) WriteRTCP(pkts []rtcp.Packet) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteRTCP", pkts) - ret0, _ := ret[0].(error) - return ret0 -} - -// WriteRTCP indicates an expected call of WriteRTCP -func (mr *MockPeerConnectionMockRecorder) WriteRTCP(pkts interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteRTCP", reflect.TypeOf((*MockPeerConnection)(nil).WriteRTCP), pkts) -} - -// CreateDataChannel mocks base method -func (m *MockPeerConnection) CreateDataChannel(label string, options *v3.DataChannelInit) (*v3.DataChannel, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateDataChannel", label, options) - ret0, _ := ret[0].(*v3.DataChannel) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateDataChannel indicates an expected call of CreateDataChannel -func (mr *MockPeerConnectionMockRecorder) CreateDataChannel(label, options interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDataChannel", reflect.TypeOf((*MockPeerConnection)(nil).CreateDataChannel), label, options) -} - -// AddTransceiverFromTrack mocks base method -func (m *MockPeerConnection) AddTransceiverFromTrack(track v3.TrackLocal, init ...v3.RtpTransceiverInit) (*v3.RTPTransceiver, error) { - m.ctrl.T.Helper() - varargs := []interface{}{track} - for _, a := range init { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "AddTransceiverFromTrack", varargs...) - ret0, _ := ret[0].(*v3.RTPTransceiver) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// AddTransceiverFromTrack indicates an expected call of AddTransceiverFromTrack -func (mr *MockPeerConnectionMockRecorder) AddTransceiverFromTrack(track interface{}, init ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{track}, init...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddTransceiverFromTrack", reflect.TypeOf((*MockPeerConnection)(nil).AddTransceiverFromTrack), varargs...) -} - -// ConnectionState mocks base method -func (m *MockPeerConnection) ConnectionState() v3.PeerConnectionState { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ConnectionState") - ret0, _ := ret[0].(v3.PeerConnectionState) - return ret0 -} - -// ConnectionState indicates an expected call of ConnectionState -func (mr *MockPeerConnectionMockRecorder) ConnectionState() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectionState", reflect.TypeOf((*MockPeerConnection)(nil).ConnectionState)) -} - -// RemoveTrack mocks base method -func (m *MockPeerConnection) RemoveTrack(sender *v3.RTPSender) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveTrack", sender) - ret0, _ := ret[0].(error) - return ret0 -} - -// RemoveTrack indicates an expected call of RemoveTrack -func (mr *MockPeerConnectionMockRecorder) RemoveTrack(sender interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveTrack", reflect.TypeOf((*MockPeerConnection)(nil).RemoveTrack), sender) -} - -// MockParticipant is a mock of Participant interface -type MockParticipant struct { - ctrl *gomock.Controller - recorder *MockParticipantMockRecorder -} - -// MockParticipantMockRecorder is the mock recorder for MockParticipant -type MockParticipantMockRecorder struct { - mock *MockParticipant -} - -// NewMockParticipant creates a new mock instance -func NewMockParticipant(ctrl *gomock.Controller) *MockParticipant { - mock := &MockParticipant{ctrl: ctrl} - mock.recorder = &MockParticipantMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockParticipant) EXPECT() *MockParticipantMockRecorder { - return m.recorder -} - -// ID mocks base method -func (m *MockParticipant) ID() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ID") - ret0, _ := ret[0].(string) - return ret0 -} - -// ID indicates an expected call of ID -func (mr *MockParticipantMockRecorder) ID() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockParticipant)(nil).ID)) -} - -// Name mocks base method -func (m *MockParticipant) Name() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Name") - ret0, _ := ret[0].(string) - return ret0 -} - -// Name indicates an expected call of Name -func (mr *MockParticipantMockRecorder) Name() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockParticipant)(nil).Name)) -} - -// State mocks base method -func (m *MockParticipant) State() livekit.ParticipantInfo_State { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "State") - ret0, _ := ret[0].(livekit.ParticipantInfo_State) - return ret0 -} - -// State indicates an expected call of State -func (mr *MockParticipantMockRecorder) State() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "State", reflect.TypeOf((*MockParticipant)(nil).State)) -} - -// ToProto mocks base method -func (m *MockParticipant) ToProto() *livekit.ParticipantInfo { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ToProto") - ret0, _ := ret[0].(*livekit.ParticipantInfo) - return ret0 -} - -// ToProto indicates an expected call of ToProto -func (mr *MockParticipantMockRecorder) ToProto() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToProto", reflect.TypeOf((*MockParticipant)(nil).ToProto)) -} - -// Answer mocks base method -func (m *MockParticipant) Answer(sdp v3.SessionDescription) (v3.SessionDescription, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Answer", sdp) - ret0, _ := ret[0].(v3.SessionDescription) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Answer indicates an expected call of Answer -func (mr *MockParticipantMockRecorder) Answer(sdp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Answer", reflect.TypeOf((*MockParticipant)(nil).Answer), sdp) -} - -// HandleNegotiate mocks base method -func (m *MockParticipant) HandleNegotiate(sd v3.SessionDescription) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HandleNegotiate", sd) - ret0, _ := ret[0].(error) - return ret0 -} - -// HandleNegotiate indicates an expected call of HandleNegotiate -func (mr *MockParticipantMockRecorder) HandleNegotiate(sd interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleNegotiate", reflect.TypeOf((*MockParticipant)(nil).HandleNegotiate), sd) -} - -// SetRemoteDescription mocks base method -func (m *MockParticipant) SetRemoteDescription(sdp v3.SessionDescription) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetRemoteDescription", sdp) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetRemoteDescription indicates an expected call of SetRemoteDescription -func (mr *MockParticipantMockRecorder) SetRemoteDescription(sdp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRemoteDescription", reflect.TypeOf((*MockParticipant)(nil).SetRemoteDescription), sdp) -} - -// AddICECandidate mocks base method -func (m *MockParticipant) AddICECandidate(candidate v3.ICECandidateInit) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddICECandidate", candidate) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddICECandidate indicates an expected call of AddICECandidate -func (mr *MockParticipantMockRecorder) AddICECandidate(candidate interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddICECandidate", reflect.TypeOf((*MockParticipant)(nil).AddICECandidate), candidate) -} - -// AddSubscriber mocks base method -func (m *MockParticipant) AddSubscriber(op Participant) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddSubscriber", op) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddSubscriber indicates an expected call of AddSubscriber -func (mr *MockParticipantMockRecorder) AddSubscriber(op interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSubscriber", reflect.TypeOf((*MockParticipant)(nil).AddSubscriber), op) -} - -// RemoveSubscriber mocks base method -func (m *MockParticipant) RemoveSubscriber(peerId string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveSubscriber", peerId) -} - -// RemoveSubscriber indicates an expected call of RemoveSubscriber -func (mr *MockParticipantMockRecorder) RemoveSubscriber(peerId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveSubscriber", reflect.TypeOf((*MockParticipant)(nil).RemoveSubscriber), peerId) -} - -// SendJoinResponse mocks base method -func (m *MockParticipant) SendJoinResponse(otherParticipants []Participant) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendJoinResponse", otherParticipants) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendJoinResponse indicates an expected call of SendJoinResponse -func (mr *MockParticipantMockRecorder) SendJoinResponse(otherParticipants interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendJoinResponse", reflect.TypeOf((*MockParticipant)(nil).SendJoinResponse), otherParticipants) -} - -// SendParticipantUpdate mocks base method -func (m *MockParticipant) SendParticipantUpdate(participants []*livekit.ParticipantInfo) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendParticipantUpdate", participants) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendParticipantUpdate indicates an expected call of SendParticipantUpdate -func (mr *MockParticipantMockRecorder) SendParticipantUpdate(participants interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendParticipantUpdate", reflect.TypeOf((*MockParticipant)(nil).SendParticipantUpdate), participants) -} - -// Start mocks base method -func (m *MockParticipant) Start() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Start") -} - -// Start indicates an expected call of Start -func (mr *MockParticipantMockRecorder) Start() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockParticipant)(nil).Start)) -} - -// Close mocks base method -func (m *MockParticipant) Close() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Close") - ret0, _ := ret[0].(error) - return ret0 -} - -// Close indicates an expected call of Close -func (mr *MockParticipantMockRecorder) Close() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockParticipant)(nil).Close)) -} - -// OnOffer mocks base method -func (m *MockParticipant) OnOffer(arg0 func(v3.SessionDescription)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnOffer", arg0) -} - -// OnOffer indicates an expected call of OnOffer -func (mr *MockParticipantMockRecorder) OnOffer(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnOffer", reflect.TypeOf((*MockParticipant)(nil).OnOffer), arg0) -} - -// OnICECandidate mocks base method -func (m *MockParticipant) OnICECandidate(arg0 func(*v3.ICECandidateInit)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnICECandidate", arg0) -} - -// OnICECandidate indicates an expected call of OnICECandidate -func (mr *MockParticipantMockRecorder) OnICECandidate(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnICECandidate", reflect.TypeOf((*MockParticipant)(nil).OnICECandidate), arg0) -} - -// OnStateChange mocks base method -func (m *MockParticipant) OnStateChange(arg0 func(Participant, livekit.ParticipantInfo_State)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnStateChange", arg0) -} - -// OnStateChange indicates an expected call of OnStateChange -func (mr *MockParticipantMockRecorder) OnStateChange(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnStateChange", reflect.TypeOf((*MockParticipant)(nil).OnStateChange), arg0) -} - -// OnTrackPublished mocks base method -func (m *MockParticipant) OnTrackPublished(arg0 func(Participant, PublishedTrack)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnTrackPublished", arg0) -} - -// OnTrackPublished indicates an expected call of OnTrackPublished -func (mr *MockParticipantMockRecorder) OnTrackPublished(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnTrackPublished", reflect.TypeOf((*MockParticipant)(nil).OnTrackPublished), arg0) -} - -// OnClose mocks base method -func (m *MockParticipant) OnClose(arg0 func(Participant)) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "OnClose", arg0) -} - -// OnClose indicates an expected call of OnClose -func (mr *MockParticipantMockRecorder) OnClose(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnClose", reflect.TypeOf((*MockParticipant)(nil).OnClose), arg0) -} - -// addDownTrack mocks base method -func (m *MockParticipant) addDownTrack(streamId string, dt *sfu.DownTrack) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "addDownTrack", streamId, dt) -} - -// addDownTrack indicates an expected call of addDownTrack -func (mr *MockParticipantMockRecorder) addDownTrack(streamId, dt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "addDownTrack", reflect.TypeOf((*MockParticipant)(nil).addDownTrack), streamId, dt) -} - -// removeDownTrack mocks base method -func (m *MockParticipant) removeDownTrack(streamId string, dt *sfu.DownTrack) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "removeDownTrack", streamId, dt) -} - -// removeDownTrack indicates an expected call of removeDownTrack -func (mr *MockParticipantMockRecorder) removeDownTrack(streamId, dt interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "removeDownTrack", reflect.TypeOf((*MockParticipant)(nil).removeDownTrack), streamId, dt) -} - -// peerConnection mocks base method -func (m *MockParticipant) peerConnection() PeerConnection { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "peerConnection") - ret0, _ := ret[0].(PeerConnection) - return ret0 -} - -// peerConnection indicates an expected call of peerConnection -func (mr *MockParticipantMockRecorder) peerConnection() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "peerConnection", reflect.TypeOf((*MockParticipant)(nil).peerConnection)) -} - -// MockPublishedTrack is a mock of PublishedTrack interface -type MockPublishedTrack struct { - ctrl *gomock.Controller - recorder *MockPublishedTrackMockRecorder -} - -// MockPublishedTrackMockRecorder is the mock recorder for MockPublishedTrack -type MockPublishedTrackMockRecorder struct { - mock *MockPublishedTrack -} - -// NewMockPublishedTrack creates a new mock instance -func NewMockPublishedTrack(ctrl *gomock.Controller) *MockPublishedTrack { - mock := &MockPublishedTrack{ctrl: ctrl} - mock.recorder = &MockPublishedTrackMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPublishedTrack) EXPECT() *MockPublishedTrackMockRecorder { - return m.recorder -} - -// Start mocks base method -func (m *MockPublishedTrack) Start() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Start") -} - -// Start indicates an expected call of Start -func (mr *MockPublishedTrackMockRecorder) Start() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockPublishedTrack)(nil).Start)) -} - -// ID mocks base method -func (m *MockPublishedTrack) ID() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ID") - ret0, _ := ret[0].(string) - return ret0 -} - -// ID indicates an expected call of ID -func (mr *MockPublishedTrackMockRecorder) ID() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockPublishedTrack)(nil).ID)) -} - -// Kind mocks base method -func (m *MockPublishedTrack) Kind() livekit.TrackInfo_Type { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Kind") - ret0, _ := ret[0].(livekit.TrackInfo_Type) - return ret0 -} - -// Kind indicates an expected call of Kind -func (mr *MockPublishedTrackMockRecorder) Kind() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Kind", reflect.TypeOf((*MockPublishedTrack)(nil).Kind)) -} - -// StreamID mocks base method -func (m *MockPublishedTrack) StreamID() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StreamID") - ret0, _ := ret[0].(string) - return ret0 -} - -// StreamID indicates an expected call of StreamID -func (mr *MockPublishedTrackMockRecorder) StreamID() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamID", reflect.TypeOf((*MockPublishedTrack)(nil).StreamID)) -} - -// AddSubscriber mocks base method -func (m *MockPublishedTrack) AddSubscriber(participant Participant) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddSubscriber", participant) - ret0, _ := ret[0].(error) - return ret0 -} - -// AddSubscriber indicates an expected call of AddSubscriber -func (mr *MockPublishedTrackMockRecorder) AddSubscriber(participant interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddSubscriber", reflect.TypeOf((*MockPublishedTrack)(nil).AddSubscriber), participant) -} - -// RemoveSubscriber mocks base method -func (m *MockPublishedTrack) RemoveSubscriber(participantId string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveSubscriber", participantId) -} - -// RemoveSubscriber indicates an expected call of RemoveSubscriber -func (mr *MockPublishedTrackMockRecorder) RemoveSubscriber(participantId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveSubscriber", reflect.TypeOf((*MockPublishedTrack)(nil).RemoveSubscriber), participantId) -} - -// RemoveAllSubscribers mocks base method -func (m *MockPublishedTrack) RemoveAllSubscribers() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveAllSubscribers") -} - -// RemoveAllSubscribers indicates an expected call of RemoveAllSubscribers -func (mr *MockPublishedTrackMockRecorder) RemoveAllSubscribers() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveAllSubscribers", reflect.TypeOf((*MockPublishedTrack)(nil).RemoveAllSubscribers)) -} diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 8075af506..47cee9742 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -340,11 +340,11 @@ func (p *ParticipantImpl) SendParticipantUpdate(participants []*livekit.Particip }) } -func (p *ParticipantImpl) peerConnection() PeerConnection { +func (p *ParticipantImpl) PeerConnection() PeerConnection { return p.peerConn } -func (p *ParticipantImpl) addDownTrack(streamId string, dt *sfu.DownTrack) { +func (p *ParticipantImpl) AddDownTrack(streamId string, dt *sfu.DownTrack) { p.lock.Lock() p.downTracks[streamId] = append(p.downTracks[streamId], dt) p.lock.Unlock() @@ -353,7 +353,7 @@ func (p *ParticipantImpl) addDownTrack(streamId string, dt *sfu.DownTrack) { }) } -func (p *ParticipantImpl) removeDownTrack(streamId string, dt *sfu.DownTrack) { +func (p *ParticipantImpl) RemoveDownTrack(streamId string, dt *sfu.DownTrack) { p.lock.Lock() defer p.lock.Unlock() tracks := p.downTracks[streamId] diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 716d9dc8b..310b544f7 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -5,6 +5,7 @@ import ( "time" "github.com/google/uuid" + "github.com/thoas/go-funk" "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/utils" @@ -47,6 +48,12 @@ func (r *Room) GetParticipant(id string) Participant { return r.participants[id] } +func (r *Room) GetParticipants() []Participant { + r.lock.RLock() + defer r.lock.RUnlock() + return funk.Values(r.participants).([]Participant) +} + func (r *Room) ToRoomInfo(node *livekit.Node) *livekit.RoomInfo { return &livekit.RoomInfo{ Sid: r.Sid, diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index bbe6b98a1..416a39dd5 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -1,45 +1,65 @@ -package rtc +package rtc_test import ( "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/livekit/livekit-server/pkg/rtc" + "github.com/livekit/livekit-server/pkg/rtc/rtcfakes" "github.com/livekit/livekit-server/proto/livekit" ) func TestRoomJoin(t *testing.T) { - mockCtrl := gomock.NewController(t) - defer mockCtrl.Finish() - t.Run("joining returns existing participant data", func(t *testing.T) { numExisting := 3 - rm := newRoomWithParticipants(mockCtrl, numExisting) - assert.NotNil(t, rm) - p := newMockParticipant(mockCtrl) - assert.NotNil(t, p) - - // expect new participant to get a JoinReply - p.EXPECT().SendJoinResponse(gomock.Any()).Return(nil).Do( - func(otherParticipants []Participant) { - assert.Len(t, otherParticipants, numExisting) - }) + rm := newRoomWithParticipants(t, numExisting) + p := newMockParticipant("new") rm.Join(p) - assert.Len(t, rm.participants, numExisting+1) + // expect new participant to get a JoinReply + participants := p.SendJoinResponseArgsForCall(0) + assert.Len(t, participants, numExisting) + assert.Len(t, rm.GetParticipants(), numExisting+1) + }) + + t.Run("subscribe to existing channels upon join", func(t *testing.T) { + numExisting := 3 + rm := newRoomWithParticipants(t, numExisting) + p := newMockParticipant("new") + + err := rm.Join(p) + assert.NoError(t, err) + + stateChangeCB := p.OnStateChangeArgsForCall(0) + assert.NotNil(t, stateChangeCB) + p.StateReturns(livekit.ParticipantInfo_JOINED) + stateChangeCB(p, livekit.ParticipantInfo_JOINING) + + // it should become a subscriber when connectivity changes + for _, op := range rm.GetParticipants() { + if p == op { + continue + } + mockP := op.(*rtcfakes.FakeParticipant) + assert.NotZero(t, mockP.AddSubscriberCallCount()) + // last call should be to add the newest participant + assert.Equal(t, p, mockP.AddSubscriberArgsForCall(mockP.AddSubscriberCallCount()-1)) + } }) } -func newRoomWithParticipants(mockCtrl *gomock.Controller, num int) *Room { - rm, err := NewRoomForRequest(&livekit.CreateRoomRequest{}, &WebRTCConfig{}) +func newRoomWithParticipants(t *testing.T, num int) *rtc.Room { + rm, err := rtc.NewRoomForRequest(&livekit.CreateRoomRequest{}, &rtc.WebRTCConfig{}) if err != nil { panic("could not create a room") } for i := 0; i < num; i++ { - participant := newMockParticipant(mockCtrl) - rm.participants[participant.ID()] = participant + participant := newMockParticipant("") + err := rm.Join(participant) + assert.NoError(t, err) + //rm.participants[participant.ID()] = participant } return rm } diff --git a/pkg/rtc/rtcfakes/fake_participant.go b/pkg/rtc/rtcfakes/fake_participant.go new file mode 100644 index 000000000..4cd746e57 --- /dev/null +++ b/pkg/rtc/rtcfakes/fake_participant.go @@ -0,0 +1,1309 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package rtcfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc" + "github.com/livekit/livekit-server/pkg/sfu" + "github.com/livekit/livekit-server/proto/livekit" + webrtc "github.com/pion/webrtc/v3" +) + +type FakeParticipant struct { + AddDownTrackStub func(string, *sfu.DownTrack) + addDownTrackMutex sync.RWMutex + addDownTrackArgsForCall []struct { + arg1 string + arg2 *sfu.DownTrack + } + AddICECandidateStub func(webrtc.ICECandidateInit) error + addICECandidateMutex sync.RWMutex + addICECandidateArgsForCall []struct { + arg1 webrtc.ICECandidateInit + } + addICECandidateReturns struct { + result1 error + } + addICECandidateReturnsOnCall map[int]struct { + result1 error + } + AddSubscriberStub func(rtc.Participant) error + addSubscriberMutex sync.RWMutex + addSubscriberArgsForCall []struct { + arg1 rtc.Participant + } + addSubscriberReturns struct { + result1 error + } + addSubscriberReturnsOnCall map[int]struct { + result1 error + } + AnswerStub func(webrtc.SessionDescription) (webrtc.SessionDescription, error) + answerMutex sync.RWMutex + answerArgsForCall []struct { + arg1 webrtc.SessionDescription + } + answerReturns struct { + result1 webrtc.SessionDescription + result2 error + } + answerReturnsOnCall map[int]struct { + result1 webrtc.SessionDescription + result2 error + } + CloseStub func() error + closeMutex sync.RWMutex + closeArgsForCall []struct { + } + closeReturns struct { + result1 error + } + closeReturnsOnCall map[int]struct { + result1 error + } + HandleNegotiateStub func(webrtc.SessionDescription) error + handleNegotiateMutex sync.RWMutex + handleNegotiateArgsForCall []struct { + arg1 webrtc.SessionDescription + } + handleNegotiateReturns struct { + result1 error + } + handleNegotiateReturnsOnCall map[int]struct { + result1 error + } + IDStub func() string + iDMutex sync.RWMutex + iDArgsForCall []struct { + } + iDReturns struct { + result1 string + } + iDReturnsOnCall map[int]struct { + result1 string + } + NameStub func() string + nameMutex sync.RWMutex + nameArgsForCall []struct { + } + nameReturns struct { + result1 string + } + nameReturnsOnCall map[int]struct { + result1 string + } + OnCloseStub func(func(rtc.Participant)) + onCloseMutex sync.RWMutex + onCloseArgsForCall []struct { + arg1 func(rtc.Participant) + } + OnICECandidateStub func(func(c *webrtc.ICECandidateInit)) + onICECandidateMutex sync.RWMutex + onICECandidateArgsForCall []struct { + arg1 func(c *webrtc.ICECandidateInit) + } + OnOfferStub func(func(webrtc.SessionDescription)) + onOfferMutex sync.RWMutex + onOfferArgsForCall []struct { + arg1 func(webrtc.SessionDescription) + } + OnStateChangeStub func(func(p rtc.Participant, oldState livekit.ParticipantInfo_State)) + onStateChangeMutex sync.RWMutex + onStateChangeArgsForCall []struct { + arg1 func(p rtc.Participant, oldState livekit.ParticipantInfo_State) + } + OnTrackPublishedStub func(func(rtc.Participant, rtc.PublishedTrack)) + onTrackPublishedMutex sync.RWMutex + onTrackPublishedArgsForCall []struct { + arg1 func(rtc.Participant, rtc.PublishedTrack) + } + PeerConnectionStub func() rtc.PeerConnection + peerConnectionMutex sync.RWMutex + peerConnectionArgsForCall []struct { + } + peerConnectionReturns struct { + result1 rtc.PeerConnection + } + peerConnectionReturnsOnCall map[int]struct { + result1 rtc.PeerConnection + } + RemoveDownTrackStub func(string, *sfu.DownTrack) + removeDownTrackMutex sync.RWMutex + removeDownTrackArgsForCall []struct { + arg1 string + arg2 *sfu.DownTrack + } + RemoveSubscriberStub func(string) + removeSubscriberMutex sync.RWMutex + removeSubscriberArgsForCall []struct { + arg1 string + } + SendJoinResponseStub func([]rtc.Participant) error + sendJoinResponseMutex sync.RWMutex + sendJoinResponseArgsForCall []struct { + arg1 []rtc.Participant + } + sendJoinResponseReturns struct { + result1 error + } + sendJoinResponseReturnsOnCall map[int]struct { + result1 error + } + SendParticipantUpdateStub func([]*livekit.ParticipantInfo) error + sendParticipantUpdateMutex sync.RWMutex + sendParticipantUpdateArgsForCall []struct { + arg1 []*livekit.ParticipantInfo + } + sendParticipantUpdateReturns struct { + result1 error + } + sendParticipantUpdateReturnsOnCall map[int]struct { + result1 error + } + SetRemoteDescriptionStub func(webrtc.SessionDescription) error + setRemoteDescriptionMutex sync.RWMutex + setRemoteDescriptionArgsForCall []struct { + arg1 webrtc.SessionDescription + } + setRemoteDescriptionReturns struct { + result1 error + } + setRemoteDescriptionReturnsOnCall map[int]struct { + result1 error + } + StartStub func() + startMutex sync.RWMutex + startArgsForCall []struct { + } + StateStub func() livekit.ParticipantInfo_State + stateMutex sync.RWMutex + stateArgsForCall []struct { + } + stateReturns struct { + result1 livekit.ParticipantInfo_State + } + stateReturnsOnCall map[int]struct { + result1 livekit.ParticipantInfo_State + } + ToProtoStub func() *livekit.ParticipantInfo + toProtoMutex sync.RWMutex + toProtoArgsForCall []struct { + } + toProtoReturns struct { + result1 *livekit.ParticipantInfo + } + toProtoReturnsOnCall map[int]struct { + result1 *livekit.ParticipantInfo + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeParticipant) AddDownTrack(arg1 string, arg2 *sfu.DownTrack) { + fake.addDownTrackMutex.Lock() + fake.addDownTrackArgsForCall = append(fake.addDownTrackArgsForCall, struct { + arg1 string + arg2 *sfu.DownTrack + }{arg1, arg2}) + stub := fake.AddDownTrackStub + fake.recordInvocation("AddDownTrack", []interface{}{arg1, arg2}) + fake.addDownTrackMutex.Unlock() + if stub != nil { + fake.AddDownTrackStub(arg1, arg2) + } +} + +func (fake *FakeParticipant) AddDownTrackCallCount() int { + fake.addDownTrackMutex.RLock() + defer fake.addDownTrackMutex.RUnlock() + return len(fake.addDownTrackArgsForCall) +} + +func (fake *FakeParticipant) AddDownTrackCalls(stub func(string, *sfu.DownTrack)) { + fake.addDownTrackMutex.Lock() + defer fake.addDownTrackMutex.Unlock() + fake.AddDownTrackStub = stub +} + +func (fake *FakeParticipant) AddDownTrackArgsForCall(i int) (string, *sfu.DownTrack) { + fake.addDownTrackMutex.RLock() + defer fake.addDownTrackMutex.RUnlock() + argsForCall := fake.addDownTrackArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipant) AddICECandidate(arg1 webrtc.ICECandidateInit) error { + fake.addICECandidateMutex.Lock() + ret, specificReturn := fake.addICECandidateReturnsOnCall[len(fake.addICECandidateArgsForCall)] + fake.addICECandidateArgsForCall = append(fake.addICECandidateArgsForCall, struct { + arg1 webrtc.ICECandidateInit + }{arg1}) + stub := fake.AddICECandidateStub + fakeReturns := fake.addICECandidateReturns + fake.recordInvocation("AddICECandidate", []interface{}{arg1}) + fake.addICECandidateMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) AddICECandidateCallCount() int { + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + return len(fake.addICECandidateArgsForCall) +} + +func (fake *FakeParticipant) AddICECandidateCalls(stub func(webrtc.ICECandidateInit) error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = stub +} + +func (fake *FakeParticipant) AddICECandidateArgsForCall(i int) webrtc.ICECandidateInit { + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + argsForCall := fake.addICECandidateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) AddICECandidateReturns(result1 error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = nil + fake.addICECandidateReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) AddICECandidateReturnsOnCall(i int, result1 error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = nil + if fake.addICECandidateReturnsOnCall == nil { + fake.addICECandidateReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.addICECandidateReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) AddSubscriber(arg1 rtc.Participant) error { + fake.addSubscriberMutex.Lock() + ret, specificReturn := fake.addSubscriberReturnsOnCall[len(fake.addSubscriberArgsForCall)] + fake.addSubscriberArgsForCall = append(fake.addSubscriberArgsForCall, struct { + arg1 rtc.Participant + }{arg1}) + stub := fake.AddSubscriberStub + fakeReturns := fake.addSubscriberReturns + fake.recordInvocation("AddSubscriber", []interface{}{arg1}) + fake.addSubscriberMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) AddSubscriberCallCount() int { + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + return len(fake.addSubscriberArgsForCall) +} + +func (fake *FakeParticipant) AddSubscriberCalls(stub func(rtc.Participant) error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = stub +} + +func (fake *FakeParticipant) AddSubscriberArgsForCall(i int) rtc.Participant { + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + argsForCall := fake.addSubscriberArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) AddSubscriberReturns(result1 error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = nil + fake.addSubscriberReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) AddSubscriberReturnsOnCall(i int, result1 error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = nil + if fake.addSubscriberReturnsOnCall == nil { + fake.addSubscriberReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.addSubscriberReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) Answer(arg1 webrtc.SessionDescription) (webrtc.SessionDescription, error) { + fake.answerMutex.Lock() + ret, specificReturn := fake.answerReturnsOnCall[len(fake.answerArgsForCall)] + fake.answerArgsForCall = append(fake.answerArgsForCall, struct { + arg1 webrtc.SessionDescription + }{arg1}) + stub := fake.AnswerStub + fakeReturns := fake.answerReturns + fake.recordInvocation("Answer", []interface{}{arg1}) + fake.answerMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeParticipant) AnswerCallCount() int { + fake.answerMutex.RLock() + defer fake.answerMutex.RUnlock() + return len(fake.answerArgsForCall) +} + +func (fake *FakeParticipant) AnswerCalls(stub func(webrtc.SessionDescription) (webrtc.SessionDescription, error)) { + fake.answerMutex.Lock() + defer fake.answerMutex.Unlock() + fake.AnswerStub = stub +} + +func (fake *FakeParticipant) AnswerArgsForCall(i int) webrtc.SessionDescription { + fake.answerMutex.RLock() + defer fake.answerMutex.RUnlock() + argsForCall := fake.answerArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) AnswerReturns(result1 webrtc.SessionDescription, result2 error) { + fake.answerMutex.Lock() + defer fake.answerMutex.Unlock() + fake.AnswerStub = nil + fake.answerReturns = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakeParticipant) AnswerReturnsOnCall(i int, result1 webrtc.SessionDescription, result2 error) { + fake.answerMutex.Lock() + defer fake.answerMutex.Unlock() + fake.AnswerStub = nil + if fake.answerReturnsOnCall == nil { + fake.answerReturnsOnCall = make(map[int]struct { + result1 webrtc.SessionDescription + result2 error + }) + } + fake.answerReturnsOnCall[i] = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakeParticipant) Close() error { + fake.closeMutex.Lock() + ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] + fake.closeArgsForCall = append(fake.closeArgsForCall, struct { + }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns + fake.recordInvocation("Close", []interface{}{}) + fake.closeMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) CloseCallCount() int { + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + return len(fake.closeArgsForCall) +} + +func (fake *FakeParticipant) CloseCalls(stub func() error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = stub +} + +func (fake *FakeParticipant) CloseReturns(result1 error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = nil + fake.closeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) CloseReturnsOnCall(i int, result1 error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = nil + if fake.closeReturnsOnCall == nil { + fake.closeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.closeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) HandleNegotiate(arg1 webrtc.SessionDescription) error { + fake.handleNegotiateMutex.Lock() + ret, specificReturn := fake.handleNegotiateReturnsOnCall[len(fake.handleNegotiateArgsForCall)] + fake.handleNegotiateArgsForCall = append(fake.handleNegotiateArgsForCall, struct { + arg1 webrtc.SessionDescription + }{arg1}) + stub := fake.HandleNegotiateStub + fakeReturns := fake.handleNegotiateReturns + fake.recordInvocation("HandleNegotiate", []interface{}{arg1}) + fake.handleNegotiateMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) HandleNegotiateCallCount() int { + fake.handleNegotiateMutex.RLock() + defer fake.handleNegotiateMutex.RUnlock() + return len(fake.handleNegotiateArgsForCall) +} + +func (fake *FakeParticipant) HandleNegotiateCalls(stub func(webrtc.SessionDescription) error) { + fake.handleNegotiateMutex.Lock() + defer fake.handleNegotiateMutex.Unlock() + fake.HandleNegotiateStub = stub +} + +func (fake *FakeParticipant) HandleNegotiateArgsForCall(i int) webrtc.SessionDescription { + fake.handleNegotiateMutex.RLock() + defer fake.handleNegotiateMutex.RUnlock() + argsForCall := fake.handleNegotiateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) HandleNegotiateReturns(result1 error) { + fake.handleNegotiateMutex.Lock() + defer fake.handleNegotiateMutex.Unlock() + fake.HandleNegotiateStub = nil + fake.handleNegotiateReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) HandleNegotiateReturnsOnCall(i int, result1 error) { + fake.handleNegotiateMutex.Lock() + defer fake.handleNegotiateMutex.Unlock() + fake.HandleNegotiateStub = nil + if fake.handleNegotiateReturnsOnCall == nil { + fake.handleNegotiateReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.handleNegotiateReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) ID() string { + fake.iDMutex.Lock() + ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] + fake.iDArgsForCall = append(fake.iDArgsForCall, struct { + }{}) + stub := fake.IDStub + fakeReturns := fake.iDReturns + fake.recordInvocation("ID", []interface{}{}) + fake.iDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) IDCallCount() int { + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + return len(fake.iDArgsForCall) +} + +func (fake *FakeParticipant) IDCalls(stub func() string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = stub +} + +func (fake *FakeParticipant) IDReturns(result1 string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + fake.iDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeParticipant) IDReturnsOnCall(i int, result1 string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + if fake.iDReturnsOnCall == nil { + fake.iDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.iDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeParticipant) Name() string { + fake.nameMutex.Lock() + ret, specificReturn := fake.nameReturnsOnCall[len(fake.nameArgsForCall)] + fake.nameArgsForCall = append(fake.nameArgsForCall, struct { + }{}) + stub := fake.NameStub + fakeReturns := fake.nameReturns + fake.recordInvocation("Name", []interface{}{}) + fake.nameMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) NameCallCount() int { + fake.nameMutex.RLock() + defer fake.nameMutex.RUnlock() + return len(fake.nameArgsForCall) +} + +func (fake *FakeParticipant) NameCalls(stub func() string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = stub +} + +func (fake *FakeParticipant) NameReturns(result1 string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = nil + fake.nameReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeParticipant) NameReturnsOnCall(i int, result1 string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = nil + if fake.nameReturnsOnCall == nil { + fake.nameReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.nameReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeParticipant) OnClose(arg1 func(rtc.Participant)) { + fake.onCloseMutex.Lock() + fake.onCloseArgsForCall = append(fake.onCloseArgsForCall, struct { + arg1 func(rtc.Participant) + }{arg1}) + stub := fake.OnCloseStub + fake.recordInvocation("OnClose", []interface{}{arg1}) + fake.onCloseMutex.Unlock() + if stub != nil { + fake.OnCloseStub(arg1) + } +} + +func (fake *FakeParticipant) OnCloseCallCount() int { + fake.onCloseMutex.RLock() + defer fake.onCloseMutex.RUnlock() + return len(fake.onCloseArgsForCall) +} + +func (fake *FakeParticipant) OnCloseCalls(stub func(func(rtc.Participant))) { + fake.onCloseMutex.Lock() + defer fake.onCloseMutex.Unlock() + fake.OnCloseStub = stub +} + +func (fake *FakeParticipant) OnCloseArgsForCall(i int) func(rtc.Participant) { + fake.onCloseMutex.RLock() + defer fake.onCloseMutex.RUnlock() + argsForCall := fake.onCloseArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) OnICECandidate(arg1 func(c *webrtc.ICECandidateInit)) { + fake.onICECandidateMutex.Lock() + fake.onICECandidateArgsForCall = append(fake.onICECandidateArgsForCall, struct { + arg1 func(c *webrtc.ICECandidateInit) + }{arg1}) + stub := fake.OnICECandidateStub + fake.recordInvocation("OnICECandidate", []interface{}{arg1}) + fake.onICECandidateMutex.Unlock() + if stub != nil { + fake.OnICECandidateStub(arg1) + } +} + +func (fake *FakeParticipant) OnICECandidateCallCount() int { + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + return len(fake.onICECandidateArgsForCall) +} + +func (fake *FakeParticipant) OnICECandidateCalls(stub func(func(c *webrtc.ICECandidateInit))) { + fake.onICECandidateMutex.Lock() + defer fake.onICECandidateMutex.Unlock() + fake.OnICECandidateStub = stub +} + +func (fake *FakeParticipant) OnICECandidateArgsForCall(i int) func(c *webrtc.ICECandidateInit) { + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + argsForCall := fake.onICECandidateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) OnOffer(arg1 func(webrtc.SessionDescription)) { + fake.onOfferMutex.Lock() + fake.onOfferArgsForCall = append(fake.onOfferArgsForCall, struct { + arg1 func(webrtc.SessionDescription) + }{arg1}) + stub := fake.OnOfferStub + fake.recordInvocation("OnOffer", []interface{}{arg1}) + fake.onOfferMutex.Unlock() + if stub != nil { + fake.OnOfferStub(arg1) + } +} + +func (fake *FakeParticipant) OnOfferCallCount() int { + fake.onOfferMutex.RLock() + defer fake.onOfferMutex.RUnlock() + return len(fake.onOfferArgsForCall) +} + +func (fake *FakeParticipant) OnOfferCalls(stub func(func(webrtc.SessionDescription))) { + fake.onOfferMutex.Lock() + defer fake.onOfferMutex.Unlock() + fake.OnOfferStub = stub +} + +func (fake *FakeParticipant) OnOfferArgsForCall(i int) func(webrtc.SessionDescription) { + fake.onOfferMutex.RLock() + defer fake.onOfferMutex.RUnlock() + argsForCall := fake.onOfferArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) OnStateChange(arg1 func(p rtc.Participant, oldState livekit.ParticipantInfo_State)) { + fake.onStateChangeMutex.Lock() + fake.onStateChangeArgsForCall = append(fake.onStateChangeArgsForCall, struct { + arg1 func(p rtc.Participant, oldState livekit.ParticipantInfo_State) + }{arg1}) + stub := fake.OnStateChangeStub + fake.recordInvocation("OnStateChange", []interface{}{arg1}) + fake.onStateChangeMutex.Unlock() + if stub != nil { + fake.OnStateChangeStub(arg1) + } +} + +func (fake *FakeParticipant) OnStateChangeCallCount() int { + fake.onStateChangeMutex.RLock() + defer fake.onStateChangeMutex.RUnlock() + return len(fake.onStateChangeArgsForCall) +} + +func (fake *FakeParticipant) OnStateChangeCalls(stub func(func(p rtc.Participant, oldState livekit.ParticipantInfo_State))) { + fake.onStateChangeMutex.Lock() + defer fake.onStateChangeMutex.Unlock() + fake.OnStateChangeStub = stub +} + +func (fake *FakeParticipant) OnStateChangeArgsForCall(i int) func(p rtc.Participant, oldState livekit.ParticipantInfo_State) { + fake.onStateChangeMutex.RLock() + defer fake.onStateChangeMutex.RUnlock() + argsForCall := fake.onStateChangeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) OnTrackPublished(arg1 func(rtc.Participant, rtc.PublishedTrack)) { + fake.onTrackPublishedMutex.Lock() + fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct { + arg1 func(rtc.Participant, rtc.PublishedTrack) + }{arg1}) + stub := fake.OnTrackPublishedStub + fake.recordInvocation("OnTrackPublished", []interface{}{arg1}) + fake.onTrackPublishedMutex.Unlock() + if stub != nil { + fake.OnTrackPublishedStub(arg1) + } +} + +func (fake *FakeParticipant) OnTrackPublishedCallCount() int { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + return len(fake.onTrackPublishedArgsForCall) +} + +func (fake *FakeParticipant) OnTrackPublishedCalls(stub func(func(rtc.Participant, rtc.PublishedTrack))) { + fake.onTrackPublishedMutex.Lock() + defer fake.onTrackPublishedMutex.Unlock() + fake.OnTrackPublishedStub = stub +} + +func (fake *FakeParticipant) OnTrackPublishedArgsForCall(i int) func(rtc.Participant, rtc.PublishedTrack) { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + argsForCall := fake.onTrackPublishedArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) PeerConnection() rtc.PeerConnection { + fake.peerConnectionMutex.Lock() + ret, specificReturn := fake.peerConnectionReturnsOnCall[len(fake.peerConnectionArgsForCall)] + fake.peerConnectionArgsForCall = append(fake.peerConnectionArgsForCall, struct { + }{}) + stub := fake.PeerConnectionStub + fakeReturns := fake.peerConnectionReturns + fake.recordInvocation("PeerConnection", []interface{}{}) + fake.peerConnectionMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) PeerConnectionCallCount() int { + fake.peerConnectionMutex.RLock() + defer fake.peerConnectionMutex.RUnlock() + return len(fake.peerConnectionArgsForCall) +} + +func (fake *FakeParticipant) PeerConnectionCalls(stub func() rtc.PeerConnection) { + fake.peerConnectionMutex.Lock() + defer fake.peerConnectionMutex.Unlock() + fake.PeerConnectionStub = stub +} + +func (fake *FakeParticipant) PeerConnectionReturns(result1 rtc.PeerConnection) { + fake.peerConnectionMutex.Lock() + defer fake.peerConnectionMutex.Unlock() + fake.PeerConnectionStub = nil + fake.peerConnectionReturns = struct { + result1 rtc.PeerConnection + }{result1} +} + +func (fake *FakeParticipant) PeerConnectionReturnsOnCall(i int, result1 rtc.PeerConnection) { + fake.peerConnectionMutex.Lock() + defer fake.peerConnectionMutex.Unlock() + fake.PeerConnectionStub = nil + if fake.peerConnectionReturnsOnCall == nil { + fake.peerConnectionReturnsOnCall = make(map[int]struct { + result1 rtc.PeerConnection + }) + } + fake.peerConnectionReturnsOnCall[i] = struct { + result1 rtc.PeerConnection + }{result1} +} + +func (fake *FakeParticipant) RemoveDownTrack(arg1 string, arg2 *sfu.DownTrack) { + fake.removeDownTrackMutex.Lock() + fake.removeDownTrackArgsForCall = append(fake.removeDownTrackArgsForCall, struct { + arg1 string + arg2 *sfu.DownTrack + }{arg1, arg2}) + stub := fake.RemoveDownTrackStub + fake.recordInvocation("RemoveDownTrack", []interface{}{arg1, arg2}) + fake.removeDownTrackMutex.Unlock() + if stub != nil { + fake.RemoveDownTrackStub(arg1, arg2) + } +} + +func (fake *FakeParticipant) RemoveDownTrackCallCount() int { + fake.removeDownTrackMutex.RLock() + defer fake.removeDownTrackMutex.RUnlock() + return len(fake.removeDownTrackArgsForCall) +} + +func (fake *FakeParticipant) RemoveDownTrackCalls(stub func(string, *sfu.DownTrack)) { + fake.removeDownTrackMutex.Lock() + defer fake.removeDownTrackMutex.Unlock() + fake.RemoveDownTrackStub = stub +} + +func (fake *FakeParticipant) RemoveDownTrackArgsForCall(i int) (string, *sfu.DownTrack) { + fake.removeDownTrackMutex.RLock() + defer fake.removeDownTrackMutex.RUnlock() + argsForCall := fake.removeDownTrackArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipant) RemoveSubscriber(arg1 string) { + fake.removeSubscriberMutex.Lock() + fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.RemoveSubscriberStub + fake.recordInvocation("RemoveSubscriber", []interface{}{arg1}) + fake.removeSubscriberMutex.Unlock() + if stub != nil { + fake.RemoveSubscriberStub(arg1) + } +} + +func (fake *FakeParticipant) RemoveSubscriberCallCount() int { + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + return len(fake.removeSubscriberArgsForCall) +} + +func (fake *FakeParticipant) RemoveSubscriberCalls(stub func(string)) { + fake.removeSubscriberMutex.Lock() + defer fake.removeSubscriberMutex.Unlock() + fake.RemoveSubscriberStub = stub +} + +func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) string { + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + argsForCall := fake.removeSubscriberArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) SendJoinResponse(arg1 []rtc.Participant) error { + var arg1Copy []rtc.Participant + if arg1 != nil { + arg1Copy = make([]rtc.Participant, len(arg1)) + copy(arg1Copy, arg1) + } + fake.sendJoinResponseMutex.Lock() + ret, specificReturn := fake.sendJoinResponseReturnsOnCall[len(fake.sendJoinResponseArgsForCall)] + fake.sendJoinResponseArgsForCall = append(fake.sendJoinResponseArgsForCall, struct { + arg1 []rtc.Participant + }{arg1Copy}) + stub := fake.SendJoinResponseStub + fakeReturns := fake.sendJoinResponseReturns + fake.recordInvocation("SendJoinResponse", []interface{}{arg1Copy}) + fake.sendJoinResponseMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) SendJoinResponseCallCount() int { + fake.sendJoinResponseMutex.RLock() + defer fake.sendJoinResponseMutex.RUnlock() + return len(fake.sendJoinResponseArgsForCall) +} + +func (fake *FakeParticipant) SendJoinResponseCalls(stub func([]rtc.Participant) error) { + fake.sendJoinResponseMutex.Lock() + defer fake.sendJoinResponseMutex.Unlock() + fake.SendJoinResponseStub = stub +} + +func (fake *FakeParticipant) SendJoinResponseArgsForCall(i int) []rtc.Participant { + fake.sendJoinResponseMutex.RLock() + defer fake.sendJoinResponseMutex.RUnlock() + argsForCall := fake.sendJoinResponseArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) SendJoinResponseReturns(result1 error) { + fake.sendJoinResponseMutex.Lock() + defer fake.sendJoinResponseMutex.Unlock() + fake.SendJoinResponseStub = nil + fake.sendJoinResponseReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) SendJoinResponseReturnsOnCall(i int, result1 error) { + fake.sendJoinResponseMutex.Lock() + defer fake.sendJoinResponseMutex.Unlock() + fake.SendJoinResponseStub = nil + if fake.sendJoinResponseReturnsOnCall == nil { + fake.sendJoinResponseReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.sendJoinResponseReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) SendParticipantUpdate(arg1 []*livekit.ParticipantInfo) error { + var arg1Copy []*livekit.ParticipantInfo + if arg1 != nil { + arg1Copy = make([]*livekit.ParticipantInfo, len(arg1)) + copy(arg1Copy, arg1) + } + fake.sendParticipantUpdateMutex.Lock() + ret, specificReturn := fake.sendParticipantUpdateReturnsOnCall[len(fake.sendParticipantUpdateArgsForCall)] + fake.sendParticipantUpdateArgsForCall = append(fake.sendParticipantUpdateArgsForCall, struct { + arg1 []*livekit.ParticipantInfo + }{arg1Copy}) + stub := fake.SendParticipantUpdateStub + fakeReturns := fake.sendParticipantUpdateReturns + fake.recordInvocation("SendParticipantUpdate", []interface{}{arg1Copy}) + fake.sendParticipantUpdateMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) SendParticipantUpdateCallCount() int { + fake.sendParticipantUpdateMutex.RLock() + defer fake.sendParticipantUpdateMutex.RUnlock() + return len(fake.sendParticipantUpdateArgsForCall) +} + +func (fake *FakeParticipant) SendParticipantUpdateCalls(stub func([]*livekit.ParticipantInfo) error) { + fake.sendParticipantUpdateMutex.Lock() + defer fake.sendParticipantUpdateMutex.Unlock() + fake.SendParticipantUpdateStub = stub +} + +func (fake *FakeParticipant) SendParticipantUpdateArgsForCall(i int) []*livekit.ParticipantInfo { + fake.sendParticipantUpdateMutex.RLock() + defer fake.sendParticipantUpdateMutex.RUnlock() + argsForCall := fake.sendParticipantUpdateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) SendParticipantUpdateReturns(result1 error) { + fake.sendParticipantUpdateMutex.Lock() + defer fake.sendParticipantUpdateMutex.Unlock() + fake.SendParticipantUpdateStub = nil + fake.sendParticipantUpdateReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) SendParticipantUpdateReturnsOnCall(i int, result1 error) { + fake.sendParticipantUpdateMutex.Lock() + defer fake.sendParticipantUpdateMutex.Unlock() + fake.SendParticipantUpdateStub = nil + if fake.sendParticipantUpdateReturnsOnCall == nil { + fake.sendParticipantUpdateReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.sendParticipantUpdateReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) SetRemoteDescription(arg1 webrtc.SessionDescription) error { + fake.setRemoteDescriptionMutex.Lock() + ret, specificReturn := fake.setRemoteDescriptionReturnsOnCall[len(fake.setRemoteDescriptionArgsForCall)] + fake.setRemoteDescriptionArgsForCall = append(fake.setRemoteDescriptionArgsForCall, struct { + arg1 webrtc.SessionDescription + }{arg1}) + stub := fake.SetRemoteDescriptionStub + fakeReturns := fake.setRemoteDescriptionReturns + fake.recordInvocation("SetRemoteDescription", []interface{}{arg1}) + fake.setRemoteDescriptionMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) SetRemoteDescriptionCallCount() int { + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + return len(fake.setRemoteDescriptionArgsForCall) +} + +func (fake *FakeParticipant) SetRemoteDescriptionCalls(stub func(webrtc.SessionDescription) error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = stub +} + +func (fake *FakeParticipant) SetRemoteDescriptionArgsForCall(i int) webrtc.SessionDescription { + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + argsForCall := fake.setRemoteDescriptionArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) SetRemoteDescriptionReturns(result1 error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = nil + fake.setRemoteDescriptionReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) SetRemoteDescriptionReturnsOnCall(i int, result1 error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = nil + if fake.setRemoteDescriptionReturnsOnCall == nil { + fake.setRemoteDescriptionReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.setRemoteDescriptionReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) Start() { + fake.startMutex.Lock() + fake.startArgsForCall = append(fake.startArgsForCall, struct { + }{}) + stub := fake.StartStub + fake.recordInvocation("Start", []interface{}{}) + fake.startMutex.Unlock() + if stub != nil { + fake.StartStub() + } +} + +func (fake *FakeParticipant) StartCallCount() int { + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + return len(fake.startArgsForCall) +} + +func (fake *FakeParticipant) StartCalls(stub func()) { + fake.startMutex.Lock() + defer fake.startMutex.Unlock() + fake.StartStub = stub +} + +func (fake *FakeParticipant) State() livekit.ParticipantInfo_State { + fake.stateMutex.Lock() + ret, specificReturn := fake.stateReturnsOnCall[len(fake.stateArgsForCall)] + fake.stateArgsForCall = append(fake.stateArgsForCall, struct { + }{}) + stub := fake.StateStub + fakeReturns := fake.stateReturns + fake.recordInvocation("State", []interface{}{}) + fake.stateMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) StateCallCount() int { + fake.stateMutex.RLock() + defer fake.stateMutex.RUnlock() + return len(fake.stateArgsForCall) +} + +func (fake *FakeParticipant) StateCalls(stub func() livekit.ParticipantInfo_State) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = stub +} + +func (fake *FakeParticipant) StateReturns(result1 livekit.ParticipantInfo_State) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = nil + fake.stateReturns = struct { + result1 livekit.ParticipantInfo_State + }{result1} +} + +func (fake *FakeParticipant) StateReturnsOnCall(i int, result1 livekit.ParticipantInfo_State) { + fake.stateMutex.Lock() + defer fake.stateMutex.Unlock() + fake.StateStub = nil + if fake.stateReturnsOnCall == nil { + fake.stateReturnsOnCall = make(map[int]struct { + result1 livekit.ParticipantInfo_State + }) + } + fake.stateReturnsOnCall[i] = struct { + result1 livekit.ParticipantInfo_State + }{result1} +} + +func (fake *FakeParticipant) ToProto() *livekit.ParticipantInfo { + fake.toProtoMutex.Lock() + ret, specificReturn := fake.toProtoReturnsOnCall[len(fake.toProtoArgsForCall)] + fake.toProtoArgsForCall = append(fake.toProtoArgsForCall, struct { + }{}) + stub := fake.ToProtoStub + fakeReturns := fake.toProtoReturns + fake.recordInvocation("ToProto", []interface{}{}) + fake.toProtoMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) ToProtoCallCount() int { + fake.toProtoMutex.RLock() + defer fake.toProtoMutex.RUnlock() + return len(fake.toProtoArgsForCall) +} + +func (fake *FakeParticipant) ToProtoCalls(stub func() *livekit.ParticipantInfo) { + fake.toProtoMutex.Lock() + defer fake.toProtoMutex.Unlock() + fake.ToProtoStub = stub +} + +func (fake *FakeParticipant) ToProtoReturns(result1 *livekit.ParticipantInfo) { + fake.toProtoMutex.Lock() + defer fake.toProtoMutex.Unlock() + fake.ToProtoStub = nil + fake.toProtoReturns = struct { + result1 *livekit.ParticipantInfo + }{result1} +} + +func (fake *FakeParticipant) ToProtoReturnsOnCall(i int, result1 *livekit.ParticipantInfo) { + fake.toProtoMutex.Lock() + defer fake.toProtoMutex.Unlock() + fake.ToProtoStub = nil + if fake.toProtoReturnsOnCall == nil { + fake.toProtoReturnsOnCall = make(map[int]struct { + result1 *livekit.ParticipantInfo + }) + } + fake.toProtoReturnsOnCall[i] = struct { + result1 *livekit.ParticipantInfo + }{result1} +} + +func (fake *FakeParticipant) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.addDownTrackMutex.RLock() + defer fake.addDownTrackMutex.RUnlock() + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + fake.answerMutex.RLock() + defer fake.answerMutex.RUnlock() + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + fake.handleNegotiateMutex.RLock() + defer fake.handleNegotiateMutex.RUnlock() + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + fake.nameMutex.RLock() + defer fake.nameMutex.RUnlock() + fake.onCloseMutex.RLock() + defer fake.onCloseMutex.RUnlock() + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + fake.onOfferMutex.RLock() + defer fake.onOfferMutex.RUnlock() + fake.onStateChangeMutex.RLock() + defer fake.onStateChangeMutex.RUnlock() + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + fake.peerConnectionMutex.RLock() + defer fake.peerConnectionMutex.RUnlock() + fake.removeDownTrackMutex.RLock() + defer fake.removeDownTrackMutex.RUnlock() + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + fake.sendJoinResponseMutex.RLock() + defer fake.sendJoinResponseMutex.RUnlock() + fake.sendParticipantUpdateMutex.RLock() + defer fake.sendParticipantUpdateMutex.RUnlock() + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + fake.stateMutex.RLock() + defer fake.stateMutex.RUnlock() + fake.toProtoMutex.RLock() + defer fake.toProtoMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeParticipant) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ rtc.Participant = new(FakeParticipant) diff --git a/pkg/rtc/rtcfakes/fake_peer_connection.go b/pkg/rtc/rtcfakes/fake_peer_connection.go new file mode 100644 index 000000000..040ccbe78 --- /dev/null +++ b/pkg/rtc/rtcfakes/fake_peer_connection.go @@ -0,0 +1,1059 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package rtcfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc" + "github.com/pion/rtcp" + webrtc "github.com/pion/webrtc/v3" +) + +type FakePeerConnection struct { + AddICECandidateStub func(webrtc.ICECandidateInit) error + addICECandidateMutex sync.RWMutex + addICECandidateArgsForCall []struct { + arg1 webrtc.ICECandidateInit + } + addICECandidateReturns struct { + result1 error + } + addICECandidateReturnsOnCall map[int]struct { + result1 error + } + AddTransceiverFromTrackStub func(webrtc.TrackLocal, ...webrtc.RTPTransceiverInit) (*webrtc.RTPTransceiver, error) + addTransceiverFromTrackMutex sync.RWMutex + addTransceiverFromTrackArgsForCall []struct { + arg1 webrtc.TrackLocal + arg2 []webrtc.RTPTransceiverInit + } + addTransceiverFromTrackReturns struct { + result1 *webrtc.RTPTransceiver + result2 error + } + addTransceiverFromTrackReturnsOnCall map[int]struct { + result1 *webrtc.RTPTransceiver + result2 error + } + CloseStub func() error + closeMutex sync.RWMutex + closeArgsForCall []struct { + } + closeReturns struct { + result1 error + } + closeReturnsOnCall map[int]struct { + result1 error + } + ConnectionStateStub func() webrtc.PeerConnectionState + connectionStateMutex sync.RWMutex + connectionStateArgsForCall []struct { + } + connectionStateReturns struct { + result1 webrtc.PeerConnectionState + } + connectionStateReturnsOnCall map[int]struct { + result1 webrtc.PeerConnectionState + } + CreateAnswerStub func(*webrtc.AnswerOptions) (webrtc.SessionDescription, error) + createAnswerMutex sync.RWMutex + createAnswerArgsForCall []struct { + arg1 *webrtc.AnswerOptions + } + createAnswerReturns struct { + result1 webrtc.SessionDescription + result2 error + } + createAnswerReturnsOnCall map[int]struct { + result1 webrtc.SessionDescription + result2 error + } + CreateDataChannelStub func(string, *webrtc.DataChannelInit) (*webrtc.DataChannel, error) + createDataChannelMutex sync.RWMutex + createDataChannelArgsForCall []struct { + arg1 string + arg2 *webrtc.DataChannelInit + } + createDataChannelReturns struct { + result1 *webrtc.DataChannel + result2 error + } + createDataChannelReturnsOnCall map[int]struct { + result1 *webrtc.DataChannel + result2 error + } + CreateOfferStub func(*webrtc.OfferOptions) (webrtc.SessionDescription, error) + createOfferMutex sync.RWMutex + createOfferArgsForCall []struct { + arg1 *webrtc.OfferOptions + } + createOfferReturns struct { + result1 webrtc.SessionDescription + result2 error + } + createOfferReturnsOnCall map[int]struct { + result1 webrtc.SessionDescription + result2 error + } + OnDataChannelStub func(func(d *webrtc.DataChannel)) + onDataChannelMutex sync.RWMutex + onDataChannelArgsForCall []struct { + arg1 func(d *webrtc.DataChannel) + } + OnICECandidateStub func(func(*webrtc.ICECandidate)) + onICECandidateMutex sync.RWMutex + onICECandidateArgsForCall []struct { + arg1 func(*webrtc.ICECandidate) + } + OnICEConnectionStateChangeStub func(func(webrtc.ICEConnectionState)) + onICEConnectionStateChangeMutex sync.RWMutex + onICEConnectionStateChangeArgsForCall []struct { + arg1 func(webrtc.ICEConnectionState) + } + OnNegotiationNeededStub func(func()) + onNegotiationNeededMutex sync.RWMutex + onNegotiationNeededArgsForCall []struct { + arg1 func() + } + OnTrackStub func(func(*webrtc.TrackRemote, *webrtc.RTPReceiver)) + onTrackMutex sync.RWMutex + onTrackArgsForCall []struct { + arg1 func(*webrtc.TrackRemote, *webrtc.RTPReceiver) + } + RemoveTrackStub func(*webrtc.RTPSender) error + removeTrackMutex sync.RWMutex + removeTrackArgsForCall []struct { + arg1 *webrtc.RTPSender + } + removeTrackReturns struct { + result1 error + } + removeTrackReturnsOnCall map[int]struct { + result1 error + } + SetLocalDescriptionStub func(webrtc.SessionDescription) error + setLocalDescriptionMutex sync.RWMutex + setLocalDescriptionArgsForCall []struct { + arg1 webrtc.SessionDescription + } + setLocalDescriptionReturns struct { + result1 error + } + setLocalDescriptionReturnsOnCall map[int]struct { + result1 error + } + SetRemoteDescriptionStub func(webrtc.SessionDescription) error + setRemoteDescriptionMutex sync.RWMutex + setRemoteDescriptionArgsForCall []struct { + arg1 webrtc.SessionDescription + } + setRemoteDescriptionReturns struct { + result1 error + } + setRemoteDescriptionReturnsOnCall map[int]struct { + result1 error + } + WriteRTCPStub func([]rtcp.Packet) error + writeRTCPMutex sync.RWMutex + writeRTCPArgsForCall []struct { + arg1 []rtcp.Packet + } + writeRTCPReturns struct { + result1 error + } + writeRTCPReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakePeerConnection) AddICECandidate(arg1 webrtc.ICECandidateInit) error { + fake.addICECandidateMutex.Lock() + ret, specificReturn := fake.addICECandidateReturnsOnCall[len(fake.addICECandidateArgsForCall)] + fake.addICECandidateArgsForCall = append(fake.addICECandidateArgsForCall, struct { + arg1 webrtc.ICECandidateInit + }{arg1}) + stub := fake.AddICECandidateStub + fakeReturns := fake.addICECandidateReturns + fake.recordInvocation("AddICECandidate", []interface{}{arg1}) + fake.addICECandidateMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) AddICECandidateCallCount() int { + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + return len(fake.addICECandidateArgsForCall) +} + +func (fake *FakePeerConnection) AddICECandidateCalls(stub func(webrtc.ICECandidateInit) error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = stub +} + +func (fake *FakePeerConnection) AddICECandidateArgsForCall(i int) webrtc.ICECandidateInit { + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + argsForCall := fake.addICECandidateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) AddICECandidateReturns(result1 error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = nil + fake.addICECandidateReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) AddICECandidateReturnsOnCall(i int, result1 error) { + fake.addICECandidateMutex.Lock() + defer fake.addICECandidateMutex.Unlock() + fake.AddICECandidateStub = nil + if fake.addICECandidateReturnsOnCall == nil { + fake.addICECandidateReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.addICECandidateReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) AddTransceiverFromTrack(arg1 webrtc.TrackLocal, arg2 ...webrtc.RTPTransceiverInit) (*webrtc.RTPTransceiver, error) { + fake.addTransceiverFromTrackMutex.Lock() + ret, specificReturn := fake.addTransceiverFromTrackReturnsOnCall[len(fake.addTransceiverFromTrackArgsForCall)] + fake.addTransceiverFromTrackArgsForCall = append(fake.addTransceiverFromTrackArgsForCall, struct { + arg1 webrtc.TrackLocal + arg2 []webrtc.RTPTransceiverInit + }{arg1, arg2}) + stub := fake.AddTransceiverFromTrackStub + fakeReturns := fake.addTransceiverFromTrackReturns + fake.recordInvocation("AddTransceiverFromTrack", []interface{}{arg1, arg2}) + fake.addTransceiverFromTrackMutex.Unlock() + if stub != nil { + return stub(arg1, arg2...) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakePeerConnection) AddTransceiverFromTrackCallCount() int { + fake.addTransceiverFromTrackMutex.RLock() + defer fake.addTransceiverFromTrackMutex.RUnlock() + return len(fake.addTransceiverFromTrackArgsForCall) +} + +func (fake *FakePeerConnection) AddTransceiverFromTrackCalls(stub func(webrtc.TrackLocal, ...webrtc.RTPTransceiverInit) (*webrtc.RTPTransceiver, error)) { + fake.addTransceiverFromTrackMutex.Lock() + defer fake.addTransceiverFromTrackMutex.Unlock() + fake.AddTransceiverFromTrackStub = stub +} + +func (fake *FakePeerConnection) AddTransceiverFromTrackArgsForCall(i int) (webrtc.TrackLocal, []webrtc.RTPTransceiverInit) { + fake.addTransceiverFromTrackMutex.RLock() + defer fake.addTransceiverFromTrackMutex.RUnlock() + argsForCall := fake.addTransceiverFromTrackArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakePeerConnection) AddTransceiverFromTrackReturns(result1 *webrtc.RTPTransceiver, result2 error) { + fake.addTransceiverFromTrackMutex.Lock() + defer fake.addTransceiverFromTrackMutex.Unlock() + fake.AddTransceiverFromTrackStub = nil + fake.addTransceiverFromTrackReturns = struct { + result1 *webrtc.RTPTransceiver + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) AddTransceiverFromTrackReturnsOnCall(i int, result1 *webrtc.RTPTransceiver, result2 error) { + fake.addTransceiverFromTrackMutex.Lock() + defer fake.addTransceiverFromTrackMutex.Unlock() + fake.AddTransceiverFromTrackStub = nil + if fake.addTransceiverFromTrackReturnsOnCall == nil { + fake.addTransceiverFromTrackReturnsOnCall = make(map[int]struct { + result1 *webrtc.RTPTransceiver + result2 error + }) + } + fake.addTransceiverFromTrackReturnsOnCall[i] = struct { + result1 *webrtc.RTPTransceiver + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) Close() error { + fake.closeMutex.Lock() + ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] + fake.closeArgsForCall = append(fake.closeArgsForCall, struct { + }{}) + stub := fake.CloseStub + fakeReturns := fake.closeReturns + fake.recordInvocation("Close", []interface{}{}) + fake.closeMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) CloseCallCount() int { + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + return len(fake.closeArgsForCall) +} + +func (fake *FakePeerConnection) CloseCalls(stub func() error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = stub +} + +func (fake *FakePeerConnection) CloseReturns(result1 error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = nil + fake.closeReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) CloseReturnsOnCall(i int, result1 error) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = nil + if fake.closeReturnsOnCall == nil { + fake.closeReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.closeReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) ConnectionState() webrtc.PeerConnectionState { + fake.connectionStateMutex.Lock() + ret, specificReturn := fake.connectionStateReturnsOnCall[len(fake.connectionStateArgsForCall)] + fake.connectionStateArgsForCall = append(fake.connectionStateArgsForCall, struct { + }{}) + stub := fake.ConnectionStateStub + fakeReturns := fake.connectionStateReturns + fake.recordInvocation("ConnectionState", []interface{}{}) + fake.connectionStateMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) ConnectionStateCallCount() int { + fake.connectionStateMutex.RLock() + defer fake.connectionStateMutex.RUnlock() + return len(fake.connectionStateArgsForCall) +} + +func (fake *FakePeerConnection) ConnectionStateCalls(stub func() webrtc.PeerConnectionState) { + fake.connectionStateMutex.Lock() + defer fake.connectionStateMutex.Unlock() + fake.ConnectionStateStub = stub +} + +func (fake *FakePeerConnection) ConnectionStateReturns(result1 webrtc.PeerConnectionState) { + fake.connectionStateMutex.Lock() + defer fake.connectionStateMutex.Unlock() + fake.ConnectionStateStub = nil + fake.connectionStateReturns = struct { + result1 webrtc.PeerConnectionState + }{result1} +} + +func (fake *FakePeerConnection) ConnectionStateReturnsOnCall(i int, result1 webrtc.PeerConnectionState) { + fake.connectionStateMutex.Lock() + defer fake.connectionStateMutex.Unlock() + fake.ConnectionStateStub = nil + if fake.connectionStateReturnsOnCall == nil { + fake.connectionStateReturnsOnCall = make(map[int]struct { + result1 webrtc.PeerConnectionState + }) + } + fake.connectionStateReturnsOnCall[i] = struct { + result1 webrtc.PeerConnectionState + }{result1} +} + +func (fake *FakePeerConnection) CreateAnswer(arg1 *webrtc.AnswerOptions) (webrtc.SessionDescription, error) { + fake.createAnswerMutex.Lock() + ret, specificReturn := fake.createAnswerReturnsOnCall[len(fake.createAnswerArgsForCall)] + fake.createAnswerArgsForCall = append(fake.createAnswerArgsForCall, struct { + arg1 *webrtc.AnswerOptions + }{arg1}) + stub := fake.CreateAnswerStub + fakeReturns := fake.createAnswerReturns + fake.recordInvocation("CreateAnswer", []interface{}{arg1}) + fake.createAnswerMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakePeerConnection) CreateAnswerCallCount() int { + fake.createAnswerMutex.RLock() + defer fake.createAnswerMutex.RUnlock() + return len(fake.createAnswerArgsForCall) +} + +func (fake *FakePeerConnection) CreateAnswerCalls(stub func(*webrtc.AnswerOptions) (webrtc.SessionDescription, error)) { + fake.createAnswerMutex.Lock() + defer fake.createAnswerMutex.Unlock() + fake.CreateAnswerStub = stub +} + +func (fake *FakePeerConnection) CreateAnswerArgsForCall(i int) *webrtc.AnswerOptions { + fake.createAnswerMutex.RLock() + defer fake.createAnswerMutex.RUnlock() + argsForCall := fake.createAnswerArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) CreateAnswerReturns(result1 webrtc.SessionDescription, result2 error) { + fake.createAnswerMutex.Lock() + defer fake.createAnswerMutex.Unlock() + fake.CreateAnswerStub = nil + fake.createAnswerReturns = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) CreateAnswerReturnsOnCall(i int, result1 webrtc.SessionDescription, result2 error) { + fake.createAnswerMutex.Lock() + defer fake.createAnswerMutex.Unlock() + fake.CreateAnswerStub = nil + if fake.createAnswerReturnsOnCall == nil { + fake.createAnswerReturnsOnCall = make(map[int]struct { + result1 webrtc.SessionDescription + result2 error + }) + } + fake.createAnswerReturnsOnCall[i] = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) CreateDataChannel(arg1 string, arg2 *webrtc.DataChannelInit) (*webrtc.DataChannel, error) { + fake.createDataChannelMutex.Lock() + ret, specificReturn := fake.createDataChannelReturnsOnCall[len(fake.createDataChannelArgsForCall)] + fake.createDataChannelArgsForCall = append(fake.createDataChannelArgsForCall, struct { + arg1 string + arg2 *webrtc.DataChannelInit + }{arg1, arg2}) + stub := fake.CreateDataChannelStub + fakeReturns := fake.createDataChannelReturns + fake.recordInvocation("CreateDataChannel", []interface{}{arg1, arg2}) + fake.createDataChannelMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakePeerConnection) CreateDataChannelCallCount() int { + fake.createDataChannelMutex.RLock() + defer fake.createDataChannelMutex.RUnlock() + return len(fake.createDataChannelArgsForCall) +} + +func (fake *FakePeerConnection) CreateDataChannelCalls(stub func(string, *webrtc.DataChannelInit) (*webrtc.DataChannel, error)) { + fake.createDataChannelMutex.Lock() + defer fake.createDataChannelMutex.Unlock() + fake.CreateDataChannelStub = stub +} + +func (fake *FakePeerConnection) CreateDataChannelArgsForCall(i int) (string, *webrtc.DataChannelInit) { + fake.createDataChannelMutex.RLock() + defer fake.createDataChannelMutex.RUnlock() + argsForCall := fake.createDataChannelArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakePeerConnection) CreateDataChannelReturns(result1 *webrtc.DataChannel, result2 error) { + fake.createDataChannelMutex.Lock() + defer fake.createDataChannelMutex.Unlock() + fake.CreateDataChannelStub = nil + fake.createDataChannelReturns = struct { + result1 *webrtc.DataChannel + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) CreateDataChannelReturnsOnCall(i int, result1 *webrtc.DataChannel, result2 error) { + fake.createDataChannelMutex.Lock() + defer fake.createDataChannelMutex.Unlock() + fake.CreateDataChannelStub = nil + if fake.createDataChannelReturnsOnCall == nil { + fake.createDataChannelReturnsOnCall = make(map[int]struct { + result1 *webrtc.DataChannel + result2 error + }) + } + fake.createDataChannelReturnsOnCall[i] = struct { + result1 *webrtc.DataChannel + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) CreateOffer(arg1 *webrtc.OfferOptions) (webrtc.SessionDescription, error) { + fake.createOfferMutex.Lock() + ret, specificReturn := fake.createOfferReturnsOnCall[len(fake.createOfferArgsForCall)] + fake.createOfferArgsForCall = append(fake.createOfferArgsForCall, struct { + arg1 *webrtc.OfferOptions + }{arg1}) + stub := fake.CreateOfferStub + fakeReturns := fake.createOfferReturns + fake.recordInvocation("CreateOffer", []interface{}{arg1}) + fake.createOfferMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakePeerConnection) CreateOfferCallCount() int { + fake.createOfferMutex.RLock() + defer fake.createOfferMutex.RUnlock() + return len(fake.createOfferArgsForCall) +} + +func (fake *FakePeerConnection) CreateOfferCalls(stub func(*webrtc.OfferOptions) (webrtc.SessionDescription, error)) { + fake.createOfferMutex.Lock() + defer fake.createOfferMutex.Unlock() + fake.CreateOfferStub = stub +} + +func (fake *FakePeerConnection) CreateOfferArgsForCall(i int) *webrtc.OfferOptions { + fake.createOfferMutex.RLock() + defer fake.createOfferMutex.RUnlock() + argsForCall := fake.createOfferArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) CreateOfferReturns(result1 webrtc.SessionDescription, result2 error) { + fake.createOfferMutex.Lock() + defer fake.createOfferMutex.Unlock() + fake.CreateOfferStub = nil + fake.createOfferReturns = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) CreateOfferReturnsOnCall(i int, result1 webrtc.SessionDescription, result2 error) { + fake.createOfferMutex.Lock() + defer fake.createOfferMutex.Unlock() + fake.CreateOfferStub = nil + if fake.createOfferReturnsOnCall == nil { + fake.createOfferReturnsOnCall = make(map[int]struct { + result1 webrtc.SessionDescription + result2 error + }) + } + fake.createOfferReturnsOnCall[i] = struct { + result1 webrtc.SessionDescription + result2 error + }{result1, result2} +} + +func (fake *FakePeerConnection) OnDataChannel(arg1 func(d *webrtc.DataChannel)) { + fake.onDataChannelMutex.Lock() + fake.onDataChannelArgsForCall = append(fake.onDataChannelArgsForCall, struct { + arg1 func(d *webrtc.DataChannel) + }{arg1}) + stub := fake.OnDataChannelStub + fake.recordInvocation("OnDataChannel", []interface{}{arg1}) + fake.onDataChannelMutex.Unlock() + if stub != nil { + fake.OnDataChannelStub(arg1) + } +} + +func (fake *FakePeerConnection) OnDataChannelCallCount() int { + fake.onDataChannelMutex.RLock() + defer fake.onDataChannelMutex.RUnlock() + return len(fake.onDataChannelArgsForCall) +} + +func (fake *FakePeerConnection) OnDataChannelCalls(stub func(func(d *webrtc.DataChannel))) { + fake.onDataChannelMutex.Lock() + defer fake.onDataChannelMutex.Unlock() + fake.OnDataChannelStub = stub +} + +func (fake *FakePeerConnection) OnDataChannelArgsForCall(i int) func(d *webrtc.DataChannel) { + fake.onDataChannelMutex.RLock() + defer fake.onDataChannelMutex.RUnlock() + argsForCall := fake.onDataChannelArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) OnICECandidate(arg1 func(*webrtc.ICECandidate)) { + fake.onICECandidateMutex.Lock() + fake.onICECandidateArgsForCall = append(fake.onICECandidateArgsForCall, struct { + arg1 func(*webrtc.ICECandidate) + }{arg1}) + stub := fake.OnICECandidateStub + fake.recordInvocation("OnICECandidate", []interface{}{arg1}) + fake.onICECandidateMutex.Unlock() + if stub != nil { + fake.OnICECandidateStub(arg1) + } +} + +func (fake *FakePeerConnection) OnICECandidateCallCount() int { + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + return len(fake.onICECandidateArgsForCall) +} + +func (fake *FakePeerConnection) OnICECandidateCalls(stub func(func(*webrtc.ICECandidate))) { + fake.onICECandidateMutex.Lock() + defer fake.onICECandidateMutex.Unlock() + fake.OnICECandidateStub = stub +} + +func (fake *FakePeerConnection) OnICECandidateArgsForCall(i int) func(*webrtc.ICECandidate) { + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + argsForCall := fake.onICECandidateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) OnICEConnectionStateChange(arg1 func(webrtc.ICEConnectionState)) { + fake.onICEConnectionStateChangeMutex.Lock() + fake.onICEConnectionStateChangeArgsForCall = append(fake.onICEConnectionStateChangeArgsForCall, struct { + arg1 func(webrtc.ICEConnectionState) + }{arg1}) + stub := fake.OnICEConnectionStateChangeStub + fake.recordInvocation("OnICEConnectionStateChange", []interface{}{arg1}) + fake.onICEConnectionStateChangeMutex.Unlock() + if stub != nil { + fake.OnICEConnectionStateChangeStub(arg1) + } +} + +func (fake *FakePeerConnection) OnICEConnectionStateChangeCallCount() int { + fake.onICEConnectionStateChangeMutex.RLock() + defer fake.onICEConnectionStateChangeMutex.RUnlock() + return len(fake.onICEConnectionStateChangeArgsForCall) +} + +func (fake *FakePeerConnection) OnICEConnectionStateChangeCalls(stub func(func(webrtc.ICEConnectionState))) { + fake.onICEConnectionStateChangeMutex.Lock() + defer fake.onICEConnectionStateChangeMutex.Unlock() + fake.OnICEConnectionStateChangeStub = stub +} + +func (fake *FakePeerConnection) OnICEConnectionStateChangeArgsForCall(i int) func(webrtc.ICEConnectionState) { + fake.onICEConnectionStateChangeMutex.RLock() + defer fake.onICEConnectionStateChangeMutex.RUnlock() + argsForCall := fake.onICEConnectionStateChangeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) OnNegotiationNeeded(arg1 func()) { + fake.onNegotiationNeededMutex.Lock() + fake.onNegotiationNeededArgsForCall = append(fake.onNegotiationNeededArgsForCall, struct { + arg1 func() + }{arg1}) + stub := fake.OnNegotiationNeededStub + fake.recordInvocation("OnNegotiationNeeded", []interface{}{arg1}) + fake.onNegotiationNeededMutex.Unlock() + if stub != nil { + fake.OnNegotiationNeededStub(arg1) + } +} + +func (fake *FakePeerConnection) OnNegotiationNeededCallCount() int { + fake.onNegotiationNeededMutex.RLock() + defer fake.onNegotiationNeededMutex.RUnlock() + return len(fake.onNegotiationNeededArgsForCall) +} + +func (fake *FakePeerConnection) OnNegotiationNeededCalls(stub func(func())) { + fake.onNegotiationNeededMutex.Lock() + defer fake.onNegotiationNeededMutex.Unlock() + fake.OnNegotiationNeededStub = stub +} + +func (fake *FakePeerConnection) OnNegotiationNeededArgsForCall(i int) func() { + fake.onNegotiationNeededMutex.RLock() + defer fake.onNegotiationNeededMutex.RUnlock() + argsForCall := fake.onNegotiationNeededArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) OnTrack(arg1 func(*webrtc.TrackRemote, *webrtc.RTPReceiver)) { + fake.onTrackMutex.Lock() + fake.onTrackArgsForCall = append(fake.onTrackArgsForCall, struct { + arg1 func(*webrtc.TrackRemote, *webrtc.RTPReceiver) + }{arg1}) + stub := fake.OnTrackStub + fake.recordInvocation("OnTrack", []interface{}{arg1}) + fake.onTrackMutex.Unlock() + if stub != nil { + fake.OnTrackStub(arg1) + } +} + +func (fake *FakePeerConnection) OnTrackCallCount() int { + fake.onTrackMutex.RLock() + defer fake.onTrackMutex.RUnlock() + return len(fake.onTrackArgsForCall) +} + +func (fake *FakePeerConnection) OnTrackCalls(stub func(func(*webrtc.TrackRemote, *webrtc.RTPReceiver))) { + fake.onTrackMutex.Lock() + defer fake.onTrackMutex.Unlock() + fake.OnTrackStub = stub +} + +func (fake *FakePeerConnection) OnTrackArgsForCall(i int) func(*webrtc.TrackRemote, *webrtc.RTPReceiver) { + fake.onTrackMutex.RLock() + defer fake.onTrackMutex.RUnlock() + argsForCall := fake.onTrackArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) RemoveTrack(arg1 *webrtc.RTPSender) error { + fake.removeTrackMutex.Lock() + ret, specificReturn := fake.removeTrackReturnsOnCall[len(fake.removeTrackArgsForCall)] + fake.removeTrackArgsForCall = append(fake.removeTrackArgsForCall, struct { + arg1 *webrtc.RTPSender + }{arg1}) + stub := fake.RemoveTrackStub + fakeReturns := fake.removeTrackReturns + fake.recordInvocation("RemoveTrack", []interface{}{arg1}) + fake.removeTrackMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) RemoveTrackCallCount() int { + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() + return len(fake.removeTrackArgsForCall) +} + +func (fake *FakePeerConnection) RemoveTrackCalls(stub func(*webrtc.RTPSender) error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = stub +} + +func (fake *FakePeerConnection) RemoveTrackArgsForCall(i int) *webrtc.RTPSender { + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() + argsForCall := fake.removeTrackArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) RemoveTrackReturns(result1 error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = nil + fake.removeTrackReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) RemoveTrackReturnsOnCall(i int, result1 error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = nil + if fake.removeTrackReturnsOnCall == nil { + fake.removeTrackReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeTrackReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) SetLocalDescription(arg1 webrtc.SessionDescription) error { + fake.setLocalDescriptionMutex.Lock() + ret, specificReturn := fake.setLocalDescriptionReturnsOnCall[len(fake.setLocalDescriptionArgsForCall)] + fake.setLocalDescriptionArgsForCall = append(fake.setLocalDescriptionArgsForCall, struct { + arg1 webrtc.SessionDescription + }{arg1}) + stub := fake.SetLocalDescriptionStub + fakeReturns := fake.setLocalDescriptionReturns + fake.recordInvocation("SetLocalDescription", []interface{}{arg1}) + fake.setLocalDescriptionMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) SetLocalDescriptionCallCount() int { + fake.setLocalDescriptionMutex.RLock() + defer fake.setLocalDescriptionMutex.RUnlock() + return len(fake.setLocalDescriptionArgsForCall) +} + +func (fake *FakePeerConnection) SetLocalDescriptionCalls(stub func(webrtc.SessionDescription) error) { + fake.setLocalDescriptionMutex.Lock() + defer fake.setLocalDescriptionMutex.Unlock() + fake.SetLocalDescriptionStub = stub +} + +func (fake *FakePeerConnection) SetLocalDescriptionArgsForCall(i int) webrtc.SessionDescription { + fake.setLocalDescriptionMutex.RLock() + defer fake.setLocalDescriptionMutex.RUnlock() + argsForCall := fake.setLocalDescriptionArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) SetLocalDescriptionReturns(result1 error) { + fake.setLocalDescriptionMutex.Lock() + defer fake.setLocalDescriptionMutex.Unlock() + fake.SetLocalDescriptionStub = nil + fake.setLocalDescriptionReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) SetLocalDescriptionReturnsOnCall(i int, result1 error) { + fake.setLocalDescriptionMutex.Lock() + defer fake.setLocalDescriptionMutex.Unlock() + fake.SetLocalDescriptionStub = nil + if fake.setLocalDescriptionReturnsOnCall == nil { + fake.setLocalDescriptionReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.setLocalDescriptionReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) SetRemoteDescription(arg1 webrtc.SessionDescription) error { + fake.setRemoteDescriptionMutex.Lock() + ret, specificReturn := fake.setRemoteDescriptionReturnsOnCall[len(fake.setRemoteDescriptionArgsForCall)] + fake.setRemoteDescriptionArgsForCall = append(fake.setRemoteDescriptionArgsForCall, struct { + arg1 webrtc.SessionDescription + }{arg1}) + stub := fake.SetRemoteDescriptionStub + fakeReturns := fake.setRemoteDescriptionReturns + fake.recordInvocation("SetRemoteDescription", []interface{}{arg1}) + fake.setRemoteDescriptionMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) SetRemoteDescriptionCallCount() int { + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + return len(fake.setRemoteDescriptionArgsForCall) +} + +func (fake *FakePeerConnection) SetRemoteDescriptionCalls(stub func(webrtc.SessionDescription) error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = stub +} + +func (fake *FakePeerConnection) SetRemoteDescriptionArgsForCall(i int) webrtc.SessionDescription { + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + argsForCall := fake.setRemoteDescriptionArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) SetRemoteDescriptionReturns(result1 error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = nil + fake.setRemoteDescriptionReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) SetRemoteDescriptionReturnsOnCall(i int, result1 error) { + fake.setRemoteDescriptionMutex.Lock() + defer fake.setRemoteDescriptionMutex.Unlock() + fake.SetRemoteDescriptionStub = nil + if fake.setRemoteDescriptionReturnsOnCall == nil { + fake.setRemoteDescriptionReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.setRemoteDescriptionReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) WriteRTCP(arg1 []rtcp.Packet) error { + var arg1Copy []rtcp.Packet + if arg1 != nil { + arg1Copy = make([]rtcp.Packet, len(arg1)) + copy(arg1Copy, arg1) + } + fake.writeRTCPMutex.Lock() + ret, specificReturn := fake.writeRTCPReturnsOnCall[len(fake.writeRTCPArgsForCall)] + fake.writeRTCPArgsForCall = append(fake.writeRTCPArgsForCall, struct { + arg1 []rtcp.Packet + }{arg1Copy}) + stub := fake.WriteRTCPStub + fakeReturns := fake.writeRTCPReturns + fake.recordInvocation("WriteRTCP", []interface{}{arg1Copy}) + fake.writeRTCPMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) WriteRTCPCallCount() int { + fake.writeRTCPMutex.RLock() + defer fake.writeRTCPMutex.RUnlock() + return len(fake.writeRTCPArgsForCall) +} + +func (fake *FakePeerConnection) WriteRTCPCalls(stub func([]rtcp.Packet) error) { + fake.writeRTCPMutex.Lock() + defer fake.writeRTCPMutex.Unlock() + fake.WriteRTCPStub = stub +} + +func (fake *FakePeerConnection) WriteRTCPArgsForCall(i int) []rtcp.Packet { + fake.writeRTCPMutex.RLock() + defer fake.writeRTCPMutex.RUnlock() + argsForCall := fake.writeRTCPArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePeerConnection) WriteRTCPReturns(result1 error) { + fake.writeRTCPMutex.Lock() + defer fake.writeRTCPMutex.Unlock() + fake.WriteRTCPStub = nil + fake.writeRTCPReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) WriteRTCPReturnsOnCall(i int, result1 error) { + fake.writeRTCPMutex.Lock() + defer fake.writeRTCPMutex.Unlock() + fake.WriteRTCPStub = nil + if fake.writeRTCPReturnsOnCall == nil { + fake.writeRTCPReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.writeRTCPReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePeerConnection) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.addICECandidateMutex.RLock() + defer fake.addICECandidateMutex.RUnlock() + fake.addTransceiverFromTrackMutex.RLock() + defer fake.addTransceiverFromTrackMutex.RUnlock() + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + fake.connectionStateMutex.RLock() + defer fake.connectionStateMutex.RUnlock() + fake.createAnswerMutex.RLock() + defer fake.createAnswerMutex.RUnlock() + fake.createDataChannelMutex.RLock() + defer fake.createDataChannelMutex.RUnlock() + fake.createOfferMutex.RLock() + defer fake.createOfferMutex.RUnlock() + fake.onDataChannelMutex.RLock() + defer fake.onDataChannelMutex.RUnlock() + fake.onICECandidateMutex.RLock() + defer fake.onICECandidateMutex.RUnlock() + fake.onICEConnectionStateChangeMutex.RLock() + defer fake.onICEConnectionStateChangeMutex.RUnlock() + fake.onNegotiationNeededMutex.RLock() + defer fake.onNegotiationNeededMutex.RUnlock() + fake.onTrackMutex.RLock() + defer fake.onTrackMutex.RUnlock() + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() + fake.setLocalDescriptionMutex.RLock() + defer fake.setLocalDescriptionMutex.RUnlock() + fake.setRemoteDescriptionMutex.RLock() + defer fake.setRemoteDescriptionMutex.RUnlock() + fake.writeRTCPMutex.RLock() + defer fake.writeRTCPMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakePeerConnection) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ rtc.PeerConnection = new(FakePeerConnection) diff --git a/pkg/rtc/rtcfakes/fake_published_track.go b/pkg/rtc/rtcfakes/fake_published_track.go new file mode 100644 index 000000000..3ab07a2ef --- /dev/null +++ b/pkg/rtc/rtcfakes/fake_published_track.go @@ -0,0 +1,406 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package rtcfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc" + "github.com/livekit/livekit-server/proto/livekit" +) + +type FakePublishedTrack struct { + AddSubscriberStub func(rtc.Participant) error + addSubscriberMutex sync.RWMutex + addSubscriberArgsForCall []struct { + arg1 rtc.Participant + } + addSubscriberReturns struct { + result1 error + } + addSubscriberReturnsOnCall map[int]struct { + result1 error + } + IDStub func() string + iDMutex sync.RWMutex + iDArgsForCall []struct { + } + iDReturns struct { + result1 string + } + iDReturnsOnCall map[int]struct { + result1 string + } + KindStub func() livekit.TrackInfo_Type + kindMutex sync.RWMutex + kindArgsForCall []struct { + } + kindReturns struct { + result1 livekit.TrackInfo_Type + } + kindReturnsOnCall map[int]struct { + result1 livekit.TrackInfo_Type + } + RemoveAllSubscribersStub func() + removeAllSubscribersMutex sync.RWMutex + removeAllSubscribersArgsForCall []struct { + } + RemoveSubscriberStub func(string) + removeSubscriberMutex sync.RWMutex + removeSubscriberArgsForCall []struct { + arg1 string + } + StartStub func() + startMutex sync.RWMutex + startArgsForCall []struct { + } + StreamIDStub func() string + streamIDMutex sync.RWMutex + streamIDArgsForCall []struct { + } + streamIDReturns struct { + result1 string + } + streamIDReturnsOnCall map[int]struct { + result1 string + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakePublishedTrack) AddSubscriber(arg1 rtc.Participant) error { + fake.addSubscriberMutex.Lock() + ret, specificReturn := fake.addSubscriberReturnsOnCall[len(fake.addSubscriberArgsForCall)] + fake.addSubscriberArgsForCall = append(fake.addSubscriberArgsForCall, struct { + arg1 rtc.Participant + }{arg1}) + stub := fake.AddSubscriberStub + fakeReturns := fake.addSubscriberReturns + fake.recordInvocation("AddSubscriber", []interface{}{arg1}) + fake.addSubscriberMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePublishedTrack) AddSubscriberCallCount() int { + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + return len(fake.addSubscriberArgsForCall) +} + +func (fake *FakePublishedTrack) AddSubscriberCalls(stub func(rtc.Participant) error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = stub +} + +func (fake *FakePublishedTrack) AddSubscriberArgsForCall(i int) rtc.Participant { + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + argsForCall := fake.addSubscriberArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePublishedTrack) AddSubscriberReturns(result1 error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = nil + fake.addSubscriberReturns = struct { + result1 error + }{result1} +} + +func (fake *FakePublishedTrack) AddSubscriberReturnsOnCall(i int, result1 error) { + fake.addSubscriberMutex.Lock() + defer fake.addSubscriberMutex.Unlock() + fake.AddSubscriberStub = nil + if fake.addSubscriberReturnsOnCall == nil { + fake.addSubscriberReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.addSubscriberReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakePublishedTrack) ID() string { + fake.iDMutex.Lock() + ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] + fake.iDArgsForCall = append(fake.iDArgsForCall, struct { + }{}) + stub := fake.IDStub + fakeReturns := fake.iDReturns + fake.recordInvocation("ID", []interface{}{}) + fake.iDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePublishedTrack) IDCallCount() int { + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + return len(fake.iDArgsForCall) +} + +func (fake *FakePublishedTrack) IDCalls(stub func() string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = stub +} + +func (fake *FakePublishedTrack) IDReturns(result1 string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + fake.iDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakePublishedTrack) IDReturnsOnCall(i int, result1 string) { + fake.iDMutex.Lock() + defer fake.iDMutex.Unlock() + fake.IDStub = nil + if fake.iDReturnsOnCall == nil { + fake.iDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.iDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakePublishedTrack) Kind() livekit.TrackInfo_Type { + fake.kindMutex.Lock() + ret, specificReturn := fake.kindReturnsOnCall[len(fake.kindArgsForCall)] + fake.kindArgsForCall = append(fake.kindArgsForCall, struct { + }{}) + stub := fake.KindStub + fakeReturns := fake.kindReturns + fake.recordInvocation("Kind", []interface{}{}) + fake.kindMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePublishedTrack) KindCallCount() int { + fake.kindMutex.RLock() + defer fake.kindMutex.RUnlock() + return len(fake.kindArgsForCall) +} + +func (fake *FakePublishedTrack) KindCalls(stub func() livekit.TrackInfo_Type) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = stub +} + +func (fake *FakePublishedTrack) KindReturns(result1 livekit.TrackInfo_Type) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = nil + fake.kindReturns = struct { + result1 livekit.TrackInfo_Type + }{result1} +} + +func (fake *FakePublishedTrack) KindReturnsOnCall(i int, result1 livekit.TrackInfo_Type) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = nil + if fake.kindReturnsOnCall == nil { + fake.kindReturnsOnCall = make(map[int]struct { + result1 livekit.TrackInfo_Type + }) + } + fake.kindReturnsOnCall[i] = struct { + result1 livekit.TrackInfo_Type + }{result1} +} + +func (fake *FakePublishedTrack) RemoveAllSubscribers() { + fake.removeAllSubscribersMutex.Lock() + fake.removeAllSubscribersArgsForCall = append(fake.removeAllSubscribersArgsForCall, struct { + }{}) + stub := fake.RemoveAllSubscribersStub + fake.recordInvocation("RemoveAllSubscribers", []interface{}{}) + fake.removeAllSubscribersMutex.Unlock() + if stub != nil { + fake.RemoveAllSubscribersStub() + } +} + +func (fake *FakePublishedTrack) RemoveAllSubscribersCallCount() int { + fake.removeAllSubscribersMutex.RLock() + defer fake.removeAllSubscribersMutex.RUnlock() + return len(fake.removeAllSubscribersArgsForCall) +} + +func (fake *FakePublishedTrack) RemoveAllSubscribersCalls(stub func()) { + fake.removeAllSubscribersMutex.Lock() + defer fake.removeAllSubscribersMutex.Unlock() + fake.RemoveAllSubscribersStub = stub +} + +func (fake *FakePublishedTrack) RemoveSubscriber(arg1 string) { + fake.removeSubscriberMutex.Lock() + fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.RemoveSubscriberStub + fake.recordInvocation("RemoveSubscriber", []interface{}{arg1}) + fake.removeSubscriberMutex.Unlock() + if stub != nil { + fake.RemoveSubscriberStub(arg1) + } +} + +func (fake *FakePublishedTrack) RemoveSubscriberCallCount() int { + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + return len(fake.removeSubscriberArgsForCall) +} + +func (fake *FakePublishedTrack) RemoveSubscriberCalls(stub func(string)) { + fake.removeSubscriberMutex.Lock() + defer fake.removeSubscriberMutex.Unlock() + fake.RemoveSubscriberStub = stub +} + +func (fake *FakePublishedTrack) RemoveSubscriberArgsForCall(i int) string { + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + argsForCall := fake.removeSubscriberArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakePublishedTrack) Start() { + fake.startMutex.Lock() + fake.startArgsForCall = append(fake.startArgsForCall, struct { + }{}) + stub := fake.StartStub + fake.recordInvocation("Start", []interface{}{}) + fake.startMutex.Unlock() + if stub != nil { + fake.StartStub() + } +} + +func (fake *FakePublishedTrack) StartCallCount() int { + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + return len(fake.startArgsForCall) +} + +func (fake *FakePublishedTrack) StartCalls(stub func()) { + fake.startMutex.Lock() + defer fake.startMutex.Unlock() + fake.StartStub = stub +} + +func (fake *FakePublishedTrack) StreamID() string { + fake.streamIDMutex.Lock() + ret, specificReturn := fake.streamIDReturnsOnCall[len(fake.streamIDArgsForCall)] + fake.streamIDArgsForCall = append(fake.streamIDArgsForCall, struct { + }{}) + stub := fake.StreamIDStub + fakeReturns := fake.streamIDReturns + fake.recordInvocation("StreamID", []interface{}{}) + fake.streamIDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePublishedTrack) StreamIDCallCount() int { + fake.streamIDMutex.RLock() + defer fake.streamIDMutex.RUnlock() + return len(fake.streamIDArgsForCall) +} + +func (fake *FakePublishedTrack) StreamIDCalls(stub func() string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = stub +} + +func (fake *FakePublishedTrack) StreamIDReturns(result1 string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = nil + fake.streamIDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakePublishedTrack) StreamIDReturnsOnCall(i int, result1 string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = nil + if fake.streamIDReturnsOnCall == nil { + fake.streamIDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.streamIDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakePublishedTrack) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.addSubscriberMutex.RLock() + defer fake.addSubscriberMutex.RUnlock() + fake.iDMutex.RLock() + defer fake.iDMutex.RUnlock() + fake.kindMutex.RLock() + defer fake.kindMutex.RUnlock() + fake.removeAllSubscribersMutex.RLock() + defer fake.removeAllSubscribersMutex.RUnlock() + fake.removeSubscriberMutex.RLock() + defer fake.removeSubscriberMutex.RUnlock() + fake.startMutex.RLock() + defer fake.startMutex.RUnlock() + fake.streamIDMutex.RLock() + defer fake.streamIDMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakePublishedTrack) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ rtc.PublishedTrack = new(FakePublishedTrack) diff --git a/pkg/rtc/rtcfakes/fake_signal_connection.go b/pkg/rtc/rtcfakes/fake_signal_connection.go new file mode 100644 index 000000000..0c505ecf3 --- /dev/null +++ b/pkg/rtc/rtcfakes/fake_signal_connection.go @@ -0,0 +1,182 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package rtcfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc" + "github.com/livekit/livekit-server/proto/livekit" +) + +type FakeSignalConnection struct { + ReadRequestStub func() (*livekit.SignalRequest, error) + readRequestMutex sync.RWMutex + readRequestArgsForCall []struct { + } + readRequestReturns struct { + result1 *livekit.SignalRequest + result2 error + } + readRequestReturnsOnCall map[int]struct { + result1 *livekit.SignalRequest + result2 error + } + WriteResponseStub func(*livekit.SignalResponse) error + writeResponseMutex sync.RWMutex + writeResponseArgsForCall []struct { + arg1 *livekit.SignalResponse + } + writeResponseReturns struct { + result1 error + } + writeResponseReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeSignalConnection) ReadRequest() (*livekit.SignalRequest, error) { + fake.readRequestMutex.Lock() + ret, specificReturn := fake.readRequestReturnsOnCall[len(fake.readRequestArgsForCall)] + fake.readRequestArgsForCall = append(fake.readRequestArgsForCall, struct { + }{}) + stub := fake.ReadRequestStub + fakeReturns := fake.readRequestReturns + fake.recordInvocation("ReadRequest", []interface{}{}) + fake.readRequestMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1, ret.result2 + } + return fakeReturns.result1, fakeReturns.result2 +} + +func (fake *FakeSignalConnection) ReadRequestCallCount() int { + fake.readRequestMutex.RLock() + defer fake.readRequestMutex.RUnlock() + return len(fake.readRequestArgsForCall) +} + +func (fake *FakeSignalConnection) ReadRequestCalls(stub func() (*livekit.SignalRequest, error)) { + fake.readRequestMutex.Lock() + defer fake.readRequestMutex.Unlock() + fake.ReadRequestStub = stub +} + +func (fake *FakeSignalConnection) ReadRequestReturns(result1 *livekit.SignalRequest, result2 error) { + fake.readRequestMutex.Lock() + defer fake.readRequestMutex.Unlock() + fake.ReadRequestStub = nil + fake.readRequestReturns = struct { + result1 *livekit.SignalRequest + result2 error + }{result1, result2} +} + +func (fake *FakeSignalConnection) ReadRequestReturnsOnCall(i int, result1 *livekit.SignalRequest, result2 error) { + fake.readRequestMutex.Lock() + defer fake.readRequestMutex.Unlock() + fake.ReadRequestStub = nil + if fake.readRequestReturnsOnCall == nil { + fake.readRequestReturnsOnCall = make(map[int]struct { + result1 *livekit.SignalRequest + result2 error + }) + } + fake.readRequestReturnsOnCall[i] = struct { + result1 *livekit.SignalRequest + result2 error + }{result1, result2} +} + +func (fake *FakeSignalConnection) WriteResponse(arg1 *livekit.SignalResponse) error { + fake.writeResponseMutex.Lock() + ret, specificReturn := fake.writeResponseReturnsOnCall[len(fake.writeResponseArgsForCall)] + fake.writeResponseArgsForCall = append(fake.writeResponseArgsForCall, struct { + arg1 *livekit.SignalResponse + }{arg1}) + stub := fake.WriteResponseStub + fakeReturns := fake.writeResponseReturns + fake.recordInvocation("WriteResponse", []interface{}{arg1}) + fake.writeResponseMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeSignalConnection) WriteResponseCallCount() int { + fake.writeResponseMutex.RLock() + defer fake.writeResponseMutex.RUnlock() + return len(fake.writeResponseArgsForCall) +} + +func (fake *FakeSignalConnection) WriteResponseCalls(stub func(*livekit.SignalResponse) error) { + fake.writeResponseMutex.Lock() + defer fake.writeResponseMutex.Unlock() + fake.WriteResponseStub = stub +} + +func (fake *FakeSignalConnection) WriteResponseArgsForCall(i int) *livekit.SignalResponse { + fake.writeResponseMutex.RLock() + defer fake.writeResponseMutex.RUnlock() + argsForCall := fake.writeResponseArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeSignalConnection) WriteResponseReturns(result1 error) { + fake.writeResponseMutex.Lock() + defer fake.writeResponseMutex.Unlock() + fake.WriteResponseStub = nil + fake.writeResponseReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeSignalConnection) WriteResponseReturnsOnCall(i int, result1 error) { + fake.writeResponseMutex.Lock() + defer fake.writeResponseMutex.Unlock() + fake.WriteResponseStub = nil + if fake.writeResponseReturnsOnCall == nil { + fake.writeResponseReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.writeResponseReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeSignalConnection) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.readRequestMutex.RLock() + defer fake.readRequestMutex.RUnlock() + fake.writeResponseMutex.RLock() + defer fake.writeResponseMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeSignalConnection) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ rtc.SignalConnection = new(FakeSignalConnection) diff --git a/pkg/rtc/rtcfakes/fake_websocket_client.go b/pkg/rtc/rtcfakes/fake_websocket_client.go new file mode 100644 index 000000000..f80bc9755 --- /dev/null +++ b/pkg/rtc/rtcfakes/fake_websocket_client.go @@ -0,0 +1,277 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package rtcfakes + +import ( + "sync" + "time" + + "github.com/livekit/livekit-server/pkg/rtc" +) + +type FakeWebsocketClient struct { + ReadMessageStub func() (int, []byte, error) + readMessageMutex sync.RWMutex + readMessageArgsForCall []struct { + } + readMessageReturns struct { + result1 int + result2 []byte + result3 error + } + readMessageReturnsOnCall map[int]struct { + result1 int + result2 []byte + result3 error + } + WriteControlStub func(int, []byte, time.Time) error + writeControlMutex sync.RWMutex + writeControlArgsForCall []struct { + arg1 int + arg2 []byte + arg3 time.Time + } + writeControlReturns struct { + result1 error + } + writeControlReturnsOnCall map[int]struct { + result1 error + } + WriteMessageStub func(int, []byte) error + writeMessageMutex sync.RWMutex + writeMessageArgsForCall []struct { + arg1 int + arg2 []byte + } + writeMessageReturns struct { + result1 error + } + writeMessageReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeWebsocketClient) ReadMessage() (int, []byte, error) { + fake.readMessageMutex.Lock() + ret, specificReturn := fake.readMessageReturnsOnCall[len(fake.readMessageArgsForCall)] + fake.readMessageArgsForCall = append(fake.readMessageArgsForCall, struct { + }{}) + stub := fake.ReadMessageStub + fakeReturns := fake.readMessageReturns + fake.recordInvocation("ReadMessage", []interface{}{}) + fake.readMessageMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1, ret.result2, ret.result3 + } + return fakeReturns.result1, fakeReturns.result2, fakeReturns.result3 +} + +func (fake *FakeWebsocketClient) ReadMessageCallCount() int { + fake.readMessageMutex.RLock() + defer fake.readMessageMutex.RUnlock() + return len(fake.readMessageArgsForCall) +} + +func (fake *FakeWebsocketClient) ReadMessageCalls(stub func() (int, []byte, error)) { + fake.readMessageMutex.Lock() + defer fake.readMessageMutex.Unlock() + fake.ReadMessageStub = stub +} + +func (fake *FakeWebsocketClient) ReadMessageReturns(result1 int, result2 []byte, result3 error) { + fake.readMessageMutex.Lock() + defer fake.readMessageMutex.Unlock() + fake.ReadMessageStub = nil + fake.readMessageReturns = struct { + result1 int + result2 []byte + result3 error + }{result1, result2, result3} +} + +func (fake *FakeWebsocketClient) ReadMessageReturnsOnCall(i int, result1 int, result2 []byte, result3 error) { + fake.readMessageMutex.Lock() + defer fake.readMessageMutex.Unlock() + fake.ReadMessageStub = nil + if fake.readMessageReturnsOnCall == nil { + fake.readMessageReturnsOnCall = make(map[int]struct { + result1 int + result2 []byte + result3 error + }) + } + fake.readMessageReturnsOnCall[i] = struct { + result1 int + result2 []byte + result3 error + }{result1, result2, result3} +} + +func (fake *FakeWebsocketClient) WriteControl(arg1 int, arg2 []byte, arg3 time.Time) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.writeControlMutex.Lock() + ret, specificReturn := fake.writeControlReturnsOnCall[len(fake.writeControlArgsForCall)] + fake.writeControlArgsForCall = append(fake.writeControlArgsForCall, struct { + arg1 int + arg2 []byte + arg3 time.Time + }{arg1, arg2Copy, arg3}) + stub := fake.WriteControlStub + fakeReturns := fake.writeControlReturns + fake.recordInvocation("WriteControl", []interface{}{arg1, arg2Copy, arg3}) + fake.writeControlMutex.Unlock() + if stub != nil { + return stub(arg1, arg2, arg3) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeWebsocketClient) WriteControlCallCount() int { + fake.writeControlMutex.RLock() + defer fake.writeControlMutex.RUnlock() + return len(fake.writeControlArgsForCall) +} + +func (fake *FakeWebsocketClient) WriteControlCalls(stub func(int, []byte, time.Time) error) { + fake.writeControlMutex.Lock() + defer fake.writeControlMutex.Unlock() + fake.WriteControlStub = stub +} + +func (fake *FakeWebsocketClient) WriteControlArgsForCall(i int) (int, []byte, time.Time) { + fake.writeControlMutex.RLock() + defer fake.writeControlMutex.RUnlock() + argsForCall := fake.writeControlArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeWebsocketClient) WriteControlReturns(result1 error) { + fake.writeControlMutex.Lock() + defer fake.writeControlMutex.Unlock() + fake.WriteControlStub = nil + fake.writeControlReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeWebsocketClient) WriteControlReturnsOnCall(i int, result1 error) { + fake.writeControlMutex.Lock() + defer fake.writeControlMutex.Unlock() + fake.WriteControlStub = nil + if fake.writeControlReturnsOnCall == nil { + fake.writeControlReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.writeControlReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeWebsocketClient) WriteMessage(arg1 int, arg2 []byte) error { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.writeMessageMutex.Lock() + ret, specificReturn := fake.writeMessageReturnsOnCall[len(fake.writeMessageArgsForCall)] + fake.writeMessageArgsForCall = append(fake.writeMessageArgsForCall, struct { + arg1 int + arg2 []byte + }{arg1, arg2Copy}) + stub := fake.WriteMessageStub + fakeReturns := fake.writeMessageReturns + fake.recordInvocation("WriteMessage", []interface{}{arg1, arg2Copy}) + fake.writeMessageMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeWebsocketClient) WriteMessageCallCount() int { + fake.writeMessageMutex.RLock() + defer fake.writeMessageMutex.RUnlock() + return len(fake.writeMessageArgsForCall) +} + +func (fake *FakeWebsocketClient) WriteMessageCalls(stub func(int, []byte) error) { + fake.writeMessageMutex.Lock() + defer fake.writeMessageMutex.Unlock() + fake.WriteMessageStub = stub +} + +func (fake *FakeWebsocketClient) WriteMessageArgsForCall(i int) (int, []byte) { + fake.writeMessageMutex.RLock() + defer fake.writeMessageMutex.RUnlock() + argsForCall := fake.writeMessageArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeWebsocketClient) WriteMessageReturns(result1 error) { + fake.writeMessageMutex.Lock() + defer fake.writeMessageMutex.Unlock() + fake.WriteMessageStub = nil + fake.writeMessageReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeWebsocketClient) WriteMessageReturnsOnCall(i int, result1 error) { + fake.writeMessageMutex.Lock() + defer fake.writeMessageMutex.Unlock() + fake.WriteMessageStub = nil + if fake.writeMessageReturnsOnCall == nil { + fake.writeMessageReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.writeMessageReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeWebsocketClient) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.readMessageMutex.RLock() + defer fake.readMessageMutex.RUnlock() + fake.writeControlMutex.RLock() + defer fake.writeControlMutex.RUnlock() + fake.writeMessageMutex.RLock() + defer fake.writeMessageMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeWebsocketClient) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ rtc.WebsocketClient = new(FakeWebsocketClient) diff --git a/tools/tools.go b/tools/tools.go new file mode 100644 index 000000000..c426f7184 --- /dev/null +++ b/tools/tools.go @@ -0,0 +1,7 @@ +// +build tools + +package tools + +import ( + _ "github.com/maxbrunsfeld/counterfeiter/v6" +)