From 7d02c01fd86142118117d81b8e55982c6cc70d8e Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sat, 13 Mar 2021 22:01:51 -0800 Subject: [PATCH] refactor - moved common code to livekit/protocol --- .gitignore | 1 - bootstrap.sh | 19 +- cmd/cli/client/client.go | 4 +- cmd/cli/commands/room.go | 4 +- cmd/cli/commands/rtc.go | 2 +- cmd/cli/commands/token.go | 2 +- cmd/cli/commands/utils.go | 2 +- cmd/server/main.go | 4 +- go.mod | 5 +- go.sum | 19 +- magefile.go | 24 +- pkg/auth/accesstoken.go | 81 - pkg/auth/accesstoken_test.go | 69 - pkg/auth/authfakes/fake_key_provider.go | 176 -- pkg/auth/authfakes/fake_token_verifier.go | 181 -- pkg/auth/grants.go | 18 - pkg/auth/interfaces.go | 23 - pkg/auth/provider.go | 38 - pkg/auth/provider_test.go | 40 - pkg/auth/verifier.go | 61 - pkg/auth/verifier_test.go | 77 - pkg/routing/interfaces.go | 2 +- pkg/routing/localrouter.go | 4 +- pkg/routing/messagechannel.go | 2 +- pkg/routing/messagechannel_test.go | 2 +- pkg/routing/node.go | 4 +- pkg/routing/randomselector.go | 3 +- pkg/routing/redis.go | 4 +- pkg/routing/redisrouter.go | 4 +- .../routingfakes/fake_node_selector.go | 2 +- pkg/routing/routingfakes/fake_router.go | 2 +- pkg/routing/utils.go | 3 +- pkg/routing/utils_test.go | 2 +- pkg/rtc/datatrack.go | 2 +- pkg/rtc/helper_test.go | 4 +- pkg/rtc/mediatrack.go | 4 +- pkg/rtc/participant.go | 4 +- pkg/rtc/participant_internal_test.go | 2 +- pkg/rtc/room.go | 4 +- pkg/rtc/room_test.go | 2 +- pkg/rtc/subscribedtrack.go | 4 +- pkg/rtc/transport.go | 2 +- pkg/rtc/types/interfaces.go | 2 +- pkg/rtc/types/typesfakes/fake_participant.go | 2 +- .../types/typesfakes/fake_published_track.go | 2 +- .../types/typesfakes/fake_subscribed_track.go | 2 +- pkg/rtc/utils.go | 2 +- pkg/service/auth.go | 2 +- pkg/service/auth_test.go | 4 +- pkg/service/localroomstore.go | 2 +- pkg/service/redisroomstore.go | 2 +- pkg/service/redisroomstore_test.go | 2 +- pkg/service/roommanager.go | 4 +- pkg/service/roomservice.go | 2 +- pkg/service/roomstore.go | 2 +- pkg/service/rtcservice.go | 2 +- pkg/service/server.go | 6 +- pkg/service/servicefakes/fake_room_store.go | 2 +- pkg/service/utils.go | 2 +- pkg/service/wire.go | 2 +- pkg/service/wire_gen.go | 2 +- pkg/service/wsprotocol.go | 2 +- pkg/utils/cachedredis.go | 64 - pkg/utils/id.go | 29 - pkg/utils/secret.go | 19 - pkg/utils/sync.go | 63 - pkg/utils/sync_test.go | 46 - proto/internal.pb.go | 802 +++++ proto/internal.proto | 64 - proto/model.pb.go | 614 ++++ proto/model.proto | 51 - proto/room.pb.go | 879 ++++++ proto/room.proto | 76 - proto/room.twirp.go | 2732 +++++++++++++++++ proto/rtc.pb.go | 1639 ++++++++++ proto/rtc.proto | 127 - test/integration_helpers.go | 6 +- test/multinode_test.go | 6 +- test/turn_test.go | 4 +- 79 files changed, 6771 insertions(+), 1410 deletions(-) delete mode 100644 pkg/auth/accesstoken.go delete mode 100644 pkg/auth/accesstoken_test.go delete mode 100644 pkg/auth/authfakes/fake_key_provider.go delete mode 100644 pkg/auth/authfakes/fake_token_verifier.go delete mode 100644 pkg/auth/grants.go delete mode 100644 pkg/auth/interfaces.go delete mode 100644 pkg/auth/provider.go delete mode 100644 pkg/auth/provider_test.go delete mode 100644 pkg/auth/verifier.go delete mode 100644 pkg/auth/verifier_test.go delete mode 100644 pkg/utils/cachedredis.go delete mode 100644 pkg/utils/id.go delete mode 100644 pkg/utils/secret.go delete mode 100644 pkg/utils/sync.go delete mode 100644 pkg/utils/sync_test.go create mode 100644 proto/internal.pb.go delete mode 100644 proto/internal.proto create mode 100644 proto/model.pb.go delete mode 100644 proto/model.proto create mode 100644 proto/room.pb.go delete mode 100644 proto/room.proto create mode 100644 proto/room.twirp.go create mode 100644 proto/rtc.pb.go delete mode 100644 proto/rtc.proto diff --git a/.gitignore b/.gitignore index d61f1a40..cc006912 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out livekit-server -proto/livekit # Dependency directories (remove the comment below to include it) # vendor/ diff --git a/bootstrap.sh b/bootstrap.sh index 5d7f3a4d..a23f0140 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,12 +1,17 @@ #!/bin/sh -cd /tmp -git clone https://github.com/magefile/mage -cd mage -go run bootstrap.go -rm -rf /tmp/mage - if ! command -v mage &> /dev/null then - echo "Ensure ${GOPATH}/bin is in your \$PATH" + pushd /tmp + git clone https://github.com/magefile/mage + cd mage + go run bootstrap.go + rm -rf /tmp/mage + popd +fi + +if ! command -v mage &> /dev/null +then + echo "Ensure `go env GOPATH`/bin is in your \$PATH" + exit 1 fi diff --git a/cmd/cli/client/client.go b/cmd/cli/client/client.go index f28f773a..9b031472 100644 --- a/cmd/cli/client/client.go +++ b/cmd/cli/client/client.go @@ -21,8 +21,8 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) type RTCClient struct { diff --git a/cmd/cli/commands/room.go b/cmd/cli/commands/room.go index b8b5f9f7..aef34833 100644 --- a/cmd/cli/commands/room.go +++ b/cmd/cli/commands/room.go @@ -9,9 +9,9 @@ import ( "github.com/urfave/cli/v2" "github.com/livekit/livekit-server/cmd/cli/client" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/auth" ) var ( diff --git a/cmd/cli/commands/rtc.go b/cmd/cli/commands/rtc.go index 4a4c97c5..251b3cb4 100644 --- a/cmd/cli/commands/rtc.go +++ b/cmd/cli/commands/rtc.go @@ -10,8 +10,8 @@ import ( "github.com/urfave/cli/v2" "github.com/livekit/livekit-server/cmd/cli/client" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/logger" + "github.com/livekit/protocol/auth" ) var ( diff --git a/cmd/cli/commands/token.go b/cmd/cli/commands/token.go index 0846ec34..82baf71d 100644 --- a/cmd/cli/commands/token.go +++ b/cmd/cli/commands/token.go @@ -6,7 +6,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/livekit/livekit-server/pkg/auth" + "github.com/livekit/protocol/auth" ) var ( diff --git a/cmd/cli/commands/utils.go b/cmd/cli/commands/utils.go index e0ab185b..e7e776d1 100644 --- a/cmd/cli/commands/utils.go +++ b/cmd/cli/commands/utils.go @@ -10,7 +10,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/livekit/livekit-server/pkg/auth" + "github.com/livekit/protocol/auth" ) var ( diff --git a/cmd/server/main.go b/cmd/server/main.go index 0e495727..ac95f3e6 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -17,13 +17,13 @@ import ( "github.com/pkg/errors" "github.com/urfave/cli/v2" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/service" - "github.com/livekit/livekit-server/pkg/utils" "github.com/livekit/livekit-server/version" + "github.com/livekit/protocol/auth" + "github.com/livekit/protocol/utils" ) func main() { diff --git a/go.mod b/go.mod index 2ea449fd..ae8d9dfe 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/golang/protobuf v1.4.3 github.com/google/wire v0.4.0 github.com/gorilla/websocket v1.4.2 - github.com/karlseguin/ccache/v2 v2.0.7 - github.com/lithammer/shortuuid/v3 v3.0.4 + github.com/lithammer/shortuuid/v3 v3.0.6 + github.com/livekit/protocol v0.1.0 github.com/lytics/base62 v0.0.0-20180808010106-0ee4de5a5d6d github.com/magefile/mage v1.11.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 @@ -31,6 +31,5 @@ require ( golang.org/x/mod v0.4.0 // indirect golang.org/x/tools v0.0.0-20201222163215-f2e330f49058 // indirect google.golang.org/protobuf v1.25.0 - gopkg.in/square/go-jose.v2 v2.5.1 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff --git a/go.sum b/go.sum index d9e2ce48..00a159ec 100644 --- a/go.sum +++ b/go.sum @@ -140,8 +140,9 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -149,7 +150,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/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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= @@ -210,10 +210,6 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/karlseguin/ccache/v2 v2.0.7 h1:y5Pfi4eiyYCOD6LS/Kj+o6Nb4M5Ngpw9qFQs+v44ZYM= -github.com/karlseguin/ccache/v2 v2.0.7/go.mod h1:2BDThcfQMf/c0jnZowt16eW405XIqZPavt+HoYEtcxQ= -github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003 h1:vJ0Snvo+SLMY72r5J4sEfkuE7AFbixEP2qRbEcum/wA= -github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYTFUbwRAV8= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -225,8 +221,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lithammer/shortuuid/v3 v3.0.4 h1:uj4xhotfY92Y1Oa6n6HUiFn87CdoEHYUlTy0+IgbLrs= -github.com/lithammer/shortuuid/v3 v3.0.4/go.mod h1:RviRjexKqIzx/7r1peoAITm6m7gnif/h+0zmolKJjzw= +github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA= +github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= +github.com/livekit/protocol v0.1.0 h1:BBJFcnuXI0Q2yrLC40U92f7lIrjUEVriewmlNzPSfcM= +github.com/livekit/protocol v0.1.0/go.mod h1:dB4MovJpCr9muBQAJUOhzgVqsrkHKf3/C0O6v/M08+I= github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ= github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -447,8 +445,6 @@ github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= 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/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 h1:3UeQBvD0TFrlVjOeLOBz+CPAI8dnbqNSVwUwRrkp7vQ= -github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0/go.mod h1:IXCdmsXIht47RaVFLEdVnh1t+pgYtTAhQGj73kz+2DM= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -485,8 +481,9 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/magefile.go b/magefile.go index 23e6fa32..49014024 100644 --- a/magefile.go +++ b/magefile.go @@ -43,11 +43,11 @@ func Deps() error { // regenerate protobuf func Proto() error { - updated, err := target.Path("proto/livekit/model.pb.go", - "proto/model.proto", - "proto/room.proto", - "proto/rtc.proto", - "proto/internal.proto", + updated, err := target.Path("proto/model.pb.go", + "../protocol/model.proto", + "../protocol/room.proto", + "../protocol/rtc.proto", + "../protocol/internal.proto", ) if err != nil { return err @@ -57,7 +57,7 @@ func Proto() error { } fmt.Println("generating protobuf") - target := "proto/livekit" + target := "proto" if err := os.MkdirAll(target, 0755); err != nil { return err } @@ -83,8 +83,8 @@ func Proto() error { "--twirp_opt=paths=source_relative", "--plugin=go="+protoc_go_path, "--plugin=twirp="+twirp_path, - "-I=proto", - "proto/room.proto", + "-I=../protocol", + "../protocol/room.proto", ) connectStd(cmd) if err := cmd.Run(); err != nil { @@ -96,10 +96,10 @@ func Proto() error { "--go_out", target, "--go_opt=paths=source_relative", "--plugin=go="+protoc_go_path, - "-I=proto", - "proto/rtc.proto", - "proto/internal.proto", - "proto/model.proto", + "-I=../protocol", + "../protocol/rtc.proto", + "../protocol/internal.proto", + "../protocol/model.proto", ) connectStd(cmd) if err := cmd.Run(); err != nil { diff --git a/pkg/auth/accesstoken.go b/pkg/auth/accesstoken.go deleted file mode 100644 index 15c8f7b7..00000000 --- a/pkg/auth/accesstoken.go +++ /dev/null @@ -1,81 +0,0 @@ -package auth - -import ( - "time" - - "gopkg.in/square/go-jose.v2" - "gopkg.in/square/go-jose.v2/jwt" -) - -const ( - defaultValidDuration = 6 * time.Hour -) - -// Signer that produces token signed with API key and secret -type AccessToken struct { - apiKey string - secret string - identity string - videoGrant *VideoGrant - metadata map[string]interface{} - validFor time.Duration -} - -func NewAccessToken(key string, secret string) *AccessToken { - return &AccessToken{ - apiKey: key, - secret: secret, - } -} - -func (t *AccessToken) SetIdentity(identity string) *AccessToken { - t.identity = identity - return t -} - -func (t *AccessToken) SetValidFor(duration time.Duration) *AccessToken { - t.validFor = duration - return t -} - -func (t *AccessToken) AddGrant(grant *VideoGrant) *AccessToken { - t.videoGrant = grant - return t -} - -func (t *AccessToken) SetMetadata(md map[string]interface{}) *AccessToken { - t.metadata = md - return t -} - -func (t *AccessToken) ToJWT() (string, error) { - if t.apiKey == "" || t.secret == "" { - return "", ErrKeysMissing - } - - sig, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.HS256, Key: []byte(t.secret)}, - (&jose.SignerOptions{}).WithType("JWT")) - if err != nil { - return "", err - } - - validFor := defaultValidDuration - if t.validFor > 0 { - validFor = t.validFor - } - - cl := jwt.Claims{ - Issuer: t.apiKey, - NotBefore: jwt.NewNumericDate(time.Now()), - Expiry: jwt.NewNumericDate(time.Now().Add(validFor)), - ID: t.identity, - } - grants := &ClaimGrants{} - if t.videoGrant != nil { - grants.Video = t.videoGrant - } - if t.metadata != nil { - grants.Metadata = t.metadata - } - return jwt.Signed(sig).Claims(cl).Claims(grants).CompactSerialize() -} diff --git a/pkg/auth/accesstoken_test.go b/pkg/auth/accesstoken_test.go deleted file mode 100644 index 8c986714..00000000 --- a/pkg/auth/accesstoken_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package auth_test - -import ( - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "gopkg.in/square/go-jose.v2/jwt" - - "github.com/livekit/livekit-server/pkg/auth" - "github.com/livekit/livekit-server/pkg/utils" -) - -func TestAccessToken(t *testing.T) { - t.Parallel() - - t.Run("keys must be set", func(t *testing.T) { - token := auth.NewAccessToken("", "") - _, err := token.ToJWT() - assert.Equal(t, auth.ErrKeysMissing, err) - }) - - t.Run("generates a decodeable key", func(t *testing.T) { - apiKey, secret := apiKeypair() - videoGrant := &auth.VideoGrant{RoomJoin: true, Room: "myroom"} - at := auth.NewAccessToken(apiKey, secret). - AddGrant(videoGrant). - SetValidFor(time.Minute * 5). - SetIdentity("user") - value, err := at.ToJWT() - //fmt.Println(raw) - assert.NoError(t, err) - - assert.Len(t, strings.Split(value, "."), 3) - - // ensure it's a valid JWT - token, err := jwt.ParseSigned(value) - assert.NoError(t, err) - - decodedGrant := auth.ClaimGrants{} - err = token.UnsafeClaimsWithoutVerification(&decodedGrant) - assert.NoError(t, err) - - assert.EqualValues(t, videoGrant, decodedGrant.Video) - }) - - t.Run("default validity should be more than a minute", func(t *testing.T) { - apiKey, secret := apiKeypair() - videoGrant := &auth.VideoGrant{RoomJoin: true, Room: "myroom"} - at := auth.NewAccessToken(apiKey, secret). - AddGrant(videoGrant) - value, err := at.ToJWT() - token, err := jwt.ParseSigned(value) - - claim := jwt.Claims{} - decodedGrant := auth.ClaimGrants{} - err = token.UnsafeClaimsWithoutVerification(&claim, &decodedGrant) - assert.NoError(t, err) - assert.EqualValues(t, videoGrant, decodedGrant.Video) - - // default validity - assert.True(t, claim.Expiry.Time().Sub(claim.IssuedAt.Time()) > time.Minute) - }) -} - -func apiKeypair() (string, string) { - return utils.NewGuid(utils.APIKeyPrefix), utils.RandomSecret() -} diff --git a/pkg/auth/authfakes/fake_key_provider.go b/pkg/auth/authfakes/fake_key_provider.go deleted file mode 100644 index 5f68e9e2..00000000 --- a/pkg/auth/authfakes/fake_key_provider.go +++ /dev/null @@ -1,176 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package authfakes - -import ( - "sync" - - "github.com/livekit/livekit-server/pkg/auth" -) - -type FakeKeyProvider struct { - GetSecretStub func(string) string - getSecretMutex sync.RWMutex - getSecretArgsForCall []struct { - arg1 string - } - getSecretReturns struct { - result1 string - } - getSecretReturnsOnCall map[int]struct { - result1 string - } - NumKeysStub func() int - numKeysMutex sync.RWMutex - numKeysArgsForCall []struct { - } - numKeysReturns struct { - result1 int - } - numKeysReturnsOnCall map[int]struct { - result1 int - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeKeyProvider) GetSecret(arg1 string) string { - fake.getSecretMutex.Lock() - ret, specificReturn := fake.getSecretReturnsOnCall[len(fake.getSecretArgsForCall)] - fake.getSecretArgsForCall = append(fake.getSecretArgsForCall, struct { - arg1 string - }{arg1}) - stub := fake.GetSecretStub - fakeReturns := fake.getSecretReturns - fake.recordInvocation("GetSecret", []interface{}{arg1}) - fake.getSecretMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeKeyProvider) GetSecretCallCount() int { - fake.getSecretMutex.RLock() - defer fake.getSecretMutex.RUnlock() - return len(fake.getSecretArgsForCall) -} - -func (fake *FakeKeyProvider) GetSecretCalls(stub func(string) string) { - fake.getSecretMutex.Lock() - defer fake.getSecretMutex.Unlock() - fake.GetSecretStub = stub -} - -func (fake *FakeKeyProvider) GetSecretArgsForCall(i int) string { - fake.getSecretMutex.RLock() - defer fake.getSecretMutex.RUnlock() - argsForCall := fake.getSecretArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeKeyProvider) GetSecretReturns(result1 string) { - fake.getSecretMutex.Lock() - defer fake.getSecretMutex.Unlock() - fake.GetSecretStub = nil - fake.getSecretReturns = struct { - result1 string - }{result1} -} - -func (fake *FakeKeyProvider) GetSecretReturnsOnCall(i int, result1 string) { - fake.getSecretMutex.Lock() - defer fake.getSecretMutex.Unlock() - fake.GetSecretStub = nil - if fake.getSecretReturnsOnCall == nil { - fake.getSecretReturnsOnCall = make(map[int]struct { - result1 string - }) - } - fake.getSecretReturnsOnCall[i] = struct { - result1 string - }{result1} -} - -func (fake *FakeKeyProvider) NumKeys() int { - fake.numKeysMutex.Lock() - ret, specificReturn := fake.numKeysReturnsOnCall[len(fake.numKeysArgsForCall)] - fake.numKeysArgsForCall = append(fake.numKeysArgsForCall, struct { - }{}) - stub := fake.NumKeysStub - fakeReturns := fake.numKeysReturns - fake.recordInvocation("NumKeys", []interface{}{}) - fake.numKeysMutex.Unlock() - if stub != nil { - return stub() - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeKeyProvider) NumKeysCallCount() int { - fake.numKeysMutex.RLock() - defer fake.numKeysMutex.RUnlock() - return len(fake.numKeysArgsForCall) -} - -func (fake *FakeKeyProvider) NumKeysCalls(stub func() int) { - fake.numKeysMutex.Lock() - defer fake.numKeysMutex.Unlock() - fake.NumKeysStub = stub -} - -func (fake *FakeKeyProvider) NumKeysReturns(result1 int) { - fake.numKeysMutex.Lock() - defer fake.numKeysMutex.Unlock() - fake.NumKeysStub = nil - fake.numKeysReturns = struct { - result1 int - }{result1} -} - -func (fake *FakeKeyProvider) NumKeysReturnsOnCall(i int, result1 int) { - fake.numKeysMutex.Lock() - defer fake.numKeysMutex.Unlock() - fake.NumKeysStub = nil - if fake.numKeysReturnsOnCall == nil { - fake.numKeysReturnsOnCall = make(map[int]struct { - result1 int - }) - } - fake.numKeysReturnsOnCall[i] = struct { - result1 int - }{result1} -} - -func (fake *FakeKeyProvider) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.getSecretMutex.RLock() - defer fake.getSecretMutex.RUnlock() - fake.numKeysMutex.RLock() - defer fake.numKeysMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeKeyProvider) 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 _ auth.KeyProvider = new(FakeKeyProvider) diff --git a/pkg/auth/authfakes/fake_token_verifier.go b/pkg/auth/authfakes/fake_token_verifier.go deleted file mode 100644 index 4ffc42b9..00000000 --- a/pkg/auth/authfakes/fake_token_verifier.go +++ /dev/null @@ -1,181 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package authfakes - -import ( - "sync" - - "github.com/livekit/livekit-server/pkg/auth" -) - -type FakeTokenVerifier struct { - IdentityStub func() string - identityMutex sync.RWMutex - identityArgsForCall []struct { - } - identityReturns struct { - result1 string - } - identityReturnsOnCall map[int]struct { - result1 string - } - VerifyStub func(interface{}) (*auth.ClaimGrants, error) - verifyMutex sync.RWMutex - verifyArgsForCall []struct { - arg1 interface{} - } - verifyReturns struct { - result1 *auth.ClaimGrants - result2 error - } - verifyReturnsOnCall map[int]struct { - result1 *auth.ClaimGrants - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeTokenVerifier) Identity() string { - fake.identityMutex.Lock() - ret, specificReturn := fake.identityReturnsOnCall[len(fake.identityArgsForCall)] - fake.identityArgsForCall = append(fake.identityArgsForCall, struct { - }{}) - stub := fake.IdentityStub - fakeReturns := fake.identityReturns - fake.recordInvocation("Identity", []interface{}{}) - fake.identityMutex.Unlock() - if stub != nil { - return stub() - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeTokenVerifier) IdentityCallCount() int { - fake.identityMutex.RLock() - defer fake.identityMutex.RUnlock() - return len(fake.identityArgsForCall) -} - -func (fake *FakeTokenVerifier) IdentityCalls(stub func() string) { - fake.identityMutex.Lock() - defer fake.identityMutex.Unlock() - fake.IdentityStub = stub -} - -func (fake *FakeTokenVerifier) IdentityReturns(result1 string) { - fake.identityMutex.Lock() - defer fake.identityMutex.Unlock() - fake.IdentityStub = nil - fake.identityReturns = struct { - result1 string - }{result1} -} - -func (fake *FakeTokenVerifier) IdentityReturnsOnCall(i int, result1 string) { - fake.identityMutex.Lock() - defer fake.identityMutex.Unlock() - fake.IdentityStub = nil - if fake.identityReturnsOnCall == nil { - fake.identityReturnsOnCall = make(map[int]struct { - result1 string - }) - } - fake.identityReturnsOnCall[i] = struct { - result1 string - }{result1} -} - -func (fake *FakeTokenVerifier) Verify(arg1 interface{}) (*auth.ClaimGrants, error) { - fake.verifyMutex.Lock() - ret, specificReturn := fake.verifyReturnsOnCall[len(fake.verifyArgsForCall)] - fake.verifyArgsForCall = append(fake.verifyArgsForCall, struct { - arg1 interface{} - }{arg1}) - stub := fake.VerifyStub - fakeReturns := fake.verifyReturns - fake.recordInvocation("Verify", []interface{}{arg1}) - fake.verifyMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeTokenVerifier) VerifyCallCount() int { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - return len(fake.verifyArgsForCall) -} - -func (fake *FakeTokenVerifier) VerifyCalls(stub func(interface{}) (*auth.ClaimGrants, error)) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = stub -} - -func (fake *FakeTokenVerifier) VerifyArgsForCall(i int) interface{} { - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - argsForCall := fake.verifyArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeTokenVerifier) VerifyReturns(result1 *auth.ClaimGrants, result2 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - fake.verifyReturns = struct { - result1 *auth.ClaimGrants - result2 error - }{result1, result2} -} - -func (fake *FakeTokenVerifier) VerifyReturnsOnCall(i int, result1 *auth.ClaimGrants, result2 error) { - fake.verifyMutex.Lock() - defer fake.verifyMutex.Unlock() - fake.VerifyStub = nil - if fake.verifyReturnsOnCall == nil { - fake.verifyReturnsOnCall = make(map[int]struct { - result1 *auth.ClaimGrants - result2 error - }) - } - fake.verifyReturnsOnCall[i] = struct { - result1 *auth.ClaimGrants - result2 error - }{result1, result2} -} - -func (fake *FakeTokenVerifier) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.identityMutex.RLock() - defer fake.identityMutex.RUnlock() - fake.verifyMutex.RLock() - defer fake.verifyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeTokenVerifier) 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 _ auth.TokenVerifier = new(FakeTokenVerifier) diff --git a/pkg/auth/grants.go b/pkg/auth/grants.go deleted file mode 100644 index f70acc36..00000000 --- a/pkg/auth/grants.go +++ /dev/null @@ -1,18 +0,0 @@ -package auth - -type VideoGrant struct { - // actions on rooms - RoomCreate bool `json:"roomCreate,omitempty"` - RoomList bool `json:"roomList,omitempty"` - - // actions on a particular room - RoomAdmin bool `json:"roomAdmin,omitempty"` - RoomJoin bool `json:"roomJoin,omitempty"` - Room string `json:"room,omitempty"` -} - -type ClaimGrants struct { - Identity string `json:"-"` - Video *VideoGrant `json:"video,omitempty"` - Metadata map[string]interface{} `json:"metadata,omitempty"` -} diff --git a/pkg/auth/interfaces.go b/pkg/auth/interfaces.go deleted file mode 100644 index 18727697..00000000 --- a/pkg/auth/interfaces.go +++ /dev/null @@ -1,23 +0,0 @@ -package auth - -import ( - "errors" -) - -//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate - -var ( - ErrKeysMissing = errors.New("missing API key or secret key") -) - -//counterfeiter:generate . TokenVerifier -type TokenVerifier interface { - Identity() string - Verify(key interface{}) (*ClaimGrants, error) -} - -//counterfeiter:generate . KeyProvider -type KeyProvider interface { - GetSecret(key string) string - NumKeys() int -} diff --git a/pkg/auth/provider.go b/pkg/auth/provider.go deleted file mode 100644 index 9feb5ca2..00000000 --- a/pkg/auth/provider.go +++ /dev/null @@ -1,38 +0,0 @@ -package auth - -import ( - "io" - - "gopkg.in/yaml.v3" -) - -type FileBasedKeyProvider struct { - keys map[string]string -} - -func NewFileBasedKeyProviderFromReader(r io.Reader) (p *FileBasedKeyProvider, err error) { - keys := make(map[string]string) - decoder := yaml.NewDecoder(r) - if err = decoder.Decode(&keys); err != nil { - return - } - p = &FileBasedKeyProvider{ - keys: keys, - } - - return -} - -func NewFileBasedKeyProviderFromMap(keys map[string]string) *FileBasedKeyProvider { - return &FileBasedKeyProvider{ - keys: keys, - } -} - -func (p *FileBasedKeyProvider) GetSecret(key string) string { - return p.keys[key] -} - -func (p *FileBasedKeyProvider) NumKeys() int { - return len(p.keys) -} diff --git a/pkg/auth/provider_test.go b/pkg/auth/provider_test.go deleted file mode 100644 index d0aad646..00000000 --- a/pkg/auth/provider_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package auth_test - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/livekit/livekit-server/pkg/auth" -) - -func TestFileBasedKeyProvider(t *testing.T) { - keys := map[string]string{ - "key1": "secret1", - "key2": "secret2", - "key3": "secret3", - } - f, err := ioutil.TempFile("", "keyfile") - assert.NoError(t, err) - defer func() { - os.Remove(f.Name()) - }() - - f.WriteString("key1: secret1\n") - f.WriteString("key2: secret2 \r\n") - f.WriteString("\n") - f.WriteString("key3: secret3") - - f.Close() - - r, err := os.Open(f.Name()) - defer r.Close() - p, err := auth.NewFileBasedKeyProviderFromReader(r) - assert.NoError(t, err) - - for key, val := range keys { - assert.Equal(t, val, p.GetSecret(key)) - } -} diff --git a/pkg/auth/verifier.go b/pkg/auth/verifier.go deleted file mode 100644 index 265f0041..00000000 --- a/pkg/auth/verifier.go +++ /dev/null @@ -1,61 +0,0 @@ -package auth - -import ( - "time" - - "gopkg.in/square/go-jose.v2/jwt" -) - -type APIKeyTokenVerifier struct { - token *jwt.JSONWebToken - identity string - apiKey string -} - -func ParseAPIToken(raw string) (*APIKeyTokenVerifier, error) { - tok, err := jwt.ParseSigned(raw) - if err != nil { - return nil, err - } - - out := jwt.Claims{} - if err := tok.UnsafeClaimsWithoutVerification(&out); err != nil { - return nil, err - } - - return &APIKeyTokenVerifier{ - token: tok, - apiKey: out.Issuer, - identity: out.ID, - }, nil -} - -// Returns the API key this token was signed with -func (v *APIKeyTokenVerifier) APIKey() string { - return v.apiKey -} - -func (v *APIKeyTokenVerifier) Identity() string { - return v.identity -} - -func (v *APIKeyTokenVerifier) Verify(key interface{}) (*ClaimGrants, error) { - if key == nil || key == "" { - return nil, ErrKeysMissing - } - if s, ok := key.(string); ok { - key = []byte(s) - } - out := jwt.Claims{} - claims := ClaimGrants{} - if err := v.token.Claims(key, &out, &claims); err != nil { - return nil, err - } - if err := out.Validate(jwt.Expected{Issuer: v.apiKey, Time: time.Now()}); err != nil { - return nil, err - } - - // copy over identity - claims.Identity = out.ID - return &claims, nil -} diff --git a/pkg/auth/verifier_test.go b/pkg/auth/verifier_test.go deleted file mode 100644 index 8d8d74f0..00000000 --- a/pkg/auth/verifier_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package auth_test - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" - - "github.com/livekit/livekit-server/pkg/auth" -) - -func TestVerifier(t *testing.T) { - apiKey := "APID3B67uxk4Nj2GKiRPibAZ9" - secret := "YHC-CUhbQhGeVCaYgn1BNA++" - accessToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDg5MzAzMDgsImlzcyI6IkFQSUQzQjY3dXhrNE5qMkdLaVJQaWJBWjkiLCJuYmYiOjE2MDg5MjY3MDgsInJvb21fam9pbiI6dHJ1ZSwicm9vbV9zaWQiOiJteWlkIiwic3ViIjoiQVBJRDNCNjd1eGs0TmoyR0tpUlBpYkFaOSJ9.cmHEBq0MLyRqphmVLM2cLXg5ao5Sro7am8yXhcYKcwE" - t.Run("cannot decode with incorrect key", func(t *testing.T) { - v, err := auth.ParseAPIToken(accessToken) - assert.NoError(t, err) - - assert.Equal(t, apiKey, v.APIKey()) - _, err = v.Verify("") - assert.Error(t, err) - - _, err = v.Verify("anothersecret") - assert.Error(t, err) - }) - - t.Run("key has expired", func(t *testing.T) { - v, err := auth.ParseAPIToken(accessToken) - - _, err = v.Verify(secret) - assert.Error(t, err) - }) - - t.Run("unexpired token is verified", func(t *testing.T) { - claim := auth.VideoGrant{RoomCreate: true} - at := auth.NewAccessToken(apiKey, secret). - AddGrant(&claim). - SetValidFor(time.Minute). - SetIdentity("me") - authToken, err := at.ToJWT() - assert.NoError(t, err) - - v, err := auth.ParseAPIToken(authToken) - assert.NoError(t, err) - assert.Equal(t, apiKey, v.APIKey()) - assert.Equal(t, "me", v.Identity()) - - decoded, err := v.Verify(secret) - assert.NoError(t, err) - assert.Equal(t, &claim, decoded.Video) - }) - - t.Run("ensure metadata can be passed through", func(t *testing.T) { - metadata := map[string]interface{}{ - "user": "value", - "number": float64(3), - } - at := auth.NewAccessToken(apiKey, secret). - AddGrant(&auth.VideoGrant{ - RoomAdmin: true, - Room: "myroom", - }). - SetMetadata(metadata) - - authToken, err := at.ToJWT() - assert.NoError(t, err) - - v, err := auth.ParseAPIToken(authToken) - assert.NoError(t, err) - - decoded, err := v.Verify(secret) - assert.NoError(t, err) - - assert.EqualValues(t, metadata, decoded.Metadata) - }) -} diff --git a/pkg/routing/interfaces.go b/pkg/routing/interfaces.go index a304dae2..199fbb57 100644 --- a/pkg/routing/interfaces.go +++ b/pkg/routing/interfaces.go @@ -3,7 +3,7 @@ package routing import ( "google.golang.org/protobuf/proto" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/pkg/routing/localrouter.go b/pkg/routing/localrouter.go index 7daa6ec5..794dfa36 100644 --- a/pkg/routing/localrouter.go +++ b/pkg/routing/localrouter.go @@ -5,8 +5,8 @@ import ( "time" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) // a router of messages on the same node, basic implementation for local testing diff --git a/pkg/routing/messagechannel.go b/pkg/routing/messagechannel.go index ecd51c13..c53fc0dc 100644 --- a/pkg/routing/messagechannel.go +++ b/pkg/routing/messagechannel.go @@ -3,7 +3,7 @@ package routing import ( "google.golang.org/protobuf/proto" - "github.com/livekit/livekit-server/pkg/utils" + "github.com/livekit/protocol/utils" ) type MessageChannel struct { diff --git a/pkg/routing/messagechannel_test.go b/pkg/routing/messagechannel_test.go index 28d4f0f6..ff938d9e 100644 --- a/pkg/routing/messagechannel_test.go +++ b/pkg/routing/messagechannel_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) func TestMessageChannel_WriteMessageClosed(t *testing.T) { diff --git a/pkg/routing/node.go b/pkg/routing/node.go index b022f227..51a872f2 100644 --- a/pkg/routing/node.go +++ b/pkg/routing/node.go @@ -13,8 +13,8 @@ import ( "github.com/pkg/errors" "github.com/livekit/livekit-server/pkg/config" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) type NodeStats struct { diff --git a/pkg/routing/randomselector.go b/pkg/routing/randomselector.go index 656bc53e..70279b5c 100644 --- a/pkg/routing/randomselector.go +++ b/pkg/routing/randomselector.go @@ -1,9 +1,8 @@ package routing import ( + livekit "github.com/livekit/livekit-server/proto" "github.com/thoas/go-funk" - - "github.com/livekit/livekit-server/proto/livekit" ) type RandomSelector struct { diff --git a/pkg/routing/redis.go b/pkg/routing/redis.go index 3b93be5a..5555d454 100644 --- a/pkg/routing/redis.go +++ b/pkg/routing/redis.go @@ -6,8 +6,8 @@ import ( "github.com/go-redis/redis/v8" "google.golang.org/protobuf/proto" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) const ( diff --git a/pkg/routing/redisrouter.go b/pkg/routing/redisrouter.go index ea653641..677b20df 100644 --- a/pkg/routing/redisrouter.go +++ b/pkg/routing/redisrouter.go @@ -9,8 +9,8 @@ import ( "google.golang.org/protobuf/proto" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) const ( diff --git a/pkg/routing/routingfakes/fake_node_selector.go b/pkg/routing/routingfakes/fake_node_selector.go index 9b7f6302..9cded4fd 100644 --- a/pkg/routing/routingfakes/fake_node_selector.go +++ b/pkg/routing/routingfakes/fake_node_selector.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) type FakeNodeSelector struct { diff --git a/pkg/routing/routingfakes/fake_router.go b/pkg/routing/routingfakes/fake_router.go index ac648255..b3888488 100644 --- a/pkg/routing/routingfakes/fake_router.go +++ b/pkg/routing/routingfakes/fake_router.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) type FakeRouter struct { diff --git a/pkg/routing/utils.go b/pkg/routing/utils.go index 113df077..00839566 100644 --- a/pkg/routing/utils.go +++ b/pkg/routing/utils.go @@ -5,9 +5,8 @@ import ( "strings" "time" + livekit "github.com/livekit/livekit-server/proto" "github.com/thoas/go-funk" - - "github.com/livekit/livekit-server/proto/livekit" ) // checks if a node has been updated recently to be considered for selection diff --git a/pkg/routing/utils_test.go b/pkg/routing/utils_test.go index ca48993c..101187b5 100644 --- a/pkg/routing/utils_test.go +++ b/pkg/routing/utils_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) func TestIsAvailable(t *testing.T) { diff --git a/pkg/rtc/datatrack.go b/pkg/rtc/datatrack.go index 64d54a2d..e68c7efd 100644 --- a/pkg/rtc/datatrack.go +++ b/pkg/rtc/datatrack.go @@ -7,7 +7,7 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/rtc/helper_test.go b/pkg/rtc/helper_test.go index 4377224c..f2649a7b 100644 --- a/pkg/rtc/helper_test.go +++ b/pkg/rtc/helper_test.go @@ -2,8 +2,8 @@ package rtc_test import ( "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) func newMockParticipant(identity string) *typesfakes.FakeParticipant { diff --git a/pkg/rtc/mediatrack.go b/pkg/rtc/mediatrack.go index 50c33544..9ccf9ce1 100644 --- a/pkg/rtc/mediatrack.go +++ b/pkg/rtc/mediatrack.go @@ -15,8 +15,8 @@ import ( "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) var ( diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 585b4e9f..0854b387 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -18,9 +18,9 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" "github.com/livekit/livekit-server/version" + "github.com/livekit/protocol/utils" ) const ( diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index 670a9319..9efe108f 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -10,7 +10,7 @@ import ( "github.com/livekit/livekit-server/pkg/routing/routingfakes" "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) //func Test diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 3bde7990..067c1516 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -8,8 +8,8 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) const ( diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 3423a6e0..4c6de2d2 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -12,7 +12,7 @@ import ( "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/rtc/subscribedtrack.go b/pkg/rtc/subscribedtrack.go index 0f1ce441..e5bb89b8 100644 --- a/pkg/rtc/subscribedtrack.go +++ b/pkg/rtc/subscribedtrack.go @@ -4,8 +4,8 @@ import ( "github.com/pion/ion-sfu/pkg/sfu" "github.com/pion/webrtc/v3" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) type SubscribedTrack struct { diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index 41f64d43..1ca3ff77 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -9,7 +9,7 @@ import ( "github.com/pion/webrtc/v3" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index 4d213c51..ad44d0a7 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -8,7 +8,7 @@ import ( "github.com/pion/webrtc/v3" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index 2820e92b..140f8881 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -6,7 +6,7 @@ import ( "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" "github.com/pion/rtcp" webrtc "github.com/pion/webrtc/v3" ) diff --git a/pkg/rtc/types/typesfakes/fake_published_track.go b/pkg/rtc/types/typesfakes/fake_published_track.go index f7fa375a..fb1b55fc 100644 --- a/pkg/rtc/types/typesfakes/fake_published_track.go +++ b/pkg/rtc/types/typesfakes/fake_published_track.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) type FakePublishedTrack struct { diff --git a/pkg/rtc/types/typesfakes/fake_subscribed_track.go b/pkg/rtc/types/typesfakes/fake_subscribed_track.go index 397cc52c..c765f6fb 100644 --- a/pkg/rtc/types/typesfakes/fake_subscribed_track.go +++ b/pkg/rtc/types/typesfakes/fake_subscribed_track.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" "github.com/pion/ion-sfu/pkg/sfu" ) diff --git a/pkg/rtc/utils.go b/pkg/rtc/utils.go index 24653616..4ac83b31 100644 --- a/pkg/rtc/utils.go +++ b/pkg/rtc/utils.go @@ -10,7 +10,7 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/service/auth.go b/pkg/service/auth.go index 15c2ca81..5a45464f 100644 --- a/pkg/service/auth.go +++ b/pkg/service/auth.go @@ -8,7 +8,7 @@ import ( "github.com/twitchtv/twirp" - "github.com/livekit/livekit-server/pkg/auth" + "github.com/livekit/protocol/auth" ) const ( diff --git a/pkg/service/auth_test.go b/pkg/service/auth_test.go index e0db9c88..f33be5c4 100644 --- a/pkg/service/auth_test.go +++ b/pkg/service/auth_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/livekit/livekit-server/pkg/auth" - "github.com/livekit/livekit-server/pkg/auth/authfakes" "github.com/livekit/livekit-server/pkg/service" + "github.com/livekit/protocol/auth" + "github.com/livekit/protocol/auth/authfakes" ) func TestAuthMiddleware(t *testing.T) { diff --git a/pkg/service/localroomstore.go b/pkg/service/localroomstore.go index 96193e74..de9d0e8d 100644 --- a/pkg/service/localroomstore.go +++ b/pkg/service/localroomstore.go @@ -6,7 +6,7 @@ import ( "github.com/thoas/go-funk" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) // encapsulates CRUD operations for room settings diff --git a/pkg/service/redisroomstore.go b/pkg/service/redisroomstore.go index 9406dc31..a3bac34c 100644 --- a/pkg/service/redisroomstore.go +++ b/pkg/service/redisroomstore.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "google.golang.org/protobuf/proto" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/service/redisroomstore_test.go b/pkg/service/redisroomstore_test.go index 0c9d85c5..fc7e82ba 100644 --- a/pkg/service/redisroomstore_test.go +++ b/pkg/service/redisroomstore_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/livekit/livekit-server/pkg/service" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) func TestParticipantPersisence(t *testing.T) { diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 2e3de5bd..d4d0b038 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -13,8 +13,8 @@ import ( "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) const ( diff --git a/pkg/service/roomservice.go b/pkg/service/roomservice.go index 41b04042..390c2064 100644 --- a/pkg/service/roomservice.go +++ b/pkg/service/roomservice.go @@ -7,7 +7,7 @@ import ( "github.com/thoas/go-funk" "github.com/twitchtv/twirp" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) // A rooms service that supports a single node diff --git a/pkg/service/roomstore.go b/pkg/service/roomstore.go index 32525850..c0c75ed8 100644 --- a/pkg/service/roomstore.go +++ b/pkg/service/roomstore.go @@ -1,7 +1,7 @@ package service import ( - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) //go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate diff --git a/pkg/service/rtcservice.go b/pkg/service/rtcservice.go index cbc6414a..a273a455 100644 --- a/pkg/service/rtcservice.go +++ b/pkg/service/rtcservice.go @@ -13,7 +13,7 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/rtc" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) type RTCService struct { diff --git a/pkg/service/server.go b/pkg/service/server.go index ff59d638..a1f8e193 100644 --- a/pkg/service/server.go +++ b/pkg/service/server.go @@ -11,13 +11,13 @@ import ( "github.com/pion/turn/v2" "github.com/urfave/negroni" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" "github.com/livekit/livekit-server/version" + "github.com/livekit/protocol/auth" + "github.com/livekit/protocol/utils" ) type LivekitServer struct { diff --git a/pkg/service/servicefakes/fake_room_store.go b/pkg/service/servicefakes/fake_room_store.go index 207df875..a71e7151 100644 --- a/pkg/service/servicefakes/fake_room_store.go +++ b/pkg/service/servicefakes/fake_room_store.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/livekit/livekit-server/pkg/service" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) type FakeRoomStore struct { diff --git a/pkg/service/utils.go b/pkg/service/utils.go index 543ed8fc..a661c52f 100644 --- a/pkg/service/utils.go +++ b/pkg/service/utils.go @@ -8,7 +8,7 @@ import ( "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) var ServiceSet = wire.NewSet( diff --git a/pkg/service/wire.go b/pkg/service/wire.go index 60848b82..72a59ca1 100644 --- a/pkg/service/wire.go +++ b/pkg/service/wire.go @@ -5,9 +5,9 @@ package service import ( "github.com/google/wire" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/routing" + "github.com/livekit/protocol/auth" ) func InitializeServer(conf *config.Config, keyProvider auth.KeyProvider, diff --git a/pkg/service/wire_gen.go b/pkg/service/wire_gen.go index bce2b171..c7bddcff 100644 --- a/pkg/service/wire_gen.go +++ b/pkg/service/wire_gen.go @@ -6,9 +6,9 @@ package service import ( - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/routing" + "github.com/livekit/protocol/auth" ) // Injectors from wire.go: diff --git a/pkg/service/wsprotocol.go b/pkg/service/wsprotocol.go index 57bc0e92..db0b3e25 100644 --- a/pkg/service/wsprotocol.go +++ b/pkg/service/wsprotocol.go @@ -10,7 +10,7 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) const ( diff --git a/pkg/utils/cachedredis.go b/pkg/utils/cachedredis.go deleted file mode 100644 index 30a0cc77..00000000 --- a/pkg/utils/cachedredis.go +++ /dev/null @@ -1,64 +0,0 @@ -package utils - -import ( - "context" - "time" - - "github.com/go-redis/redis/v8" - "github.com/karlseguin/ccache/v2" - "github.com/pkg/errors" -) - -const ( - defaultCacheTTL = time.Minute -) - -type CachedRedis struct { - ctx context.Context - rc *redis.Client - cache *ccache.Cache -} - -func NewCachedRedis(ctx context.Context, rc *redis.Client) *CachedRedis { - return &CachedRedis{ - ctx: ctx, - rc: rc, - cache: ccache.New(ccache.Configure()), - } -} - -func (r *CachedRedis) CachedHGet(key, hashKey string) (string, error) { - cacheKey := key + ":" + hashKey - item := r.cache.Get(cacheKey) - if item != nil && !item.Expired() { - return item.Value().(string), nil - } - val, err := r.rc.HGet(r.ctx, key, hashKey).Result() - if err != nil { - return "", errors.Wrapf(err, "could not hget %s[%s]", key, hashKey) - } - r.cache.Set(key, val, defaultCacheTTL) - return val, nil -} - -func (r *CachedRedis) CachedGet(key string) (string, error) { - item := r.cache.Get(key) - if item != nil && !item.Expired() { - return item.Value().(string), nil - } - val, err := r.rc.Get(r.ctx, key).Result() - if err != nil { - return "", errors.Wrapf(err, "could not get %s", key) - } - - r.cache.Set(key, val, defaultCacheTTL) - return val, nil -} - -func (r *CachedRedis) ExpireHash(key, hashKey string) { - r.cache.Delete(key + ":" + hashKey) -} - -func (r *CachedRedis) Expire(key string) { - r.cache.Delete(key) -} diff --git a/pkg/utils/id.go b/pkg/utils/id.go deleted file mode 100644 index 375dc07a..00000000 --- a/pkg/utils/id.go +++ /dev/null @@ -1,29 +0,0 @@ -package utils - -import ( - "crypto/sha1" - - "github.com/lithammer/shortuuid/v3" - "github.com/lytics/base62" -) - -const ( - RoomPrefix = "RM_" - NodePrefix = "ND_" - ParticipantPrefix = "PA_" - TrackPrefix = "TR_" - APIKeyPrefix = "API" -) - -func NewGuid(prefix string) string { - return prefix + shortuuid.New()[:12] -} - -// Creates a hashed ID from a unique string -func HashedID(str string) string { - h := sha1.New() - h.Write([]byte(str)) - val := h.Sum(nil) - - return base62.StdEncoding.EncodeToString(val) -} diff --git a/pkg/utils/secret.go b/pkg/utils/secret.go deleted file mode 100644 index 0b6eae9d..00000000 --- a/pkg/utils/secret.go +++ /dev/null @@ -1,19 +0,0 @@ -package utils - -import ( - "crypto/rand" - "io" - - "github.com/lytics/base62" -) - -func RandomSecret() string { - // 256 bit secret - buf := make([]byte, 32) - _, err := io.ReadFull(rand.Reader, buf) - // cannot error - if err != nil { - panic("could not read random") - } - return base62.StdEncoding.EncodeToString(buf) -} diff --git a/pkg/utils/sync.go b/pkg/utils/sync.go deleted file mode 100644 index edae9a69..00000000 --- a/pkg/utils/sync.go +++ /dev/null @@ -1,63 +0,0 @@ -package utils - -import ( - "errors" - "sync/atomic" -) - -var ( - ErrChannelClosed = errors.New("cannot write to closed channel") -) - -type AtomicFlag struct { - val int32 -} - -// set flag to value if existing flag is different, otherwise return -func (b *AtomicFlag) TrySet(bVal bool) bool { - var v int32 - if bVal { - v = 1 - } - prev := atomic.SwapInt32(&b.val, v) - // already set. unsuccessful - if prev == v { - return false - } - return true -} - -func (b *AtomicFlag) Get() bool { - return atomic.LoadInt32(&b.val) == 1 -} - -// a channel that ignores writes when it closes instead of panic -type CalmChannel struct { - channel chan interface{} - isClosed AtomicFlag -} - -func NewCalmChannel(size int) *CalmChannel { - return &CalmChannel{ - channel: make(chan interface{}, size), - } -} - -func (c *CalmChannel) Close() { - if !c.isClosed.TrySet(true) { - return - } - close(c.channel) -} - -func (c *CalmChannel) ReadChan() <-chan interface{} { - return c.channel -} - -func (c *CalmChannel) Write(o interface{}) error { - if c.isClosed.Get() { - return ErrChannelClosed - } - c.channel <- o - return nil -} diff --git a/pkg/utils/sync_test.go b/pkg/utils/sync_test.go deleted file mode 100644 index 08f04b62..00000000 --- a/pkg/utils/sync_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package utils - -import ( - "sync" - "sync/atomic" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestAtomicFlag(t *testing.T) { - t.Run("single thread, basic functionality", func(t *testing.T) { - f := AtomicFlag{} - assert.False(t, f.TrySet(false)) - assert.False(t, f.Get()) - assert.True(t, f.TrySet(true)) - assert.True(t, f.Get()) - }) - - t.Run("only one thread should succeed", func(t *testing.T) { - var numSets uint32 - f := AtomicFlag{} - wg := sync.WaitGroup{} - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - if f.TrySet(true) { - atomic.AddUint32(&numSets, 1) - } - wg.Done() - }() - } - wg.Wait() - - assert.Equal(t, 1, int(numSets)) - }) -} - -func TestCalmChannel(t *testing.T) { - t.Run("should receive nil after close", func(t *testing.T) { - c := NewCalmChannel(1) - c.Close() - - assert.Equal(t, nil, <-c.ReadChan()) - }) -} diff --git a/proto/internal.pb.go b/proto/internal.pb.go new file mode 100644 index 00000000..b2a2746d --- /dev/null +++ b/proto/internal.pb.go @@ -0,0 +1,802 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: internal.proto + +package livekit + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type Node struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` + NumCpus uint32 `protobuf:"varint,3,opt,name=num_cpus,json=numCpus,proto3" json:"num_cpus,omitempty"` + Stats *NodeStats `protobuf:"bytes,4,opt,name=stats,proto3" json:"stats,omitempty"` +} + +func (x *Node) Reset() { + *x = Node{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Node) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Node) ProtoMessage() {} + +func (x *Node) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Node.ProtoReflect.Descriptor instead. +func (*Node) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{0} +} + +func (x *Node) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Node) GetIp() string { + if x != nil { + return x.Ip + } + return "" +} + +func (x *Node) GetNumCpus() uint32 { + if x != nil { + return x.NumCpus + } + return 0 +} + +func (x *Node) GetStats() *NodeStats { + if x != nil { + return x.Stats + } + return nil +} + +type NodeStats struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // when server was started + StartedAt int64 `protobuf:"varint,1,opt,name=started_at,json=startedAt,proto3" json:"started_at,omitempty"` + // when server last reported its status + UpdatedAt int64 `protobuf:"varint,2,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + NumRooms uint32 `protobuf:"varint,3,opt,name=num_rooms,json=numRooms,proto3" json:"num_rooms,omitempty"` + NumClients uint32 `protobuf:"varint,4,opt,name=num_clients,json=numClients,proto3" json:"num_clients,omitempty"` + NumTracksIn uint32 `protobuf:"varint,5,opt,name=num_tracks_in,json=numTracksIn,proto3" json:"num_tracks_in,omitempty"` + NumTracksOut uint32 `protobuf:"varint,6,opt,name=num_tracks_out,json=numTracksOut,proto3" json:"num_tracks_out,omitempty"` +} + +func (x *NodeStats) Reset() { + *x = NodeStats{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeStats) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeStats) ProtoMessage() {} + +func (x *NodeStats) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeStats.ProtoReflect.Descriptor instead. +func (*NodeStats) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{1} +} + +func (x *NodeStats) GetStartedAt() int64 { + if x != nil { + return x.StartedAt + } + return 0 +} + +func (x *NodeStats) GetUpdatedAt() int64 { + if x != nil { + return x.UpdatedAt + } + return 0 +} + +func (x *NodeStats) GetNumRooms() uint32 { + if x != nil { + return x.NumRooms + } + return 0 +} + +func (x *NodeStats) GetNumClients() uint32 { + if x != nil { + return x.NumClients + } + return 0 +} + +func (x *NodeStats) GetNumTracksIn() uint32 { + if x != nil { + return x.NumTracksIn + } + return 0 +} + +func (x *NodeStats) GetNumTracksOut() uint32 { + if x != nil { + return x.NumTracksOut + } + return 0 +} + +// message to RTC nodes +type RTCNodeMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ParticipantKey string `protobuf:"bytes,1,opt,name=participant_key,json=participantKey,proto3" json:"participant_key,omitempty"` + // Types that are assignable to Message: + // *RTCNodeMessage_StartSession + // *RTCNodeMessage_Request + // *RTCNodeMessage_RemoveParticipant + // *RTCNodeMessage_MuteTrack + Message isRTCNodeMessage_Message `protobuf_oneof:"message"` +} + +func (x *RTCNodeMessage) Reset() { + *x = RTCNodeMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RTCNodeMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RTCNodeMessage) ProtoMessage() {} + +func (x *RTCNodeMessage) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RTCNodeMessage.ProtoReflect.Descriptor instead. +func (*RTCNodeMessage) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{2} +} + +func (x *RTCNodeMessage) GetParticipantKey() string { + if x != nil { + return x.ParticipantKey + } + return "" +} + +func (m *RTCNodeMessage) GetMessage() isRTCNodeMessage_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *RTCNodeMessage) GetStartSession() *StartSession { + if x, ok := x.GetMessage().(*RTCNodeMessage_StartSession); ok { + return x.StartSession + } + return nil +} + +func (x *RTCNodeMessage) GetRequest() *SignalRequest { + if x, ok := x.GetMessage().(*RTCNodeMessage_Request); ok { + return x.Request + } + return nil +} + +func (x *RTCNodeMessage) GetRemoveParticipant() *RoomParticipantIdentity { + if x, ok := x.GetMessage().(*RTCNodeMessage_RemoveParticipant); ok { + return x.RemoveParticipant + } + return nil +} + +func (x *RTCNodeMessage) GetMuteTrack() *MuteRoomTrackRequest { + if x, ok := x.GetMessage().(*RTCNodeMessage_MuteTrack); ok { + return x.MuteTrack + } + return nil +} + +type isRTCNodeMessage_Message interface { + isRTCNodeMessage_Message() +} + +type RTCNodeMessage_StartSession struct { + StartSession *StartSession `protobuf:"bytes,2,opt,name=start_session,json=startSession,proto3,oneof"` +} + +type RTCNodeMessage_Request struct { + Request *SignalRequest `protobuf:"bytes,3,opt,name=request,proto3,oneof"` +} + +type RTCNodeMessage_RemoveParticipant struct { + // internal messages + RemoveParticipant *RoomParticipantIdentity `protobuf:"bytes,4,opt,name=remove_participant,json=removeParticipant,proto3,oneof"` +} + +type RTCNodeMessage_MuteTrack struct { + MuteTrack *MuteRoomTrackRequest `protobuf:"bytes,5,opt,name=mute_track,json=muteTrack,proto3,oneof"` +} + +func (*RTCNodeMessage_StartSession) isRTCNodeMessage_Message() {} + +func (*RTCNodeMessage_Request) isRTCNodeMessage_Message() {} + +func (*RTCNodeMessage_RemoveParticipant) isRTCNodeMessage_Message() {} + +func (*RTCNodeMessage_MuteTrack) isRTCNodeMessage_Message() {} + +// message to Signal nodes +type SignalNodeMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ConnectionId string `protobuf:"bytes,1,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` + // Types that are assignable to Message: + // *SignalNodeMessage_Response + // *SignalNodeMessage_EndSession + Message isSignalNodeMessage_Message `protobuf_oneof:"message"` +} + +func (x *SignalNodeMessage) Reset() { + *x = SignalNodeMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SignalNodeMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignalNodeMessage) ProtoMessage() {} + +func (x *SignalNodeMessage) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignalNodeMessage.ProtoReflect.Descriptor instead. +func (*SignalNodeMessage) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{3} +} + +func (x *SignalNodeMessage) GetConnectionId() string { + if x != nil { + return x.ConnectionId + } + return "" +} + +func (m *SignalNodeMessage) GetMessage() isSignalNodeMessage_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *SignalNodeMessage) GetResponse() *SignalResponse { + if x, ok := x.GetMessage().(*SignalNodeMessage_Response); ok { + return x.Response + } + return nil +} + +func (x *SignalNodeMessage) GetEndSession() *EndSession { + if x, ok := x.GetMessage().(*SignalNodeMessage_EndSession); ok { + return x.EndSession + } + return nil +} + +type isSignalNodeMessage_Message interface { + isSignalNodeMessage_Message() +} + +type SignalNodeMessage_Response struct { + Response *SignalResponse `protobuf:"bytes,2,opt,name=response,proto3,oneof"` +} + +type SignalNodeMessage_EndSession struct { + EndSession *EndSession `protobuf:"bytes,3,opt,name=end_session,json=endSession,proto3,oneof"` +} + +func (*SignalNodeMessage_Response) isSignalNodeMessage_Message() {} + +func (*SignalNodeMessage_EndSession) isSignalNodeMessage_Message() {} + +type StartSession struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RoomName string `protobuf:"bytes,1,opt,name=room_name,json=roomName,proto3" json:"room_name,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + ConnectionId string `protobuf:"bytes,3,opt,name=connection_id,json=connectionId,proto3" json:"connection_id,omitempty"` + // if a client is reconnecting (i.e. resume instead of restart) + Reconnect bool `protobuf:"varint,4,opt,name=reconnect,proto3" json:"reconnect,omitempty"` + // metadata to pass to participant + Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *StartSession) Reset() { + *x = StartSession{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartSession) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartSession) ProtoMessage() {} + +func (x *StartSession) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartSession.ProtoReflect.Descriptor instead. +func (*StartSession) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{4} +} + +func (x *StartSession) GetRoomName() string { + if x != nil { + return x.RoomName + } + return "" +} + +func (x *StartSession) GetIdentity() string { + if x != nil { + return x.Identity + } + return "" +} + +func (x *StartSession) GetConnectionId() string { + if x != nil { + return x.ConnectionId + } + return "" +} + +func (x *StartSession) GetReconnect() bool { + if x != nil { + return x.Reconnect + } + return false +} + +func (x *StartSession) GetMetadata() string { + if x != nil { + return x.Metadata + } + return "" +} + +type EndSession struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *EndSession) Reset() { + *x = EndSession{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EndSession) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EndSession) ProtoMessage() {} + +func (x *EndSession) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EndSession.ProtoReflect.Descriptor instead. +func (*EndSession) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{5} +} + +type RemoveParticipant struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ParticipantId string `protobuf:"bytes,1,opt,name=participant_id,json=participantId,proto3" json:"participant_id,omitempty"` +} + +func (x *RemoveParticipant) Reset() { + *x = RemoveParticipant{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveParticipant) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveParticipant) ProtoMessage() {} + +func (x *RemoveParticipant) ProtoReflect() protoreflect.Message { + mi := &file_internal_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveParticipant.ProtoReflect.Descriptor instead. +func (*RemoveParticipant) Descriptor() ([]byte, []int) { + return file_internal_proto_rawDescGZIP(), []int{6} +} + +func (x *RemoveParticipant) GetParticipantId() string { + if x != nil { + return x.ParticipantId + } + return "" +} + +var File_internal_proto protoreflect.FileDescriptor + +var file_internal_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x07, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x1a, 0x09, 0x72, 0x74, 0x63, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x72, 0x6f, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x6b, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x5f, + 0x63, 0x70, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x6e, 0x75, 0x6d, 0x43, + 0x70, 0x75, 0x73, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4e, 0x6f, 0x64, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x22, 0xd1, 0x01, + 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x75, 0x6d, + 0x5f, 0x72, 0x6f, 0x6f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6e, 0x75, + 0x6d, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x75, 0x6d, 0x5f, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6e, 0x75, 0x6d, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x75, 0x6d, 0x5f, 0x74, + 0x72, 0x61, 0x63, 0x6b, 0x73, 0x5f, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, + 0x6e, 0x75, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x73, 0x49, 0x6e, 0x12, 0x24, 0x0a, 0x0e, 0x6e, + 0x75, 0x6d, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x73, 0x5f, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6e, 0x75, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x73, 0x4f, 0x75, + 0x74, 0x22, 0xc9, 0x02, 0x0a, 0x0e, 0x52, 0x54, 0x43, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, + 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x3c, 0x0a, + 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x07, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x51, 0x0a, 0x12, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x48, 0x00, 0x52, + 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x12, 0x3e, 0x0a, 0x0a, 0x6d, 0x75, 0x74, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, + 0x2e, 0x4d, 0x75, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x09, 0x6d, 0x75, 0x74, 0x65, 0x54, 0x72, 0x61, + 0x63, 0x6b, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xb2, 0x01, + 0x0a, 0x11, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x35, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6c, 0x69, 0x76, + 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x36, 0x0a, 0x0b, 0x65, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x45, + 0x6e, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0a, 0x65, 0x6e, 0x64, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x22, 0xa6, 0x01, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x23, 0x0a, 0x0d, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x72, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, + 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x0c, 0x0a, 0x0a, 0x45, + 0x6e, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x0a, 0x11, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x12, 0x25, + 0x0a, 0x0e, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x49, 0x64, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2f, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_proto_rawDescOnce sync.Once + file_internal_proto_rawDescData = file_internal_proto_rawDesc +) + +func file_internal_proto_rawDescGZIP() []byte { + file_internal_proto_rawDescOnce.Do(func() { + file_internal_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_proto_rawDescData) + }) + return file_internal_proto_rawDescData +} + +var file_internal_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_internal_proto_goTypes = []interface{}{ + (*Node)(nil), // 0: livekit.Node + (*NodeStats)(nil), // 1: livekit.NodeStats + (*RTCNodeMessage)(nil), // 2: livekit.RTCNodeMessage + (*SignalNodeMessage)(nil), // 3: livekit.SignalNodeMessage + (*StartSession)(nil), // 4: livekit.StartSession + (*EndSession)(nil), // 5: livekit.EndSession + (*RemoveParticipant)(nil), // 6: livekit.RemoveParticipant + (*SignalRequest)(nil), // 7: livekit.SignalRequest + (*RoomParticipantIdentity)(nil), // 8: livekit.RoomParticipantIdentity + (*MuteRoomTrackRequest)(nil), // 9: livekit.MuteRoomTrackRequest + (*SignalResponse)(nil), // 10: livekit.SignalResponse +} +var file_internal_proto_depIdxs = []int32{ + 1, // 0: livekit.Node.stats:type_name -> livekit.NodeStats + 4, // 1: livekit.RTCNodeMessage.start_session:type_name -> livekit.StartSession + 7, // 2: livekit.RTCNodeMessage.request:type_name -> livekit.SignalRequest + 8, // 3: livekit.RTCNodeMessage.remove_participant:type_name -> livekit.RoomParticipantIdentity + 9, // 4: livekit.RTCNodeMessage.mute_track:type_name -> livekit.MuteRoomTrackRequest + 10, // 5: livekit.SignalNodeMessage.response:type_name -> livekit.SignalResponse + 5, // 6: livekit.SignalNodeMessage.end_session:type_name -> livekit.EndSession + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_internal_proto_init() } +func file_internal_proto_init() { + if File_internal_proto != nil { + return + } + file_rtc_proto_init() + file_room_proto_init() + if !protoimpl.UnsafeEnabled { + file_internal_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Node); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeStats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RTCNodeMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SignalNodeMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartSession); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EndSession); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveParticipant); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_internal_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*RTCNodeMessage_StartSession)(nil), + (*RTCNodeMessage_Request)(nil), + (*RTCNodeMessage_RemoveParticipant)(nil), + (*RTCNodeMessage_MuteTrack)(nil), + } + file_internal_proto_msgTypes[3].OneofWrappers = []interface{}{ + (*SignalNodeMessage_Response)(nil), + (*SignalNodeMessage_EndSession)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_internal_proto_goTypes, + DependencyIndexes: file_internal_proto_depIdxs, + MessageInfos: file_internal_proto_msgTypes, + }.Build() + File_internal_proto = out.File + file_internal_proto_rawDesc = nil + file_internal_proto_goTypes = nil + file_internal_proto_depIdxs = nil +} diff --git a/proto/internal.proto b/proto/internal.proto deleted file mode 100644 index 0be6d0da..00000000 --- a/proto/internal.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; - -package livekit; -option go_package = "github.com/livekit/livekit-server/proto/livekit"; - -// internal protos, not exposed to clients -import "rtc.proto"; -import "room.proto"; - -message Node { - string id = 1; - string ip = 2; - uint32 num_cpus = 3; - NodeStats stats = 4; -} - -message NodeStats { - // when server was started - int64 started_at = 1; - // when server last reported its status - int64 updated_at = 2; - uint32 num_rooms = 3; - uint32 num_clients = 4; - uint32 num_tracks_in = 5; - uint32 num_tracks_out = 6; -} - -// message to RTC nodes -message RTCNodeMessage { - string participant_key = 1; - oneof message { - StartSession start_session = 2; - SignalRequest request = 3; - // internal messages - RoomParticipantIdentity remove_participant = 4; - MuteRoomTrackRequest mute_track = 5; - } -} - -// message to Signal nodes -message SignalNodeMessage { - string connection_id = 1; - oneof message { - SignalResponse response = 2; - EndSession end_session = 3; - } -} - -message StartSession { - string room_name = 1; - string identity = 2; - string connection_id = 3; - // if a client is reconnecting (i.e. resume instead of restart) - bool reconnect = 4; - // metadata to pass to participant - string metadata = 5; -} - -message EndSession { -} - -message RemoveParticipant { - string participant_id = 1; -} \ No newline at end of file diff --git a/proto/model.pb.go b/proto/model.pb.go new file mode 100644 index 00000000..8b21c572 --- /dev/null +++ b/proto/model.pb.go @@ -0,0 +1,614 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: model.proto + +package livekit + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type TrackType int32 + +const ( + TrackType_AUDIO TrackType = 0 + TrackType_VIDEO TrackType = 1 + TrackType_DATA TrackType = 2 +) + +// Enum value maps for TrackType. +var ( + TrackType_name = map[int32]string{ + 0: "AUDIO", + 1: "VIDEO", + 2: "DATA", + } + TrackType_value = map[string]int32{ + "AUDIO": 0, + "VIDEO": 1, + "DATA": 2, + } +) + +func (x TrackType) Enum() *TrackType { + p := new(TrackType) + *p = x + return p +} + +func (x TrackType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TrackType) Descriptor() protoreflect.EnumDescriptor { + return file_model_proto_enumTypes[0].Descriptor() +} + +func (TrackType) Type() protoreflect.EnumType { + return &file_model_proto_enumTypes[0] +} + +func (x TrackType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TrackType.Descriptor instead. +func (TrackType) EnumDescriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{0} +} + +type ParticipantInfo_State int32 + +const ( + // websocket' connected, but not offered yet + ParticipantInfo_JOINING ParticipantInfo_State = 0 + // server received client offer + ParticipantInfo_JOINED ParticipantInfo_State = 1 + // ICE connectivity established + ParticipantInfo_ACTIVE ParticipantInfo_State = 2 + // WS disconnected + ParticipantInfo_DISCONNECTED ParticipantInfo_State = 3 +) + +// Enum value maps for ParticipantInfo_State. +var ( + ParticipantInfo_State_name = map[int32]string{ + 0: "JOINING", + 1: "JOINED", + 2: "ACTIVE", + 3: "DISCONNECTED", + } + ParticipantInfo_State_value = map[string]int32{ + "JOINING": 0, + "JOINED": 1, + "ACTIVE": 2, + "DISCONNECTED": 3, + } +) + +func (x ParticipantInfo_State) Enum() *ParticipantInfo_State { + p := new(ParticipantInfo_State) + *p = x + return p +} + +func (x ParticipantInfo_State) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ParticipantInfo_State) Descriptor() protoreflect.EnumDescriptor { + return file_model_proto_enumTypes[1].Descriptor() +} + +func (ParticipantInfo_State) Type() protoreflect.EnumType { + return &file_model_proto_enumTypes[1] +} + +func (x ParticipantInfo_State) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ParticipantInfo_State.Descriptor instead. +func (ParticipantInfo_State) EnumDescriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{1, 0} +} + +type Room struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + EmptyTimeout uint32 `protobuf:"varint,3,opt,name=empty_timeout,json=emptyTimeout,proto3" json:"empty_timeout,omitempty"` + MaxParticipants uint32 `protobuf:"varint,4,opt,name=max_participants,json=maxParticipants,proto3" json:"max_participants,omitempty"` + CreationTime int64 `protobuf:"varint,5,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + TurnPassword string `protobuf:"bytes,6,opt,name=turn_password,json=turnPassword,proto3" json:"turn_password,omitempty"` +} + +func (x *Room) Reset() { + *x = Room{} + if protoimpl.UnsafeEnabled { + mi := &file_model_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Room) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Room) ProtoMessage() {} + +func (x *Room) ProtoReflect() protoreflect.Message { + mi := &file_model_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Room.ProtoReflect.Descriptor instead. +func (*Room) Descriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{0} +} + +func (x *Room) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + +func (x *Room) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Room) GetEmptyTimeout() uint32 { + if x != nil { + return x.EmptyTimeout + } + return 0 +} + +func (x *Room) GetMaxParticipants() uint32 { + if x != nil { + return x.MaxParticipants + } + return 0 +} + +func (x *Room) GetCreationTime() int64 { + if x != nil { + return x.CreationTime + } + return 0 +} + +func (x *Room) GetTurnPassword() string { + if x != nil { + return x.TurnPassword + } + return "" +} + +type ParticipantInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + State ParticipantInfo_State `protobuf:"varint,3,opt,name=state,proto3,enum=livekit.ParticipantInfo_State" json:"state,omitempty"` + Tracks []*TrackInfo `protobuf:"bytes,4,rep,name=tracks,proto3" json:"tracks,omitempty"` + Metadata string `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *ParticipantInfo) Reset() { + *x = ParticipantInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_model_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ParticipantInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParticipantInfo) ProtoMessage() {} + +func (x *ParticipantInfo) ProtoReflect() protoreflect.Message { + mi := &file_model_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParticipantInfo.ProtoReflect.Descriptor instead. +func (*ParticipantInfo) Descriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{1} +} + +func (x *ParticipantInfo) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + +func (x *ParticipantInfo) GetIdentity() string { + if x != nil { + return x.Identity + } + return "" +} + +func (x *ParticipantInfo) GetState() ParticipantInfo_State { + if x != nil { + return x.State + } + return ParticipantInfo_JOINING +} + +func (x *ParticipantInfo) GetTracks() []*TrackInfo { + if x != nil { + return x.Tracks + } + return nil +} + +func (x *ParticipantInfo) GetMetadata() string { + if x != nil { + return x.Metadata + } + return "" +} + +type TrackInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + Type TrackType `protobuf:"varint,2,opt,name=type,proto3,enum=livekit.TrackType" json:"type,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Muted bool `protobuf:"varint,4,opt,name=muted,proto3" json:"muted,omitempty"` +} + +func (x *TrackInfo) Reset() { + *x = TrackInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_model_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TrackInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TrackInfo) ProtoMessage() {} + +func (x *TrackInfo) ProtoReflect() protoreflect.Message { + mi := &file_model_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TrackInfo.ProtoReflect.Descriptor instead. +func (*TrackInfo) Descriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{2} +} + +func (x *TrackInfo) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + +func (x *TrackInfo) GetType() TrackType { + if x != nil { + return x.Type + } + return TrackType_AUDIO +} + +func (x *TrackInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TrackInfo) GetMuted() bool { + if x != nil { + return x.Muted + } + return false +} + +type DataMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Value: + // *DataMessage_Text + // *DataMessage_Binary + Value isDataMessage_Value `protobuf_oneof:"value"` +} + +func (x *DataMessage) Reset() { + *x = DataMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_model_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage) ProtoMessage() {} + +func (x *DataMessage) ProtoReflect() protoreflect.Message { + mi := &file_model_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage.ProtoReflect.Descriptor instead. +func (*DataMessage) Descriptor() ([]byte, []int) { + return file_model_proto_rawDescGZIP(), []int{3} +} + +func (m *DataMessage) GetValue() isDataMessage_Value { + if m != nil { + return m.Value + } + return nil +} + +func (x *DataMessage) GetText() string { + if x, ok := x.GetValue().(*DataMessage_Text); ok { + return x.Text + } + return "" +} + +func (x *DataMessage) GetBinary() []byte { + if x, ok := x.GetValue().(*DataMessage_Binary); ok { + return x.Binary + } + return nil +} + +type isDataMessage_Value interface { + isDataMessage_Value() +} + +type DataMessage_Text struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3,oneof"` +} + +type DataMessage_Binary struct { + Binary []byte `protobuf:"bytes,2,opt,name=binary,proto3,oneof"` +} + +func (*DataMessage_Text) isDataMessage_Value() {} + +func (*DataMessage_Binary) isDataMessage_Value() {} + +var File_model_proto protoreflect.FileDescriptor + +var file_model_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x22, 0xc6, 0x01, 0x0a, 0x04, 0x52, 0x6f, 0x6f, 0x6d, 0x12, + 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x69, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x61, + 0x78, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x6d, 0x61, 0x78, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x75, + 0x72, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x74, 0x75, 0x72, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, + 0xfd, 0x01, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x12, 0x34, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1e, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x63, 0x6b, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x74, 0x72, 0x61, + 0x63, 0x6b, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x3e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x4a, 0x4f, 0x49, 0x4e, + 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4a, 0x4f, 0x49, 0x4e, 0x45, 0x44, 0x10, + 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x12, 0x10, 0x0a, + 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x22, + 0x6f, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, + 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x26, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x75, + 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, 0x75, 0x74, 0x65, 0x64, + 0x22, 0x46, 0x0a, 0x0b, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x14, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x18, 0x0a, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x42, + 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x2b, 0x0a, 0x09, 0x54, 0x72, 0x61, 0x63, + 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x55, 0x44, 0x49, 0x4f, 0x10, 0x00, + 0x12, 0x09, 0x0a, 0x05, 0x56, 0x49, 0x44, 0x45, 0x4f, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, + 0x41, 0x54, 0x41, 0x10, 0x02, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2f, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_model_proto_rawDescOnce sync.Once + file_model_proto_rawDescData = file_model_proto_rawDesc +) + +func file_model_proto_rawDescGZIP() []byte { + file_model_proto_rawDescOnce.Do(func() { + file_model_proto_rawDescData = protoimpl.X.CompressGZIP(file_model_proto_rawDescData) + }) + return file_model_proto_rawDescData +} + +var file_model_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_model_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_model_proto_goTypes = []interface{}{ + (TrackType)(0), // 0: livekit.TrackType + (ParticipantInfo_State)(0), // 1: livekit.ParticipantInfo.State + (*Room)(nil), // 2: livekit.Room + (*ParticipantInfo)(nil), // 3: livekit.ParticipantInfo + (*TrackInfo)(nil), // 4: livekit.TrackInfo + (*DataMessage)(nil), // 5: livekit.DataMessage +} +var file_model_proto_depIdxs = []int32{ + 1, // 0: livekit.ParticipantInfo.state:type_name -> livekit.ParticipantInfo.State + 4, // 1: livekit.ParticipantInfo.tracks:type_name -> livekit.TrackInfo + 0, // 2: livekit.TrackInfo.type:type_name -> livekit.TrackType + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_model_proto_init() } +func file_model_proto_init() { + if File_model_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_model_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Room); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_model_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ParticipantInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_model_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TrackInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_model_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_model_proto_msgTypes[3].OneofWrappers = []interface{}{ + (*DataMessage_Text)(nil), + (*DataMessage_Binary)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_model_proto_rawDesc, + NumEnums: 2, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_model_proto_goTypes, + DependencyIndexes: file_model_proto_depIdxs, + EnumInfos: file_model_proto_enumTypes, + MessageInfos: file_model_proto_msgTypes, + }.Build() + File_model_proto = out.File + file_model_proto_rawDesc = nil + file_model_proto_goTypes = nil + file_model_proto_depIdxs = nil +} diff --git a/proto/model.proto b/proto/model.proto deleted file mode 100644 index 01d4dbdd..00000000 --- a/proto/model.proto +++ /dev/null @@ -1,51 +0,0 @@ -syntax = "proto3"; - -package livekit; -option go_package = "github.com/livekit/livekit-server/proto/livekit"; - -message Room { - string sid = 1; - string name = 2; - uint32 empty_timeout = 3; - uint32 max_participants = 4; - int64 creation_time = 5; - string turn_password = 6; -} - -message ParticipantInfo { - enum State { - // websocket' connected, but not offered yet - JOINING = 0; - // server received client offer - JOINED = 1; - // ICE connectivity established - ACTIVE = 2; - // WS disconnected - DISCONNECTED = 3; - } - string sid = 1; - string identity = 2; - State state = 3; - repeated TrackInfo tracks = 4; - string metadata = 5; -} - -enum TrackType { - AUDIO = 0; - VIDEO = 1; - DATA = 2; -} - -message TrackInfo { - string sid = 1; - TrackType type = 2; - string name = 3; - bool muted = 4; -} - -message DataMessage { - oneof value { - string text = 1; - bytes binary = 2; - } -} diff --git a/proto/room.pb.go b/proto/room.pb.go new file mode 100644 index 00000000..ce265e52 --- /dev/null +++ b/proto/room.pb.go @@ -0,0 +1,879 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: room.proto + +package livekit + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type CreateRoomRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // number of seconds the room should cleanup after being empty + EmptyTimeout uint32 `protobuf:"varint,2,opt,name=empty_timeout,json=emptyTimeout,proto3" json:"empty_timeout,omitempty"` + MaxParticipants uint32 `protobuf:"varint,3,opt,name=max_participants,json=maxParticipants,proto3" json:"max_participants,omitempty"` + // override the node room is allocated to, for debugging + NodeId string `protobuf:"bytes,4,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *CreateRoomRequest) Reset() { + *x = CreateRoomRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateRoomRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRoomRequest) ProtoMessage() {} + +func (x *CreateRoomRequest) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateRoomRequest.ProtoReflect.Descriptor instead. +func (*CreateRoomRequest) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateRoomRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateRoomRequest) GetEmptyTimeout() uint32 { + if x != nil { + return x.EmptyTimeout + } + return 0 +} + +func (x *CreateRoomRequest) GetMaxParticipants() uint32 { + if x != nil { + return x.MaxParticipants + } + return 0 +} + +func (x *CreateRoomRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +type ListRoomsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListRoomsRequest) Reset() { + *x = ListRoomsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRoomsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRoomsRequest) ProtoMessage() {} + +func (x *ListRoomsRequest) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRoomsRequest.ProtoReflect.Descriptor instead. +func (*ListRoomsRequest) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{1} +} + +type ListRoomsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Rooms []*Room `protobuf:"bytes,1,rep,name=rooms,proto3" json:"rooms,omitempty"` +} + +func (x *ListRoomsResponse) Reset() { + *x = ListRoomsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRoomsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRoomsResponse) ProtoMessage() {} + +func (x *ListRoomsResponse) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRoomsResponse.ProtoReflect.Descriptor instead. +func (*ListRoomsResponse) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{2} +} + +func (x *ListRoomsResponse) GetRooms() []*Room { + if x != nil { + return x.Rooms + } + return nil +} + +type DeleteRoomRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Room string `protobuf:"bytes,1,opt,name=room,proto3" json:"room,omitempty"` +} + +func (x *DeleteRoomRequest) Reset() { + *x = DeleteRoomRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRoomRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRoomRequest) ProtoMessage() {} + +func (x *DeleteRoomRequest) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRoomRequest.ProtoReflect.Descriptor instead. +func (*DeleteRoomRequest) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{3} +} + +func (x *DeleteRoomRequest) GetRoom() string { + if x != nil { + return x.Room + } + return "" +} + +type DeleteRoomResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteRoomResponse) Reset() { + *x = DeleteRoomResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteRoomResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRoomResponse) ProtoMessage() {} + +func (x *DeleteRoomResponse) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteRoomResponse.ProtoReflect.Descriptor instead. +func (*DeleteRoomResponse) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{4} +} + +type ListParticipantsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Room string `protobuf:"bytes,1,opt,name=room,proto3" json:"room,omitempty"` +} + +func (x *ListParticipantsRequest) Reset() { + *x = ListParticipantsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListParticipantsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListParticipantsRequest) ProtoMessage() {} + +func (x *ListParticipantsRequest) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListParticipantsRequest.ProtoReflect.Descriptor instead. +func (*ListParticipantsRequest) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{5} +} + +func (x *ListParticipantsRequest) GetRoom() string { + if x != nil { + return x.Room + } + return "" +} + +type ListParticipantsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Participants []*ParticipantInfo `protobuf:"bytes,1,rep,name=participants,proto3" json:"participants,omitempty"` +} + +func (x *ListParticipantsResponse) Reset() { + *x = ListParticipantsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListParticipantsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListParticipantsResponse) ProtoMessage() {} + +func (x *ListParticipantsResponse) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListParticipantsResponse.ProtoReflect.Descriptor instead. +func (*ListParticipantsResponse) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{6} +} + +func (x *ListParticipantsResponse) GetParticipants() []*ParticipantInfo { + if x != nil { + return x.Participants + } + return nil +} + +type RoomParticipantIdentity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Room string `protobuf:"bytes,1,opt,name=room,proto3" json:"room,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` +} + +func (x *RoomParticipantIdentity) Reset() { + *x = RoomParticipantIdentity{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RoomParticipantIdentity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoomParticipantIdentity) ProtoMessage() {} + +func (x *RoomParticipantIdentity) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoomParticipantIdentity.ProtoReflect.Descriptor instead. +func (*RoomParticipantIdentity) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{7} +} + +func (x *RoomParticipantIdentity) GetRoom() string { + if x != nil { + return x.Room + } + return "" +} + +func (x *RoomParticipantIdentity) GetIdentity() string { + if x != nil { + return x.Identity + } + return "" +} + +type RemoveParticipantResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RemoveParticipantResponse) Reset() { + *x = RemoveParticipantResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveParticipantResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveParticipantResponse) ProtoMessage() {} + +func (x *RemoveParticipantResponse) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveParticipantResponse.ProtoReflect.Descriptor instead. +func (*RemoveParticipantResponse) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{8} +} + +type MuteRoomTrackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Room string `protobuf:"bytes,1,opt,name=room,proto3" json:"room,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + TrackSid string `protobuf:"bytes,3,opt,name=track_sid,json=trackSid,proto3" json:"track_sid,omitempty"` + Muted bool `protobuf:"varint,4,opt,name=muted,proto3" json:"muted,omitempty"` +} + +func (x *MuteRoomTrackRequest) Reset() { + *x = MuteRoomTrackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MuteRoomTrackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MuteRoomTrackRequest) ProtoMessage() {} + +func (x *MuteRoomTrackRequest) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MuteRoomTrackRequest.ProtoReflect.Descriptor instead. +func (*MuteRoomTrackRequest) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{9} +} + +func (x *MuteRoomTrackRequest) GetRoom() string { + if x != nil { + return x.Room + } + return "" +} + +func (x *MuteRoomTrackRequest) GetIdentity() string { + if x != nil { + return x.Identity + } + return "" +} + +func (x *MuteRoomTrackRequest) GetTrackSid() string { + if x != nil { + return x.TrackSid + } + return "" +} + +func (x *MuteRoomTrackRequest) GetMuted() bool { + if x != nil { + return x.Muted + } + return false +} + +type MuteRoomTrackResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Track *TrackInfo `protobuf:"bytes,1,opt,name=track,proto3" json:"track,omitempty"` +} + +func (x *MuteRoomTrackResponse) Reset() { + *x = MuteRoomTrackResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_room_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MuteRoomTrackResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MuteRoomTrackResponse) ProtoMessage() {} + +func (x *MuteRoomTrackResponse) ProtoReflect() protoreflect.Message { + mi := &file_room_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MuteRoomTrackResponse.ProtoReflect.Descriptor instead. +func (*MuteRoomTrackResponse) Descriptor() ([]byte, []int) { + return file_room_proto_rawDescGZIP(), []int{10} +} + +func (x *MuteRoomTrackResponse) GetTrack() *TrackInfo { + if x != nil { + return x.Track + } + return nil +} + +var File_room_proto protoreflect.FileDescriptor + +var file_room_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x72, 0x6f, 0x6f, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x1a, 0x0b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x90, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, + 0x74, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x6d, 0x61, 0x78, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x17, 0x0a, 0x07, + 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, + 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6f, + 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x38, 0x0a, 0x11, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, + 0x0a, 0x05, 0x72, 0x6f, 0x6f, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x52, 0x05, 0x72, 0x6f, + 0x6f, 0x6d, 0x73, 0x22, 0x27, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6f, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x6d, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x22, 0x14, 0x0a, 0x12, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x2d, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6f, + 0x6d, 0x22, 0x58, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, + 0x70, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, + 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x70, + 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x49, 0x0a, 0x17, 0x52, + 0x6f, 0x6f, 0x6d, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0x1b, 0x0a, 0x19, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x79, 0x0a, 0x14, 0x4d, 0x75, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x54, + 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72, + 0x6f, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x12, + 0x1a, 0x0a, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, + 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x73, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x74, 0x72, 0x61, 0x63, 0x6b, 0x53, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x75, 0x74, 0x65, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, 0x75, 0x74, 0x65, 0x64, 0x22, 0x41, + 0x0a, 0x15, 0x4d, 0x75, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x63, 0x6b, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, + 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x74, 0x72, 0x61, 0x63, + 0x6b, 0x32, 0xa8, 0x04, 0x0a, 0x0b, 0x52, 0x6f, 0x6f, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x12, + 0x1a, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x52, 0x6f, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x42, 0x0a, 0x09, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x12, 0x19, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, + 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x1a, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6f, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x20, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, + 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, + 0x12, 0x20, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x50, + 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x59, 0x0a, 0x11, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, + 0x74, 0x12, 0x20, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x1a, 0x22, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x4d, 0x75, 0x74, 0x65, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x12, 0x1d, 0x2e, + 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4d, 0x75, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, + 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4d, 0x75, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x6d, 0x54, + 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_room_proto_rawDescOnce sync.Once + file_room_proto_rawDescData = file_room_proto_rawDesc +) + +func file_room_proto_rawDescGZIP() []byte { + file_room_proto_rawDescOnce.Do(func() { + file_room_proto_rawDescData = protoimpl.X.CompressGZIP(file_room_proto_rawDescData) + }) + return file_room_proto_rawDescData +} + +var file_room_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_room_proto_goTypes = []interface{}{ + (*CreateRoomRequest)(nil), // 0: livekit.CreateRoomRequest + (*ListRoomsRequest)(nil), // 1: livekit.ListRoomsRequest + (*ListRoomsResponse)(nil), // 2: livekit.ListRoomsResponse + (*DeleteRoomRequest)(nil), // 3: livekit.DeleteRoomRequest + (*DeleteRoomResponse)(nil), // 4: livekit.DeleteRoomResponse + (*ListParticipantsRequest)(nil), // 5: livekit.ListParticipantsRequest + (*ListParticipantsResponse)(nil), // 6: livekit.ListParticipantsResponse + (*RoomParticipantIdentity)(nil), // 7: livekit.RoomParticipantIdentity + (*RemoveParticipantResponse)(nil), // 8: livekit.RemoveParticipantResponse + (*MuteRoomTrackRequest)(nil), // 9: livekit.MuteRoomTrackRequest + (*MuteRoomTrackResponse)(nil), // 10: livekit.MuteRoomTrackResponse + (*Room)(nil), // 11: livekit.Room + (*ParticipantInfo)(nil), // 12: livekit.ParticipantInfo + (*TrackInfo)(nil), // 13: livekit.TrackInfo +} +var file_room_proto_depIdxs = []int32{ + 11, // 0: livekit.ListRoomsResponse.rooms:type_name -> livekit.Room + 12, // 1: livekit.ListParticipantsResponse.participants:type_name -> livekit.ParticipantInfo + 13, // 2: livekit.MuteRoomTrackResponse.track:type_name -> livekit.TrackInfo + 0, // 3: livekit.RoomService.CreateRoom:input_type -> livekit.CreateRoomRequest + 1, // 4: livekit.RoomService.ListRooms:input_type -> livekit.ListRoomsRequest + 3, // 5: livekit.RoomService.DeleteRoom:input_type -> livekit.DeleteRoomRequest + 5, // 6: livekit.RoomService.ListParticipants:input_type -> livekit.ListParticipantsRequest + 7, // 7: livekit.RoomService.GetParticipant:input_type -> livekit.RoomParticipantIdentity + 7, // 8: livekit.RoomService.RemoveParticipant:input_type -> livekit.RoomParticipantIdentity + 9, // 9: livekit.RoomService.MutePublishedTrack:input_type -> livekit.MuteRoomTrackRequest + 11, // 10: livekit.RoomService.CreateRoom:output_type -> livekit.Room + 2, // 11: livekit.RoomService.ListRooms:output_type -> livekit.ListRoomsResponse + 4, // 12: livekit.RoomService.DeleteRoom:output_type -> livekit.DeleteRoomResponse + 6, // 13: livekit.RoomService.ListParticipants:output_type -> livekit.ListParticipantsResponse + 12, // 14: livekit.RoomService.GetParticipant:output_type -> livekit.ParticipantInfo + 8, // 15: livekit.RoomService.RemoveParticipant:output_type -> livekit.RemoveParticipantResponse + 10, // 16: livekit.RoomService.MutePublishedTrack:output_type -> livekit.MuteRoomTrackResponse + 10, // [10:17] is the sub-list for method output_type + 3, // [3:10] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_room_proto_init() } +func file_room_proto_init() { + if File_room_proto != nil { + return + } + file_model_proto_init() + if !protoimpl.UnsafeEnabled { + file_room_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateRoomRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRoomsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRoomsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRoomRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteRoomResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListParticipantsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListParticipantsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RoomParticipantIdentity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveParticipantResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MuteRoomTrackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_room_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MuteRoomTrackResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_room_proto_rawDesc, + NumEnums: 0, + NumMessages: 11, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_room_proto_goTypes, + DependencyIndexes: file_room_proto_depIdxs, + MessageInfos: file_room_proto_msgTypes, + }.Build() + File_room_proto = out.File + file_room_proto_rawDesc = nil + file_room_proto_goTypes = nil + file_room_proto_depIdxs = nil +} diff --git a/proto/room.proto b/proto/room.proto deleted file mode 100644 index 2dae20f5..00000000 --- a/proto/room.proto +++ /dev/null @@ -1,76 +0,0 @@ -syntax = "proto3"; - -package livekit; -option go_package = "github.com/livekit/livekit-server/proto/livekit"; - -import "model.proto"; - -// Room service that can be performed on any node -// they are Twirp-based HTTP req/responses -service RoomService { - - // should be accessible to only internal servers, not external - rpc CreateRoom(CreateRoomRequest) returns (Room); - rpc ListRooms(ListRoomsRequest) returns (ListRoomsResponse); - rpc DeleteRoom(DeleteRoomRequest) returns (DeleteRoomResponse); - - // lists participants in a room, requires RoomAdmin - rpc ListParticipants(ListParticipantsRequest) returns (ListParticipantsResponse); - // get information on a specific participant, requires RoomAdmin - rpc GetParticipant(RoomParticipantIdentity) returns (ParticipantInfo); - // removes a participant from room, requires RoomAdmin - rpc RemoveParticipant(RoomParticipantIdentity) returns (RemoveParticipantResponse); - - // mute/unmute a participant, requires RoomAdmin - rpc MutePublishedTrack(MuteRoomTrackRequest) returns (MuteRoomTrackResponse); -} - -message CreateRoomRequest { - string name = 1; - // number of seconds the room should cleanup after being empty - uint32 empty_timeout = 2; - uint32 max_participants = 3; - // override the node room is allocated to, for debugging - string node_id = 4; -} - -message ListRoomsRequest { -} - -message ListRoomsResponse { - repeated Room rooms = 1; -} - -message DeleteRoomRequest { - string room = 1; -} - -message DeleteRoomResponse { -} - -message ListParticipantsRequest { - string room = 1; -} - -message ListParticipantsResponse { - repeated ParticipantInfo participants = 1; -} - -message RoomParticipantIdentity { - string room = 1; - string identity = 2; -} - -message RemoveParticipantResponse { -} - -message MuteRoomTrackRequest { - string room = 1; - string identity = 2; - string track_sid = 3; - bool muted = 4; -} - -message MuteRoomTrackResponse { - TrackInfo track = 1; -} \ No newline at end of file diff --git a/proto/room.twirp.go b/proto/room.twirp.go new file mode 100644 index 00000000..e55761e9 --- /dev/null +++ b/proto/room.twirp.go @@ -0,0 +1,2732 @@ +// Code generated by protoc-gen-twirp v7.1.1, DO NOT EDIT. +// source: room.proto + +/* +Package livekit is a generated twirp stub package. +This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v7.1.1. + +It is generated from these files: + room.proto +*/ +package livekit + +import bytes "bytes" +import strings "strings" +import context "context" +import fmt "fmt" +import ioutil "io/ioutil" +import http "net/http" +import strconv "strconv" + +import jsonpb "github.com/golang/protobuf/jsonpb" +import proto "github.com/golang/protobuf/proto" +import twirp "github.com/twitchtv/twirp" +import ctxsetters "github.com/twitchtv/twirp/ctxsetters" + +// Imports only used by utility functions: +import io "io" +import json "encoding/json" +import path "path" +import url "net/url" + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the twirp package used in your project. +// A compilation error at this line likely means your copy of the +// twirp package needs to be updated. +const _ = twirp.TwirpPackageIsVersion7 + +// ===================== +// RoomService Interface +// ===================== + +// Room service that can be performed on any node +// they are Twirp-based HTTP req/responses +type RoomService interface { + // should be accessible to only internal servers, not external + CreateRoom(context.Context, *CreateRoomRequest) (*Room, error) + + ListRooms(context.Context, *ListRoomsRequest) (*ListRoomsResponse, error) + + DeleteRoom(context.Context, *DeleteRoomRequest) (*DeleteRoomResponse, error) + + // lists participants in a room, requires RoomAdmin + ListParticipants(context.Context, *ListParticipantsRequest) (*ListParticipantsResponse, error) + + // get information on a specific participant, requires RoomAdmin + GetParticipant(context.Context, *RoomParticipantIdentity) (*ParticipantInfo, error) + + // removes a participant from room, requires RoomAdmin + RemoveParticipant(context.Context, *RoomParticipantIdentity) (*RemoveParticipantResponse, error) + + // mute/unmute a participant, requires RoomAdmin + MutePublishedTrack(context.Context, *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) +} + +// =========================== +// RoomService Protobuf Client +// =========================== + +type roomServiceProtobufClient struct { + client HTTPClient + urls [7]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewRoomServiceProtobufClient creates a Protobuf client that implements the RoomService interface. +// It communicates using Protobuf and can be configured with a custom HTTPClient. +func NewRoomServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) RoomService { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(clientOpts.PathPrefix(), "livekit", "RoomService") + urls := [7]string{ + serviceURL + "CreateRoom", + serviceURL + "ListRooms", + serviceURL + "DeleteRoom", + serviceURL + "ListParticipants", + serviceURL + "GetParticipant", + serviceURL + "RemoveParticipant", + serviceURL + "MutePublishedTrack", + } + + return &roomServiceProtobufClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *roomServiceProtobufClient) CreateRoom(ctx context.Context, in *CreateRoomRequest) (*Room, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "CreateRoom") + caller := c.callCreateRoom + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateRoomRequest) (*Room, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateRoomRequest) when calling interceptor") + } + return c.callCreateRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*Room) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*Room) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callCreateRoom(ctx context.Context, in *CreateRoomRequest) (*Room, error) { + out := new(Room) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) ListRooms(ctx context.Context, in *ListRoomsRequest) (*ListRoomsResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "ListRooms") + caller := c.callListRooms + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListRoomsRequest) (*ListRoomsResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListRoomsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListRoomsRequest) when calling interceptor") + } + return c.callListRooms(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListRoomsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListRoomsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callListRooms(ctx context.Context, in *ListRoomsRequest) (*ListRoomsResponse, error) { + out := new(ListRoomsResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) DeleteRoom(ctx context.Context, in *DeleteRoomRequest) (*DeleteRoomResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "DeleteRoom") + caller := c.callDeleteRoom + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteRoomRequest) (*DeleteRoomResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteRoomRequest) when calling interceptor") + } + return c.callDeleteRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*DeleteRoomResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*DeleteRoomResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callDeleteRoom(ctx context.Context, in *DeleteRoomRequest) (*DeleteRoomResponse, error) { + out := new(DeleteRoomResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) ListParticipants(ctx context.Context, in *ListParticipantsRequest) (*ListParticipantsResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "ListParticipants") + caller := c.callListParticipants + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListParticipantsRequest) (*ListParticipantsResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListParticipantsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListParticipantsRequest) when calling interceptor") + } + return c.callListParticipants(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListParticipantsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListParticipantsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callListParticipants(ctx context.Context, in *ListParticipantsRequest) (*ListParticipantsResponse, error) { + out := new(ListParticipantsResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) GetParticipant(ctx context.Context, in *RoomParticipantIdentity) (*ParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "GetParticipant") + caller := c.callGetParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *RoomParticipantIdentity) (*ParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return c.callGetParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callGetParticipant(ctx context.Context, in *RoomParticipantIdentity) (*ParticipantInfo, error) { + out := new(ParticipantInfo) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) RemoveParticipant(ctx context.Context, in *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "RemoveParticipant") + caller := c.callRemoveParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return c.callRemoveParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*RemoveParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*RemoveParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callRemoveParticipant(ctx context.Context, in *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + out := new(RemoveParticipantResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceProtobufClient) MutePublishedTrack(ctx context.Context, in *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "MutePublishedTrack") + caller := c.callMutePublishedTrack + if c.interceptor != nil { + caller = func(ctx context.Context, req *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*MuteRoomTrackRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*MuteRoomTrackRequest) when calling interceptor") + } + return c.callMutePublishedTrack(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*MuteRoomTrackResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*MuteRoomTrackResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceProtobufClient) callMutePublishedTrack(ctx context.Context, in *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + out := new(MuteRoomTrackResponse) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// ======================= +// RoomService JSON Client +// ======================= + +type roomServiceJSONClient struct { + client HTTPClient + urls [7]string + interceptor twirp.Interceptor + opts twirp.ClientOptions +} + +// NewRoomServiceJSONClient creates a JSON client that implements the RoomService interface. +// It communicates using JSON and can be configured with a custom HTTPClient. +func NewRoomServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) RoomService { + if c, ok := client.(*http.Client); ok { + client = withoutRedirects(c) + } + + clientOpts := twirp.ClientOptions{} + for _, o := range opts { + o(&clientOpts) + } + + // Build method URLs: []/./ + serviceURL := sanitizeBaseURL(baseURL) + serviceURL += baseServicePath(clientOpts.PathPrefix(), "livekit", "RoomService") + urls := [7]string{ + serviceURL + "CreateRoom", + serviceURL + "ListRooms", + serviceURL + "DeleteRoom", + serviceURL + "ListParticipants", + serviceURL + "GetParticipant", + serviceURL + "RemoveParticipant", + serviceURL + "MutePublishedTrack", + } + + return &roomServiceJSONClient{ + client: client, + urls: urls, + interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), + opts: clientOpts, + } +} + +func (c *roomServiceJSONClient) CreateRoom(ctx context.Context, in *CreateRoomRequest) (*Room, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "CreateRoom") + caller := c.callCreateRoom + if c.interceptor != nil { + caller = func(ctx context.Context, req *CreateRoomRequest) (*Room, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateRoomRequest) when calling interceptor") + } + return c.callCreateRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*Room) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*Room) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callCreateRoom(ctx context.Context, in *CreateRoomRequest) (*Room, error) { + out := new(Room) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) ListRooms(ctx context.Context, in *ListRoomsRequest) (*ListRoomsResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "ListRooms") + caller := c.callListRooms + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListRoomsRequest) (*ListRoomsResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListRoomsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListRoomsRequest) when calling interceptor") + } + return c.callListRooms(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListRoomsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListRoomsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callListRooms(ctx context.Context, in *ListRoomsRequest) (*ListRoomsResponse, error) { + out := new(ListRoomsResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) DeleteRoom(ctx context.Context, in *DeleteRoomRequest) (*DeleteRoomResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "DeleteRoom") + caller := c.callDeleteRoom + if c.interceptor != nil { + caller = func(ctx context.Context, req *DeleteRoomRequest) (*DeleteRoomResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteRoomRequest) when calling interceptor") + } + return c.callDeleteRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*DeleteRoomResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*DeleteRoomResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callDeleteRoom(ctx context.Context, in *DeleteRoomRequest) (*DeleteRoomResponse, error) { + out := new(DeleteRoomResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) ListParticipants(ctx context.Context, in *ListParticipantsRequest) (*ListParticipantsResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "ListParticipants") + caller := c.callListParticipants + if c.interceptor != nil { + caller = func(ctx context.Context, req *ListParticipantsRequest) (*ListParticipantsResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListParticipantsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListParticipantsRequest) when calling interceptor") + } + return c.callListParticipants(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListParticipantsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListParticipantsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callListParticipants(ctx context.Context, in *ListParticipantsRequest) (*ListParticipantsResponse, error) { + out := new(ListParticipantsResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) GetParticipant(ctx context.Context, in *RoomParticipantIdentity) (*ParticipantInfo, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "GetParticipant") + caller := c.callGetParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *RoomParticipantIdentity) (*ParticipantInfo, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return c.callGetParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callGetParticipant(ctx context.Context, in *RoomParticipantIdentity) (*ParticipantInfo, error) { + out := new(ParticipantInfo) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) RemoveParticipant(ctx context.Context, in *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "RemoveParticipant") + caller := c.callRemoveParticipant + if c.interceptor != nil { + caller = func(ctx context.Context, req *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return c.callRemoveParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*RemoveParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*RemoveParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callRemoveParticipant(ctx context.Context, in *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + out := new(RemoveParticipantResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +func (c *roomServiceJSONClient) MutePublishedTrack(ctx context.Context, in *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithMethodName(ctx, "MutePublishedTrack") + caller := c.callMutePublishedTrack + if c.interceptor != nil { + caller = func(ctx context.Context, req *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + resp, err := c.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*MuteRoomTrackRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*MuteRoomTrackRequest) when calling interceptor") + } + return c.callMutePublishedTrack(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*MuteRoomTrackResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*MuteRoomTrackResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + return caller(ctx, in) +} + +func (c *roomServiceJSONClient) callMutePublishedTrack(ctx context.Context, in *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + out := new(MuteRoomTrackResponse) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out) + if err != nil { + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + callClientError(ctx, c.opts.Hooks, twerr) + return nil, err + } + + callClientResponseReceived(ctx, c.opts.Hooks) + + return out, nil +} + +// ========================== +// RoomService Server Handler +// ========================== + +type roomServiceServer struct { + RoomService + interceptor twirp.Interceptor + hooks *twirp.ServerHooks + pathPrefix string // prefix for routing + jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response +} + +// NewRoomServiceServer builds a TwirpServer that can be used as an http.Handler to handle +// HTTP requests that are routed to the right method in the provided svc implementation. +// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). +func NewRoomServiceServer(svc RoomService, opts ...interface{}) TwirpServer { + serverOpts := twirp.ServerOptions{} + for _, opt := range opts { + switch o := opt.(type) { + case twirp.ServerOption: + o(&serverOpts) + case *twirp.ServerHooks: // backwards compatibility, allow to specify hooks as an argument + twirp.WithServerHooks(o)(&serverOpts) + case nil: // backwards compatibility, allow nil value for the argument + continue + default: + panic(fmt.Sprintf("Invalid option type %T on NewRoomServiceServer", o)) + } + } + + return &roomServiceServer{ + RoomService: svc, + pathPrefix: serverOpts.PathPrefix(), + interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), + hooks: serverOpts.Hooks, + jsonSkipDefaults: serverOpts.JSONSkipDefaults, + } +} + +// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. +// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) +func (s *roomServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { + writeError(ctx, resp, err, s.hooks) +} + +// RoomServicePathPrefix is a convenience constant that could used to identify URL paths. +// Should be used with caution, it only matches routes generated by Twirp Go clients, +// that add a "/twirp" prefix by default, and use CamelCase service and method names. +// More info: https://twitchtv.github.io/twirp/docs/routing.html +const RoomServicePathPrefix = "/twirp/livekit.RoomService/" + +func (s *roomServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { + ctx := req.Context() + ctx = ctxsetters.WithPackageName(ctx, "livekit") + ctx = ctxsetters.WithServiceName(ctx, "RoomService") + ctx = ctxsetters.WithResponseWriter(ctx, resp) + + var err error + ctx, err = callRequestReceived(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + if req.Method != "POST" { + msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + // Verify path format: []/./ + prefix, pkgService, method := parseTwirpPath(req.URL.Path) + if pkgService != "livekit.RoomService" { + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + if prefix != s.pathPrefix { + msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } + + switch method { + case "CreateRoom": + s.serveCreateRoom(ctx, resp, req) + return + case "ListRooms": + s.serveListRooms(ctx, resp, req) + return + case "DeleteRoom": + s.serveDeleteRoom(ctx, resp, req) + return + case "ListParticipants": + s.serveListParticipants(ctx, resp, req) + return + case "GetParticipant": + s.serveGetParticipant(ctx, resp, req) + return + case "RemoveParticipant": + s.serveRemoveParticipant(ctx, resp, req) + return + case "MutePublishedTrack": + s.serveMutePublishedTrack(ctx, resp, req) + return + default: + msg := fmt.Sprintf("no handler for path %q", req.URL.Path) + s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) + return + } +} + +func (s *roomServiceServer) serveCreateRoom(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveCreateRoomJSON(ctx, resp, req) + case "application/protobuf": + s.serveCreateRoomProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveCreateRoomJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateRoom") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(CreateRoomRequest) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.CreateRoom + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateRoomRequest) (*Room, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateRoomRequest) when calling interceptor") + } + return s.RoomService.CreateRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*Room) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*Room) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *Room + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *Room and nil error while calling CreateRoom. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveCreateRoomProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "CreateRoom") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(CreateRoomRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.CreateRoom + if s.interceptor != nil { + handler = func(ctx context.Context, req *CreateRoomRequest) (*Room, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*CreateRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*CreateRoomRequest) when calling interceptor") + } + return s.RoomService.CreateRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*Room) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*Room) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *Room + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *Room and nil error while calling CreateRoom. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveListRooms(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveListRoomsJSON(ctx, resp, req) + case "application/protobuf": + s.serveListRoomsProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveListRoomsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListRooms") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(ListRoomsRequest) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.ListRooms + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListRoomsRequest) (*ListRoomsResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListRoomsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListRoomsRequest) when calling interceptor") + } + return s.RoomService.ListRooms(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListRoomsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListRoomsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListRoomsResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListRoomsResponse and nil error while calling ListRooms. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveListRoomsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListRooms") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(ListRoomsRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.ListRooms + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListRoomsRequest) (*ListRoomsResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListRoomsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListRoomsRequest) when calling interceptor") + } + return s.RoomService.ListRooms(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListRoomsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListRoomsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListRoomsResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListRoomsResponse and nil error while calling ListRooms. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveDeleteRoom(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveDeleteRoomJSON(ctx, resp, req) + case "application/protobuf": + s.serveDeleteRoomProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveDeleteRoomJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteRoom") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(DeleteRoomRequest) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.DeleteRoom + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteRoomRequest) (*DeleteRoomResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteRoomRequest) when calling interceptor") + } + return s.RoomService.DeleteRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*DeleteRoomResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*DeleteRoomResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *DeleteRoomResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *DeleteRoomResponse and nil error while calling DeleteRoom. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveDeleteRoomProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "DeleteRoom") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(DeleteRoomRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.DeleteRoom + if s.interceptor != nil { + handler = func(ctx context.Context, req *DeleteRoomRequest) (*DeleteRoomResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*DeleteRoomRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*DeleteRoomRequest) when calling interceptor") + } + return s.RoomService.DeleteRoom(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*DeleteRoomResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*DeleteRoomResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *DeleteRoomResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *DeleteRoomResponse and nil error while calling DeleteRoom. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveListParticipants(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveListParticipantsJSON(ctx, resp, req) + case "application/protobuf": + s.serveListParticipantsProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveListParticipantsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListParticipants") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(ListParticipantsRequest) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.ListParticipants + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListParticipantsRequest) (*ListParticipantsResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListParticipantsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListParticipantsRequest) when calling interceptor") + } + return s.RoomService.ListParticipants(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListParticipantsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListParticipantsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListParticipantsResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListParticipantsResponse and nil error while calling ListParticipants. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveListParticipantsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "ListParticipants") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(ListParticipantsRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.ListParticipants + if s.interceptor != nil { + handler = func(ctx context.Context, req *ListParticipantsRequest) (*ListParticipantsResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*ListParticipantsRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*ListParticipantsRequest) when calling interceptor") + } + return s.RoomService.ListParticipants(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ListParticipantsResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ListParticipantsResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ListParticipantsResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ListParticipantsResponse and nil error while calling ListParticipants. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveGetParticipant(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveGetParticipantJSON(ctx, resp, req) + case "application/protobuf": + s.serveGetParticipantProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveGetParticipantJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "GetParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(RoomParticipantIdentity) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.GetParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *RoomParticipantIdentity) (*ParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return s.RoomService.GetParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ParticipantInfo and nil error while calling GetParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveGetParticipantProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "GetParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(RoomParticipantIdentity) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.GetParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *RoomParticipantIdentity) (*ParticipantInfo, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return s.RoomService.GetParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*ParticipantInfo) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*ParticipantInfo) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *ParticipantInfo + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *ParticipantInfo and nil error while calling GetParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveRemoveParticipant(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveRemoveParticipantJSON(ctx, resp, req) + case "application/protobuf": + s.serveRemoveParticipantProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveRemoveParticipantJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "RemoveParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(RoomParticipantIdentity) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.RemoveParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return s.RoomService.RemoveParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*RemoveParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*RemoveParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *RemoveParticipantResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveParticipantResponse and nil error while calling RemoveParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveRemoveParticipantProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "RemoveParticipant") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(RoomParticipantIdentity) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.RemoveParticipant + if s.interceptor != nil { + handler = func(ctx context.Context, req *RoomParticipantIdentity) (*RemoveParticipantResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*RoomParticipantIdentity) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*RoomParticipantIdentity) when calling interceptor") + } + return s.RoomService.RemoveParticipant(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*RemoveParticipantResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*RemoveParticipantResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *RemoveParticipantResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *RemoveParticipantResponse and nil error while calling RemoveParticipant. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveMutePublishedTrack(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + header := req.Header.Get("Content-Type") + i := strings.Index(header, ";") + if i == -1 { + i = len(header) + } + switch strings.TrimSpace(strings.ToLower(header[:i])) { + case "application/json": + s.serveMutePublishedTrackJSON(ctx, resp, req) + case "application/protobuf": + s.serveMutePublishedTrackProtobuf(ctx, resp, req) + default: + msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) + twerr := badRouteError(msg, req.Method, req.URL.Path) + s.writeError(ctx, resp, twerr) + } +} + +func (s *roomServiceServer) serveMutePublishedTrackJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "MutePublishedTrack") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + reqContent := new(MuteRoomTrackRequest) + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) + return + } + + handler := s.RoomService.MutePublishedTrack + if s.interceptor != nil { + handler = func(ctx context.Context, req *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*MuteRoomTrackRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*MuteRoomTrackRequest) when calling interceptor") + } + return s.RoomService.MutePublishedTrack(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*MuteRoomTrackResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*MuteRoomTrackResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *MuteRoomTrackResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *MuteRoomTrackResponse and nil error while calling MutePublishedTrack. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + var buf bytes.Buffer + marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} + if err = marshaler.Marshal(&buf, respContent); err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + respBytes := buf.Bytes() + resp.Header().Set("Content-Type", "application/json") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) serveMutePublishedTrackProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { + var err error + ctx = ctxsetters.WithMethodName(ctx, "MutePublishedTrack") + ctx, err = callRequestRouted(ctx, s.hooks) + if err != nil { + s.writeError(ctx, resp, err) + return + } + + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) + return + } + reqContent := new(MuteRoomTrackRequest) + if err = proto.Unmarshal(buf, reqContent); err != nil { + s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) + return + } + + handler := s.RoomService.MutePublishedTrack + if s.interceptor != nil { + handler = func(ctx context.Context, req *MuteRoomTrackRequest) (*MuteRoomTrackResponse, error) { + resp, err := s.interceptor( + func(ctx context.Context, req interface{}) (interface{}, error) { + typedReq, ok := req.(*MuteRoomTrackRequest) + if !ok { + return nil, twirp.InternalError("failed type assertion req.(*MuteRoomTrackRequest) when calling interceptor") + } + return s.RoomService.MutePublishedTrack(ctx, typedReq) + }, + )(ctx, req) + if resp != nil { + typedResp, ok := resp.(*MuteRoomTrackResponse) + if !ok { + return nil, twirp.InternalError("failed type assertion resp.(*MuteRoomTrackResponse) when calling interceptor") + } + return typedResp, err + } + return nil, err + } + } + + // Call service method + var respContent *MuteRoomTrackResponse + func() { + defer ensurePanicResponses(ctx, resp, s.hooks) + respContent, err = handler(ctx, reqContent) + }() + + if err != nil { + s.writeError(ctx, resp, err) + return + } + if respContent == nil { + s.writeError(ctx, resp, twirp.InternalError("received a nil *MuteRoomTrackResponse and nil error while calling MutePublishedTrack. nil responses are not supported")) + return + } + + ctx = callResponsePrepared(ctx, s.hooks) + + respBytes, err := proto.Marshal(respContent) + if err != nil { + s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) + return + } + + ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) + resp.Header().Set("Content-Type", "application/protobuf") + resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) + resp.WriteHeader(http.StatusOK) + if n, err := resp.Write(respBytes); err != nil { + msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) + twerr := twirp.NewError(twirp.Unknown, msg) + ctx = callError(ctx, s.hooks, twerr) + } + callResponseSent(ctx, s.hooks) +} + +func (s *roomServiceServer) ServiceDescriptor() ([]byte, int) { + return twirpFileDescriptor0, 0 +} + +func (s *roomServiceServer) ProtocGenTwirpVersion() string { + return "v7.1.1" +} + +// PathPrefix returns the base service path, in the form: "//./" +// that is everything in a Twirp route except for the . This can be used for routing, +// for example to identify the requests that are targeted to this service in a mux. +func (s *roomServiceServer) PathPrefix() string { + return baseServicePath(s.pathPrefix, "livekit", "RoomService") +} + +// ===== +// Utils +// ===== + +// HTTPClient is the interface used by generated clients to send HTTP requests. +// It is fulfilled by *(net/http).Client, which is sufficient for most users. +// Users can provide their own implementation for special retry policies. +// +// HTTPClient implementations should not follow redirects. Redirects are +// automatically disabled if *(net/http).Client is passed to client +// constructors. See the withoutRedirects function in this file for more +// details. +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +// TwirpServer is the interface generated server structs will support: they're +// HTTP handlers with additional methods for accessing metadata about the +// service. Those accessors are a low-level API for building reflection tools. +// Most people can think of TwirpServers as just http.Handlers. +type TwirpServer interface { + http.Handler + + // ServiceDescriptor returns gzipped bytes describing the .proto file that + // this service was generated from. Once unzipped, the bytes can be + // unmarshalled as a + // github.com/golang/protobuf/protoc-gen-go/descriptor.FileDescriptorProto. + // + // The returned integer is the index of this particular service within that + // FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a + // low-level field, expected to be used for reflection. + ServiceDescriptor() ([]byte, int) + + // ProtocGenTwirpVersion is the semantic version string of the version of + // twirp used to generate this file. + ProtocGenTwirpVersion() string + + // PathPrefix returns the HTTP URL path prefix for all methods handled by this + // service. This can be used with an HTTP mux to route Twirp requests. + // The path prefix is in the form: "//./" + // that is, everything in a Twirp route except for the at the end. + PathPrefix() string +} + +// WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). +// Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. +// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) +func WriteError(resp http.ResponseWriter, err error) { + writeError(context.Background(), resp, err, nil) +} + +// writeError writes Twirp errors in the response and triggers hooks. +func writeError(ctx context.Context, resp http.ResponseWriter, err error, hooks *twirp.ServerHooks) { + // Non-twirp errors are wrapped as Internal (default) + twerr, ok := err.(twirp.Error) + if !ok { + twerr = twirp.InternalErrorWith(err) + } + + statusCode := twirp.ServerHTTPStatusFromErrorCode(twerr.Code()) + ctx = ctxsetters.WithStatusCode(ctx, statusCode) + ctx = callError(ctx, hooks, twerr) + + respBody := marshalErrorToJSON(twerr) + + resp.Header().Set("Content-Type", "application/json") // Error responses are always JSON + resp.Header().Set("Content-Length", strconv.Itoa(len(respBody))) + resp.WriteHeader(statusCode) // set HTTP status code and send response + + _, writeErr := resp.Write(respBody) + if writeErr != nil { + // We have three options here. We could log the error, call the Error + // hook, or just silently ignore the error. + // + // Logging is unacceptable because we don't have a user-controlled + // logger; writing out to stderr without permission is too rude. + // + // Calling the Error hook would confuse users: it would mean the Error + // hook got called twice for one request, which is likely to lead to + // duplicated log messages and metrics, no matter how well we document + // the behavior. + // + // Silently ignoring the error is our least-bad option. It's highly + // likely that the connection is broken and the original 'err' says + // so anyway. + _ = writeErr + } + + callResponseSent(ctx, hooks) +} + +// sanitizeBaseURL parses the the baseURL, and adds the "http" scheme if needed. +// If the URL is unparsable, the baseURL is returned unchaged. +func sanitizeBaseURL(baseURL string) string { + u, err := url.Parse(baseURL) + if err != nil { + return baseURL // invalid URL will fail later when making requests + } + if u.Scheme == "" { + u.Scheme = "http" + } + return u.String() +} + +// baseServicePath composes the path prefix for the service (without ). +// e.g.: baseServicePath("/twirp", "my.pkg", "MyService") +// returns => "/twirp/my.pkg.MyService/" +// e.g.: baseServicePath("", "", "MyService") +// returns => "/MyService/" +func baseServicePath(prefix, pkg, service string) string { + fullServiceName := service + if pkg != "" { + fullServiceName = pkg + "." + service + } + return path.Join("/", prefix, fullServiceName) + "/" +} + +// parseTwirpPath extracts path components form a valid Twirp route. +// Expected format: "[]/./" +// e.g.: prefix, pkgService, method := parseTwirpPath("/twirp/pkg.Svc/MakeHat") +func parseTwirpPath(path string) (string, string, string) { + parts := strings.Split(path, "/") + if len(parts) < 2 { + return "", "", "" + } + method := parts[len(parts)-1] + pkgService := parts[len(parts)-2] + prefix := strings.Join(parts[0:len(parts)-2], "/") + return prefix, pkgService, method +} + +// getCustomHTTPReqHeaders retrieves a copy of any headers that are set in +// a context through the twirp.WithHTTPRequestHeaders function. +// If there are no headers set, or if they have the wrong type, nil is returned. +func getCustomHTTPReqHeaders(ctx context.Context) http.Header { + header, ok := twirp.HTTPRequestHeaders(ctx) + if !ok || header == nil { + return nil + } + copied := make(http.Header) + for k, vv := range header { + if vv == nil { + copied[k] = nil + continue + } + copied[k] = make([]string, len(vv)) + copy(copied[k], vv) + } + return copied +} + +// newRequest makes an http.Request from a client, adding common headers. +func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) { + req, err := http.NewRequest("POST", url, reqBody) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil { + req.Header = customHeader + } + req.Header.Set("Accept", contentType) + req.Header.Set("Content-Type", contentType) + req.Header.Set("Twirp-Version", "v7.1.1") + return req, nil +} + +// JSON serialization for errors +type twerrJSON struct { + Code string `json:"code"` + Msg string `json:"msg"` + Meta map[string]string `json:"meta,omitempty"` +} + +// marshalErrorToJSON returns JSON from a twirp.Error, that can be used as HTTP error response body. +// If serialization fails, it will use a descriptive Internal error instead. +func marshalErrorToJSON(twerr twirp.Error) []byte { + // make sure that msg is not too large + msg := twerr.Msg() + if len(msg) > 1e6 { + msg = msg[:1e6] + } + + tj := twerrJSON{ + Code: string(twerr.Code()), + Msg: msg, + Meta: twerr.MetaMap(), + } + + buf, err := json.Marshal(&tj) + if err != nil { + buf = []byte("{\"type\": \"" + twirp.Internal + "\", \"msg\": \"There was an error but it could not be serialized into JSON\"}") // fallback + } + + return buf +} + +// errorFromResponse builds a twirp.Error from a non-200 HTTP response. +// If the response has a valid serialized Twirp error, then it's returned. +// If not, the response status code is used to generate a similar twirp +// error. See twirpErrorFromIntermediary for more info on intermediary errors. +func errorFromResponse(resp *http.Response) twirp.Error { + statusCode := resp.StatusCode + statusText := http.StatusText(statusCode) + + if isHTTPRedirect(statusCode) { + // Unexpected redirect: it must be an error from an intermediary. + // Twirp clients don't follow redirects automatically, Twirp only handles + // POST requests, redirects should only happen on GET and HEAD requests. + location := resp.Header.Get("Location") + msg := fmt.Sprintf("unexpected HTTP status code %d %q received, Location=%q", statusCode, statusText, location) + return twirpErrorFromIntermediary(statusCode, msg, location) + } + + respBodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return wrapInternal(err, "failed to read server error response body") + } + + var tj twerrJSON + dec := json.NewDecoder(bytes.NewReader(respBodyBytes)) + dec.DisallowUnknownFields() + if err := dec.Decode(&tj); err != nil || tj.Code == "" { + // Invalid JSON response; it must be an error from an intermediary. + msg := fmt.Sprintf("Error from intermediary with HTTP status code %d %q", statusCode, statusText) + return twirpErrorFromIntermediary(statusCode, msg, string(respBodyBytes)) + } + + errorCode := twirp.ErrorCode(tj.Code) + if !twirp.IsValidErrorCode(errorCode) { + msg := "invalid type returned from server error response: " + tj.Code + return twirp.InternalError(msg).WithMeta("body", string(respBodyBytes)) + } + + twerr := twirp.NewError(errorCode, tj.Msg) + for k, v := range tj.Meta { + twerr = twerr.WithMeta(k, v) + } + return twerr +} + +// twirpErrorFromIntermediary maps HTTP errors from non-twirp sources to twirp errors. +// The mapping is similar to gRPC: https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md. +// Returned twirp Errors have some additional metadata for inspection. +func twirpErrorFromIntermediary(status int, msg string, bodyOrLocation string) twirp.Error { + var code twirp.ErrorCode + if isHTTPRedirect(status) { // 3xx + code = twirp.Internal + } else { + switch status { + case 400: // Bad Request + code = twirp.Internal + case 401: // Unauthorized + code = twirp.Unauthenticated + case 403: // Forbidden + code = twirp.PermissionDenied + case 404: // Not Found + code = twirp.BadRoute + case 429: // Too Many Requests + code = twirp.ResourceExhausted + case 502, 503, 504: // Bad Gateway, Service Unavailable, Gateway Timeout + code = twirp.Unavailable + default: // All other codes + code = twirp.Unknown + } + } + + twerr := twirp.NewError(code, msg) + twerr = twerr.WithMeta("http_error_from_intermediary", "true") // to easily know if this error was from intermediary + twerr = twerr.WithMeta("status_code", strconv.Itoa(status)) + if isHTTPRedirect(status) { + twerr = twerr.WithMeta("location", bodyOrLocation) + } else { + twerr = twerr.WithMeta("body", bodyOrLocation) + } + return twerr +} + +func isHTTPRedirect(status int) bool { + return status >= 300 && status <= 399 +} + +// wrapInternal wraps an error with a prefix as an Internal error. +// The original error cause is accessible by github.com/pkg/errors.Cause. +func wrapInternal(err error, prefix string) twirp.Error { + return twirp.InternalErrorWith(&wrappedError{prefix: prefix, cause: err}) +} + +type wrappedError struct { + prefix string + cause error +} + +func (e *wrappedError) Error() string { return e.prefix + ": " + e.cause.Error() } +func (e *wrappedError) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *wrappedError) Cause() error { return e.cause } // for github.com/pkg/errors + +// ensurePanicResponses makes sure that rpc methods causing a panic still result in a Twirp Internal +// error response (status 500), and error hooks are properly called with the panic wrapped as an error. +// The panic is re-raised so it can be handled normally with middleware. +func ensurePanicResponses(ctx context.Context, resp http.ResponseWriter, hooks *twirp.ServerHooks) { + if r := recover(); r != nil { + // Wrap the panic as an error so it can be passed to error hooks. + // The original error is accessible from error hooks, but not visible in the response. + err := errFromPanic(r) + twerr := &internalWithCause{msg: "Internal service panic", cause: err} + // Actually write the error + writeError(ctx, resp, twerr, hooks) + // If possible, flush the error to the wire. + f, ok := resp.(http.Flusher) + if ok { + f.Flush() + } + + panic(r) + } +} + +// errFromPanic returns the typed error if the recovered panic is an error, otherwise formats as error. +func errFromPanic(p interface{}) error { + if err, ok := p.(error); ok { + return err + } + return fmt.Errorf("panic: %v", p) +} + +// internalWithCause is a Twirp Internal error wrapping an original error cause, +// but the original error message is not exposed on Msg(). The original error +// can be checked with go1.13+ errors.Is/As, and also by (github.com/pkg/errors).Unwrap +type internalWithCause struct { + msg string + cause error +} + +func (e *internalWithCause) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As +func (e *internalWithCause) Cause() error { return e.cause } // for github.com/pkg/errors +func (e *internalWithCause) Error() string { return e.msg + ": " + e.cause.Error() } +func (e *internalWithCause) Code() twirp.ErrorCode { return twirp.Internal } +func (e *internalWithCause) Msg() string { return e.msg } +func (e *internalWithCause) Meta(key string) string { return "" } +func (e *internalWithCause) MetaMap() map[string]string { return nil } +func (e *internalWithCause) WithMeta(key string, val string) twirp.Error { return e } + +// malformedRequestError is used when the twirp server cannot unmarshal a request +func malformedRequestError(msg string) twirp.Error { + return twirp.NewError(twirp.Malformed, msg) +} + +// badRouteError is used when the twirp server cannot route a request +func badRouteError(msg string, method, url string) twirp.Error { + err := twirp.NewError(twirp.BadRoute, msg) + err = err.WithMeta("twirp_invalid_route", method+" "+url) + return err +} + +// withoutRedirects makes sure that the POST request can not be redirected. +// The standard library will, by default, redirect requests (including POSTs) if it gets a 302 or +// 303 response, and also 301s in go1.8. It redirects by making a second request, changing the +// method to GET and removing the body. This produces very confusing error messages, so instead we +// set a redirect policy that always errors. This stops Go from executing the redirect. +// +// We have to be a little careful in case the user-provided http.Client has its own CheckRedirect +// policy - if so, we'll run through that policy first. +// +// Because this requires modifying the http.Client, we make a new copy of the client and return it. +func withoutRedirects(in *http.Client) *http.Client { + copy := *in + copy.CheckRedirect = func(req *http.Request, via []*http.Request) error { + if in.CheckRedirect != nil { + // Run the input's redirect if it exists, in case it has side effects, but ignore any error it + // returns, since we want to use ErrUseLastResponse. + err := in.CheckRedirect(req, via) + _ = err // Silly, but this makes sure generated code passes errcheck -blank, which some people use. + } + return http.ErrUseLastResponse + } + return © +} + +// doProtobufRequest makes a Protobuf request to the remote Twirp service. +func doProtobufRequest(ctx context.Context, client HTTPClient, hooks *twirp.ClientHooks, url string, in, out proto.Message) (_ context.Context, err error) { + reqBodyBytes, err := proto.Marshal(in) + if err != nil { + return ctx, wrapInternal(err, "failed to marshal proto request") + } + reqBody := bytes.NewBuffer(reqBodyBytes) + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + + req, err := newRequest(ctx, url, reqBody, "application/protobuf") + if err != nil { + return ctx, wrapInternal(err, "could not build request") + } + ctx, err = callClientRequestPrepared(ctx, hooks, req) + if err != nil { + return ctx, err + } + + req = req.WithContext(ctx) + resp, err := client.Do(req) + if err != nil { + return ctx, wrapInternal(err, "failed to do request") + } + + defer func() { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = wrapInternal(cerr, "failed to close response body") + } + }() + + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + + if resp.StatusCode != 200 { + return ctx, errorFromResponse(resp) + } + + respBodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return ctx, wrapInternal(err, "failed to read response body") + } + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + + if err = proto.Unmarshal(respBodyBytes, out); err != nil { + return ctx, wrapInternal(err, "failed to unmarshal proto response") + } + return ctx, nil +} + +// doJSONRequest makes a JSON request to the remote Twirp service. +func doJSONRequest(ctx context.Context, client HTTPClient, hooks *twirp.ClientHooks, url string, in, out proto.Message) (_ context.Context, err error) { + reqBody := bytes.NewBuffer(nil) + marshaler := &jsonpb.Marshaler{OrigName: true} + if err = marshaler.Marshal(reqBody, in); err != nil { + return ctx, wrapInternal(err, "failed to marshal json request") + } + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + + req, err := newRequest(ctx, url, reqBody, "application/json") + if err != nil { + return ctx, wrapInternal(err, "could not build request") + } + ctx, err = callClientRequestPrepared(ctx, hooks, req) + if err != nil { + return ctx, err + } + + req = req.WithContext(ctx) + resp, err := client.Do(req) + if err != nil { + return ctx, wrapInternal(err, "failed to do request") + } + + defer func() { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = wrapInternal(cerr, "failed to close response body") + } + }() + + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + + if resp.StatusCode != 200 { + return ctx, errorFromResponse(resp) + } + + unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} + if err = unmarshaler.Unmarshal(resp.Body, out); err != nil { + return ctx, wrapInternal(err, "failed to unmarshal json response") + } + if err = ctx.Err(); err != nil { + return ctx, wrapInternal(err, "aborted because context was done") + } + return ctx, nil +} + +// Call twirp.ServerHooks.RequestReceived if the hook is available +func callRequestReceived(ctx context.Context, h *twirp.ServerHooks) (context.Context, error) { + if h == nil || h.RequestReceived == nil { + return ctx, nil + } + return h.RequestReceived(ctx) +} + +// Call twirp.ServerHooks.RequestRouted if the hook is available +func callRequestRouted(ctx context.Context, h *twirp.ServerHooks) (context.Context, error) { + if h == nil || h.RequestRouted == nil { + return ctx, nil + } + return h.RequestRouted(ctx) +} + +// Call twirp.ServerHooks.ResponsePrepared if the hook is available +func callResponsePrepared(ctx context.Context, h *twirp.ServerHooks) context.Context { + if h == nil || h.ResponsePrepared == nil { + return ctx + } + return h.ResponsePrepared(ctx) +} + +// Call twirp.ServerHooks.ResponseSent if the hook is available +func callResponseSent(ctx context.Context, h *twirp.ServerHooks) { + if h == nil || h.ResponseSent == nil { + return + } + h.ResponseSent(ctx) +} + +// Call twirp.ServerHooks.Error if the hook is available +func callError(ctx context.Context, h *twirp.ServerHooks, err twirp.Error) context.Context { + if h == nil || h.Error == nil { + return ctx + } + return h.Error(ctx, err) +} + +func callClientResponseReceived(ctx context.Context, h *twirp.ClientHooks) { + if h == nil || h.ResponseReceived == nil { + return + } + h.ResponseReceived(ctx) +} + +func callClientRequestPrepared(ctx context.Context, h *twirp.ClientHooks, req *http.Request) (context.Context, error) { + if h == nil || h.RequestPrepared == nil { + return ctx, nil + } + return h.RequestPrepared(ctx, req) +} + +func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) { + if h == nil || h.Error == nil { + return + } + h.Error(ctx, err) +} + +var twirpFileDescriptor0 = []byte{ + // 549 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xdf, 0x6f, 0x12, 0x41, + 0x10, 0x0e, 0xb6, 0xb4, 0x30, 0x14, 0x2d, 0x13, 0x0c, 0xd7, 0x23, 0x1a, 0x3c, 0x1f, 0xc4, 0x87, + 0x42, 0xc4, 0x07, 0x7d, 0xf0, 0xc5, 0xaa, 0x31, 0x24, 0x35, 0x69, 0x8e, 0x26, 0xfe, 0x78, 0x21, + 0x07, 0x37, 0xda, 0x4d, 0xd9, 0x5b, 0xbc, 0xdb, 0x23, 0xe5, 0xbf, 0xf0, 0xcf, 0xf0, 0xcf, 0x34, + 0xbb, 0x7b, 0x1c, 0x4b, 0x39, 0x88, 0x4f, 0xdc, 0xce, 0x7c, 0x33, 0xdf, 0x37, 0xb3, 0xdf, 0x02, + 0x10, 0x0b, 0xc1, 0x7b, 0xf3, 0x58, 0x48, 0x81, 0xc7, 0x33, 0xb6, 0xa0, 0x5b, 0x26, 0xdd, 0x1a, + 0x17, 0x21, 0xcd, 0x4c, 0xd4, 0xfb, 0x53, 0x82, 0xc6, 0x87, 0x98, 0x02, 0x49, 0xbe, 0x10, 0xdc, + 0xa7, 0xdf, 0x29, 0x25, 0x12, 0x11, 0x0e, 0xa3, 0x80, 0x93, 0x53, 0xea, 0x94, 0xba, 0x55, 0x5f, + 0x7f, 0xe3, 0x73, 0xa8, 0x13, 0x9f, 0xcb, 0xe5, 0x58, 0x32, 0x4e, 0x22, 0x95, 0xce, 0x83, 0x4e, + 0xa9, 0x5b, 0xf7, 0x4f, 0x74, 0xf0, 0xda, 0xc4, 0xf0, 0x25, 0x9c, 0xf2, 0xe0, 0x6e, 0x3c, 0x0f, + 0x62, 0xc9, 0xa6, 0x6c, 0x1e, 0x44, 0x32, 0x71, 0x0e, 0x34, 0xee, 0x11, 0x0f, 0xee, 0xae, 0xac, + 0x30, 0xb6, 0xe0, 0x38, 0x12, 0x21, 0x8d, 0x59, 0xe8, 0x1c, 0x6a, 0x9a, 0x23, 0x75, 0x1c, 0x86, + 0x1e, 0xc2, 0xe9, 0x25, 0x4b, 0xa4, 0xd2, 0x93, 0x64, 0x82, 0xbc, 0xb7, 0xd0, 0xb0, 0x62, 0xc9, + 0x5c, 0x44, 0x89, 0x52, 0x54, 0x56, 0xf3, 0x25, 0x4e, 0xa9, 0x73, 0xd0, 0xad, 0x0d, 0xea, 0xbd, + 0x6c, 0xc2, 0x9e, 0x1e, 0xc5, 0xe4, 0xbc, 0x17, 0xd0, 0xf8, 0x48, 0x33, 0xda, 0x9a, 0x4f, 0x65, + 0x57, 0xf3, 0xa9, 0x6f, 0xaf, 0x09, 0x68, 0x03, 0x0d, 0x87, 0x77, 0x0e, 0x2d, 0x45, 0x6c, 0x2b, + 0xdf, 0xd7, 0xe4, 0x1b, 0x38, 0xdb, 0xf0, 0x4c, 0xee, 0x3b, 0x38, 0xd9, 0xd8, 0x8b, 0x51, 0xed, + 0xe4, 0xaa, 0xad, 0xa2, 0x61, 0xf4, 0x53, 0xf8, 0x1b, 0x68, 0x6f, 0x08, 0x2d, 0x25, 0xcc, 0x06, + 0x85, 0x14, 0x49, 0x26, 0x97, 0x45, 0x42, 0xd0, 0x85, 0x0a, 0xcb, 0xf2, 0xfa, 0xa2, 0xaa, 0x7e, + 0x7e, 0xf6, 0xda, 0x70, 0xe6, 0x13, 0x17, 0x0b, 0xb2, 0x9a, 0xe5, 0x03, 0x2f, 0xa1, 0xf9, 0x25, + 0x35, 0x4b, 0xb8, 0x8e, 0x83, 0xe9, 0xed, 0x9e, 0x69, 0xf7, 0x91, 0x60, 0x1b, 0xaa, 0x52, 0xd5, + 0x8f, 0x13, 0x16, 0x6a, 0x0b, 0x54, 0xfd, 0x8a, 0x0e, 0x8c, 0x58, 0x88, 0x4d, 0x28, 0xf3, 0x54, + 0x92, 0xb9, 0xf9, 0x8a, 0x6f, 0x0e, 0xde, 0x7b, 0x78, 0x7c, 0x8f, 0x3a, 0xdb, 0x5c, 0x17, 0xca, + 0xba, 0x54, 0x93, 0xd7, 0x06, 0x98, 0xaf, 0x4c, 0xc3, 0xf4, 0xb2, 0x0c, 0x60, 0xf0, 0xf7, 0x10, + 0x6a, 0xaa, 0x7e, 0x44, 0xf1, 0x82, 0x4d, 0x09, 0xdf, 0x00, 0xac, 0xdd, 0x8d, 0x6e, 0x5e, 0xb8, + 0x65, 0x79, 0x77, 0xd3, 0x3d, 0x78, 0x01, 0xd5, 0xdc, 0x70, 0x78, 0x96, 0xe7, 0xee, 0x1b, 0xd3, + 0x75, 0x8b, 0x52, 0x99, 0xec, 0x4f, 0x00, 0x6b, 0x47, 0x59, 0xe4, 0x5b, 0x7e, 0x74, 0xdb, 0x85, + 0xb9, 0xac, 0xcd, 0x57, 0xf3, 0x1e, 0x36, 0x1e, 0x4f, 0x67, 0x83, 0xb6, 0xc0, 0x9d, 0xee, 0xb3, + 0x3d, 0x88, 0xac, 0xf1, 0x25, 0x3c, 0xfc, 0x4c, 0x76, 0xca, 0x6a, 0xbb, 0xc3, 0x6b, 0xee, 0x4e, + 0xbb, 0xe2, 0x77, 0x68, 0x6c, 0xb9, 0xea, 0x3f, 0x1a, 0x7a, 0x6b, 0xc4, 0x2e, 0x4f, 0xe2, 0x08, + 0x50, 0x19, 0xe3, 0x2a, 0x9d, 0xcc, 0x58, 0x72, 0x43, 0xa1, 0xbe, 0x76, 0x7c, 0x92, 0x57, 0x16, + 0x19, 0xd6, 0x7d, 0xba, 0x2b, 0x6d, 0x9a, 0x5e, 0xbc, 0xfa, 0xd1, 0xff, 0xc5, 0xe4, 0x4d, 0x3a, + 0xe9, 0x4d, 0x05, 0xef, 0x67, 0xd8, 0xd5, 0xef, 0x79, 0x42, 0xf1, 0x82, 0xe2, 0xbe, 0xfe, 0x93, + 0x5c, 0x05, 0x27, 0x47, 0xfa, 0xf8, 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0x66, 0x2b, + 0xf4, 0x57, 0x05, 0x00, 0x00, +} diff --git a/proto/rtc.pb.go b/proto/rtc.pb.go new file mode 100644 index 00000000..e251b2e4 --- /dev/null +++ b/proto/rtc.pb.go @@ -0,0 +1,1639 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: rtc.proto + +package livekit + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type SignalTarget int32 + +const ( + SignalTarget_PUBLISHER SignalTarget = 0 + SignalTarget_SUBSCRIBER SignalTarget = 1 +) + +// Enum value maps for SignalTarget. +var ( + SignalTarget_name = map[int32]string{ + 0: "PUBLISHER", + 1: "SUBSCRIBER", + } + SignalTarget_value = map[string]int32{ + "PUBLISHER": 0, + "SUBSCRIBER": 1, + } +) + +func (x SignalTarget) Enum() *SignalTarget { + p := new(SignalTarget) + *p = x + return p +} + +func (x SignalTarget) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SignalTarget) Descriptor() protoreflect.EnumDescriptor { + return file_rtc_proto_enumTypes[0].Descriptor() +} + +func (SignalTarget) Type() protoreflect.EnumType { + return &file_rtc_proto_enumTypes[0] +} + +func (x SignalTarget) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SignalTarget.Descriptor instead. +func (SignalTarget) EnumDescriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{0} +} + +type VideoQuality int32 + +const ( + VideoQuality_LOW VideoQuality = 0 + VideoQuality_MEDIUM VideoQuality = 1 + VideoQuality_HIGH VideoQuality = 2 +) + +// Enum value maps for VideoQuality. +var ( + VideoQuality_name = map[int32]string{ + 0: "LOW", + 1: "MEDIUM", + 2: "HIGH", + } + VideoQuality_value = map[string]int32{ + "LOW": 0, + "MEDIUM": 1, + "HIGH": 2, + } +) + +func (x VideoQuality) Enum() *VideoQuality { + p := new(VideoQuality) + *p = x + return p +} + +func (x VideoQuality) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (VideoQuality) Descriptor() protoreflect.EnumDescriptor { + return file_rtc_proto_enumTypes[1].Descriptor() +} + +func (VideoQuality) Type() protoreflect.EnumType { + return &file_rtc_proto_enumTypes[1] +} + +func (x VideoQuality) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use VideoQuality.Descriptor instead. +func (VideoQuality) EnumDescriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{1} +} + +type SignalRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Message: + // *SignalRequest_Offer + // *SignalRequest_Answer + // *SignalRequest_Trickle + // *SignalRequest_AddTrack + // *SignalRequest_Mute + // *SignalRequest_Subscription + // *SignalRequest_TrackSetting + Message isSignalRequest_Message `protobuf_oneof:"message"` +} + +func (x *SignalRequest) Reset() { + *x = SignalRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SignalRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignalRequest) ProtoMessage() {} + +func (x *SignalRequest) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignalRequest.ProtoReflect.Descriptor instead. +func (*SignalRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{0} +} + +func (m *SignalRequest) GetMessage() isSignalRequest_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *SignalRequest) GetOffer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalRequest_Offer); ok { + return x.Offer + } + return nil +} + +func (x *SignalRequest) GetAnswer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalRequest_Answer); ok { + return x.Answer + } + return nil +} + +func (x *SignalRequest) GetTrickle() *TrickleRequest { + if x, ok := x.GetMessage().(*SignalRequest_Trickle); ok { + return x.Trickle + } + return nil +} + +func (x *SignalRequest) GetAddTrack() *AddTrackRequest { + if x, ok := x.GetMessage().(*SignalRequest_AddTrack); ok { + return x.AddTrack + } + return nil +} + +func (x *SignalRequest) GetMute() *MuteTrackRequest { + if x, ok := x.GetMessage().(*SignalRequest_Mute); ok { + return x.Mute + } + return nil +} + +func (x *SignalRequest) GetSubscription() *UpdateSubscription { + if x, ok := x.GetMessage().(*SignalRequest_Subscription); ok { + return x.Subscription + } + return nil +} + +func (x *SignalRequest) GetTrackSetting() *UpdateTrackSettings { + if x, ok := x.GetMessage().(*SignalRequest_TrackSetting); ok { + return x.TrackSetting + } + return nil +} + +type isSignalRequest_Message interface { + isSignalRequest_Message() +} + +type SignalRequest_Offer struct { + // initial join exchange, for publisher + Offer *SessionDescription `protobuf:"bytes,1,opt,name=offer,proto3,oneof"` +} + +type SignalRequest_Answer struct { + // participant answering publisher offer + Answer *SessionDescription `protobuf:"bytes,2,opt,name=answer,proto3,oneof"` +} + +type SignalRequest_Trickle struct { + Trickle *TrickleRequest `protobuf:"bytes,3,opt,name=trickle,proto3,oneof"` +} + +type SignalRequest_AddTrack struct { + AddTrack *AddTrackRequest `protobuf:"bytes,4,opt,name=add_track,json=addTrack,proto3,oneof"` +} + +type SignalRequest_Mute struct { + // mute the participant's own tracks + Mute *MuteTrackRequest `protobuf:"bytes,5,opt,name=mute,proto3,oneof"` +} + +type SignalRequest_Subscription struct { + // Subscribe or unsubscribe from tracks + Subscription *UpdateSubscription `protobuf:"bytes,6,opt,name=subscription,proto3,oneof"` +} + +type SignalRequest_TrackSetting struct { + // Update settings of subscribed tracks + TrackSetting *UpdateTrackSettings `protobuf:"bytes,7,opt,name=track_setting,json=trackSetting,proto3,oneof"` +} + +func (*SignalRequest_Offer) isSignalRequest_Message() {} + +func (*SignalRequest_Answer) isSignalRequest_Message() {} + +func (*SignalRequest_Trickle) isSignalRequest_Message() {} + +func (*SignalRequest_AddTrack) isSignalRequest_Message() {} + +func (*SignalRequest_Mute) isSignalRequest_Message() {} + +func (*SignalRequest_Subscription) isSignalRequest_Message() {} + +func (*SignalRequest_TrackSetting) isSignalRequest_Message() {} + +type SignalResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Message: + // *SignalResponse_Join + // *SignalResponse_Answer + // *SignalResponse_Offer + // *SignalResponse_Trickle + // *SignalResponse_Update + // *SignalResponse_TrackPublished + // *SignalResponse_Speaker + Message isSignalResponse_Message `protobuf_oneof:"message"` +} + +func (x *SignalResponse) Reset() { + *x = SignalResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SignalResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignalResponse) ProtoMessage() {} + +func (x *SignalResponse) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignalResponse.ProtoReflect.Descriptor instead. +func (*SignalResponse) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{1} +} + +func (m *SignalResponse) GetMessage() isSignalResponse_Message { + if m != nil { + return m.Message + } + return nil +} + +func (x *SignalResponse) GetJoin() *JoinResponse { + if x, ok := x.GetMessage().(*SignalResponse_Join); ok { + return x.Join + } + return nil +} + +func (x *SignalResponse) GetAnswer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalResponse_Answer); ok { + return x.Answer + } + return nil +} + +func (x *SignalResponse) GetOffer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalResponse_Offer); ok { + return x.Offer + } + return nil +} + +func (x *SignalResponse) GetTrickle() *TrickleRequest { + if x, ok := x.GetMessage().(*SignalResponse_Trickle); ok { + return x.Trickle + } + return nil +} + +func (x *SignalResponse) GetUpdate() *ParticipantUpdate { + if x, ok := x.GetMessage().(*SignalResponse_Update); ok { + return x.Update + } + return nil +} + +func (x *SignalResponse) GetTrackPublished() *TrackPublishedResponse { + if x, ok := x.GetMessage().(*SignalResponse_TrackPublished); ok { + return x.TrackPublished + } + return nil +} + +func (x *SignalResponse) GetSpeaker() *ActiveSpeakerUpdate { + if x, ok := x.GetMessage().(*SignalResponse_Speaker); ok { + return x.Speaker + } + return nil +} + +type isSignalResponse_Message interface { + isSignalResponse_Message() +} + +type SignalResponse_Join struct { + // sent when join is accepted + Join *JoinResponse `protobuf:"bytes,1,opt,name=join,proto3,oneof"` +} + +type SignalResponse_Answer struct { + // sent when server answers publisher + Answer *SessionDescription `protobuf:"bytes,2,opt,name=answer,proto3,oneof"` +} + +type SignalResponse_Offer struct { + // sent when server is sending subscriber an offer + Offer *SessionDescription `protobuf:"bytes,3,opt,name=offer,proto3,oneof"` +} + +type SignalResponse_Trickle struct { + // sent when an ICE candidate is available + Trickle *TrickleRequest `protobuf:"bytes,4,opt,name=trickle,proto3,oneof"` +} + +type SignalResponse_Update struct { + // sent when participants in the room has changed + Update *ParticipantUpdate `protobuf:"bytes,5,opt,name=update,proto3,oneof"` +} + +type SignalResponse_TrackPublished struct { + // sent to the participant when their track has been published + TrackPublished *TrackPublishedResponse `protobuf:"bytes,6,opt,name=track_published,json=trackPublished,proto3,oneof"` +} + +type SignalResponse_Speaker struct { + // list of active speakers + Speaker *ActiveSpeakerUpdate `protobuf:"bytes,7,opt,name=speaker,proto3,oneof"` +} + +func (*SignalResponse_Join) isSignalResponse_Message() {} + +func (*SignalResponse_Answer) isSignalResponse_Message() {} + +func (*SignalResponse_Offer) isSignalResponse_Message() {} + +func (*SignalResponse_Trickle) isSignalResponse_Message() {} + +func (*SignalResponse_Update) isSignalResponse_Message() {} + +func (*SignalResponse_TrackPublished) isSignalResponse_Message() {} + +func (*SignalResponse_Speaker) isSignalResponse_Message() {} + +type AddTrackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // client ID of track, to match it when RTC track is received + Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Type TrackType `protobuf:"varint,3,opt,name=type,proto3,enum=livekit.TrackType" json:"type,omitempty"` +} + +func (x *AddTrackRequest) Reset() { + *x = AddTrackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddTrackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddTrackRequest) ProtoMessage() {} + +func (x *AddTrackRequest) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddTrackRequest.ProtoReflect.Descriptor instead. +func (*AddTrackRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{2} +} + +func (x *AddTrackRequest) GetCid() string { + if x != nil { + return x.Cid + } + return "" +} + +func (x *AddTrackRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *AddTrackRequest) GetType() TrackType { + if x != nil { + return x.Type + } + return TrackType_AUDIO +} + +type TrickleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CandidateInit string `protobuf:"bytes,1,opt,name=candidateInit,proto3" json:"candidateInit,omitempty"` + Target SignalTarget `protobuf:"varint,2,opt,name=target,proto3,enum=livekit.SignalTarget" json:"target,omitempty"` +} + +func (x *TrickleRequest) Reset() { + *x = TrickleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TrickleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TrickleRequest) ProtoMessage() {} + +func (x *TrickleRequest) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TrickleRequest.ProtoReflect.Descriptor instead. +func (*TrickleRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{3} +} + +func (x *TrickleRequest) GetCandidateInit() string { + if x != nil { + return x.CandidateInit + } + return "" +} + +func (x *TrickleRequest) GetTarget() SignalTarget { + if x != nil { + return x.Target + } + return SignalTarget_PUBLISHER +} + +type MuteTrackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + Muted bool `protobuf:"varint,2,opt,name=muted,proto3" json:"muted,omitempty"` +} + +func (x *MuteTrackRequest) Reset() { + *x = MuteTrackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MuteTrackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MuteTrackRequest) ProtoMessage() {} + +func (x *MuteTrackRequest) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MuteTrackRequest.ProtoReflect.Descriptor instead. +func (*MuteTrackRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{4} +} + +func (x *MuteTrackRequest) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + +func (x *MuteTrackRequest) GetMuted() bool { + if x != nil { + return x.Muted + } + return false +} + +type NegotiationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NegotiationRequest) Reset() { + *x = NegotiationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NegotiationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NegotiationRequest) ProtoMessage() {} + +func (x *NegotiationRequest) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NegotiationRequest.ProtoReflect.Descriptor instead. +func (*NegotiationRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{5} +} + +type JoinResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Room *Room `protobuf:"bytes,1,opt,name=room,proto3" json:"room,omitempty"` + Participant *ParticipantInfo `protobuf:"bytes,2,opt,name=participant,proto3" json:"participant,omitempty"` + OtherParticipants []*ParticipantInfo `protobuf:"bytes,3,rep,name=other_participants,json=otherParticipants,proto3" json:"other_participants,omitempty"` + ServerVersion string `protobuf:"bytes,4,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"` + IceServers []*ICEServer `protobuf:"bytes,5,rep,name=ice_servers,json=iceServers,proto3" json:"ice_servers,omitempty"` +} + +func (x *JoinResponse) Reset() { + *x = JoinResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *JoinResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*JoinResponse) ProtoMessage() {} + +func (x *JoinResponse) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use JoinResponse.ProtoReflect.Descriptor instead. +func (*JoinResponse) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{6} +} + +func (x *JoinResponse) GetRoom() *Room { + if x != nil { + return x.Room + } + return nil +} + +func (x *JoinResponse) GetParticipant() *ParticipantInfo { + if x != nil { + return x.Participant + } + return nil +} + +func (x *JoinResponse) GetOtherParticipants() []*ParticipantInfo { + if x != nil { + return x.OtherParticipants + } + return nil +} + +func (x *JoinResponse) GetServerVersion() string { + if x != nil { + return x.ServerVersion + } + return "" +} + +func (x *JoinResponse) GetIceServers() []*ICEServer { + if x != nil { + return x.IceServers + } + return nil +} + +type TrackPublishedResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Cid string `protobuf:"bytes,1,opt,name=cid,proto3" json:"cid,omitempty"` + Track *TrackInfo `protobuf:"bytes,2,opt,name=track,proto3" json:"track,omitempty"` +} + +func (x *TrackPublishedResponse) Reset() { + *x = TrackPublishedResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TrackPublishedResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TrackPublishedResponse) ProtoMessage() {} + +func (x *TrackPublishedResponse) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TrackPublishedResponse.ProtoReflect.Descriptor instead. +func (*TrackPublishedResponse) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{7} +} + +func (x *TrackPublishedResponse) GetCid() string { + if x != nil { + return x.Cid + } + return "" +} + +func (x *TrackPublishedResponse) GetTrack() *TrackInfo { + if x != nil { + return x.Track + } + return nil +} + +type SessionDescription struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // "answer" | "offer" | "pranswer" | "rollback" + Sdp string `protobuf:"bytes,2,opt,name=sdp,proto3" json:"sdp,omitempty"` +} + +func (x *SessionDescription) Reset() { + *x = SessionDescription{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SessionDescription) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SessionDescription) ProtoMessage() {} + +func (x *SessionDescription) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SessionDescription.ProtoReflect.Descriptor instead. +func (*SessionDescription) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{8} +} + +func (x *SessionDescription) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *SessionDescription) GetSdp() string { + if x != nil { + return x.Sdp + } + return "" +} + +type ParticipantUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Participants []*ParticipantInfo `protobuf:"bytes,1,rep,name=participants,proto3" json:"participants,omitempty"` +} + +func (x *ParticipantUpdate) Reset() { + *x = ParticipantUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ParticipantUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ParticipantUpdate) ProtoMessage() {} + +func (x *ParticipantUpdate) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ParticipantUpdate.ProtoReflect.Descriptor instead. +func (*ParticipantUpdate) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{9} +} + +func (x *ParticipantUpdate) GetParticipants() []*ParticipantInfo { + if x != nil { + return x.Participants + } + return nil +} + +type ActiveSpeakerUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Speakers []*SpeakerInfo `protobuf:"bytes,1,rep,name=speakers,proto3" json:"speakers,omitempty"` +} + +func (x *ActiveSpeakerUpdate) Reset() { + *x = ActiveSpeakerUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ActiveSpeakerUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ActiveSpeakerUpdate) ProtoMessage() {} + +func (x *ActiveSpeakerUpdate) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ActiveSpeakerUpdate.ProtoReflect.Descriptor instead. +func (*ActiveSpeakerUpdate) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{10} +} + +func (x *ActiveSpeakerUpdate) GetSpeakers() []*SpeakerInfo { + if x != nil { + return x.Speakers + } + return nil +} + +type SpeakerInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` + // audio level, 0-1.0, 1 is loudest + Level float32 `protobuf:"fixed32,2,opt,name=level,proto3" json:"level,omitempty"` + // true if speaker is currently active + Active bool `protobuf:"varint,3,opt,name=active,proto3" json:"active,omitempty"` +} + +func (x *SpeakerInfo) Reset() { + *x = SpeakerInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SpeakerInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SpeakerInfo) ProtoMessage() {} + +func (x *SpeakerInfo) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SpeakerInfo.ProtoReflect.Descriptor instead. +func (*SpeakerInfo) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{11} +} + +func (x *SpeakerInfo) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + +func (x *SpeakerInfo) GetLevel() float32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *SpeakerInfo) GetActive() bool { + if x != nil { + return x.Active + } + return false +} + +type UpdateSubscription struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TrackSids []string `protobuf:"bytes,1,rep,name=track_sids,json=trackSids,proto3" json:"track_sids,omitempty"` + Subscribe bool `protobuf:"varint,2,opt,name=subscribe,proto3" json:"subscribe,omitempty"` + Mute bool `protobuf:"varint,3,opt,name=mute,proto3" json:"mute,omitempty"` + Quality VideoQuality `protobuf:"varint,4,opt,name=quality,proto3,enum=livekit.VideoQuality" json:"quality,omitempty"` +} + +func (x *UpdateSubscription) Reset() { + *x = UpdateSubscription{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateSubscription) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateSubscription) ProtoMessage() {} + +func (x *UpdateSubscription) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateSubscription.ProtoReflect.Descriptor instead. +func (*UpdateSubscription) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{12} +} + +func (x *UpdateSubscription) GetTrackSids() []string { + if x != nil { + return x.TrackSids + } + return nil +} + +func (x *UpdateSubscription) GetSubscribe() bool { + if x != nil { + return x.Subscribe + } + return false +} + +func (x *UpdateSubscription) GetMute() bool { + if x != nil { + return x.Mute + } + return false +} + +func (x *UpdateSubscription) GetQuality() VideoQuality { + if x != nil { + return x.Quality + } + return VideoQuality_LOW +} + +type UpdateTrackSettings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TrackSids []string `protobuf:"bytes,1,rep,name=track_sids,json=trackSids,proto3" json:"track_sids,omitempty"` + Mute bool `protobuf:"varint,3,opt,name=mute,proto3" json:"mute,omitempty"` + Quality VideoQuality `protobuf:"varint,4,opt,name=quality,proto3,enum=livekit.VideoQuality" json:"quality,omitempty"` +} + +func (x *UpdateTrackSettings) Reset() { + *x = UpdateTrackSettings{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateTrackSettings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateTrackSettings) ProtoMessage() {} + +func (x *UpdateTrackSettings) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateTrackSettings.ProtoReflect.Descriptor instead. +func (*UpdateTrackSettings) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{13} +} + +func (x *UpdateTrackSettings) GetTrackSids() []string { + if x != nil { + return x.TrackSids + } + return nil +} + +func (x *UpdateTrackSettings) GetMute() bool { + if x != nil { + return x.Mute + } + return false +} + +func (x *UpdateTrackSettings) GetQuality() VideoQuality { + if x != nil { + return x.Quality + } + return VideoQuality_LOW +} + +type ICEServer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Urls []string `protobuf:"bytes,1,rep,name=urls,proto3" json:"urls,omitempty"` + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Credential string `protobuf:"bytes,3,opt,name=credential,proto3" json:"credential,omitempty"` +} + +func (x *ICEServer) Reset() { + *x = ICEServer{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ICEServer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ICEServer) ProtoMessage() {} + +func (x *ICEServer) ProtoReflect() protoreflect.Message { + mi := &file_rtc_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ICEServer.ProtoReflect.Descriptor instead. +func (*ICEServer) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{14} +} + +func (x *ICEServer) GetUrls() []string { + if x != nil { + return x.Urls + } + return nil +} + +func (x *ICEServer) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *ICEServer) GetCredential() string { + if x != nil { + return x.Credential + } + return "" +} + +var File_rtc_proto protoreflect.FileDescriptor + +var file_rtc_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x72, 0x74, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x69, 0x76, + 0x65, 0x6b, 0x69, 0x74, 0x1a, 0x0b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xad, 0x03, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x48, + 0x00, 0x52, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, + 0x33, 0x0a, 0x07, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x17, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x69, 0x63, 0x6b, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x07, 0x74, 0x72, 0x69, + 0x63, 0x6b, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x63, + 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x48, 0x00, 0x52, 0x08, 0x61, 0x64, 0x64, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x12, 0x2f, 0x0a, + 0x04, 0x6d, 0x75, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4d, 0x75, 0x74, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x12, 0x41, + 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x43, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x48, 0x00, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0xa5, 0x03, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x04, 0x6a, 0x6f, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4a, 0x6f, 0x69, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x04, 0x6a, 0x6f, 0x69, + 0x6e, 0x12, 0x35, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, + 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x05, 0x6f, 0x66, 0x66, 0x65, + 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, + 0x74, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x05, 0x6f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x33, 0x0a, + 0x07, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x07, 0x74, 0x72, 0x69, 0x63, 0x6b, + 0x6c, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, + 0x52, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x74, 0x72, 0x61, 0x63, + 0x6b, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, + 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x65, 0x64, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x07, 0x73, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x42, 0x09, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 0x0a, 0x0f, 0x41, 0x64, 0x64, + 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, + 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x65, 0x0a, 0x0e, 0x54, 0x72, + 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, + 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x69, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, + 0x69, 0x74, 0x12, 0x2d, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x22, 0x3a, 0x0a, 0x10, 0x4d, 0x75, 0x74, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x75, 0x74, 0x65, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, 0x75, 0x74, 0x65, 0x64, 0x22, 0x14, 0x0a, + 0x12, 0x4e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x92, 0x02, 0x0a, 0x0c, 0x4a, 0x6f, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, + 0x6d, 0x52, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x12, 0x3a, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, + 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6c, + 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, + 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, + 0x61, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x12, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x72, + 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x18, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, + 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x11, 0x6f, 0x74, 0x68, 0x65, 0x72, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, 0x0b, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x49, 0x43, 0x45, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x69, 0x63, + 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x22, 0x54, 0x0a, 0x16, 0x54, 0x72, 0x61, 0x63, + 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x63, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, + 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x22, 0x3a, + 0x0a, 0x12, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x64, 0x70, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x64, 0x70, 0x22, 0x51, 0x0a, 0x11, 0x50, 0x61, + 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, + 0x3c, 0x0a, 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x0c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x47, 0x0a, + 0x13, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, + 0x2e, 0x53, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x73, 0x70, + 0x65, 0x61, 0x6b, 0x65, 0x72, 0x73, 0x22, 0x4d, 0x0a, 0x0b, 0x53, 0x70, 0x65, 0x61, 0x6b, 0x65, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, + 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x73, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x09, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x53, 0x69, 0x64, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x75, 0x74, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x12, 0x2f, 0x0a, + 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, + 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x51, 0x75, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x79, + 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x73, + 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x61, 0x63, 0x6b, + 0x53, 0x69, 0x64, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x12, 0x2f, 0x0a, 0x07, 0x71, 0x75, 0x61, 0x6c, + 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x76, 0x65, + 0x6b, 0x69, 0x74, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x51, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x5b, 0x0a, 0x09, 0x49, 0x43, 0x45, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x72, 0x6c, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x75, 0x72, 0x6c, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2a, 0x2d, 0x0a, 0x0c, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x0d, 0x0a, 0x09, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x53, + 0x48, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, + 0x42, 0x45, 0x52, 0x10, 0x01, 0x2a, 0x2d, 0x0a, 0x0c, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x51, 0x75, + 0x61, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x07, 0x0a, 0x03, 0x4c, 0x4f, 0x57, 0x10, 0x00, 0x12, 0x0a, + 0x0a, 0x06, 0x4d, 0x45, 0x44, 0x49, 0x55, 0x4d, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x49, + 0x47, 0x48, 0x10, 0x02, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2f, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rtc_proto_rawDescOnce sync.Once + file_rtc_proto_rawDescData = file_rtc_proto_rawDesc +) + +func file_rtc_proto_rawDescGZIP() []byte { + file_rtc_proto_rawDescOnce.Do(func() { + file_rtc_proto_rawDescData = protoimpl.X.CompressGZIP(file_rtc_proto_rawDescData) + }) + return file_rtc_proto_rawDescData +} + +var file_rtc_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_rtc_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_rtc_proto_goTypes = []interface{}{ + (SignalTarget)(0), // 0: livekit.SignalTarget + (VideoQuality)(0), // 1: livekit.VideoQuality + (*SignalRequest)(nil), // 2: livekit.SignalRequest + (*SignalResponse)(nil), // 3: livekit.SignalResponse + (*AddTrackRequest)(nil), // 4: livekit.AddTrackRequest + (*TrickleRequest)(nil), // 5: livekit.TrickleRequest + (*MuteTrackRequest)(nil), // 6: livekit.MuteTrackRequest + (*NegotiationRequest)(nil), // 7: livekit.NegotiationRequest + (*JoinResponse)(nil), // 8: livekit.JoinResponse + (*TrackPublishedResponse)(nil), // 9: livekit.TrackPublishedResponse + (*SessionDescription)(nil), // 10: livekit.SessionDescription + (*ParticipantUpdate)(nil), // 11: livekit.ParticipantUpdate + (*ActiveSpeakerUpdate)(nil), // 12: livekit.ActiveSpeakerUpdate + (*SpeakerInfo)(nil), // 13: livekit.SpeakerInfo + (*UpdateSubscription)(nil), // 14: livekit.UpdateSubscription + (*UpdateTrackSettings)(nil), // 15: livekit.UpdateTrackSettings + (*ICEServer)(nil), // 16: livekit.ICEServer + (TrackType)(0), // 17: livekit.TrackType + (*Room)(nil), // 18: livekit.Room + (*ParticipantInfo)(nil), // 19: livekit.ParticipantInfo + (*TrackInfo)(nil), // 20: livekit.TrackInfo +} +var file_rtc_proto_depIdxs = []int32{ + 10, // 0: livekit.SignalRequest.offer:type_name -> livekit.SessionDescription + 10, // 1: livekit.SignalRequest.answer:type_name -> livekit.SessionDescription + 5, // 2: livekit.SignalRequest.trickle:type_name -> livekit.TrickleRequest + 4, // 3: livekit.SignalRequest.add_track:type_name -> livekit.AddTrackRequest + 6, // 4: livekit.SignalRequest.mute:type_name -> livekit.MuteTrackRequest + 14, // 5: livekit.SignalRequest.subscription:type_name -> livekit.UpdateSubscription + 15, // 6: livekit.SignalRequest.track_setting:type_name -> livekit.UpdateTrackSettings + 8, // 7: livekit.SignalResponse.join:type_name -> livekit.JoinResponse + 10, // 8: livekit.SignalResponse.answer:type_name -> livekit.SessionDescription + 10, // 9: livekit.SignalResponse.offer:type_name -> livekit.SessionDescription + 5, // 10: livekit.SignalResponse.trickle:type_name -> livekit.TrickleRequest + 11, // 11: livekit.SignalResponse.update:type_name -> livekit.ParticipantUpdate + 9, // 12: livekit.SignalResponse.track_published:type_name -> livekit.TrackPublishedResponse + 12, // 13: livekit.SignalResponse.speaker:type_name -> livekit.ActiveSpeakerUpdate + 17, // 14: livekit.AddTrackRequest.type:type_name -> livekit.TrackType + 0, // 15: livekit.TrickleRequest.target:type_name -> livekit.SignalTarget + 18, // 16: livekit.JoinResponse.room:type_name -> livekit.Room + 19, // 17: livekit.JoinResponse.participant:type_name -> livekit.ParticipantInfo + 19, // 18: livekit.JoinResponse.other_participants:type_name -> livekit.ParticipantInfo + 16, // 19: livekit.JoinResponse.ice_servers:type_name -> livekit.ICEServer + 20, // 20: livekit.TrackPublishedResponse.track:type_name -> livekit.TrackInfo + 19, // 21: livekit.ParticipantUpdate.participants:type_name -> livekit.ParticipantInfo + 13, // 22: livekit.ActiveSpeakerUpdate.speakers:type_name -> livekit.SpeakerInfo + 1, // 23: livekit.UpdateSubscription.quality:type_name -> livekit.VideoQuality + 1, // 24: livekit.UpdateTrackSettings.quality:type_name -> livekit.VideoQuality + 25, // [25:25] is the sub-list for method output_type + 25, // [25:25] is the sub-list for method input_type + 25, // [25:25] is the sub-list for extension type_name + 25, // [25:25] is the sub-list for extension extendee + 0, // [0:25] is the sub-list for field type_name +} + +func init() { file_rtc_proto_init() } +func file_rtc_proto_init() { + if File_rtc_proto != nil { + return + } + file_model_proto_init() + if !protoimpl.UnsafeEnabled { + file_rtc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SignalRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SignalResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddTrackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TrickleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MuteTrackRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NegotiationRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*JoinResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TrackPublishedResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SessionDescription); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ParticipantUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ActiveSpeakerUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SpeakerInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateSubscription); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateTrackSettings); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rtc_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ICEServer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_rtc_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*SignalRequest_Offer)(nil), + (*SignalRequest_Answer)(nil), + (*SignalRequest_Trickle)(nil), + (*SignalRequest_AddTrack)(nil), + (*SignalRequest_Mute)(nil), + (*SignalRequest_Subscription)(nil), + (*SignalRequest_TrackSetting)(nil), + } + file_rtc_proto_msgTypes[1].OneofWrappers = []interface{}{ + (*SignalResponse_Join)(nil), + (*SignalResponse_Answer)(nil), + (*SignalResponse_Offer)(nil), + (*SignalResponse_Trickle)(nil), + (*SignalResponse_Update)(nil), + (*SignalResponse_TrackPublished)(nil), + (*SignalResponse_Speaker)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rtc_proto_rawDesc, + NumEnums: 2, + NumMessages: 15, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rtc_proto_goTypes, + DependencyIndexes: file_rtc_proto_depIdxs, + EnumInfos: file_rtc_proto_enumTypes, + MessageInfos: file_rtc_proto_msgTypes, + }.Build() + File_rtc_proto = out.File + file_rtc_proto_rawDesc = nil + file_rtc_proto_goTypes = nil + file_rtc_proto_depIdxs = nil +} diff --git a/proto/rtc.proto b/proto/rtc.proto deleted file mode 100644 index 54831b87..00000000 --- a/proto/rtc.proto +++ /dev/null @@ -1,127 +0,0 @@ -syntax = "proto3"; - -package livekit; -option go_package = "github.com/livekit/livekit-server/proto/livekit"; - -import "model.proto"; - -message SignalRequest { - oneof message { - // initial join exchange, for publisher - SessionDescription offer = 1; - // participant answering publisher offer - SessionDescription answer = 2; - TrickleRequest trickle = 3; - AddTrackRequest add_track = 4; - // mute the participant's own tracks - MuteTrackRequest mute = 5; - // Subscribe or unsubscribe from tracks - UpdateSubscription subscription = 6; - // Update settings of subscribed tracks - UpdateTrackSettings track_setting = 7; - } -} - -message SignalResponse { - oneof message { - // sent when join is accepted - JoinResponse join = 1; - // sent when server answers publisher - SessionDescription answer = 2; - // sent when server is sending subscriber an offer - SessionDescription offer = 3; - // sent when an ICE candidate is available - TrickleRequest trickle = 4; - // sent when participants in the room has changed - ParticipantUpdate update = 5; - // sent to the participant when their track has been published - TrackPublishedResponse track_published = 6; - // list of active speakers - ActiveSpeakerUpdate speaker = 7; - } -} - -enum SignalTarget { - PUBLISHER = 0; - SUBSCRIBER = 1; -} - -message AddTrackRequest { - // client ID of track, to match it when RTC track is received - string cid = 1; - string name = 2; - TrackType type = 3; -} - -message TrickleRequest { - string candidateInit = 1; - SignalTarget target = 2; -} - -message MuteTrackRequest { - string sid = 1; - bool muted = 2; -} - -message NegotiationRequest { - // empty -} - -message JoinResponse { - Room room = 1; - ParticipantInfo participant = 2; - repeated ParticipantInfo other_participants = 3; - string server_version = 4; - repeated ICEServer ice_servers = 5; -} - -message TrackPublishedResponse { - string cid = 1; - TrackInfo track = 2; -} - -message SessionDescription { - string type = 1; // "answer" | "offer" | "pranswer" | "rollback" - string sdp = 2; -} - -message ParticipantUpdate { - repeated ParticipantInfo participants = 1; -} - -message ActiveSpeakerUpdate { - repeated SpeakerInfo speakers = 1; -} - -message SpeakerInfo { - string sid = 1; - // audio level, 0-1.0, 1 is loudest - float level = 2; - // true if speaker is currently active - bool active = 3; -} - -enum VideoQuality { - LOW = 0; - MEDIUM = 1; - HIGH = 2; -} - -message UpdateSubscription { - repeated string track_sids = 1; - bool subscribe = 2; - bool mute = 3; - VideoQuality quality = 4; -} - -message UpdateTrackSettings { - repeated string track_sids = 1; - bool mute = 3; - VideoQuality quality = 4; -} - -message ICEServer { - repeated string urls = 1; - string username = 2; - string credential = 3; -} diff --git a/test/integration_helpers.go b/test/integration_helpers.go index c57bd2f3..56f308eb 100644 --- a/test/integration_helpers.go +++ b/test/integration_helpers.go @@ -12,13 +12,13 @@ import ( "github.com/twitchtv/twirp" "github.com/livekit/livekit-server/cmd/cli/client" - "github.com/livekit/livekit-server/pkg/auth" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/service" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/auth" + "github.com/livekit/protocol/utils" ) const ( diff --git a/test/multinode_test.go b/test/multinode_test.go index 4cb21433..b88b30b7 100644 --- a/test/multinode_test.go +++ b/test/multinode_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" ) func TestMultiNodeRouting(t *testing.T) { @@ -115,8 +115,8 @@ func TestMultinodeReconnectAfterNodeShutdown(t *testing.T) { return } - logger.Infow("\n\n---Starting TestMultiNodeRouting---") - defer logger.Infow("---Finishing TestMultiNodeRouting---") + logger.Infow("\n\n---Starting TestMultinodeReconnectAfterNodeShutdown---") + defer logger.Infow("---Finishing TestMultinodeReconnectAfterNodeShutdown---") s1, s2 := setupMultiNodeTest() defer s1.Stop() diff --git a/test/turn_test.go b/test/turn_test.go index d430d78c..beb3c5cc 100644 --- a/test/turn_test.go +++ b/test/turn_test.go @@ -12,8 +12,8 @@ import ( "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/service" - "github.com/livekit/livekit-server/pkg/utils" - "github.com/livekit/livekit-server/proto/livekit" + livekit "github.com/livekit/livekit-server/proto" + "github.com/livekit/protocol/utils" ) func TestTurnServer(t *testing.T) {