diff --git a/cmd/cli/client/client.go b/cmd/cli/client/client.go index b49790647..9917153c2 100644 --- a/cmd/cli/client/client.go +++ b/cmd/cli/client/client.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "path/filepath" + "strings" "sync" "time" @@ -17,6 +18,7 @@ import ( "github.com/livekit/livekit-server/pkg/logger" "github.com/livekit/livekit-server/pkg/rtc" + "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/proto/livekit" ) @@ -100,25 +102,24 @@ func NewRTCClient(conn *websocket.Conn) (*RTCClient, error) { peerConn.OnTrack(func(track *webrtc.TrackRemote, rtpReceiver *webrtc.RTPReceiver) { c.AppendLog("track received", "label", track.StreamID(), "id", track.ID()) - peerId, _ := rtc.UnpackTrackId(track.ID()) - r := rtc.NewReceiver(peerId, rtpReceiver, nil) + r := rtc.NewReceiver(nil, rtpReceiver, track) c.lock.Lock() c.receivers = append(c.receivers, r) - r.Start() - go c.consumeReceiver(r) + go c.consumeReceiver(track.ID(), r) c.lock.Unlock() }) peerConn.OnNegotiationNeeded(func() { - c.AppendLog("negotiate needed") - if !c.connected { - c.AppendLog("not yet connected, skipping negotiate") - return - } - err := c.Negotiate() - if err != nil { - c.AppendLog("error negotiating", "err", err) - } + // do nothing + //c.AppendLog("negotiate needed") + //if !c.connected { + // c.AppendLog("not yet connected, skipping negotiate") + // return + //} + //err := c.Negotiate() + //if err != nil { + // c.AppendLog("error negotiating", "err", err) + //} }) peerConn.OnDataChannel(func(channel *webrtc.DataChannel) { @@ -218,11 +219,11 @@ func (c *RTCClient) Run() error { } c.pendingCandidates = nil c.lock.Unlock() - case *livekit.SignalResponse_Negotiate: - c.AppendLog("received negotiate", - "type", msg.Negotiate.Type) - desc := rtc.FromProtoSessionDescription(msg.Negotiate) - if err := c.handleNegotiate(desc); err != nil { + case *livekit.SignalResponse_Offer: + c.AppendLog("received server offer", + "type", msg.Offer.Type) + desc := rtc.FromProtoSessionDescription(msg.Offer) + if err := c.handleOffer(desc); err != nil { return err } case *livekit.SignalResponse_Trickle: @@ -313,31 +314,7 @@ func (c *RTCClient) SendIceCandidate(ic *webrtc.ICECandidate) error { }) } -func (c *RTCClient) Negotiate() error { - // Create an offer to send to the other process - offer, err := c.PeerConn.CreateOffer(nil) - if err != nil { - return err - } - - if err = c.PeerConn.SetLocalDescription(offer); err != nil { - return err - } - - // send the offer to remote - req := &livekit.SignalRequest{ - Message: &livekit.SignalRequest_Negotiate{ - Negotiate: rtc.ToProtoSessionDescription(offer), - }, - } - c.AppendLog("sending negotiate offer to remote...") - if err = c.SendRequest(req); err != nil { - return err - } - return nil -} - -func (c *RTCClient) handleNegotiate(desc webrtc.SessionDescription) error { +func (c *RTCClient) handleOffer(desc webrtc.SessionDescription) error { // always set remote description for both offer and answer if err := c.PeerConn.SetRemoteDescription(desc); err != nil { return err @@ -362,8 +339,8 @@ func (c *RTCClient) handleNegotiate(desc webrtc.SessionDescription) error { // send remote an answer return c.SendRequest(&livekit.SignalRequest{ - Message: &livekit.SignalRequest_Negotiate{ - Negotiate: rtc.ToProtoSessionDescription(answer), + Message: &livekit.SignalRequest_Answer{ + Answer: rtc.ToProtoSessionDescription(answer), }, }) } @@ -407,6 +384,26 @@ func (c *RTCClient) AddTrack(path string, id string, label string) error { c.pendingTrackWriters = append(c.pendingTrackWriters, tw) return nil } + + trackType := livekit.TrackType_AUDIO + if strings.HasPrefix(mime, "video") { + trackType = livekit.TrackType_VIDEO + } + + return c.SendAddTrack(id, label, trackType) +} + +// send AddTrack command to server to initiate server-side negotiation +func (c *RTCClient) SendAddTrack(cid string, name string, trackType livekit.TrackType) error { + return c.SendRequest(&livekit.SignalRequest{ + Message: &livekit.SignalRequest_AddTrack{ + AddTrack: &livekit.AddTrackRequest{ + Cid: cid, + Name: name, + Type: trackType, + }, + }, + }) } type logEntry struct { @@ -446,16 +443,11 @@ func (c *RTCClient) logLoop() { } } -func (c *RTCClient) consumeReceiver(r *rtc.ReceiverImpl) { +func (c *RTCClient) consumeReceiver(trackId string, r types.Receiver) { lastUpdate := time.Time{} - peerId, trackId := rtc.UnpackTrackId(r.TrackId()) + peerId, trackId := rtc.UnpackTrackId(trackId) numBytes := 0 - for { - pkt, err := r.ReadRTP() - if rtc.IsEOF(err) { - // all done - return - } + for pkt := range r.RTPChan() { numBytes += pkt.MarshalSize() if time.Now().Sub(lastUpdate) > 30*time.Second { c.AppendLog("consumed from peer", diff --git a/cmd/cli/commands/utils.go b/cmd/cli/commands/utils.go index ccad59c8a..47d70d706 100644 --- a/cmd/cli/commands/utils.go +++ b/cmd/cli/commands/utils.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/urfave/cli/v2" @@ -61,6 +62,7 @@ func accessToken(c *cli.Context, grant *auth.VideoGrant, identity string) (value at := auth.NewAccessToken(apiKey, apiSecret). AddGrant(grant). - SetIdentity(identity) + SetIdentity(identity). + SetValidFor(time.Hour * 24) return at.ToJWT() } diff --git a/cmd/server/main.go b/cmd/server/main.go index 6ae6b6389..1edab552e 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "math/rand" "net" "net/http" "os" @@ -66,6 +67,8 @@ func main() { } func startServer(c *cli.Context) error { + rand.Seed(time.Now().UnixNano()) + conf, err := config.NewConfig(c.String("config")) if err != nil { return err @@ -78,14 +81,15 @@ func startServer(c *cli.Context) error { logger.InitDevelopment() } else { logger.InitProduction() - // require a key provider - if keyProvider, err = createKeyProvider(c.String("key-file"), c.String("keys")); err != nil { - return err - } - service.AuthRequired = true - logger.GetLogger().Infow("auth enabled", "num_keys", keyProvider.NumKeys()) } + // require a key provider + if keyProvider, err = createKeyProvider(c.String("key-file"), c.String("keys")); err != nil { + return err + } + service.AuthRequired = true + logger.GetLogger().Infow("auth enabled", "num_keys", keyProvider.NumKeys()) + server, err := InitializeServer(conf, keyProvider) if err != nil { return err diff --git a/go.mod b/go.mod index 494df38eb..ef49512a2 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/livekit/livekit-server go 1.15 require ( + github.com/bep/debounce v1.2.0 + github.com/gammazero/workerpool v1.1.1 github.com/golang/protobuf v1.4.3 - github.com/google/uuid v1.1.2 github.com/google/wire v0.4.0 github.com/gorilla/websocket v1.4.2 github.com/lithammer/shortuuid/v3 v3.0.4 @@ -13,14 +14,13 @@ require ( github.com/magefile/mage v1.10.0 github.com/manifoldco/promptui v0.8.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 - github.com/pion/interceptor v0.0.5 github.com/pion/ion-log v1.0.0 - github.com/pion/ion-sfu v1.6.5 + github.com/pion/ion-sfu v1.7.2 github.com/pion/rtcp v1.2.6 - github.com/pion/rtp v1.6.1 - github.com/pion/sdp/v3 v3.0.3 + github.com/pion/rtp v1.6.2 github.com/pion/stun v0.3.5 - github.com/pion/webrtc/v3 v3.0.0-beta.16 + github.com/pion/transport v0.12.2 + github.com/pion/webrtc/v3 v3.0.3 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.6.1 github.com/thoas/go-funk v0.7.0 diff --git a/go.sum b/go.sum index f673aed67..b6eccdee4 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,7 @@ github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZw github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo= github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= @@ -92,8 +93,11 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/gammazero/deque v0.0.0-20200721202602-07291166fe33/go.mod h1:D90+MBHVc9Sk1lJAbEVgws0eYEurY4mv2TDso3Nxh3w= github.com/gammazero/deque v0.0.0-20201010052221-3932da5530cc h1:F7BbnLACph7UYiz9ZHi6npcROwKaZUyviDjsNERsoMM= github.com/gammazero/deque v0.0.0-20201010052221-3932da5530cc/go.mod h1:IlBLfYXnuw9sspy1XS6ctu5exGb6WHGKQsyo4s7bOEA= +github.com/gammazero/workerpool v1.1.1 h1:MN29GcZtZZAgzTU+Zk54Y+J9XkE54MoXON/NCZvNulo= +github.com/gammazero/workerpool v1.1.1/go.mod h1:5BN0IJVRjSFAypo9QTJCaWdijjNz9Jjl6VFS1PRjCeg= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -304,52 +308,47 @@ github.com/pion/datachannel v1.4.21 h1:3ZvhNyfmxsAqltQrApLPQMhSFNA+aT87RqyCq4OXm github.com/pion/datachannel v1.4.21/go.mod h1:oiNyP4gHx2DIwRzX/MFyH0Rz/Gz05OgBlayAI2hAWjg= github.com/pion/dtls/v2 v2.0.4 h1:WuUcqi6oYMu/noNTz92QrF1DaFj4eXbhQ6dzaaAwOiI= github.com/pion/dtls/v2 v2.0.4/go.mod h1:qAkFscX0ZHoI1E07RfYPoRw3manThveu+mlTDdOxoGI= -github.com/pion/ice/v2 v2.0.13 h1:lVe7g86tQ0vKdH430hQR/t7zV1oeXbK75130TUArrnw= -github.com/pion/ice/v2 v2.0.13/go.mod h1:mZlypgoynMn2ayhGsjrPY/G/WiRiYO8WCPC6gUeg1RA= github.com/pion/ice/v2 v2.0.14 h1:FxXxauyykf89SWAtkQCfnHkno6G8+bhRkNguSh9zU+4= github.com/pion/ice/v2 v2.0.14/go.mod h1:wqaUbOq5ObDNU5ox1hRsEst0rWfsKuH1zXjQFEWiZwM= -github.com/pion/interceptor v0.0.5 h1:BOwlubM1lntji3eNaVrhW1Qk3u1UoemrhM4mbv24XGM= -github.com/pion/interceptor v0.0.5/go.mod h1:lPVrf5xfosI989ZcmgPS4WwwRhd+XAyTFaYI2wHf7nU= +github.com/pion/interceptor v0.0.9 h1:fk5hTdyLO3KURQsf/+RjMpEm4NE3yeTY9Kh97b5BvwA= +github.com/pion/interceptor v0.0.9/go.mod h1:dHgEP5dtxOTf21MObuBAjJeAayPxLUAZjerGH8Xr07c= github.com/pion/ion-log v1.0.0 h1:2lJLImCmfCWCR38hLWsjQfBWe6NFz/htbqiYHwvOP/Q= github.com/pion/ion-log v1.0.0/go.mod h1:jwcla9KoB9bB/4FxYDSRJPcPYSLp5XiUUMnOLaqwl4E= -github.com/pion/ion-sfu v1.6.5 h1:L1V0eJ2hW0ox6LJAKBayOVaoHzQMIqKMP+kjS5IMp6Q= -github.com/pion/ion-sfu v1.6.5/go.mod h1:1NUUIynUZuNjfnc/r7sjeI7RlVk+sq6q/sFnu8x9Sv8= +github.com/pion/ion-sfu v1.7.2 h1:jW59IxIQtcGotK/BYlTqOF1Vsp/UqM4BoRD6MMnYw1Y= +github.com/pion/ion-sfu v1.7.2/go.mod h1:61HfTCWVx6rTpYCc7kmvnTToEpyBoMwDhOyvMiUtNhk= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/mdns v0.0.4 h1:O4vvVqr4DGX63vzmO6Fw9vpy3lfztVWHGCQfyw0ZLSY= github.com/pion/mdns v0.0.4/go.mod h1:R1sL0p50l42S5lJs91oNdUL58nm0QHrhxnSegr++qC0= github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= -github.com/pion/rtcp v1.2.4 h1:NT3H5LkUGgaEapvp0HGik+a+CpflRF7KTD7H+o7OWIM= -github.com/pion/rtcp v1.2.4/go.mod h1:52rMNPWFsjr39z9B9MhnkqhPLoeHTv1aN63o/42bWE0= github.com/pion/rtcp v1.2.6 h1:1zvwBbyd0TeEuuWftrd/4d++m+/kZSeiguxU61LFWpo= github.com/pion/rtcp v1.2.6/go.mod h1:52rMNPWFsjr39z9B9MhnkqhPLoeHTv1aN63o/42bWE0= -github.com/pion/rtp v1.6.1 h1:2Y2elcVBrahYnHKN2X7rMHX/r1R4TEBMP1LaVu/wNhk= -github.com/pion/rtp v1.6.1/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= +github.com/pion/rtp v1.6.2 h1:iGBerLX6JiDjB9NXuaPzHyxHFG9JsIEdgwTC0lp5n/U= +github.com/pion/rtp v1.6.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= github.com/pion/sctp v1.7.10/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0= github.com/pion/sctp v1.7.11 h1:UCnj7MsobLKLuP/Hh+JMiI/6W5Bs/VF45lWKgHFjSIE= github.com/pion/sctp v1.7.11/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0= github.com/pion/sdp/v3 v3.0.3 h1:gJK9hk+JFD2NGIM1nXmqNCq1DkVaIZ9dlA3u3otnkaw= github.com/pion/sdp/v3 v3.0.3/go.mod h1:bNiSknmJE0HYBprTHXKPQ3+JjacTv5uap92ueJZKsRk= -github.com/pion/srtp/v2 v2.0.0-rc.3 h1:1fPiK1nJlNyh235tSGgBnXrPc99wK1/D707f6ntb3qY= -github.com/pion/srtp/v2 v2.0.0-rc.3/go.mod h1:S6J9oY6ahAXdU3ni4nUwhWTJuBfssFjPxoB0u41TBpY= +github.com/pion/srtp/v2 v2.0.1 h1:kgfh65ob3EcnFYA4kUBvU/menCp9u7qaJLXwWgpobzs= +github.com/pion/srtp/v2 v2.0.1/go.mod h1:c8NWHhhkFf/drmHTAblkdu8++lsISEBBdAuiyxgqIsE= github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg= github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA= github.com/pion/transport v0.8.10/go.mod h1:tBmha/UCjpum5hqTWhfAEs3CO4/tHSg0MYRhSzR+CZ8= github.com/pion/transport v0.10.0/go.mod h1:BnHnUipd0rZQyTVB2SBGojFHT9CBt5C5TcsJSQGkvSE= github.com/pion/transport v0.10.1 h1:2W+yJT+0mOQ160ThZYUx5Zp2skzshiNgxrNE9GUfhJM= github.com/pion/transport v0.10.1/go.mod h1:PBis1stIILMiis0PewDw91WJeLJkyIMcEk+DwKOzf4A= -github.com/pion/transport v0.11.0/go.mod h1:ORH8Ouyl1enoJyHwU+MwMeQocWbeorEk5068FOsHjog= github.com/pion/transport v0.12.0 h1:UFmOBBZkTZ3LgvLRf/NGrfWdZEubcU6zkLU3PsA9YvU= github.com/pion/transport v0.12.0/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= +github.com/pion/transport v0.12.2 h1:WYEjhloRHt1R86LhUKjC5y+P52Y11/QqEUalvtzVoys= +github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= github.com/pion/turn/v2 v2.0.5 h1:iwMHqDfPEDEOFzwWKT56eFmh6DYC6o/+xnLAEzgISbA= github.com/pion/turn/v2 v2.0.5/go.mod h1:APg43CFyt/14Uy7heYUOGWdkem/Wu4PhCO/bjyrTqMw= github.com/pion/udp v0.1.0 h1:uGxQsNyrqG3GLINv36Ff60covYmfrLoxzwnCsIYspXI= github.com/pion/udp v0.1.0/go.mod h1:BPELIjbwE9PRbd/zxI/KYBnbo7B6+oA6YuEaNE8lths= -github.com/pion/webrtc/v3 v3.0.0-beta.15.0.20201209023348-63401a8837fb h1:odlj6CPofUlcqGpFZyRbCCBHEv9WJaPWUIqO/IPiTuk= -github.com/pion/webrtc/v3 v3.0.0-beta.15.0.20201209023348-63401a8837fb/go.mod h1:549ITPqIAp16O7ZtSRPAhj+CSteoM3Yjcb5xpDoT3vY= -github.com/pion/webrtc/v3 v3.0.0-beta.16 h1:0z4vYmw423qF6/qKXMFc8aAyPC8PKe9m2RLvpqlJDvI= -github.com/pion/webrtc/v3 v3.0.0-beta.16/go.mod h1:HsPeqc1J+fz3FZx3ZIGc43m0uVdktfF+rvJaxXWny1M= +github.com/pion/webrtc/v3 v3.0.3 h1:nAXJ5niRFRRMneuhM56xsh3J76sv+HAHCNuBmab3YR0= +github.com/pion/webrtc/v3 v3.0.3/go.mod h1:DZonLDfkjMlsY/IGixAbcq8izHu0zJIk04DYx51KUvk= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -364,7 +363,7 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= +github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -377,7 +376,7 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -478,8 +477,8 @@ 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-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604= -golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +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/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= @@ -533,8 +532,8 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102 h1:42cLlJJdEh+ySyeUUbEQ5bsTi golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7 h1:3uJsdck53FDIpWwLeAXlia9p4C8j0BO2xZrqzKpL0D8= golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201207224615-747e23833adb h1:xj2oMIbduz83x7tzglytWT7spn6rP+9hvKjTpro6/pM= -golang.org/x/net v0.0.0-20201207224615-747e23833adb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -545,8 +544,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -577,10 +576,12 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d h1:MiWWjyhUzZ+jvhZvloX6ZrUsdEghn8a64Upd8EMHglE= -golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo= +golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= diff --git a/magefile.go b/magefile.go index 6a8c6b366..fb1de8124 100644 --- a/magefile.go +++ b/magefile.go @@ -74,6 +74,7 @@ func Proto() error { "proto/room.proto", "proto/model.proto", ) + connectStd(cmd) if err := cmd.Run(); err != nil { return err } @@ -86,6 +87,7 @@ func Proto() error { "-I=proto", "proto/rtc.proto", ) + connectStd(cmd) if err := cmd.Run(); err != nil { return err } diff --git a/pkg/rtc/config.go b/pkg/rtc/config.go index bc78042d1..a8c7a16b9 100644 --- a/pkg/rtc/config.go +++ b/pkg/rtc/config.go @@ -11,7 +11,6 @@ import ( type WebRTCConfig struct { Configuration webrtc.Configuration SettingEngine webrtc.SettingEngine - feedbackTypes []webrtc.RTCPFeedback receiver ReceiverConfig } @@ -26,12 +25,6 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig, SDPSemantics: webrtc.SDPSemanticsUnifiedPlan, } s := webrtc.SettingEngine{} - ft := []webrtc.RTCPFeedback{ - {Type: webrtc.TypeRTCPFBCCM}, - {Type: webrtc.TypeRTCPFBNACK}, - {Type: webrtc.TypeRTCPFBGoogREMB}, - {Type: "nack pli"}, - } if conf.ICEPortRangeStart != 0 && conf.ICEPortRangeEnd != 0 { if err := s.SetEphemeralUDPPortRange(conf.ICEPortRangeStart, conf.ICEPortRangeEnd); err != nil { @@ -55,7 +48,6 @@ func NewWebRTCConfig(conf *config.RTCConfig, externalIP string) (*WebRTCConfig, return &WebRTCConfig{ Configuration: c, SettingEngine: s, - feedbackTypes: ft, receiver: ReceiverConfig{ maxBandwidth: conf.MaxBandwidth, maxBufferTime: conf.MaxBufferTime, diff --git a/pkg/rtc/datatrack.go b/pkg/rtc/datatrack.go index e30c09a0c..2777cfbe0 100644 --- a/pkg/rtc/datatrack.go +++ b/pkg/rtc/datatrack.go @@ -19,6 +19,7 @@ const ( // it shall forward publishedTracks to all of its subscribers type DataTrack struct { id string + name string participantId string dataChannel *webrtc.DataChannel lock sync.RWMutex @@ -33,6 +34,7 @@ func NewDataTrack(participantId string, dc *webrtc.DataChannel) *DataTrack { t := &DataTrack{ //ctx: context.Background(), id: utils.NewGuid(utils.TrackPrefix), + name: dc.Label(), participantId: participantId, dataChannel: dc, msgChan: make(chan livekit.DataMessage, dataBufferSize), @@ -58,12 +60,16 @@ func (t *DataTrack) ID() string { return t.id } -func (t *DataTrack) Kind() livekit.TrackInfo_Type { - return livekit.TrackInfo_DATA +func (t *DataTrack) Kind() livekit.TrackType { + return livekit.TrackType_DATA } -func (t *DataTrack) StreamID() string { - return t.dataChannel.Label() +func (t *DataTrack) Name() string { + return t.name +} + +func (t *DataTrack) SetName(name string) { + t.name = name } // DataTrack cannot be muted diff --git a/pkg/rtc/errors.go b/pkg/rtc/errors.go index 4a9778b41..829b0f1cf 100644 --- a/pkg/rtc/errors.go +++ b/pkg/rtc/errors.go @@ -7,4 +7,5 @@ var ( ErrInvalidRoomName = errors.New("room must have a unique name") ErrRoomNotFound = errors.New("requested room does not exist") ErrPermissionDenied = errors.New("no permissions to access the room") + ErrUnexpectedOffer = errors.New("expected answer SDP, received offer") ) diff --git a/pkg/rtc/factory.go b/pkg/rtc/factory.go new file mode 100644 index 000000000..c9b6709b6 --- /dev/null +++ b/pkg/rtc/factory.go @@ -0,0 +1,21 @@ +package rtc + +import ( + "sync" + + "github.com/pion/ion-sfu/pkg/buffer" +) + +const ( + rtpPacketMaxSize = 1460 +) + +// package level factories for buffers +var ( + bufferFactory = buffer.NewBufferFactory() + packetFactory = &sync.Pool{ + New: func() interface{} { + return make([]byte, rtpPacketMaxSize) + }, + } +) diff --git a/pkg/rtc/forwarder.go b/pkg/rtc/forwarder.go deleted file mode 100644 index 1a66fc19e..000000000 --- a/pkg/rtc/forwarder.go +++ /dev/null @@ -1,170 +0,0 @@ -package rtc - -import ( - "context" - "io" - "sync" - "time" - - "github.com/pion/rtcp" - "github.com/pion/rtp" - - "github.com/livekit/livekit-server/pkg/logger" - "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/sfu" -) - -type SimpleForwarder struct { - ctx context.Context - cancel context.CancelFunc - sourceRtcpCh chan []rtcp.Packet // channel to write RTCP packets to source - track *sfu.DownTrack // sender track - packetBuffer types.PacketBuffer - - lastPli time.Time - createdAt time.Time - - once sync.Once - - // handlers - onClose func(forwarder types.Forwarder) -} - -func NewSimpleForwarder(ctx context.Context, rtcpCh chan []rtcp.Packet, track *sfu.DownTrack, pb types.PacketBuffer) *SimpleForwarder { - ctx, cancel := context.WithCancel(ctx) - f := &SimpleForwarder{ - ctx: ctx, - cancel: cancel, - sourceRtcpCh: rtcpCh, - packetBuffer: pb, - track: track, - createdAt: time.Now(), - } - - // when underlying track is closed, close the forwarder too - track.OnCloseHandler(f.Close) - - return f -} - -func (f *SimpleForwarder) Start() { - f.once.Do(func() { - defer func() { - recover() - }() - go f.rtcpWorker() - }) -} - -func (f *SimpleForwarder) Close() { - if f.ctx.Err() != nil { - return - } - f.cancel() - if f.onClose != nil { - f.onClose(f) - } -} - -// Writes an RTP packet to peer -func (f *SimpleForwarder) WriteRTP(pkt *rtp.Packet) error { - if f.ctx.Err() != nil { - // skip canceled context errors - return nil - } - - err := f.track.WriteRTP(pkt) - - if err != nil { - if err == io.ErrClosedPipe { - // TODO: log and error? how should this error be handled - return nil - } - return err - } - return nil -} - -func (f *SimpleForwarder) OnClose(closeFunc func(types.Forwarder)) { - f.onClose = closeFunc -} - -func (f *SimpleForwarder) CreatedAt() time.Time { - return f.createdAt -} - -func (f *SimpleForwarder) Track() *sfu.DownTrack { - return f.track -} - -// rtcpWorker receives RTCP packets from the destination peer -// this include packet loss packets -func (f *SimpleForwarder) rtcpWorker() { - for { - pkts, err := f.track.RTPSender().ReadRTCP() - if err == io.ErrClosedPipe || err == io.EOF { - f.Close() - return - } - - if f.ctx.Err() != nil { - return - } - - if err != nil { - logger.GetLogger().Errorw("could not write read RTCP", - "err", err) - continue - } - - var fwdPkts []rtcp.Packet - pliOnce := true - firOnce := true - for _, pkt := range pkts { - switch p := pkt.(type) { - case *rtcp.PictureLossIndication: - if pliOnce { - p.MediaSSRC = f.track.LastSSRC() - p.SenderSSRC = f.track.SSRC() - fwdPkts = append(fwdPkts, p) - pliOnce = false - } - case *rtcp.FullIntraRequest: - if firOnce { - p.MediaSSRC = f.track.LastSSRC() - p.SenderSSRC = f.track.SSRC() - fwdPkts = append(fwdPkts, p) - firOnce = false - } - case *rtcp.ReceiverReport: - if len(p.Reports) > 0 && p.Reports[0].FractionLost > 25 { - //log.Tracef("Slow link for sender %s, fraction packet lost %.2f", f.track.peerID, float64(p.Reports[0].FractionLost)/256) - } - case *rtcp.TransportLayerNack: - logger.GetLogger().Debugw("forwarder got nack", - "packet", p) - for _, pair := range p.Nacks { - bufferedPackets := f.packetBuffer.GetBufferedPackets( - f.track.SSRC(), - f.track.SnOffset(), - f.track.TsOffset(), - f.track.GetNACKSeqNo(pair.PacketList()), - ) - for i, _ := range bufferedPackets { - pt := bufferedPackets[i] - f.track.WriteRTP(&rtp.Packet{Header: pt.Header, Payload: pt.Payload}) - } - } - default: - // TODO: Use fb packets for congestion control - } - } - - if f.ctx.Err() != nil { - return - } - if len(fwdPkts) > 0 { - f.sourceRtcpCh <- fwdPkts - } - } -} diff --git a/pkg/rtc/helper_test.go b/pkg/rtc/helper_test.go index 327f951a0..7fbce077e 100644 --- a/pkg/rtc/helper_test.go +++ b/pkg/rtc/helper_test.go @@ -15,10 +15,10 @@ func newMockParticipant(name string) *typesfakes.FakeParticipant { return p } -func newMockTrack(kind livekit.TrackInfo_Type, name string) *typesfakes.FakePublishedTrack { +func newMockTrack(kind livekit.TrackType, name string) *typesfakes.FakePublishedTrack { t := &typesfakes.FakePublishedTrack{} t.IDReturns(utils.NewGuid(utils.TrackPrefix)) t.KindReturns(kind) - t.StreamIDReturns(name) + t.NameReturns(name) return t } diff --git a/pkg/rtc/mediatrack.go b/pkg/rtc/mediatrack.go index e8ec6295d..e49c6e6c4 100644 --- a/pkg/rtc/mediatrack.go +++ b/pkg/rtc/mediatrack.go @@ -2,10 +2,14 @@ package rtc import ( "context" + "io" "sync" "time" + "github.com/gammazero/workerpool" + "github.com/pion/ion-sfu/pkg/buffer" "github.com/pion/rtcp" + "github.com/pion/transport/packetio" "github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3/pkg/rtcerr" @@ -18,7 +22,11 @@ import ( var ( maxPLIFrequency = 1 * time.Second - feedbackTypes = []webrtc.RTCPFeedback{{"goog-remb", ""}, {"nack", ""}, {"nack", "pli"}} + feedbackTypes = []webrtc.RTCPFeedback{ + {webrtc.TypeRTCPFBGoogREMB, ""}, + {webrtc.TypeRTCPFBTransportCC, ""}, + {webrtc.TypeRTCPFBNACK, ""}, + {webrtc.TypeRTCPFBNACK, "pli"}} ) // MediaTrack represents a WebRTC track that needs to be forwarded @@ -29,19 +37,19 @@ type MediaTrack struct { participantId string muted bool - // duplicated properties from TrackRemote - ssrc webrtc.SSRC - streamID string // otherwise known as label - kind livekit.TrackInfo_Type - codec webrtc.RTPCodecParameters + ssrc webrtc.SSRC + name string + kind livekit.TrackType + codec webrtc.RTPCodecParameters // channel to send RTCP packets to the source rtcpCh chan []rtcp.Packet lock sync.RWMutex once sync.Once - // map of target participantId -> forwarder - forwarders map[string]types.Forwarder + // map of target participantId -> DownTrack + downtracks map[string]types.DownTrack receiver types.Receiver + nackWorker *workerpool.WorkerPool //lastNack int64 lastPLI time.Time } @@ -52,14 +60,15 @@ func NewMediaTrack(pId string, rtcpCh chan []rtcp.Packet, track *webrtc.TrackRem id: utils.NewGuid(utils.TrackPrefix), participantId: pId, ssrc: track.SSRC(), - streamID: track.StreamID(), + name: track.StreamID(), kind: ToProtoTrackKind(track.Kind()), codec: track.Codec(), rtcpCh: rtcpCh, lock: sync.RWMutex{}, once: sync.Once{}, - forwarders: make(map[string]types.Forwarder), + downtracks: make(map[string]types.DownTrack), receiver: receiver, + nackWorker: workerpool.New(1), } return t @@ -67,7 +76,6 @@ func NewMediaTrack(pId string, rtcpCh chan []rtcp.Packet, track *webrtc.TrackRem func (t *MediaTrack) Start() { t.once.Do(func() { - t.receiver.Start() // start worker go t.forwardRTPWorker() }) @@ -77,12 +85,16 @@ func (t *MediaTrack) ID() string { return t.id } -func (t *MediaTrack) Kind() livekit.TrackInfo_Type { +func (t *MediaTrack) Kind() livekit.TrackType { return t.kind } -func (t *MediaTrack) StreamID() string { - return t.streamID +func (t *MediaTrack) Name() string { + return t.name +} + +func (t *MediaTrack) SetName(name string) { + t.name = name } func (t *MediaTrack) IsMuted() bool { @@ -103,7 +115,7 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error { Channels: codec.Channels, SDPFmtpLine: codec.SDPFmtpLine, RTCPFeedback: feedbackTypes, - }, packedId, t.StreamID()) + }, packedId, t.Name()) if err != nil { return err } @@ -117,15 +129,17 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error { outTrack.SetTransceiver(transceiver) // TODO: when outtrack is bound, start loop to send reports - //outTrack.OnBind(func() { - // go sub.sendStreamDownTracksReports(recv.StreamID()) - //}) - participant.AddDownTrack(t.StreamID(), outTrack) - - forwarder := NewSimpleForwarder(t.ctx, t.rtcpCh, outTrack, t.receiver) - forwarder.OnClose(func(f types.Forwarder) { + outTrack.OnBind(func() { + if rr := bufferFactory.GetOrNew(packetio.RTCPBufferPacket, outTrack.SSRC()).(*buffer.RTCPReader); rr != nil { + rr.OnPacket(func(pkt []byte) { + t.handleRTCP(outTrack, pkt) + }) + } + //go sub.sendStreamDownTracksReports(recv.Name()) + }) + outTrack.OnCloseHandler(func() { t.lock.Lock() - delete(t.forwarders, participant.ID()) + delete(t.downtracks, participant.ID()) t.lock.Unlock() if participant.PeerConnection().ConnectionState() == webrtc.PeerConnectionStateClosed { @@ -142,15 +156,13 @@ func (t *MediaTrack) AddSubscriber(participant types.Participant) error { } } - participant.RemoveDownTrack(t.StreamID(), outTrack) + participant.RemoveDownTrack(t.Name(), outTrack) }) + participant.AddDownTrack(t.Name(), outTrack) t.lock.Lock() defer t.lock.Unlock() - t.forwarders[participant.ID()] = forwarder - - // start forwarder - forwarder.Start() + t.downtracks[participant.ID()] = outTrack return nil } @@ -161,8 +173,8 @@ func (t *MediaTrack) RemoveSubscriber(participantId string) { t.lock.RLock() defer t.lock.RUnlock() - if forwarder := t.forwarders[participantId]; forwarder != nil { - go forwarder.Close() + if dt := t.downtracks[participantId]; dt != nil { + go dt.Close() } } @@ -170,10 +182,10 @@ func (t *MediaTrack) RemoveAllSubscribers() { logger.GetLogger().Debugw("removing all subscribers", "track", t.id) t.lock.RLock() defer t.lock.RUnlock() - for _, f := range t.forwarders { - go f.Close() + for _, dt := range t.downtracks { + go dt.Close() } - t.forwarders = make(map[string]types.Forwarder) + t.downtracks = make(map[string]types.DownTrack) } // forwardRTPWorker reads from the receiver and writes to each sender @@ -181,25 +193,13 @@ func (t *MediaTrack) forwardRTPWorker() { defer func() { t.RemoveAllSubscribers() // TODO: send unpublished events? + t.nackWorker.Stop() }() - for { - pkt, err := t.receiver.ReadRTP() - if IsEOF(err) { - logger.GetLogger().Debugw("Track received EOF, closing", - "participant", t.participantId, - "track", t.id) - return - } - - if err != nil { - logger.GetLogger().Errorw("error while reading RTP", - "participant", t.participantId, - "track", t.id) - } - + for pkt := range t.receiver.RTPChan() { + // when track is muted, it's "disabled" on the client side, and will still be sending black frames + // when our metadata is updated as such, we shortcircuit forwarding of black frames if t.muted { - // short circuit when track is muted continue } @@ -207,8 +207,8 @@ func (t *MediaTrack) forwardRTPWorker() { // "participantId", t.participantId, // "remoteTrack", t.remoteTrack.ID()) t.lock.RLock() - for dstId, forwarder := range t.forwarders { - err := forwarder.WriteRTP(pkt) + for dstId, dt := range t.downtracks { + err := dt.WriteRTP(pkt) if IsEOF(err) { // this participant unsubscribed, remove it t.RemoveSubscriber(dstId) @@ -240,3 +240,62 @@ func (t *MediaTrack) forwardRTPWorker() { t.lock.RUnlock() } } + +func (t *MediaTrack) handleRTCP(dt *sfu.DownTrack, rtcpBuf []byte) { + pkts, err := rtcp.Unmarshal(rtcpBuf) + if err != nil { + logger.GetLogger().Warnw("could not decode RTCP packet", "err", err) + } + + var fwdPkts []rtcp.Packet + // sufficient to send this only once + pliOnce := true + firOnce := true + for _, pkt := range pkts { + switch p := pkt.(type) { + case *rtcp.PictureLossIndication: + if pliOnce { + p.MediaSSRC = dt.LastSSRC() + p.SenderSSRC = dt.SSRC() + fwdPkts = append(fwdPkts, p) + pliOnce = false + } + case *rtcp.FullIntraRequest: + if firOnce { + p.MediaSSRC = dt.LastSSRC() + p.SenderSSRC = dt.SSRC() + fwdPkts = append(fwdPkts, p) + firOnce = false + } + case *rtcp.ReceiverReport: + if len(p.Reports) > 0 && p.Reports[0].FractionLost > 25 { + //log.Tracef("Slow link for sender %s, fraction packet lost %.2f", f.track.peerID, float64(p.Reports[0].FractionLost)/256) + } + case *rtcp.TransportLayerNack: + logger.GetLogger().Debugw("forwarder got nack", + "packet", p) + var nackedPackets []uint16 + for _, pair := range p.Nacks { + nackedPackets = append(nackedPackets, dt.GetNACKSeqNo(pair.PacketList())...) + } + t.nackWorker.Submit(func() { + pktBuf := packetFactory.Get().([]byte) + for _, sn := range nackedPackets { + pkt, err := t.receiver.GetBufferedPacket(pktBuf, sn, dt.SnOffset()) + if err == io.EOF { + break + } else if err != nil { + continue + } + // what about handling write errors such as no packet found + dt.WriteRTP(pkt) + } + packetFactory.Put(pktBuf) + }) + } + } + + if len(fwdPkts) > 0 { + t.rtcpCh <- fwdPkts + } +} diff --git a/pkg/rtc/mediatrack_internal_test.go b/pkg/rtc/mediatrack_internal_test.go index 359663f79..eb95c9f38 100644 --- a/pkg/rtc/mediatrack_internal_test.go +++ b/pkg/rtc/mediatrack_internal_test.go @@ -2,11 +2,11 @@ package rtc import ( "context" - "io" "sync" "testing" "time" + "github.com/gammazero/workerpool" "github.com/pion/rtcp" "github.com/pion/rtp" "github.com/pion/webrtc/v3" @@ -27,30 +27,29 @@ func TestForwardRTP(t *testing.T) { t.Run("ensure that forwarders are getting packets", func(t *testing.T) { mt := newMediaTrackWithReceiver() receiver := mt.receiver.(*typesfakes.FakeReceiver) - packet := &rtp.Packet{} - receiver.ReadRTPReturnsOnCall(0, packet, nil) + packet := rtp.Packet{} + receiver.RTPChanReturns(packetGenerator(packet)) - forwarder := &typesfakes.FakeForwarder{} - mt.forwarders["test"] = forwarder + dt := &typesfakes.FakeDownTrack{} + mt.downtracks["test"] = dt mt.Start() time.Sleep(testWaitDuration) - assert.Equal(t, 2, receiver.ReadRTPCallCount(), "worker didn't call ReadRTP twice") - assert.Equal(t, 1, forwarder.WriteRTPCallCount(), "WriteRTP wasn't called on Forwarder") - assert.Equal(t, packet, forwarder.WriteRTPArgsForCall(0)) + assert.Equal(t, 1, dt.WriteRTPCallCount(), "WriteRTP wasn't called on Forwarder") + assert.EqualValues(t, packet, dt.WriteRTPArgsForCall(0)) }) t.Run("muted tracks do not forward data", func(t *testing.T) { mt := newMediaTrackWithReceiver() mt.muted = true - forwarder := &typesfakes.FakeForwarder{} - mt.forwarders["test"] = forwarder + dt := &typesfakes.FakeDownTrack{} + mt.downtracks["test"] = dt mt.Start() time.Sleep(testWaitDuration) - assert.Zero(t, forwarder.WriteRTPCallCount()) + assert.Zero(t, dt.WriteRTPCallCount()) }) } @@ -58,9 +57,9 @@ func TestMissingKeyFrames(t *testing.T) { t.Run("PLI packet is sent when forwarder misses keyframe", func(t *testing.T) { mt := newMediaTrackWithReceiver() - forwarder := &typesfakes.FakeForwarder{} - mt.forwarders["test"] = forwarder - forwarder.WriteRTPReturns(sfu.ErrRequiresKeyFrame) + dt := &typesfakes.FakeDownTrack{} + mt.downtracks["test"] = dt + dt.WriteRTPReturns(sfu.ErrRequiresKeyFrame) mt.Start() time.Sleep(testWaitDuration) @@ -77,21 +76,35 @@ func TestMissingKeyFrames(t *testing.T) { // returns a receiver that reads a packet then returns EOF func newMediaTrackWithReceiver() *MediaTrack { - packet := &rtp.Packet{} - receiver := &typesfakes.FakeReceiver{} - receiver.ReadRTPReturnsOnCall(0, packet, nil) - receiver.ReadRTPReturnsOnCall(1, nil, io.EOF) + packet := rtp.Packet{} + receiver := &typesfakes.FakeReceiver{ + RTPChanStub: func() <-chan rtp.Packet { + return packetGenerator(packet) + }, + } return &MediaTrack{ ctx: context.Background(), id: utils.NewGuid(utils.TrackPrefix), participantId: "PAtest", muted: false, - kind: livekit.TrackInfo_VIDEO, + kind: livekit.TrackType_VIDEO, codec: webrtc.RTPCodecParameters{}, rtcpCh: make(chan []rtcp.Packet, 5), lock: sync.RWMutex{}, once: sync.Once{}, - forwarders: map[string]types.Forwarder{}, + downtracks: map[string]types.DownTrack{}, receiver: receiver, + nackWorker: workerpool.New(1), } } + +func packetGenerator(packets ...rtp.Packet) <-chan rtp.Packet { + pc := make(chan rtp.Packet) + go func() { + defer close(pc) + for _, p := range packets { + pc <- p + } + }() + return pc +} diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 53b66a0bd..a8c624b15 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -2,12 +2,12 @@ package rtc import ( "context" + "fmt" "io" "sync" "time" - "github.com/pion/interceptor" - "github.com/pion/ion-sfu/pkg/buffer" + "github.com/bep/debounce" "github.com/pion/rtcp" "github.com/pion/webrtc/v3" "github.com/pkg/errors" @@ -22,6 +22,7 @@ import ( const ( placeholderDataChannel = "_private" sdBatchSize = 20 + negotiationFrequency = 100 * time.Millisecond ) type ParticipantImpl struct { @@ -33,11 +34,13 @@ type ParticipantImpl struct { mediaEngine *webrtc.MediaEngine name string state livekit.ParticipantInfo_State - bi *buffer.Interceptor rtcpCh chan []rtcp.Packet subscribedTracks map[string][]*sfu.DownTrack // publishedTracks that participant is publishing publishedTracks map[string]types.PublishedTrack + // client intended to publish, yet to be reconciled + pendingTracks map[string]*livekit.TrackInfo + debouncedNegotiate func(func()) lock sync.RWMutex once sync.Once @@ -45,7 +48,6 @@ type ParticipantImpl struct { // callbacks & handlers onTrackPublished func(types.Participant, types.PublishedTrack) onTrackUpdated func(types.Participant, types.PublishedTrack) - onOffer func(webrtc.SessionDescription) onICECandidate func(c *webrtc.ICECandidateInit) onStateChange func(p types.Participant, oldState livekit.ParticipantInfo_State) onClose func(types.Participant) @@ -54,7 +56,10 @@ type ParticipantImpl struct { func NewPeerConnection(conf *WebRTCConfig) (*webrtc.PeerConnection, error) { me := &webrtc.MediaEngine{} me.RegisterDefaultCodecs() - api := webrtc.NewAPI(webrtc.WithMediaEngine(me), webrtc.WithSettingEngine(conf.SettingEngine)) + se := conf.SettingEngine + se.BufferFactory = bufferFactory.GetOrNew + + api := webrtc.NewAPI(webrtc.WithMediaEngine(me), webrtc.WithSettingEngine(se)) return api.NewPeerConnection(conf.Configuration) } @@ -62,29 +67,26 @@ func NewParticipant(pc types.PeerConnection, sc types.SignalConnection, name str me := &webrtc.MediaEngine{} me.RegisterDefaultCodecs() - bi := buffer.NewBufferInterceptor() - ir := &interceptor.Registry{} - ir.Add(bi) - ctx, cancel := context.WithCancel(context.Background()) participant := &ParticipantImpl{ - id: utils.NewGuid(utils.ParticipantPrefix), - name: name, - peerConn: pc, - sigConn: sc, - ctx: ctx, - cancel: cancel, - bi: bi, - rtcpCh: make(chan []rtcp.Packet, 10), - subscribedTracks: make(map[string][]*sfu.DownTrack), - state: livekit.ParticipantInfo_JOINING, - lock: sync.RWMutex{}, - publishedTracks: make(map[string]types.PublishedTrack, 0), - mediaEngine: me, + id: utils.NewGuid(utils.ParticipantPrefix), + name: name, + peerConn: pc, + sigConn: sc, + ctx: ctx, + cancel: cancel, + rtcpCh: make(chan []rtcp.Packet, 10), + subscribedTracks: make(map[string][]*sfu.DownTrack), + state: livekit.ParticipantInfo_JOINING, + lock: sync.RWMutex{}, + publishedTracks: make(map[string]types.PublishedTrack, 0), + pendingTracks: make(map[string]*livekit.TrackInfo), + mediaEngine: me, + debouncedNegotiate: debounce.New(negotiationFrequency), } log := logger.GetLogger() - + pc.ConnectionState() pc.OnTrack(participant.onMediaTrack) pc.OnICECandidate(func(c *webrtc.ICECandidate) { @@ -95,6 +97,7 @@ func NewParticipant(pc types.PeerConnection, sc types.SignalConnection, name str ci := c.ToJSON() // write candidate + logger.GetLogger().Debugw("sending ice candidates") err := sc.WriteResponse(&livekit.SignalResponse{ Message: &livekit.SignalResponse_Trickle{ Trickle: ToProtoTrickle(ci), @@ -152,10 +155,6 @@ func (p *ParticipantImpl) OnTrackPublished(callback func(types.Participant, type p.onTrackPublished = callback } -func (p *ParticipantImpl) OnOffer(callback func(webrtc.SessionDescription)) { - p.onOffer = callback -} - func (p *ParticipantImpl) OnICECandidate(callback func(c *webrtc.ICECandidateInit)) { p.onICECandidate = callback } @@ -172,7 +171,7 @@ func (p *ParticipantImpl) OnClose(callback func(types.Participant)) { p.onClose = callback } -// Answer an offer from remote participant +// Answer an offer from remote participant, used when clients make the initial connection func (p *ParticipantImpl) Answer(sdp webrtc.SessionDescription) (answer webrtc.SessionDescription, err error) { if err = p.peerConn.SetRemoteDescription(sdp); err != nil { return @@ -192,32 +191,7 @@ func (p *ParticipantImpl) Answer(sdp webrtc.SessionDescription) (answer webrtc.S // only set after answered p.peerConn.OnNegotiationNeeded(func() { logger.GetLogger().Debugw("negotiation needed", "participantId", p.ID()) - offer, err := p.peerConn.CreateOffer(nil) - if err != nil { - logger.GetLogger().Errorw("could not create offer", "err", err) - return - } - - err = p.peerConn.SetLocalDescription(offer) - if err != nil { - logger.GetLogger().Errorw("could not set local description", "err", err) - return - } - - logger.GetLogger().Debugw("sending available offer to participant") - err = p.sigConn.WriteResponse(&livekit.SignalResponse{ - Message: &livekit.SignalResponse_Negotiate{ - Negotiate: ToProtoSessionDescription(offer), - }, - }) - if err != nil { - logger.GetLogger().Errorw("could not send offer to peer", - "err", err) - } - - if p.onOffer != nil { - p.onOffer(offer) - } + p.scheduleNegotiate() }) err = p.sigConn.WriteResponse(&livekit.SignalResponse{ @@ -232,35 +206,34 @@ func (p *ParticipantImpl) Answer(sdp webrtc.SessionDescription) (answer webrtc.S return } -// HandleNegotiate when receiving session description from client -func (p *ParticipantImpl) HandleNegotiate(sd webrtc.SessionDescription) error { - if err := p.peerConn.SetRemoteDescription(sd); err != nil { - return errors.Wrap(err, "could not set remote description") +// client intends to publish track, this function records track details and schedules negotiation +func (p *ParticipantImpl) AddTrack(clientId, name string, trackType livekit.TrackType) { + p.lock.Lock() + defer p.lock.Unlock() + + p.pendingTracks[clientId] = &livekit.TrackInfo{ + Type: trackType, + Name: name, } - if sd.Type == webrtc.SDPTypeOffer { - answer, err := p.peerConn.CreateAnswer(nil) - if err != nil { - return errors.Wrap(err, "could not create answer") - } + p.scheduleNegotiate() +} - if err = p.peerConn.SetLocalDescription(answer); err != nil { - return errors.Wrap(err, "could not set local description") - } +func (p *ParticipantImpl) RemoveTrack(sid string) error { + p.lock.Lock() + defer p.lock.Unlock() - // send a negotiate response back - return p.sigConn.WriteResponse(&livekit.SignalResponse{ - Message: &livekit.SignalResponse_Negotiate{ - Negotiate: ToProtoSessionDescription(answer), - }, - }) - } + // + p.scheduleNegotiate() return nil } -func (p *ParticipantImpl) SetRemoteDescription(sdp webrtc.SessionDescription) error { - logger.GetLogger().Debugw("setting remote description", "type", sdp.Type) +func (p *ParticipantImpl) HandleAnswer(sdp webrtc.SessionDescription) error { + if sdp.Type != webrtc.SDPTypeAnswer { + return ErrUnexpectedOffer + } + logger.GetLogger().Debugw("setting remote answer") if err := p.peerConn.SetRemoteDescription(sdp); err != nil { return errors.Wrap(err, "could not set remote description") } @@ -391,6 +364,41 @@ func (p *ParticipantImpl) RemoveDownTrack(streamId string, dt *sfu.DownTrack) { p.subscribedTracks[streamId] = newTracks } +func (p *ParticipantImpl) scheduleNegotiate() { + p.debouncedNegotiate(p.negotiate) +} + +func (p *ParticipantImpl) negotiate() { + offer, err := p.peerConn.CreateOffer(nil) + if err != nil { + logger.GetLogger().Errorw("could not create offer", "err", err) + return + } + + if p.peerConn.SignalingState() != webrtc.SignalingStateStable { + // try this again + p.scheduleNegotiate() + return + } + + err = p.peerConn.SetLocalDescription(offer) + if err != nil { + logger.GetLogger().Errorw("could not set local description", "err", err) + return + } + + logger.GetLogger().Debugw("sending available offer to participant") + err = p.sigConn.WriteResponse(&livekit.SignalResponse{ + Message: &livekit.SignalResponse_Offer{ + Offer: ToProtoSessionDescription(offer), + }, + }) + if err != nil { + logger.GetLogger().Errorw("could not send offer to peer", + "err", err) + } +} + func (p *ParticipantImpl) updateState(state livekit.ParticipantInfo_State) { if state == p.state { return @@ -410,10 +418,10 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w logger.GetLogger().Debugw("remoteTrack added", "participantId", p.ID(), "remoteTrack", track.ID()) // create ReceiverImpl - receiver := NewReceiver(p.id, rtpReceiver, p.bi) + receiver := NewReceiver(p.rtcpCh, rtpReceiver, track) mt := NewMediaTrack(p.id, p.rtcpCh, track, receiver) - p.handleTrackPublished(mt) + p.handleTrackPublished(track.ID(), mt) } func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) { @@ -429,13 +437,22 @@ func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) { dt.Start() - p.handleTrackPublished(dt) + cid := fmt.Sprintf("%d", dc.ID()) + p.handleTrackPublished(cid, dt) } -func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) { +func (p *ParticipantImpl) handleTrackPublished(clientId string, track types.PublishedTrack) { + // fill in p.lock.Lock() + defer p.lock.Unlock() + ti := p.pendingTracks[clientId] + if ti == nil { + logger.GetLogger().Errorw("track info not published prior to track", "clientId", clientId) + } else { + track.SetName(ti.Name) + delete(p.pendingTracks, clientId) + } p.publishedTracks[track.ID()] = track - p.lock.Unlock() track.Start() diff --git a/pkg/rtc/receiver.go b/pkg/rtc/receiver.go index 3f7336b90..af96dba72 100644 --- a/pkg/rtc/receiver.go +++ b/pkg/rtc/receiver.go @@ -1,9 +1,8 @@ package rtc import ( - "sync" - "github.com/pion/ion-sfu/pkg/buffer" + "github.com/pion/rtcp" "github.com/pion/rtp" "github.com/pion/webrtc/v3" @@ -15,64 +14,70 @@ const ( maxChanSize = 1024 ) -// A receiver is responsible for pulling from a remoteTrack +// A receiver is responsible for pulling from a single logical track type ReceiverImpl struct { - participantId string - rtpReceiver *webrtc.RTPReceiver - track *webrtc.TrackRemote - bi *buffer.Interceptor - once sync.Once - bytesRead int64 + rtpReceiver *webrtc.RTPReceiver + track *webrtc.TrackRemote + buffer *buffer.Buffer + rtcpReader *buffer.RTCPReader + rtcpChan chan []rtcp.Packet } -func NewReceiver(peerId string, rtpReceiver *webrtc.RTPReceiver, bi *buffer.Interceptor) *ReceiverImpl { - return &ReceiverImpl{ - participantId: peerId, - rtpReceiver: rtpReceiver, - track: rtpReceiver.Track(), - bi: bi, - once: sync.Once{}, +func NewReceiver(rtcpCh chan []rtcp.Packet, rtpReceiver *webrtc.RTPReceiver, track *webrtc.TrackRemote) *ReceiverImpl { + r := &ReceiverImpl{ + rtpReceiver: rtpReceiver, + rtcpChan: rtcpCh, + track: track, } -} -func (r *ReceiverImpl) TrackId() string { - return r.track.ID() -} + r.buffer, r.rtcpReader = bufferFactory.GetBufferPair(uint32(track.SSRC())) -// starts reading RTP and push to buffer -func (r *ReceiverImpl) Start() { - r.once.Do(func() { - go r.rtcpWorker() + // when we have feedback for the sender, send through the rtcp channel + r.buffer.OnFeedback(func(fb []rtcp.Packet) { + if r.rtcpChan != nil { + r.rtcpChan <- fb + } }) -} -// PacketBuffer interface, to provide forwarders packets from the buffer -func (r *ReceiverImpl) GetBufferedPackets(mediaSSRC uint32, snOffset uint16, tsOffset uint32, sn []uint16) []rtp.Packet { - if r.bi == nil { - return nil - } - return r.bi.GetBufferedPackets(uint32(r.track.SSRC()), mediaSSRC, snOffset, tsOffset, sn) -} + r.buffer.OnTransportWideCC(func(sn uint16, timeNS int64, marker bool) { + // TODO: figure out how to handle this + }) -func (r *ReceiverImpl) ReadRTP() (*rtp.Packet, error) { - return r.track.ReadRTP() -} - -// rtcpWorker reads RTCP messages from receiver, notifies buffer -func (r *ReceiverImpl) rtcpWorker() { - // consume RTCP from the sender/source, but don't need to do anything with the packets - for { - _, err := r.rtpReceiver.ReadRTCP() - if IsEOF(err) { + // received sender updates + r.rtcpReader.OnPacket(func(bytes []byte) { + pkts, err := rtcp.Unmarshal(bytes) + if err != nil { + logger.GetLogger().Warnw("could not unmarshal RTCP packet") return } - if err != nil { - logger.GetLogger().Warnw("receiver error reading RTCP", - "participant", r.participantId, - "remoteTrack", r.track.SSRC(), - "err", err, - ) - continue + for _, pkt := range pkts { + switch p := pkt.(type) { + case *rtcp.SenderReport: + r.buffer.SetSenderReportData(p.RTPTime, p.NTPTime) + case *rtcp.SourceDescription: + // TODO: see what we'd want to do with this + } } - } + }) + + return r +} + +// PacketBuffer interface, retrieves a packet from buffer and deserializes +// it's possible that the packet can't be found, or the connection has been closed (io.EOF) +func (r *ReceiverImpl) GetBufferedPacket(pktBuf []byte, sn uint16, snOffset uint16) (p rtp.Packet, err error) { + if pktBuf == nil { + pktBuf = make([]byte, rtpPacketMaxSize) + } + size, err := r.buffer.GetPacket(pktBuf, sn+snOffset) + if err != nil { + return + } + + err = p.Unmarshal(pktBuf[:size]) + return +} + +func (r *ReceiverImpl) RTPChan() <-chan rtp.Packet { + return r.buffer.PacketChan() } diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 94e2dd34a..ed7582cd0 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -137,7 +137,7 @@ func (r *Room) onTrackAdded(participant types.Participant, track types.Published // this is the default behavior. in the future this could be more selective for _, existingParticipant := range r.participants { if existingParticipant == participant { - // skip publishing peer + // skip publishing participant continue } if existingParticipant.State() != livekit.ParticipantInfo_JOINED { diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index d3483c457..0ba9644aa 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -112,7 +112,7 @@ func TestNewTrack(t *testing.T) { p3 := participants[3].(*typesfakes.FakeParticipant) // p3 adds track - track := newMockTrack(livekit.TrackInfo_VIDEO, "webcam") + track := newMockTrack(livekit.TrackType_VIDEO, "webcam") trackCB := p3.OnTrackPublishedArgsForCall(0) assert.NotNil(t, trackCB) trackCB(p3, track) diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index bfc58b017..8f853cb9f 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -45,6 +45,7 @@ type PeerConnection interface { // used by mediatrack AddTransceiverFromTrack(track webrtc.TrackLocal, init ...webrtc.RtpTransceiverInit) (*webrtc.RTPTransceiver, error) ConnectionState() webrtc.PeerConnectionState + SignalingState() webrtc.SignalingState RemoveTrack(sender *webrtc.RTPSender) error } @@ -54,9 +55,10 @@ type Participant interface { Name() string State() livekit.ParticipantInfo_State ToProto() *livekit.ParticipantInfo + AddTrack(clientId, name string, trackType livekit.TrackType) + RemoveTrack(sid string) error Answer(sdp webrtc.SessionDescription) (answer webrtc.SessionDescription, err error) - HandleNegotiate(sd webrtc.SessionDescription) error - SetRemoteDescription(sdp webrtc.SessionDescription) error + HandleAnswer(sdp webrtc.SessionDescription) error AddICECandidate(candidate webrtc.ICECandidateInit) error AddSubscriber(op Participant) error RemoveSubscriber(peerId string) @@ -68,8 +70,6 @@ type Participant interface { Close() error // callbacks - // OnOffer - offer is ready for remote peer - OnOffer(func(webrtc.SessionDescription)) // OnICECandidate - ice candidate discovered for local peer OnICECandidate(func(c *webrtc.ICECandidateInit)) OnStateChange(func(p Participant, oldState livekit.ParticipantInfo_State)) @@ -91,8 +91,9 @@ type Participant interface { type PublishedTrack interface { Start() ID() string - Kind() livekit.TrackInfo_Type - StreamID() string + Kind() livekit.TrackType + Name() string + SetName(name string) IsMuted() bool AddSubscriber(participant Participant) error RemoveSubscriber(participantId string) @@ -101,26 +102,30 @@ type PublishedTrack interface { //counterfeiter:generate . Receiver type Receiver interface { - TrackId() string - Start() - GetBufferedPackets(mediaSSRC uint32, snOffset uint16, tsOffset uint32, sn []uint16) []rtp.Packet - ReadRTP() (*rtp.Packet, error) + RTPChan() <-chan rtp.Packet + GetBufferedPacket(pktBuf []byte, sn uint16, snOffset uint16) (rtp.Packet, error) } -//counterfeiter:generate . PacketBuffer -type PacketBuffer interface { - GetBufferedPackets(mediaSSRC uint32, snOffset uint16, tsOffset uint32, sn []uint16) []rtp.Packet -} - -// a Forwarder publishes data to a target remoteTrack or datachannel -// manages the RTCP loop with the target participant -//counterfeiter:generate . Forwarder -type Forwarder interface { - WriteRTP(*rtp.Packet) error - Start() +// DownTrack publishes data to a target participant +// using this interface to make testing more practical +//counterfeiter:generate . DownTrack +type DownTrack interface { + WriteRTP(p rtp.Packet) error Close() - CreatedAt() time.Time - Track() *sfu.DownTrack - - OnClose(func(Forwarder)) + OnCloseHandler(fn func()) + OnBind(fn func()) + SSRC() uint32 + LastSSRC() uint32 + SnOffset() uint16 + TsOffset() uint32 + GetNACKSeqNo(seqNo []uint16) []uint16 +} + +// interface for properties of webrtc.TrackRemote +//counterfeiter:generate . TrackRemote +type TrackRemote interface { + SSRC() webrtc.SSRC + StreamID() string + Kind() webrtc.RTPCodecType + Codec() webrtc.RTPCodecParameters } diff --git a/pkg/rtc/types/typesfakes/fake_down_track.go b/pkg/rtc/types/typesfakes/fake_down_track.go new file mode 100644 index 000000000..8c09317a9 --- /dev/null +++ b/pkg/rtc/types/typesfakes/fake_down_track.go @@ -0,0 +1,559 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package typesfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc/types" + "github.com/pion/rtp" +) + +type FakeDownTrack struct { + CloseStub func() + closeMutex sync.RWMutex + closeArgsForCall []struct { + } + GetNACKSeqNoStub func([]uint16) []uint16 + getNACKSeqNoMutex sync.RWMutex + getNACKSeqNoArgsForCall []struct { + arg1 []uint16 + } + getNACKSeqNoReturns struct { + result1 []uint16 + } + getNACKSeqNoReturnsOnCall map[int]struct { + result1 []uint16 + } + LastSSRCStub func() uint32 + lastSSRCMutex sync.RWMutex + lastSSRCArgsForCall []struct { + } + lastSSRCReturns struct { + result1 uint32 + } + lastSSRCReturnsOnCall map[int]struct { + result1 uint32 + } + OnBindStub func(func()) + onBindMutex sync.RWMutex + onBindArgsForCall []struct { + arg1 func() + } + OnCloseHandlerStub func(func()) + onCloseHandlerMutex sync.RWMutex + onCloseHandlerArgsForCall []struct { + arg1 func() + } + SSRCStub func() uint32 + sSRCMutex sync.RWMutex + sSRCArgsForCall []struct { + } + sSRCReturns struct { + result1 uint32 + } + sSRCReturnsOnCall map[int]struct { + result1 uint32 + } + SnOffsetStub func() uint16 + snOffsetMutex sync.RWMutex + snOffsetArgsForCall []struct { + } + snOffsetReturns struct { + result1 uint16 + } + snOffsetReturnsOnCall map[int]struct { + result1 uint16 + } + TsOffsetStub func() uint32 + tsOffsetMutex sync.RWMutex + tsOffsetArgsForCall []struct { + } + tsOffsetReturns struct { + result1 uint32 + } + tsOffsetReturnsOnCall map[int]struct { + result1 uint32 + } + WriteRTPStub func(rtp.Packet) error + writeRTPMutex sync.RWMutex + writeRTPArgsForCall []struct { + arg1 rtp.Packet + } + writeRTPReturns struct { + result1 error + } + writeRTPReturnsOnCall map[int]struct { + result1 error + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeDownTrack) Close() { + fake.closeMutex.Lock() + fake.closeArgsForCall = append(fake.closeArgsForCall, struct { + }{}) + stub := fake.CloseStub + fake.recordInvocation("Close", []interface{}{}) + fake.closeMutex.Unlock() + if stub != nil { + fake.CloseStub() + } +} + +func (fake *FakeDownTrack) CloseCallCount() int { + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + return len(fake.closeArgsForCall) +} + +func (fake *FakeDownTrack) CloseCalls(stub func()) { + fake.closeMutex.Lock() + defer fake.closeMutex.Unlock() + fake.CloseStub = stub +} + +func (fake *FakeDownTrack) GetNACKSeqNo(arg1 []uint16) []uint16 { + var arg1Copy []uint16 + if arg1 != nil { + arg1Copy = make([]uint16, len(arg1)) + copy(arg1Copy, arg1) + } + fake.getNACKSeqNoMutex.Lock() + ret, specificReturn := fake.getNACKSeqNoReturnsOnCall[len(fake.getNACKSeqNoArgsForCall)] + fake.getNACKSeqNoArgsForCall = append(fake.getNACKSeqNoArgsForCall, struct { + arg1 []uint16 + }{arg1Copy}) + stub := fake.GetNACKSeqNoStub + fakeReturns := fake.getNACKSeqNoReturns + fake.recordInvocation("GetNACKSeqNo", []interface{}{arg1Copy}) + fake.getNACKSeqNoMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) GetNACKSeqNoCallCount() int { + fake.getNACKSeqNoMutex.RLock() + defer fake.getNACKSeqNoMutex.RUnlock() + return len(fake.getNACKSeqNoArgsForCall) +} + +func (fake *FakeDownTrack) GetNACKSeqNoCalls(stub func([]uint16) []uint16) { + fake.getNACKSeqNoMutex.Lock() + defer fake.getNACKSeqNoMutex.Unlock() + fake.GetNACKSeqNoStub = stub +} + +func (fake *FakeDownTrack) GetNACKSeqNoArgsForCall(i int) []uint16 { + fake.getNACKSeqNoMutex.RLock() + defer fake.getNACKSeqNoMutex.RUnlock() + argsForCall := fake.getNACKSeqNoArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeDownTrack) GetNACKSeqNoReturns(result1 []uint16) { + fake.getNACKSeqNoMutex.Lock() + defer fake.getNACKSeqNoMutex.Unlock() + fake.GetNACKSeqNoStub = nil + fake.getNACKSeqNoReturns = struct { + result1 []uint16 + }{result1} +} + +func (fake *FakeDownTrack) GetNACKSeqNoReturnsOnCall(i int, result1 []uint16) { + fake.getNACKSeqNoMutex.Lock() + defer fake.getNACKSeqNoMutex.Unlock() + fake.GetNACKSeqNoStub = nil + if fake.getNACKSeqNoReturnsOnCall == nil { + fake.getNACKSeqNoReturnsOnCall = make(map[int]struct { + result1 []uint16 + }) + } + fake.getNACKSeqNoReturnsOnCall[i] = struct { + result1 []uint16 + }{result1} +} + +func (fake *FakeDownTrack) LastSSRC() uint32 { + fake.lastSSRCMutex.Lock() + ret, specificReturn := fake.lastSSRCReturnsOnCall[len(fake.lastSSRCArgsForCall)] + fake.lastSSRCArgsForCall = append(fake.lastSSRCArgsForCall, struct { + }{}) + stub := fake.LastSSRCStub + fakeReturns := fake.lastSSRCReturns + fake.recordInvocation("LastSSRC", []interface{}{}) + fake.lastSSRCMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) LastSSRCCallCount() int { + fake.lastSSRCMutex.RLock() + defer fake.lastSSRCMutex.RUnlock() + return len(fake.lastSSRCArgsForCall) +} + +func (fake *FakeDownTrack) LastSSRCCalls(stub func() uint32) { + fake.lastSSRCMutex.Lock() + defer fake.lastSSRCMutex.Unlock() + fake.LastSSRCStub = stub +} + +func (fake *FakeDownTrack) LastSSRCReturns(result1 uint32) { + fake.lastSSRCMutex.Lock() + defer fake.lastSSRCMutex.Unlock() + fake.LastSSRCStub = nil + fake.lastSSRCReturns = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) LastSSRCReturnsOnCall(i int, result1 uint32) { + fake.lastSSRCMutex.Lock() + defer fake.lastSSRCMutex.Unlock() + fake.LastSSRCStub = nil + if fake.lastSSRCReturnsOnCall == nil { + fake.lastSSRCReturnsOnCall = make(map[int]struct { + result1 uint32 + }) + } + fake.lastSSRCReturnsOnCall[i] = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) OnBind(arg1 func()) { + fake.onBindMutex.Lock() + fake.onBindArgsForCall = append(fake.onBindArgsForCall, struct { + arg1 func() + }{arg1}) + stub := fake.OnBindStub + fake.recordInvocation("OnBind", []interface{}{arg1}) + fake.onBindMutex.Unlock() + if stub != nil { + fake.OnBindStub(arg1) + } +} + +func (fake *FakeDownTrack) OnBindCallCount() int { + fake.onBindMutex.RLock() + defer fake.onBindMutex.RUnlock() + return len(fake.onBindArgsForCall) +} + +func (fake *FakeDownTrack) OnBindCalls(stub func(func())) { + fake.onBindMutex.Lock() + defer fake.onBindMutex.Unlock() + fake.OnBindStub = stub +} + +func (fake *FakeDownTrack) OnBindArgsForCall(i int) func() { + fake.onBindMutex.RLock() + defer fake.onBindMutex.RUnlock() + argsForCall := fake.onBindArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeDownTrack) OnCloseHandler(arg1 func()) { + fake.onCloseHandlerMutex.Lock() + fake.onCloseHandlerArgsForCall = append(fake.onCloseHandlerArgsForCall, struct { + arg1 func() + }{arg1}) + stub := fake.OnCloseHandlerStub + fake.recordInvocation("OnCloseHandler", []interface{}{arg1}) + fake.onCloseHandlerMutex.Unlock() + if stub != nil { + fake.OnCloseHandlerStub(arg1) + } +} + +func (fake *FakeDownTrack) OnCloseHandlerCallCount() int { + fake.onCloseHandlerMutex.RLock() + defer fake.onCloseHandlerMutex.RUnlock() + return len(fake.onCloseHandlerArgsForCall) +} + +func (fake *FakeDownTrack) OnCloseHandlerCalls(stub func(func())) { + fake.onCloseHandlerMutex.Lock() + defer fake.onCloseHandlerMutex.Unlock() + fake.OnCloseHandlerStub = stub +} + +func (fake *FakeDownTrack) OnCloseHandlerArgsForCall(i int) func() { + fake.onCloseHandlerMutex.RLock() + defer fake.onCloseHandlerMutex.RUnlock() + argsForCall := fake.onCloseHandlerArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeDownTrack) SSRC() uint32 { + fake.sSRCMutex.Lock() + ret, specificReturn := fake.sSRCReturnsOnCall[len(fake.sSRCArgsForCall)] + fake.sSRCArgsForCall = append(fake.sSRCArgsForCall, struct { + }{}) + stub := fake.SSRCStub + fakeReturns := fake.sSRCReturns + fake.recordInvocation("SSRC", []interface{}{}) + fake.sSRCMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) SSRCCallCount() int { + fake.sSRCMutex.RLock() + defer fake.sSRCMutex.RUnlock() + return len(fake.sSRCArgsForCall) +} + +func (fake *FakeDownTrack) SSRCCalls(stub func() uint32) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = stub +} + +func (fake *FakeDownTrack) SSRCReturns(result1 uint32) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = nil + fake.sSRCReturns = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) SSRCReturnsOnCall(i int, result1 uint32) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = nil + if fake.sSRCReturnsOnCall == nil { + fake.sSRCReturnsOnCall = make(map[int]struct { + result1 uint32 + }) + } + fake.sSRCReturnsOnCall[i] = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) SnOffset() uint16 { + fake.snOffsetMutex.Lock() + ret, specificReturn := fake.snOffsetReturnsOnCall[len(fake.snOffsetArgsForCall)] + fake.snOffsetArgsForCall = append(fake.snOffsetArgsForCall, struct { + }{}) + stub := fake.SnOffsetStub + fakeReturns := fake.snOffsetReturns + fake.recordInvocation("SnOffset", []interface{}{}) + fake.snOffsetMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) SnOffsetCallCount() int { + fake.snOffsetMutex.RLock() + defer fake.snOffsetMutex.RUnlock() + return len(fake.snOffsetArgsForCall) +} + +func (fake *FakeDownTrack) SnOffsetCalls(stub func() uint16) { + fake.snOffsetMutex.Lock() + defer fake.snOffsetMutex.Unlock() + fake.SnOffsetStub = stub +} + +func (fake *FakeDownTrack) SnOffsetReturns(result1 uint16) { + fake.snOffsetMutex.Lock() + defer fake.snOffsetMutex.Unlock() + fake.SnOffsetStub = nil + fake.snOffsetReturns = struct { + result1 uint16 + }{result1} +} + +func (fake *FakeDownTrack) SnOffsetReturnsOnCall(i int, result1 uint16) { + fake.snOffsetMutex.Lock() + defer fake.snOffsetMutex.Unlock() + fake.SnOffsetStub = nil + if fake.snOffsetReturnsOnCall == nil { + fake.snOffsetReturnsOnCall = make(map[int]struct { + result1 uint16 + }) + } + fake.snOffsetReturnsOnCall[i] = struct { + result1 uint16 + }{result1} +} + +func (fake *FakeDownTrack) TsOffset() uint32 { + fake.tsOffsetMutex.Lock() + ret, specificReturn := fake.tsOffsetReturnsOnCall[len(fake.tsOffsetArgsForCall)] + fake.tsOffsetArgsForCall = append(fake.tsOffsetArgsForCall, struct { + }{}) + stub := fake.TsOffsetStub + fakeReturns := fake.tsOffsetReturns + fake.recordInvocation("TsOffset", []interface{}{}) + fake.tsOffsetMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) TsOffsetCallCount() int { + fake.tsOffsetMutex.RLock() + defer fake.tsOffsetMutex.RUnlock() + return len(fake.tsOffsetArgsForCall) +} + +func (fake *FakeDownTrack) TsOffsetCalls(stub func() uint32) { + fake.tsOffsetMutex.Lock() + defer fake.tsOffsetMutex.Unlock() + fake.TsOffsetStub = stub +} + +func (fake *FakeDownTrack) TsOffsetReturns(result1 uint32) { + fake.tsOffsetMutex.Lock() + defer fake.tsOffsetMutex.Unlock() + fake.TsOffsetStub = nil + fake.tsOffsetReturns = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) TsOffsetReturnsOnCall(i int, result1 uint32) { + fake.tsOffsetMutex.Lock() + defer fake.tsOffsetMutex.Unlock() + fake.TsOffsetStub = nil + if fake.tsOffsetReturnsOnCall == nil { + fake.tsOffsetReturnsOnCall = make(map[int]struct { + result1 uint32 + }) + } + fake.tsOffsetReturnsOnCall[i] = struct { + result1 uint32 + }{result1} +} + +func (fake *FakeDownTrack) WriteRTP(arg1 rtp.Packet) error { + fake.writeRTPMutex.Lock() + ret, specificReturn := fake.writeRTPReturnsOnCall[len(fake.writeRTPArgsForCall)] + fake.writeRTPArgsForCall = append(fake.writeRTPArgsForCall, struct { + arg1 rtp.Packet + }{arg1}) + stub := fake.WriteRTPStub + fakeReturns := fake.writeRTPReturns + fake.recordInvocation("WriteRTP", []interface{}{arg1}) + fake.writeRTPMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeDownTrack) WriteRTPCallCount() int { + fake.writeRTPMutex.RLock() + defer fake.writeRTPMutex.RUnlock() + return len(fake.writeRTPArgsForCall) +} + +func (fake *FakeDownTrack) WriteRTPCalls(stub func(rtp.Packet) error) { + fake.writeRTPMutex.Lock() + defer fake.writeRTPMutex.Unlock() + fake.WriteRTPStub = stub +} + +func (fake *FakeDownTrack) WriteRTPArgsForCall(i int) rtp.Packet { + fake.writeRTPMutex.RLock() + defer fake.writeRTPMutex.RUnlock() + argsForCall := fake.writeRTPArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeDownTrack) WriteRTPReturns(result1 error) { + fake.writeRTPMutex.Lock() + defer fake.writeRTPMutex.Unlock() + fake.WriteRTPStub = nil + fake.writeRTPReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeDownTrack) WriteRTPReturnsOnCall(i int, result1 error) { + fake.writeRTPMutex.Lock() + defer fake.writeRTPMutex.Unlock() + fake.WriteRTPStub = nil + if fake.writeRTPReturnsOnCall == nil { + fake.writeRTPReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.writeRTPReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeDownTrack) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.closeMutex.RLock() + defer fake.closeMutex.RUnlock() + fake.getNACKSeqNoMutex.RLock() + defer fake.getNACKSeqNoMutex.RUnlock() + fake.lastSSRCMutex.RLock() + defer fake.lastSSRCMutex.RUnlock() + fake.onBindMutex.RLock() + defer fake.onBindMutex.RUnlock() + fake.onCloseHandlerMutex.RLock() + defer fake.onCloseHandlerMutex.RUnlock() + fake.sSRCMutex.RLock() + defer fake.sSRCMutex.RUnlock() + fake.snOffsetMutex.RLock() + defer fake.snOffsetMutex.RUnlock() + fake.tsOffsetMutex.RLock() + defer fake.tsOffsetMutex.RUnlock() + fake.writeRTPMutex.RLock() + defer fake.writeRTPMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeDownTrack) 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 _ types.DownTrack = new(FakeDownTrack) diff --git a/pkg/rtc/types/typesfakes/fake_forwarder.go b/pkg/rtc/types/typesfakes/fake_forwarder.go deleted file mode 100644 index f1b80dd09..000000000 --- a/pkg/rtc/types/typesfakes/fake_forwarder.go +++ /dev/null @@ -1,343 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package typesfakes - -import ( - "sync" - "time" - - "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/livekit/livekit-server/pkg/sfu" - "github.com/pion/rtp" -) - -type FakeForwarder struct { - CloseStub func() - closeMutex sync.RWMutex - closeArgsForCall []struct { - } - CreatedAtStub func() time.Time - createdAtMutex sync.RWMutex - createdAtArgsForCall []struct { - } - createdAtReturns struct { - result1 time.Time - } - createdAtReturnsOnCall map[int]struct { - result1 time.Time - } - OnCloseStub func(func(types.Forwarder)) - onCloseMutex sync.RWMutex - onCloseArgsForCall []struct { - arg1 func(types.Forwarder) - } - StartStub func() - startMutex sync.RWMutex - startArgsForCall []struct { - } - TrackStub func() *sfu.DownTrack - trackMutex sync.RWMutex - trackArgsForCall []struct { - } - trackReturns struct { - result1 *sfu.DownTrack - } - trackReturnsOnCall map[int]struct { - result1 *sfu.DownTrack - } - WriteRTPStub func(*rtp.Packet) error - writeRTPMutex sync.RWMutex - writeRTPArgsForCall []struct { - arg1 *rtp.Packet - } - writeRTPReturns struct { - result1 error - } - writeRTPReturnsOnCall map[int]struct { - result1 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeForwarder) Close() { - fake.closeMutex.Lock() - fake.closeArgsForCall = append(fake.closeArgsForCall, struct { - }{}) - stub := fake.CloseStub - fake.recordInvocation("Close", []interface{}{}) - fake.closeMutex.Unlock() - if stub != nil { - fake.CloseStub() - } -} - -func (fake *FakeForwarder) CloseCallCount() int { - fake.closeMutex.RLock() - defer fake.closeMutex.RUnlock() - return len(fake.closeArgsForCall) -} - -func (fake *FakeForwarder) CloseCalls(stub func()) { - fake.closeMutex.Lock() - defer fake.closeMutex.Unlock() - fake.CloseStub = stub -} - -func (fake *FakeForwarder) CreatedAt() time.Time { - fake.createdAtMutex.Lock() - ret, specificReturn := fake.createdAtReturnsOnCall[len(fake.createdAtArgsForCall)] - fake.createdAtArgsForCall = append(fake.createdAtArgsForCall, struct { - }{}) - stub := fake.CreatedAtStub - fakeReturns := fake.createdAtReturns - fake.recordInvocation("CreatedAt", []interface{}{}) - fake.createdAtMutex.Unlock() - if stub != nil { - return stub() - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeForwarder) CreatedAtCallCount() int { - fake.createdAtMutex.RLock() - defer fake.createdAtMutex.RUnlock() - return len(fake.createdAtArgsForCall) -} - -func (fake *FakeForwarder) CreatedAtCalls(stub func() time.Time) { - fake.createdAtMutex.Lock() - defer fake.createdAtMutex.Unlock() - fake.CreatedAtStub = stub -} - -func (fake *FakeForwarder) CreatedAtReturns(result1 time.Time) { - fake.createdAtMutex.Lock() - defer fake.createdAtMutex.Unlock() - fake.CreatedAtStub = nil - fake.createdAtReturns = struct { - result1 time.Time - }{result1} -} - -func (fake *FakeForwarder) CreatedAtReturnsOnCall(i int, result1 time.Time) { - fake.createdAtMutex.Lock() - defer fake.createdAtMutex.Unlock() - fake.CreatedAtStub = nil - if fake.createdAtReturnsOnCall == nil { - fake.createdAtReturnsOnCall = make(map[int]struct { - result1 time.Time - }) - } - fake.createdAtReturnsOnCall[i] = struct { - result1 time.Time - }{result1} -} - -func (fake *FakeForwarder) OnClose(arg1 func(types.Forwarder)) { - fake.onCloseMutex.Lock() - fake.onCloseArgsForCall = append(fake.onCloseArgsForCall, struct { - arg1 func(types.Forwarder) - }{arg1}) - stub := fake.OnCloseStub - fake.recordInvocation("OnClose", []interface{}{arg1}) - fake.onCloseMutex.Unlock() - if stub != nil { - fake.OnCloseStub(arg1) - } -} - -func (fake *FakeForwarder) OnCloseCallCount() int { - fake.onCloseMutex.RLock() - defer fake.onCloseMutex.RUnlock() - return len(fake.onCloseArgsForCall) -} - -func (fake *FakeForwarder) OnCloseCalls(stub func(func(types.Forwarder))) { - fake.onCloseMutex.Lock() - defer fake.onCloseMutex.Unlock() - fake.OnCloseStub = stub -} - -func (fake *FakeForwarder) OnCloseArgsForCall(i int) func(types.Forwarder) { - fake.onCloseMutex.RLock() - defer fake.onCloseMutex.RUnlock() - argsForCall := fake.onCloseArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeForwarder) Start() { - fake.startMutex.Lock() - fake.startArgsForCall = append(fake.startArgsForCall, struct { - }{}) - stub := fake.StartStub - fake.recordInvocation("Start", []interface{}{}) - fake.startMutex.Unlock() - if stub != nil { - fake.StartStub() - } -} - -func (fake *FakeForwarder) StartCallCount() int { - fake.startMutex.RLock() - defer fake.startMutex.RUnlock() - return len(fake.startArgsForCall) -} - -func (fake *FakeForwarder) StartCalls(stub func()) { - fake.startMutex.Lock() - defer fake.startMutex.Unlock() - fake.StartStub = stub -} - -func (fake *FakeForwarder) Track() *sfu.DownTrack { - fake.trackMutex.Lock() - ret, specificReturn := fake.trackReturnsOnCall[len(fake.trackArgsForCall)] - fake.trackArgsForCall = append(fake.trackArgsForCall, struct { - }{}) - stub := fake.TrackStub - fakeReturns := fake.trackReturns - fake.recordInvocation("Track", []interface{}{}) - fake.trackMutex.Unlock() - if stub != nil { - return stub() - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeForwarder) TrackCallCount() int { - fake.trackMutex.RLock() - defer fake.trackMutex.RUnlock() - return len(fake.trackArgsForCall) -} - -func (fake *FakeForwarder) TrackCalls(stub func() *sfu.DownTrack) { - fake.trackMutex.Lock() - defer fake.trackMutex.Unlock() - fake.TrackStub = stub -} - -func (fake *FakeForwarder) TrackReturns(result1 *sfu.DownTrack) { - fake.trackMutex.Lock() - defer fake.trackMutex.Unlock() - fake.TrackStub = nil - fake.trackReturns = struct { - result1 *sfu.DownTrack - }{result1} -} - -func (fake *FakeForwarder) TrackReturnsOnCall(i int, result1 *sfu.DownTrack) { - fake.trackMutex.Lock() - defer fake.trackMutex.Unlock() - fake.TrackStub = nil - if fake.trackReturnsOnCall == nil { - fake.trackReturnsOnCall = make(map[int]struct { - result1 *sfu.DownTrack - }) - } - fake.trackReturnsOnCall[i] = struct { - result1 *sfu.DownTrack - }{result1} -} - -func (fake *FakeForwarder) WriteRTP(arg1 *rtp.Packet) error { - fake.writeRTPMutex.Lock() - ret, specificReturn := fake.writeRTPReturnsOnCall[len(fake.writeRTPArgsForCall)] - fake.writeRTPArgsForCall = append(fake.writeRTPArgsForCall, struct { - arg1 *rtp.Packet - }{arg1}) - stub := fake.WriteRTPStub - fakeReturns := fake.writeRTPReturns - fake.recordInvocation("WriteRTP", []interface{}{arg1}) - fake.writeRTPMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeForwarder) WriteRTPCallCount() int { - fake.writeRTPMutex.RLock() - defer fake.writeRTPMutex.RUnlock() - return len(fake.writeRTPArgsForCall) -} - -func (fake *FakeForwarder) WriteRTPCalls(stub func(*rtp.Packet) error) { - fake.writeRTPMutex.Lock() - defer fake.writeRTPMutex.Unlock() - fake.WriteRTPStub = stub -} - -func (fake *FakeForwarder) WriteRTPArgsForCall(i int) *rtp.Packet { - fake.writeRTPMutex.RLock() - defer fake.writeRTPMutex.RUnlock() - argsForCall := fake.writeRTPArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeForwarder) WriteRTPReturns(result1 error) { - fake.writeRTPMutex.Lock() - defer fake.writeRTPMutex.Unlock() - fake.WriteRTPStub = nil - fake.writeRTPReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeForwarder) WriteRTPReturnsOnCall(i int, result1 error) { - fake.writeRTPMutex.Lock() - defer fake.writeRTPMutex.Unlock() - fake.WriteRTPStub = nil - if fake.writeRTPReturnsOnCall == nil { - fake.writeRTPReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.writeRTPReturnsOnCall[i] = struct { - result1 error - }{result1} -} - -func (fake *FakeForwarder) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.closeMutex.RLock() - defer fake.closeMutex.RUnlock() - fake.createdAtMutex.RLock() - defer fake.createdAtMutex.RUnlock() - fake.onCloseMutex.RLock() - defer fake.onCloseMutex.RUnlock() - fake.startMutex.RLock() - defer fake.startMutex.RUnlock() - fake.trackMutex.RLock() - defer fake.trackMutex.RUnlock() - fake.writeRTPMutex.RLock() - defer fake.writeRTPMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeForwarder) 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 _ types.Forwarder = new(FakeForwarder) diff --git a/pkg/rtc/types/typesfakes/fake_packet_buffer.go b/pkg/rtc/types/typesfakes/fake_packet_buffer.go deleted file mode 100644 index 79286cf9a..000000000 --- a/pkg/rtc/types/typesfakes/fake_packet_buffer.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package typesfakes - -import ( - "sync" - - "github.com/livekit/livekit-server/pkg/rtc/types" - "github.com/pion/rtp" -) - -type FakePacketBuffer struct { - GetBufferedPacketsStub func(uint32, uint16, uint32, []uint16) []rtp.Packet - getBufferedPacketsMutex sync.RWMutex - getBufferedPacketsArgsForCall []struct { - arg1 uint32 - arg2 uint16 - arg3 uint32 - arg4 []uint16 - } - getBufferedPacketsReturns struct { - result1 []rtp.Packet - } - getBufferedPacketsReturnsOnCall map[int]struct { - result1 []rtp.Packet - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakePacketBuffer) GetBufferedPackets(arg1 uint32, arg2 uint16, arg3 uint32, arg4 []uint16) []rtp.Packet { - var arg4Copy []uint16 - if arg4 != nil { - arg4Copy = make([]uint16, len(arg4)) - copy(arg4Copy, arg4) - } - fake.getBufferedPacketsMutex.Lock() - ret, specificReturn := fake.getBufferedPacketsReturnsOnCall[len(fake.getBufferedPacketsArgsForCall)] - fake.getBufferedPacketsArgsForCall = append(fake.getBufferedPacketsArgsForCall, struct { - arg1 uint32 - arg2 uint16 - arg3 uint32 - arg4 []uint16 - }{arg1, arg2, arg3, arg4Copy}) - stub := fake.GetBufferedPacketsStub - fakeReturns := fake.getBufferedPacketsReturns - fake.recordInvocation("GetBufferedPackets", []interface{}{arg1, arg2, arg3, arg4Copy}) - fake.getBufferedPacketsMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakePacketBuffer) GetBufferedPacketsCallCount() int { - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - return len(fake.getBufferedPacketsArgsForCall) -} - -func (fake *FakePacketBuffer) GetBufferedPacketsCalls(stub func(uint32, uint16, uint32, []uint16) []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = stub -} - -func (fake *FakePacketBuffer) GetBufferedPacketsArgsForCall(i int) (uint32, uint16, uint32, []uint16) { - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - argsForCall := fake.getBufferedPacketsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *FakePacketBuffer) GetBufferedPacketsReturns(result1 []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = nil - fake.getBufferedPacketsReturns = struct { - result1 []rtp.Packet - }{result1} -} - -func (fake *FakePacketBuffer) GetBufferedPacketsReturnsOnCall(i int, result1 []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = nil - if fake.getBufferedPacketsReturnsOnCall == nil { - fake.getBufferedPacketsReturnsOnCall = make(map[int]struct { - result1 []rtp.Packet - }) - } - fake.getBufferedPacketsReturnsOnCall[i] = struct { - result1 []rtp.Packet - }{result1} -} - -func (fake *FakePacketBuffer) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakePacketBuffer) 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 _ types.PacketBuffer = new(FakePacketBuffer) diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index 0dd179f04..d9cf194b5 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -39,6 +39,13 @@ type FakeParticipant struct { addSubscriberReturnsOnCall map[int]struct { result1 error } + AddTrackStub func(string, string, livekit.TrackType) + addTrackMutex sync.RWMutex + addTrackArgsForCall []struct { + arg1 string + arg2 string + arg3 livekit.TrackType + } AnswerStub func(webrtc.SessionDescription) (webrtc.SessionDescription, error) answerMutex sync.RWMutex answerArgsForCall []struct { @@ -62,15 +69,15 @@ type FakeParticipant struct { closeReturnsOnCall map[int]struct { result1 error } - HandleNegotiateStub func(webrtc.SessionDescription) error - handleNegotiateMutex sync.RWMutex - handleNegotiateArgsForCall []struct { + HandleAnswerStub func(webrtc.SessionDescription) error + handleAnswerMutex sync.RWMutex + handleAnswerArgsForCall []struct { arg1 webrtc.SessionDescription } - handleNegotiateReturns struct { + handleAnswerReturns struct { result1 error } - handleNegotiateReturnsOnCall map[int]struct { + handleAnswerReturnsOnCall map[int]struct { result1 error } IDStub func() string @@ -103,11 +110,6 @@ type FakeParticipant struct { onICECandidateArgsForCall []struct { arg1 func(c *webrtc.ICECandidateInit) } - OnOfferStub func(func(webrtc.SessionDescription)) - onOfferMutex sync.RWMutex - onOfferArgsForCall []struct { - arg1 func(webrtc.SessionDescription) - } OnStateChangeStub func(func(p types.Participant, oldState livekit.ParticipantInfo_State)) onStateChangeMutex sync.RWMutex onStateChangeArgsForCall []struct { @@ -144,6 +146,17 @@ type FakeParticipant struct { removeSubscriberArgsForCall []struct { arg1 string } + RemoveTrackStub func(string) error + removeTrackMutex sync.RWMutex + removeTrackArgsForCall []struct { + arg1 string + } + removeTrackReturns struct { + result1 error + } + removeTrackReturnsOnCall map[int]struct { + result1 error + } SendJoinResponseStub func(*livekit.RoomInfo, []types.Participant) error sendJoinResponseMutex sync.RWMutex sendJoinResponseArgsForCall []struct { @@ -167,17 +180,6 @@ type FakeParticipant struct { sendParticipantUpdateReturnsOnCall map[int]struct { result1 error } - SetRemoteDescriptionStub func(webrtc.SessionDescription) error - setRemoteDescriptionMutex sync.RWMutex - setRemoteDescriptionArgsForCall []struct { - arg1 webrtc.SessionDescription - } - setRemoteDescriptionReturns struct { - result1 error - } - setRemoteDescriptionReturnsOnCall map[int]struct { - result1 error - } SetTrackMutedStub func(string, bool) setTrackMutedMutex sync.RWMutex setTrackMutedArgsForCall []struct { @@ -367,6 +369,40 @@ func (fake *FakeParticipant) AddSubscriberReturnsOnCall(i int, result1 error) { }{result1} } +func (fake *FakeParticipant) AddTrack(arg1 string, arg2 string, arg3 livekit.TrackType) { + fake.addTrackMutex.Lock() + fake.addTrackArgsForCall = append(fake.addTrackArgsForCall, struct { + arg1 string + arg2 string + arg3 livekit.TrackType + }{arg1, arg2, arg3}) + stub := fake.AddTrackStub + fake.recordInvocation("AddTrack", []interface{}{arg1, arg2, arg3}) + fake.addTrackMutex.Unlock() + if stub != nil { + fake.AddTrackStub(arg1, arg2, arg3) + } +} + +func (fake *FakeParticipant) AddTrackCallCount() int { + fake.addTrackMutex.RLock() + defer fake.addTrackMutex.RUnlock() + return len(fake.addTrackArgsForCall) +} + +func (fake *FakeParticipant) AddTrackCalls(stub func(string, string, livekit.TrackType)) { + fake.addTrackMutex.Lock() + defer fake.addTrackMutex.Unlock() + fake.AddTrackStub = stub +} + +func (fake *FakeParticipant) AddTrackArgsForCall(i int) (string, string, livekit.TrackType) { + fake.addTrackMutex.RLock() + defer fake.addTrackMutex.RUnlock() + argsForCall := fake.addTrackArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + func (fake *FakeParticipant) Answer(arg1 webrtc.SessionDescription) (webrtc.SessionDescription, error) { fake.answerMutex.Lock() ret, specificReturn := fake.answerReturnsOnCall[len(fake.answerArgsForCall)] @@ -484,16 +520,16 @@ func (fake *FakeParticipant) CloseReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeParticipant) HandleNegotiate(arg1 webrtc.SessionDescription) error { - fake.handleNegotiateMutex.Lock() - ret, specificReturn := fake.handleNegotiateReturnsOnCall[len(fake.handleNegotiateArgsForCall)] - fake.handleNegotiateArgsForCall = append(fake.handleNegotiateArgsForCall, struct { +func (fake *FakeParticipant) HandleAnswer(arg1 webrtc.SessionDescription) error { + fake.handleAnswerMutex.Lock() + ret, specificReturn := fake.handleAnswerReturnsOnCall[len(fake.handleAnswerArgsForCall)] + fake.handleAnswerArgsForCall = append(fake.handleAnswerArgsForCall, struct { arg1 webrtc.SessionDescription }{arg1}) - stub := fake.HandleNegotiateStub - fakeReturns := fake.handleNegotiateReturns - fake.recordInvocation("HandleNegotiate", []interface{}{arg1}) - fake.handleNegotiateMutex.Unlock() + stub := fake.HandleAnswerStub + fakeReturns := fake.handleAnswerReturns + fake.recordInvocation("HandleAnswer", []interface{}{arg1}) + fake.handleAnswerMutex.Unlock() if stub != nil { return stub(arg1) } @@ -503,44 +539,44 @@ func (fake *FakeParticipant) HandleNegotiate(arg1 webrtc.SessionDescription) err return fakeReturns.result1 } -func (fake *FakeParticipant) HandleNegotiateCallCount() int { - fake.handleNegotiateMutex.RLock() - defer fake.handleNegotiateMutex.RUnlock() - return len(fake.handleNegotiateArgsForCall) +func (fake *FakeParticipant) HandleAnswerCallCount() int { + fake.handleAnswerMutex.RLock() + defer fake.handleAnswerMutex.RUnlock() + return len(fake.handleAnswerArgsForCall) } -func (fake *FakeParticipant) HandleNegotiateCalls(stub func(webrtc.SessionDescription) error) { - fake.handleNegotiateMutex.Lock() - defer fake.handleNegotiateMutex.Unlock() - fake.HandleNegotiateStub = stub +func (fake *FakeParticipant) HandleAnswerCalls(stub func(webrtc.SessionDescription) error) { + fake.handleAnswerMutex.Lock() + defer fake.handleAnswerMutex.Unlock() + fake.HandleAnswerStub = stub } -func (fake *FakeParticipant) HandleNegotiateArgsForCall(i int) webrtc.SessionDescription { - fake.handleNegotiateMutex.RLock() - defer fake.handleNegotiateMutex.RUnlock() - argsForCall := fake.handleNegotiateArgsForCall[i] +func (fake *FakeParticipant) HandleAnswerArgsForCall(i int) webrtc.SessionDescription { + fake.handleAnswerMutex.RLock() + defer fake.handleAnswerMutex.RUnlock() + argsForCall := fake.handleAnswerArgsForCall[i] return argsForCall.arg1 } -func (fake *FakeParticipant) HandleNegotiateReturns(result1 error) { - fake.handleNegotiateMutex.Lock() - defer fake.handleNegotiateMutex.Unlock() - fake.HandleNegotiateStub = nil - fake.handleNegotiateReturns = struct { +func (fake *FakeParticipant) HandleAnswerReturns(result1 error) { + fake.handleAnswerMutex.Lock() + defer fake.handleAnswerMutex.Unlock() + fake.HandleAnswerStub = nil + fake.handleAnswerReturns = struct { result1 error }{result1} } -func (fake *FakeParticipant) HandleNegotiateReturnsOnCall(i int, result1 error) { - fake.handleNegotiateMutex.Lock() - defer fake.handleNegotiateMutex.Unlock() - fake.HandleNegotiateStub = nil - if fake.handleNegotiateReturnsOnCall == nil { - fake.handleNegotiateReturnsOnCall = make(map[int]struct { +func (fake *FakeParticipant) HandleAnswerReturnsOnCall(i int, result1 error) { + fake.handleAnswerMutex.Lock() + defer fake.handleAnswerMutex.Unlock() + fake.HandleAnswerStub = nil + if fake.handleAnswerReturnsOnCall == nil { + fake.handleAnswerReturnsOnCall = make(map[int]struct { result1 error }) } - fake.handleNegotiateReturnsOnCall[i] = struct { + fake.handleAnswerReturnsOnCall[i] = struct { result1 error }{result1} } @@ -715,38 +751,6 @@ func (fake *FakeParticipant) OnICECandidateArgsForCall(i int) func(c *webrtc.ICE return argsForCall.arg1 } -func (fake *FakeParticipant) OnOffer(arg1 func(webrtc.SessionDescription)) { - fake.onOfferMutex.Lock() - fake.onOfferArgsForCall = append(fake.onOfferArgsForCall, struct { - arg1 func(webrtc.SessionDescription) - }{arg1}) - stub := fake.OnOfferStub - fake.recordInvocation("OnOffer", []interface{}{arg1}) - fake.onOfferMutex.Unlock() - if stub != nil { - fake.OnOfferStub(arg1) - } -} - -func (fake *FakeParticipant) OnOfferCallCount() int { - fake.onOfferMutex.RLock() - defer fake.onOfferMutex.RUnlock() - return len(fake.onOfferArgsForCall) -} - -func (fake *FakeParticipant) OnOfferCalls(stub func(func(webrtc.SessionDescription))) { - fake.onOfferMutex.Lock() - defer fake.onOfferMutex.Unlock() - fake.OnOfferStub = stub -} - -func (fake *FakeParticipant) OnOfferArgsForCall(i int) func(webrtc.SessionDescription) { - fake.onOfferMutex.RLock() - defer fake.onOfferMutex.RUnlock() - argsForCall := fake.onOfferArgsForCall[i] - return argsForCall.arg1 -} - func (fake *FakeParticipant) OnStateChange(arg1 func(p types.Participant, oldState livekit.ParticipantInfo_State)) { fake.onStateChangeMutex.Lock() fake.onStateChangeArgsForCall = append(fake.onStateChangeArgsForCall, struct { @@ -961,6 +965,67 @@ func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) string { return argsForCall.arg1 } +func (fake *FakeParticipant) RemoveTrack(arg1 string) error { + fake.removeTrackMutex.Lock() + ret, specificReturn := fake.removeTrackReturnsOnCall[len(fake.removeTrackArgsForCall)] + fake.removeTrackArgsForCall = append(fake.removeTrackArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.RemoveTrackStub + fakeReturns := fake.removeTrackReturns + fake.recordInvocation("RemoveTrack", []interface{}{arg1}) + fake.removeTrackMutex.Unlock() + if stub != nil { + return stub(arg1) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) RemoveTrackCallCount() int { + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() + return len(fake.removeTrackArgsForCall) +} + +func (fake *FakeParticipant) RemoveTrackCalls(stub func(string) error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = stub +} + +func (fake *FakeParticipant) RemoveTrackArgsForCall(i int) string { + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() + argsForCall := fake.removeTrackArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipant) RemoveTrackReturns(result1 error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = nil + fake.removeTrackReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeParticipant) RemoveTrackReturnsOnCall(i int, result1 error) { + fake.removeTrackMutex.Lock() + defer fake.removeTrackMutex.Unlock() + fake.RemoveTrackStub = nil + if fake.removeTrackReturnsOnCall == nil { + fake.removeTrackReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.removeTrackReturnsOnCall[i] = struct { + result1 error + }{result1} +} + func (fake *FakeParticipant) SendJoinResponse(arg1 *livekit.RoomInfo, arg2 []types.Participant) error { var arg2Copy []types.Participant if arg2 != nil { @@ -1094,67 +1159,6 @@ func (fake *FakeParticipant) SendParticipantUpdateReturnsOnCall(i int, result1 e }{result1} } -func (fake *FakeParticipant) SetRemoteDescription(arg1 webrtc.SessionDescription) error { - fake.setRemoteDescriptionMutex.Lock() - ret, specificReturn := fake.setRemoteDescriptionReturnsOnCall[len(fake.setRemoteDescriptionArgsForCall)] - fake.setRemoteDescriptionArgsForCall = append(fake.setRemoteDescriptionArgsForCall, struct { - arg1 webrtc.SessionDescription - }{arg1}) - stub := fake.SetRemoteDescriptionStub - fakeReturns := fake.setRemoteDescriptionReturns - fake.recordInvocation("SetRemoteDescription", []interface{}{arg1}) - fake.setRemoteDescriptionMutex.Unlock() - if stub != nil { - return stub(arg1) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeParticipant) SetRemoteDescriptionCallCount() int { - fake.setRemoteDescriptionMutex.RLock() - defer fake.setRemoteDescriptionMutex.RUnlock() - return len(fake.setRemoteDescriptionArgsForCall) -} - -func (fake *FakeParticipant) SetRemoteDescriptionCalls(stub func(webrtc.SessionDescription) error) { - fake.setRemoteDescriptionMutex.Lock() - defer fake.setRemoteDescriptionMutex.Unlock() - fake.SetRemoteDescriptionStub = stub -} - -func (fake *FakeParticipant) SetRemoteDescriptionArgsForCall(i int) webrtc.SessionDescription { - fake.setRemoteDescriptionMutex.RLock() - defer fake.setRemoteDescriptionMutex.RUnlock() - argsForCall := fake.setRemoteDescriptionArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) SetRemoteDescriptionReturns(result1 error) { - fake.setRemoteDescriptionMutex.Lock() - defer fake.setRemoteDescriptionMutex.Unlock() - fake.SetRemoteDescriptionStub = nil - fake.setRemoteDescriptionReturns = struct { - result1 error - }{result1} -} - -func (fake *FakeParticipant) SetRemoteDescriptionReturnsOnCall(i int, result1 error) { - fake.setRemoteDescriptionMutex.Lock() - defer fake.setRemoteDescriptionMutex.Unlock() - fake.SetRemoteDescriptionStub = nil - if fake.setRemoteDescriptionReturnsOnCall == nil { - fake.setRemoteDescriptionReturnsOnCall = make(map[int]struct { - result1 error - }) - } - fake.setRemoteDescriptionReturnsOnCall[i] = struct { - result1 error - }{result1} -} - func (fake *FakeParticipant) SetTrackMuted(arg1 string, arg2 bool) { fake.setTrackMutedMutex.Lock() fake.setTrackMutedArgsForCall = append(fake.setTrackMutedArgsForCall, struct { @@ -1327,12 +1331,14 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} { defer fake.addICECandidateMutex.RUnlock() fake.addSubscriberMutex.RLock() defer fake.addSubscriberMutex.RUnlock() + fake.addTrackMutex.RLock() + defer fake.addTrackMutex.RUnlock() fake.answerMutex.RLock() defer fake.answerMutex.RUnlock() fake.closeMutex.RLock() defer fake.closeMutex.RUnlock() - fake.handleNegotiateMutex.RLock() - defer fake.handleNegotiateMutex.RUnlock() + fake.handleAnswerMutex.RLock() + defer fake.handleAnswerMutex.RUnlock() fake.iDMutex.RLock() defer fake.iDMutex.RUnlock() fake.nameMutex.RLock() @@ -1341,8 +1347,6 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} { defer fake.onCloseMutex.RUnlock() fake.onICECandidateMutex.RLock() defer fake.onICECandidateMutex.RUnlock() - fake.onOfferMutex.RLock() - defer fake.onOfferMutex.RUnlock() fake.onStateChangeMutex.RLock() defer fake.onStateChangeMutex.RUnlock() fake.onTrackPublishedMutex.RLock() @@ -1355,12 +1359,12 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} { defer fake.removeDownTrackMutex.RUnlock() fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() + fake.removeTrackMutex.RLock() + defer fake.removeTrackMutex.RUnlock() fake.sendJoinResponseMutex.RLock() defer fake.sendJoinResponseMutex.RUnlock() fake.sendParticipantUpdateMutex.RLock() defer fake.sendParticipantUpdateMutex.RUnlock() - fake.setRemoteDescriptionMutex.RLock() - defer fake.setRemoteDescriptionMutex.RUnlock() fake.setTrackMutedMutex.RLock() defer fake.setTrackMutedMutex.RUnlock() fake.startMutex.RLock() diff --git a/pkg/rtc/types/typesfakes/fake_peer_connection.go b/pkg/rtc/types/typesfakes/fake_peer_connection.go index 867ea9f40..8abb47508 100644 --- a/pkg/rtc/types/typesfakes/fake_peer_connection.go +++ b/pkg/rtc/types/typesfakes/fake_peer_connection.go @@ -153,6 +153,16 @@ type FakePeerConnection struct { setRemoteDescriptionReturnsOnCall map[int]struct { result1 error } + SignalingStateStub func() webrtc.SignalingState + signalingStateMutex sync.RWMutex + signalingStateArgsForCall []struct { + } + signalingStateReturns struct { + result1 webrtc.SignalingState + } + signalingStateReturnsOnCall map[int]struct { + result1 webrtc.SignalingState + } WriteRTCPStub func([]rtcp.Packet) error writeRTCPMutex sync.RWMutex writeRTCPArgsForCall []struct { @@ -936,6 +946,59 @@ func (fake *FakePeerConnection) SetRemoteDescriptionReturnsOnCall(i int, result1 }{result1} } +func (fake *FakePeerConnection) SignalingState() webrtc.SignalingState { + fake.signalingStateMutex.Lock() + ret, specificReturn := fake.signalingStateReturnsOnCall[len(fake.signalingStateArgsForCall)] + fake.signalingStateArgsForCall = append(fake.signalingStateArgsForCall, struct { + }{}) + stub := fake.SignalingStateStub + fakeReturns := fake.signalingStateReturns + fake.recordInvocation("SignalingState", []interface{}{}) + fake.signalingStateMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePeerConnection) SignalingStateCallCount() int { + fake.signalingStateMutex.RLock() + defer fake.signalingStateMutex.RUnlock() + return len(fake.signalingStateArgsForCall) +} + +func (fake *FakePeerConnection) SignalingStateCalls(stub func() webrtc.SignalingState) { + fake.signalingStateMutex.Lock() + defer fake.signalingStateMutex.Unlock() + fake.SignalingStateStub = stub +} + +func (fake *FakePeerConnection) SignalingStateReturns(result1 webrtc.SignalingState) { + fake.signalingStateMutex.Lock() + defer fake.signalingStateMutex.Unlock() + fake.SignalingStateStub = nil + fake.signalingStateReturns = struct { + result1 webrtc.SignalingState + }{result1} +} + +func (fake *FakePeerConnection) SignalingStateReturnsOnCall(i int, result1 webrtc.SignalingState) { + fake.signalingStateMutex.Lock() + defer fake.signalingStateMutex.Unlock() + fake.SignalingStateStub = nil + if fake.signalingStateReturnsOnCall == nil { + fake.signalingStateReturnsOnCall = make(map[int]struct { + result1 webrtc.SignalingState + }) + } + fake.signalingStateReturnsOnCall[i] = struct { + result1 webrtc.SignalingState + }{result1} +} + func (fake *FakePeerConnection) WriteRTCP(arg1 []rtcp.Packet) error { var arg1Copy []rtcp.Packet if arg1 != nil { @@ -1035,6 +1098,8 @@ func (fake *FakePeerConnection) Invocations() map[string][][]interface{} { defer fake.setLocalDescriptionMutex.RUnlock() fake.setRemoteDescriptionMutex.RLock() defer fake.setRemoteDescriptionMutex.RUnlock() + fake.signalingStateMutex.RLock() + defer fake.signalingStateMutex.RUnlock() fake.writeRTCPMutex.RLock() defer fake.writeRTCPMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} diff --git a/pkg/rtc/types/typesfakes/fake_published_track.go b/pkg/rtc/types/typesfakes/fake_published_track.go index 0cb8ce686..63000c5f3 100644 --- a/pkg/rtc/types/typesfakes/fake_published_track.go +++ b/pkg/rtc/types/typesfakes/fake_published_track.go @@ -40,15 +40,25 @@ type FakePublishedTrack struct { isMutedReturnsOnCall map[int]struct { result1 bool } - KindStub func() livekit.TrackInfo_Type + KindStub func() livekit.TrackType kindMutex sync.RWMutex kindArgsForCall []struct { } kindReturns struct { - result1 livekit.TrackInfo_Type + result1 livekit.TrackType } kindReturnsOnCall map[int]struct { - result1 livekit.TrackInfo_Type + result1 livekit.TrackType + } + NameStub func() string + nameMutex sync.RWMutex + nameArgsForCall []struct { + } + nameReturns struct { + result1 string + } + nameReturnsOnCall map[int]struct { + result1 string } RemoveAllSubscribersStub func() removeAllSubscribersMutex sync.RWMutex @@ -59,20 +69,15 @@ type FakePublishedTrack struct { removeSubscriberArgsForCall []struct { arg1 string } + SetNameStub func(string) + setNameMutex sync.RWMutex + setNameArgsForCall []struct { + arg1 string + } StartStub func() startMutex sync.RWMutex startArgsForCall []struct { } - StreamIDStub func() string - streamIDMutex sync.RWMutex - streamIDArgsForCall []struct { - } - streamIDReturns struct { - result1 string - } - streamIDReturnsOnCall map[int]struct { - result1 string - } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } @@ -244,7 +249,7 @@ func (fake *FakePublishedTrack) IsMutedReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakePublishedTrack) Kind() livekit.TrackInfo_Type { +func (fake *FakePublishedTrack) Kind() livekit.TrackType { fake.kindMutex.Lock() ret, specificReturn := fake.kindReturnsOnCall[len(fake.kindArgsForCall)] fake.kindArgsForCall = append(fake.kindArgsForCall, struct { @@ -268,32 +273,85 @@ func (fake *FakePublishedTrack) KindCallCount() int { return len(fake.kindArgsForCall) } -func (fake *FakePublishedTrack) KindCalls(stub func() livekit.TrackInfo_Type) { +func (fake *FakePublishedTrack) KindCalls(stub func() livekit.TrackType) { fake.kindMutex.Lock() defer fake.kindMutex.Unlock() fake.KindStub = stub } -func (fake *FakePublishedTrack) KindReturns(result1 livekit.TrackInfo_Type) { +func (fake *FakePublishedTrack) KindReturns(result1 livekit.TrackType) { fake.kindMutex.Lock() defer fake.kindMutex.Unlock() fake.KindStub = nil fake.kindReturns = struct { - result1 livekit.TrackInfo_Type + result1 livekit.TrackType }{result1} } -func (fake *FakePublishedTrack) KindReturnsOnCall(i int, result1 livekit.TrackInfo_Type) { +func (fake *FakePublishedTrack) KindReturnsOnCall(i int, result1 livekit.TrackType) { fake.kindMutex.Lock() defer fake.kindMutex.Unlock() fake.KindStub = nil if fake.kindReturnsOnCall == nil { fake.kindReturnsOnCall = make(map[int]struct { - result1 livekit.TrackInfo_Type + result1 livekit.TrackType }) } fake.kindReturnsOnCall[i] = struct { - result1 livekit.TrackInfo_Type + result1 livekit.TrackType + }{result1} +} + +func (fake *FakePublishedTrack) Name() string { + fake.nameMutex.Lock() + ret, specificReturn := fake.nameReturnsOnCall[len(fake.nameArgsForCall)] + fake.nameArgsForCall = append(fake.nameArgsForCall, struct { + }{}) + stub := fake.NameStub + fakeReturns := fake.nameReturns + fake.recordInvocation("Name", []interface{}{}) + fake.nameMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakePublishedTrack) NameCallCount() int { + fake.nameMutex.RLock() + defer fake.nameMutex.RUnlock() + return len(fake.nameArgsForCall) +} + +func (fake *FakePublishedTrack) NameCalls(stub func() string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = stub +} + +func (fake *FakePublishedTrack) NameReturns(result1 string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = nil + fake.nameReturns = struct { + result1 string + }{result1} +} + +func (fake *FakePublishedTrack) NameReturnsOnCall(i int, result1 string) { + fake.nameMutex.Lock() + defer fake.nameMutex.Unlock() + fake.NameStub = nil + if fake.nameReturnsOnCall == nil { + fake.nameReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.nameReturnsOnCall[i] = struct { + result1 string }{result1} } @@ -353,6 +411,38 @@ func (fake *FakePublishedTrack) RemoveSubscriberArgsForCall(i int) string { return argsForCall.arg1 } +func (fake *FakePublishedTrack) SetName(arg1 string) { + fake.setNameMutex.Lock() + fake.setNameArgsForCall = append(fake.setNameArgsForCall, struct { + arg1 string + }{arg1}) + stub := fake.SetNameStub + fake.recordInvocation("SetName", []interface{}{arg1}) + fake.setNameMutex.Unlock() + if stub != nil { + fake.SetNameStub(arg1) + } +} + +func (fake *FakePublishedTrack) SetNameCallCount() int { + fake.setNameMutex.RLock() + defer fake.setNameMutex.RUnlock() + return len(fake.setNameArgsForCall) +} + +func (fake *FakePublishedTrack) SetNameCalls(stub func(string)) { + fake.setNameMutex.Lock() + defer fake.setNameMutex.Unlock() + fake.SetNameStub = stub +} + +func (fake *FakePublishedTrack) SetNameArgsForCall(i int) string { + fake.setNameMutex.RLock() + defer fake.setNameMutex.RUnlock() + argsForCall := fake.setNameArgsForCall[i] + return argsForCall.arg1 +} + func (fake *FakePublishedTrack) Start() { fake.startMutex.Lock() fake.startArgsForCall = append(fake.startArgsForCall, struct { @@ -377,59 +467,6 @@ func (fake *FakePublishedTrack) StartCalls(stub func()) { fake.StartStub = stub } -func (fake *FakePublishedTrack) StreamID() string { - fake.streamIDMutex.Lock() - ret, specificReturn := fake.streamIDReturnsOnCall[len(fake.streamIDArgsForCall)] - fake.streamIDArgsForCall = append(fake.streamIDArgsForCall, struct { - }{}) - stub := fake.StreamIDStub - fakeReturns := fake.streamIDReturns - fake.recordInvocation("StreamID", []interface{}{}) - fake.streamIDMutex.Unlock() - if stub != nil { - return stub() - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakePublishedTrack) StreamIDCallCount() int { - fake.streamIDMutex.RLock() - defer fake.streamIDMutex.RUnlock() - return len(fake.streamIDArgsForCall) -} - -func (fake *FakePublishedTrack) StreamIDCalls(stub func() string) { - fake.streamIDMutex.Lock() - defer fake.streamIDMutex.Unlock() - fake.StreamIDStub = stub -} - -func (fake *FakePublishedTrack) StreamIDReturns(result1 string) { - fake.streamIDMutex.Lock() - defer fake.streamIDMutex.Unlock() - fake.StreamIDStub = nil - fake.streamIDReturns = struct { - result1 string - }{result1} -} - -func (fake *FakePublishedTrack) StreamIDReturnsOnCall(i int, result1 string) { - fake.streamIDMutex.Lock() - defer fake.streamIDMutex.Unlock() - fake.StreamIDStub = nil - if fake.streamIDReturnsOnCall == nil { - fake.streamIDReturnsOnCall = make(map[int]struct { - result1 string - }) - } - fake.streamIDReturnsOnCall[i] = struct { - result1 string - }{result1} -} - func (fake *FakePublishedTrack) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() @@ -441,14 +478,16 @@ func (fake *FakePublishedTrack) Invocations() map[string][][]interface{} { defer fake.isMutedMutex.RUnlock() fake.kindMutex.RLock() defer fake.kindMutex.RUnlock() + fake.nameMutex.RLock() + defer fake.nameMutex.RUnlock() fake.removeAllSubscribersMutex.RLock() defer fake.removeAllSubscribersMutex.RUnlock() fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() + fake.setNameMutex.RLock() + defer fake.setNameMutex.RUnlock() fake.startMutex.RLock() defer fake.startMutex.RUnlock() - fake.streamIDMutex.RLock() - defer fake.streamIDMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/pkg/rtc/types/typesfakes/fake_receiver.go b/pkg/rtc/types/typesfakes/fake_receiver.go index b605d6c15..ec350ef5b 100644 --- a/pkg/rtc/types/typesfakes/fake_receiver.go +++ b/pkg/rtc/types/typesfakes/fake_receiver.go @@ -9,130 +9,54 @@ import ( ) type FakeReceiver struct { - GetBufferedPacketsStub func(uint32, uint16, uint32, []uint16) []rtp.Packet - getBufferedPacketsMutex sync.RWMutex - getBufferedPacketsArgsForCall []struct { - arg1 uint32 + GetBufferedPacketStub func([]byte, uint16, uint16) (rtp.Packet, error) + getBufferedPacketMutex sync.RWMutex + getBufferedPacketArgsForCall []struct { + arg1 []byte arg2 uint16 - arg3 uint32 - arg4 []uint16 + arg3 uint16 } - getBufferedPacketsReturns struct { - result1 []rtp.Packet - } - getBufferedPacketsReturnsOnCall map[int]struct { - result1 []rtp.Packet - } - ReadRTPStub func() (*rtp.Packet, error) - readRTPMutex sync.RWMutex - readRTPArgsForCall []struct { - } - readRTPReturns struct { - result1 *rtp.Packet + getBufferedPacketReturns struct { + result1 rtp.Packet result2 error } - readRTPReturnsOnCall map[int]struct { - result1 *rtp.Packet + getBufferedPacketReturnsOnCall map[int]struct { + result1 rtp.Packet result2 error } - StartStub func() - startMutex sync.RWMutex - startArgsForCall []struct { + RTPChanStub func() <-chan rtp.Packet + rTPChanMutex sync.RWMutex + rTPChanArgsForCall []struct { } - TrackIdStub func() string - trackIdMutex sync.RWMutex - trackIdArgsForCall []struct { + rTPChanReturns struct { + result1 <-chan rtp.Packet } - trackIdReturns struct { - result1 string - } - trackIdReturnsOnCall map[int]struct { - result1 string + rTPChanReturnsOnCall map[int]struct { + result1 <-chan rtp.Packet } invocations map[string][][]interface{} invocationsMutex sync.RWMutex } -func (fake *FakeReceiver) GetBufferedPackets(arg1 uint32, arg2 uint16, arg3 uint32, arg4 []uint16) []rtp.Packet { - var arg4Copy []uint16 - if arg4 != nil { - arg4Copy = make([]uint16, len(arg4)) - copy(arg4Copy, arg4) +func (fake *FakeReceiver) GetBufferedPacket(arg1 []byte, arg2 uint16, arg3 uint16) (rtp.Packet, error) { + var arg1Copy []byte + if arg1 != nil { + arg1Copy = make([]byte, len(arg1)) + copy(arg1Copy, arg1) } - fake.getBufferedPacketsMutex.Lock() - ret, specificReturn := fake.getBufferedPacketsReturnsOnCall[len(fake.getBufferedPacketsArgsForCall)] - fake.getBufferedPacketsArgsForCall = append(fake.getBufferedPacketsArgsForCall, struct { - arg1 uint32 + fake.getBufferedPacketMutex.Lock() + ret, specificReturn := fake.getBufferedPacketReturnsOnCall[len(fake.getBufferedPacketArgsForCall)] + fake.getBufferedPacketArgsForCall = append(fake.getBufferedPacketArgsForCall, struct { + arg1 []byte arg2 uint16 - arg3 uint32 - arg4 []uint16 - }{arg1, arg2, arg3, arg4Copy}) - stub := fake.GetBufferedPacketsStub - fakeReturns := fake.getBufferedPacketsReturns - fake.recordInvocation("GetBufferedPackets", []interface{}{arg1, arg2, arg3, arg4Copy}) - fake.getBufferedPacketsMutex.Unlock() + arg3 uint16 + }{arg1Copy, arg2, arg3}) + stub := fake.GetBufferedPacketStub + fakeReturns := fake.getBufferedPacketReturns + fake.recordInvocation("GetBufferedPacket", []interface{}{arg1Copy, arg2, arg3}) + fake.getBufferedPacketMutex.Unlock() if stub != nil { - return stub(arg1, arg2, arg3, arg4) - } - if specificReturn { - return ret.result1 - } - return fakeReturns.result1 -} - -func (fake *FakeReceiver) GetBufferedPacketsCallCount() int { - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - return len(fake.getBufferedPacketsArgsForCall) -} - -func (fake *FakeReceiver) GetBufferedPacketsCalls(stub func(uint32, uint16, uint32, []uint16) []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = stub -} - -func (fake *FakeReceiver) GetBufferedPacketsArgsForCall(i int) (uint32, uint16, uint32, []uint16) { - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - argsForCall := fake.getBufferedPacketsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 -} - -func (fake *FakeReceiver) GetBufferedPacketsReturns(result1 []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = nil - fake.getBufferedPacketsReturns = struct { - result1 []rtp.Packet - }{result1} -} - -func (fake *FakeReceiver) GetBufferedPacketsReturnsOnCall(i int, result1 []rtp.Packet) { - fake.getBufferedPacketsMutex.Lock() - defer fake.getBufferedPacketsMutex.Unlock() - fake.GetBufferedPacketsStub = nil - if fake.getBufferedPacketsReturnsOnCall == nil { - fake.getBufferedPacketsReturnsOnCall = make(map[int]struct { - result1 []rtp.Packet - }) - } - fake.getBufferedPacketsReturnsOnCall[i] = struct { - result1 []rtp.Packet - }{result1} -} - -func (fake *FakeReceiver) ReadRTP() (*rtp.Packet, error) { - fake.readRTPMutex.Lock() - ret, specificReturn := fake.readRTPReturnsOnCall[len(fake.readRTPArgsForCall)] - fake.readRTPArgsForCall = append(fake.readRTPArgsForCall, struct { - }{}) - stub := fake.ReadRTPStub - fakeReturns := fake.readRTPReturns - fake.recordInvocation("ReadRTP", []interface{}{}) - fake.readRTPMutex.Unlock() - if stub != nil { - return stub() + return stub(arg1, arg2, arg3) } if specificReturn { return ret.result1, ret.result2 @@ -140,77 +64,60 @@ func (fake *FakeReceiver) ReadRTP() (*rtp.Packet, error) { return fakeReturns.result1, fakeReturns.result2 } -func (fake *FakeReceiver) ReadRTPCallCount() int { - fake.readRTPMutex.RLock() - defer fake.readRTPMutex.RUnlock() - return len(fake.readRTPArgsForCall) +func (fake *FakeReceiver) GetBufferedPacketCallCount() int { + fake.getBufferedPacketMutex.RLock() + defer fake.getBufferedPacketMutex.RUnlock() + return len(fake.getBufferedPacketArgsForCall) } -func (fake *FakeReceiver) ReadRTPCalls(stub func() (*rtp.Packet, error)) { - fake.readRTPMutex.Lock() - defer fake.readRTPMutex.Unlock() - fake.ReadRTPStub = stub +func (fake *FakeReceiver) GetBufferedPacketCalls(stub func([]byte, uint16, uint16) (rtp.Packet, error)) { + fake.getBufferedPacketMutex.Lock() + defer fake.getBufferedPacketMutex.Unlock() + fake.GetBufferedPacketStub = stub } -func (fake *FakeReceiver) ReadRTPReturns(result1 *rtp.Packet, result2 error) { - fake.readRTPMutex.Lock() - defer fake.readRTPMutex.Unlock() - fake.ReadRTPStub = nil - fake.readRTPReturns = struct { - result1 *rtp.Packet +func (fake *FakeReceiver) GetBufferedPacketArgsForCall(i int) ([]byte, uint16, uint16) { + fake.getBufferedPacketMutex.RLock() + defer fake.getBufferedPacketMutex.RUnlock() + argsForCall := fake.getBufferedPacketArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeReceiver) GetBufferedPacketReturns(result1 rtp.Packet, result2 error) { + fake.getBufferedPacketMutex.Lock() + defer fake.getBufferedPacketMutex.Unlock() + fake.GetBufferedPacketStub = nil + fake.getBufferedPacketReturns = struct { + result1 rtp.Packet result2 error }{result1, result2} } -func (fake *FakeReceiver) ReadRTPReturnsOnCall(i int, result1 *rtp.Packet, result2 error) { - fake.readRTPMutex.Lock() - defer fake.readRTPMutex.Unlock() - fake.ReadRTPStub = nil - if fake.readRTPReturnsOnCall == nil { - fake.readRTPReturnsOnCall = make(map[int]struct { - result1 *rtp.Packet +func (fake *FakeReceiver) GetBufferedPacketReturnsOnCall(i int, result1 rtp.Packet, result2 error) { + fake.getBufferedPacketMutex.Lock() + defer fake.getBufferedPacketMutex.Unlock() + fake.GetBufferedPacketStub = nil + if fake.getBufferedPacketReturnsOnCall == nil { + fake.getBufferedPacketReturnsOnCall = make(map[int]struct { + result1 rtp.Packet result2 error }) } - fake.readRTPReturnsOnCall[i] = struct { - result1 *rtp.Packet + fake.getBufferedPacketReturnsOnCall[i] = struct { + result1 rtp.Packet result2 error }{result1, result2} } -func (fake *FakeReceiver) Start() { - fake.startMutex.Lock() - fake.startArgsForCall = append(fake.startArgsForCall, struct { +func (fake *FakeReceiver) RTPChan() <-chan rtp.Packet { + fake.rTPChanMutex.Lock() + ret, specificReturn := fake.rTPChanReturnsOnCall[len(fake.rTPChanArgsForCall)] + fake.rTPChanArgsForCall = append(fake.rTPChanArgsForCall, struct { }{}) - stub := fake.StartStub - fake.recordInvocation("Start", []interface{}{}) - fake.startMutex.Unlock() - if stub != nil { - fake.StartStub() - } -} - -func (fake *FakeReceiver) StartCallCount() int { - fake.startMutex.RLock() - defer fake.startMutex.RUnlock() - return len(fake.startArgsForCall) -} - -func (fake *FakeReceiver) StartCalls(stub func()) { - fake.startMutex.Lock() - defer fake.startMutex.Unlock() - fake.StartStub = stub -} - -func (fake *FakeReceiver) TrackId() string { - fake.trackIdMutex.Lock() - ret, specificReturn := fake.trackIdReturnsOnCall[len(fake.trackIdArgsForCall)] - fake.trackIdArgsForCall = append(fake.trackIdArgsForCall, struct { - }{}) - stub := fake.TrackIdStub - fakeReturns := fake.trackIdReturns - fake.recordInvocation("TrackId", []interface{}{}) - fake.trackIdMutex.Unlock() + stub := fake.RTPChanStub + fakeReturns := fake.rTPChanReturns + fake.recordInvocation("RTPChan", []interface{}{}) + fake.rTPChanMutex.Unlock() if stub != nil { return stub() } @@ -220,52 +127,48 @@ func (fake *FakeReceiver) TrackId() string { return fakeReturns.result1 } -func (fake *FakeReceiver) TrackIdCallCount() int { - fake.trackIdMutex.RLock() - defer fake.trackIdMutex.RUnlock() - return len(fake.trackIdArgsForCall) +func (fake *FakeReceiver) RTPChanCallCount() int { + fake.rTPChanMutex.RLock() + defer fake.rTPChanMutex.RUnlock() + return len(fake.rTPChanArgsForCall) } -func (fake *FakeReceiver) TrackIdCalls(stub func() string) { - fake.trackIdMutex.Lock() - defer fake.trackIdMutex.Unlock() - fake.TrackIdStub = stub +func (fake *FakeReceiver) RTPChanCalls(stub func() <-chan rtp.Packet) { + fake.rTPChanMutex.Lock() + defer fake.rTPChanMutex.Unlock() + fake.RTPChanStub = stub } -func (fake *FakeReceiver) TrackIdReturns(result1 string) { - fake.trackIdMutex.Lock() - defer fake.trackIdMutex.Unlock() - fake.TrackIdStub = nil - fake.trackIdReturns = struct { - result1 string +func (fake *FakeReceiver) RTPChanReturns(result1 <-chan rtp.Packet) { + fake.rTPChanMutex.Lock() + defer fake.rTPChanMutex.Unlock() + fake.RTPChanStub = nil + fake.rTPChanReturns = struct { + result1 <-chan rtp.Packet }{result1} } -func (fake *FakeReceiver) TrackIdReturnsOnCall(i int, result1 string) { - fake.trackIdMutex.Lock() - defer fake.trackIdMutex.Unlock() - fake.TrackIdStub = nil - if fake.trackIdReturnsOnCall == nil { - fake.trackIdReturnsOnCall = make(map[int]struct { - result1 string +func (fake *FakeReceiver) RTPChanReturnsOnCall(i int, result1 <-chan rtp.Packet) { + fake.rTPChanMutex.Lock() + defer fake.rTPChanMutex.Unlock() + fake.RTPChanStub = nil + if fake.rTPChanReturnsOnCall == nil { + fake.rTPChanReturnsOnCall = make(map[int]struct { + result1 <-chan rtp.Packet }) } - fake.trackIdReturnsOnCall[i] = struct { - result1 string + fake.rTPChanReturnsOnCall[i] = struct { + result1 <-chan rtp.Packet }{result1} } func (fake *FakeReceiver) Invocations() map[string][][]interface{} { fake.invocationsMutex.RLock() defer fake.invocationsMutex.RUnlock() - fake.getBufferedPacketsMutex.RLock() - defer fake.getBufferedPacketsMutex.RUnlock() - fake.readRTPMutex.RLock() - defer fake.readRTPMutex.RUnlock() - fake.startMutex.RLock() - defer fake.startMutex.RUnlock() - fake.trackIdMutex.RLock() - defer fake.trackIdMutex.RUnlock() + fake.getBufferedPacketMutex.RLock() + defer fake.getBufferedPacketMutex.RUnlock() + fake.rTPChanMutex.RLock() + defer fake.rTPChanMutex.RUnlock() copiedInvocations := map[string][][]interface{}{} for key, value := range fake.invocations { copiedInvocations[key] = value diff --git a/pkg/rtc/types/typesfakes/fake_track_remote.go b/pkg/rtc/types/typesfakes/fake_track_remote.go new file mode 100644 index 000000000..246ca75a6 --- /dev/null +++ b/pkg/rtc/types/typesfakes/fake_track_remote.go @@ -0,0 +1,298 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package typesfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc/types" + webrtc "github.com/pion/webrtc/v3" +) + +type FakeTrackRemote struct { + CodecStub func() webrtc.RTPCodecParameters + codecMutex sync.RWMutex + codecArgsForCall []struct { + } + codecReturns struct { + result1 webrtc.RTPCodecParameters + } + codecReturnsOnCall map[int]struct { + result1 webrtc.RTPCodecParameters + } + KindStub func() webrtc.RTPCodecType + kindMutex sync.RWMutex + kindArgsForCall []struct { + } + kindReturns struct { + result1 webrtc.RTPCodecType + } + kindReturnsOnCall map[int]struct { + result1 webrtc.RTPCodecType + } + SSRCStub func() webrtc.SSRC + sSRCMutex sync.RWMutex + sSRCArgsForCall []struct { + } + sSRCReturns struct { + result1 webrtc.SSRC + } + sSRCReturnsOnCall map[int]struct { + result1 webrtc.SSRC + } + StreamIDStub func() string + streamIDMutex sync.RWMutex + streamIDArgsForCall []struct { + } + streamIDReturns struct { + result1 string + } + streamIDReturnsOnCall map[int]struct { + result1 string + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeTrackRemote) Codec() webrtc.RTPCodecParameters { + fake.codecMutex.Lock() + ret, specificReturn := fake.codecReturnsOnCall[len(fake.codecArgsForCall)] + fake.codecArgsForCall = append(fake.codecArgsForCall, struct { + }{}) + stub := fake.CodecStub + fakeReturns := fake.codecReturns + fake.recordInvocation("Codec", []interface{}{}) + fake.codecMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTrackRemote) CodecCallCount() int { + fake.codecMutex.RLock() + defer fake.codecMutex.RUnlock() + return len(fake.codecArgsForCall) +} + +func (fake *FakeTrackRemote) CodecCalls(stub func() webrtc.RTPCodecParameters) { + fake.codecMutex.Lock() + defer fake.codecMutex.Unlock() + fake.CodecStub = stub +} + +func (fake *FakeTrackRemote) CodecReturns(result1 webrtc.RTPCodecParameters) { + fake.codecMutex.Lock() + defer fake.codecMutex.Unlock() + fake.CodecStub = nil + fake.codecReturns = struct { + result1 webrtc.RTPCodecParameters + }{result1} +} + +func (fake *FakeTrackRemote) CodecReturnsOnCall(i int, result1 webrtc.RTPCodecParameters) { + fake.codecMutex.Lock() + defer fake.codecMutex.Unlock() + fake.CodecStub = nil + if fake.codecReturnsOnCall == nil { + fake.codecReturnsOnCall = make(map[int]struct { + result1 webrtc.RTPCodecParameters + }) + } + fake.codecReturnsOnCall[i] = struct { + result1 webrtc.RTPCodecParameters + }{result1} +} + +func (fake *FakeTrackRemote) Kind() webrtc.RTPCodecType { + fake.kindMutex.Lock() + ret, specificReturn := fake.kindReturnsOnCall[len(fake.kindArgsForCall)] + fake.kindArgsForCall = append(fake.kindArgsForCall, struct { + }{}) + stub := fake.KindStub + fakeReturns := fake.kindReturns + fake.recordInvocation("Kind", []interface{}{}) + fake.kindMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTrackRemote) KindCallCount() int { + fake.kindMutex.RLock() + defer fake.kindMutex.RUnlock() + return len(fake.kindArgsForCall) +} + +func (fake *FakeTrackRemote) KindCalls(stub func() webrtc.RTPCodecType) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = stub +} + +func (fake *FakeTrackRemote) KindReturns(result1 webrtc.RTPCodecType) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = nil + fake.kindReturns = struct { + result1 webrtc.RTPCodecType + }{result1} +} + +func (fake *FakeTrackRemote) KindReturnsOnCall(i int, result1 webrtc.RTPCodecType) { + fake.kindMutex.Lock() + defer fake.kindMutex.Unlock() + fake.KindStub = nil + if fake.kindReturnsOnCall == nil { + fake.kindReturnsOnCall = make(map[int]struct { + result1 webrtc.RTPCodecType + }) + } + fake.kindReturnsOnCall[i] = struct { + result1 webrtc.RTPCodecType + }{result1} +} + +func (fake *FakeTrackRemote) SSRC() webrtc.SSRC { + fake.sSRCMutex.Lock() + ret, specificReturn := fake.sSRCReturnsOnCall[len(fake.sSRCArgsForCall)] + fake.sSRCArgsForCall = append(fake.sSRCArgsForCall, struct { + }{}) + stub := fake.SSRCStub + fakeReturns := fake.sSRCReturns + fake.recordInvocation("SSRC", []interface{}{}) + fake.sSRCMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTrackRemote) SSRCCallCount() int { + fake.sSRCMutex.RLock() + defer fake.sSRCMutex.RUnlock() + return len(fake.sSRCArgsForCall) +} + +func (fake *FakeTrackRemote) SSRCCalls(stub func() webrtc.SSRC) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = stub +} + +func (fake *FakeTrackRemote) SSRCReturns(result1 webrtc.SSRC) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = nil + fake.sSRCReturns = struct { + result1 webrtc.SSRC + }{result1} +} + +func (fake *FakeTrackRemote) SSRCReturnsOnCall(i int, result1 webrtc.SSRC) { + fake.sSRCMutex.Lock() + defer fake.sSRCMutex.Unlock() + fake.SSRCStub = nil + if fake.sSRCReturnsOnCall == nil { + fake.sSRCReturnsOnCall = make(map[int]struct { + result1 webrtc.SSRC + }) + } + fake.sSRCReturnsOnCall[i] = struct { + result1 webrtc.SSRC + }{result1} +} + +func (fake *FakeTrackRemote) StreamID() string { + fake.streamIDMutex.Lock() + ret, specificReturn := fake.streamIDReturnsOnCall[len(fake.streamIDArgsForCall)] + fake.streamIDArgsForCall = append(fake.streamIDArgsForCall, struct { + }{}) + stub := fake.StreamIDStub + fakeReturns := fake.streamIDReturns + fake.recordInvocation("StreamID", []interface{}{}) + fake.streamIDMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeTrackRemote) StreamIDCallCount() int { + fake.streamIDMutex.RLock() + defer fake.streamIDMutex.RUnlock() + return len(fake.streamIDArgsForCall) +} + +func (fake *FakeTrackRemote) StreamIDCalls(stub func() string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = stub +} + +func (fake *FakeTrackRemote) StreamIDReturns(result1 string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = nil + fake.streamIDReturns = struct { + result1 string + }{result1} +} + +func (fake *FakeTrackRemote) StreamIDReturnsOnCall(i int, result1 string) { + fake.streamIDMutex.Lock() + defer fake.streamIDMutex.Unlock() + fake.StreamIDStub = nil + if fake.streamIDReturnsOnCall == nil { + fake.streamIDReturnsOnCall = make(map[int]struct { + result1 string + }) + } + fake.streamIDReturnsOnCall[i] = struct { + result1 string + }{result1} +} + +func (fake *FakeTrackRemote) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + fake.codecMutex.RLock() + defer fake.codecMutex.RUnlock() + fake.kindMutex.RLock() + defer fake.kindMutex.RUnlock() + fake.sSRCMutex.RLock() + defer fake.sSRCMutex.RUnlock() + fake.streamIDMutex.RLock() + defer fake.streamIDMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeTrackRemote) 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 _ types.TrackRemote = new(FakeTrackRemote) diff --git a/pkg/rtc/utils.go b/pkg/rtc/utils.go index c27779b8b..7b333f0bd 100644 --- a/pkg/rtc/utils.go +++ b/pkg/rtc/utils.go @@ -75,14 +75,14 @@ func FromProtoSessionDescription(sd *livekit.SessionDescription) webrtc.SessionD } } -func ToProtoTrickle(candidateInit webrtc.ICECandidateInit) *livekit.Trickle { +func ToProtoTrickle(candidateInit webrtc.ICECandidateInit) *livekit.TrickleRequest { data, _ := json.Marshal(candidateInit) - return &livekit.Trickle{ + return &livekit.TrickleRequest{ CandidateInit: string(data), } } -func FromProtoTrickle(trickle *livekit.Trickle) webrtc.ICECandidateInit { +func FromProtoTrickle(trickle *livekit.TrickleRequest) webrtc.ICECandidateInit { ci := webrtc.ICECandidateInit{} json.Unmarshal([]byte(trickle.CandidateInit), &ci) return ci @@ -92,17 +92,17 @@ func ToProtoTrack(t types.PublishedTrack) *livekit.TrackInfo { return &livekit.TrackInfo{ Sid: t.ID(), Type: t.Kind(), - Name: t.StreamID(), + Name: t.Name(), Muted: t.IsMuted(), } } -func ToProtoTrackKind(kind webrtc.RTPCodecType) livekit.TrackInfo_Type { +func ToProtoTrackKind(kind webrtc.RTPCodecType) livekit.TrackType { switch kind { case webrtc.RTPCodecTypeVideo: - return livekit.TrackInfo_VIDEO + return livekit.TrackType_VIDEO case webrtc.RTPCodecTypeAudio: - return livekit.TrackInfo_AUDIO + return livekit.TrackType_AUDIO } panic("unsupported track kind") } diff --git a/pkg/service/rtc.go b/pkg/service/rtc.go index 74d895eb1..3849f1b82 100644 --- a/pkg/service/rtc.go +++ b/pkg/service/rtc.go @@ -131,16 +131,20 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Errorw("could not handle join", "err", err, "participant", participant.ID()) return } - case *livekit.SignalRequest_Negotiate: + case *livekit.SignalRequest_AddTrack: + log.Debugw("publishing track", "participant", participant.ID(), + "track", msg.AddTrack.Cid) + participant.AddTrack(msg.AddTrack.Cid, msg.AddTrack.Name, msg.AddTrack.Type) + case *livekit.SignalRequest_Answer: if participant.State() == livekit.ParticipantInfo_JOINING { log.Errorw("cannot negotiate before peer offer", "participant", participant.ID()) //conn.WriteJSON(jsonError(http.StatusNotAcceptable, "cannot negotiate before peer offer")) return } - sd := rtc.FromProtoSessionDescription(msg.Negotiate) - err = participant.HandleNegotiate(sd) + sd := rtc.FromProtoSessionDescription(msg.Answer) + err = participant.HandleAnswer(sd) if err != nil { - log.Errorw("could not handle negotiate", "participant", participant.ID(), "err", err) + log.Errorw("could not handle answer", "participant", participant.ID(), "err", err) //conn.WriteJSON( // jsonError(http.StatusInternalServerError, "could not handle negotiate", err.Error())) return @@ -160,9 +164,10 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } case *livekit.SignalRequest_Mute: - participant.SetTrackMuted(msg.Mute.TrackSid, msg.Mute.Muted) + participant.SetTrackMuted(msg.Mute.Sid, msg.Mute.Muted) + case *livekit.SignalRequest_RemoveTrack: + participant.RemoveTrack(msg.RemoveTrack.Sid) } - } } @@ -178,7 +183,7 @@ func (s *RTCService) handleOffer(participant types.Participant, offer *livekit.S return nil } -func (s *RTCService) handleTrickle(participant types.Participant, trickle *livekit.Trickle) error { +func (s *RTCService) handleTrickle(participant types.Participant, trickle *livekit.TrickleRequest) error { candidateInit := rtc.FromProtoTrickle(trickle) logger.GetLogger().Debugw("adding peer candidate", "participant", participant.ID()) if err := participant.AddICECandidate(candidateInit); err != nil { diff --git a/pkg/sfu/downtrack.go b/pkg/sfu/downtrack.go index 8c2a54407..63d155fb8 100644 --- a/pkg/sfu/downtrack.go +++ b/pkg/sfu/downtrack.go @@ -113,11 +113,11 @@ func (d *DownTrack) Kind() webrtc.RTPCodecType { } // WriteRTP writes a RTP Packet to the DownTrack -func (d *DownTrack) WriteRTP(p *rtp.Packet) error { +func (d *DownTrack) WriteRTP(p rtp.Packet) error { if !d.IsBound() { return nil } - return d.writeSimpleRTP(*p) + return d.writeSimpleRTP(p) } func (d *DownTrack) CreateSourceDescriptionChunks() []rtcp.SourceDescriptionChunk { diff --git a/proto/livekit/model.pb.go b/proto/livekit/model.pb.go index a31064827..18177bbd2 100644 --- a/proto/livekit/model.pb.go +++ b/proto/livekit/model.pb.go @@ -25,6 +25,55 @@ const ( // 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 ( @@ -65,11 +114,11 @@ func (x ParticipantInfo_State) String() string { } func (ParticipantInfo_State) Descriptor() protoreflect.EnumDescriptor { - return file_model_proto_enumTypes[0].Descriptor() + return file_model_proto_enumTypes[1].Descriptor() } func (ParticipantInfo_State) Type() protoreflect.EnumType { - return &file_model_proto_enumTypes[0] + return &file_model_proto_enumTypes[1] } func (x ParticipantInfo_State) Number() protoreflect.EnumNumber { @@ -81,55 +130,6 @@ func (ParticipantInfo_State) EnumDescriptor() ([]byte, []int) { return file_model_proto_rawDescGZIP(), []int{4, 0} } -type TrackInfo_Type int32 - -const ( - TrackInfo_AUDIO TrackInfo_Type = 0 - TrackInfo_VIDEO TrackInfo_Type = 1 - TrackInfo_DATA TrackInfo_Type = 2 -) - -// Enum value maps for TrackInfo_Type. -var ( - TrackInfo_Type_name = map[int32]string{ - 0: "AUDIO", - 1: "VIDEO", - 2: "DATA", - } - TrackInfo_Type_value = map[string]int32{ - "AUDIO": 0, - "VIDEO": 1, - "DATA": 2, - } -) - -func (x TrackInfo_Type) Enum() *TrackInfo_Type { - p := new(TrackInfo_Type) - *p = x - return p -} - -func (x TrackInfo_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (TrackInfo_Type) Descriptor() protoreflect.EnumDescriptor { - return file_model_proto_enumTypes[1].Descriptor() -} - -func (TrackInfo_Type) Type() protoreflect.EnumType { - return &file_model_proto_enumTypes[1] -} - -func (x TrackInfo_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use TrackInfo_Type.Descriptor instead. -func (TrackInfo_Type) EnumDescriptor() ([]byte, []int) { - return file_model_proto_rawDescGZIP(), []int{5, 0} -} - type Node struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -484,10 +484,10 @@ type TrackInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` - Type TrackInfo_Type `protobuf:"varint,2,opt,name=type,proto3,enum=livekit.TrackInfo_Type" 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"` + 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() { @@ -529,11 +529,11 @@ func (x *TrackInfo) GetSid() string { return "" } -func (x *TrackInfo) GetType() TrackInfo_Type { +func (x *TrackInfo) GetType() TrackType { if x != nil { return x.Type } - return TrackInfo_AUDIO + return TrackType_AUDIO } func (x *TrackInfo) GetName() string { @@ -676,25 +676,25 @@ var file_model_proto_rawDesc = []byte{ 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, 0x9c, - 0x01, 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, 0x2b, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x6c, - 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, - 0x2e, 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, 0x26, 0x0a, 0x04, 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, 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, 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, + 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 ( @@ -712,8 +712,8 @@ func file_model_proto_rawDescGZIP() []byte { var file_model_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_model_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_model_proto_goTypes = []interface{}{ - (ParticipantInfo_State)(0), // 0: livekit.ParticipantInfo.State - (TrackInfo_Type)(0), // 1: livekit.TrackInfo.Type + (TrackType)(0), // 0: livekit.TrackType + (ParticipantInfo_State)(0), // 1: livekit.ParticipantInfo.State (*Node)(nil), // 2: livekit.Node (*NodeStats)(nil), // 3: livekit.NodeStats (*Room)(nil), // 4: livekit.Room @@ -724,9 +724,9 @@ var file_model_proto_goTypes = []interface{}{ } var file_model_proto_depIdxs = []int32{ 3, // 0: livekit.Node.stats:type_name -> livekit.NodeStats - 0, // 1: livekit.ParticipantInfo.state:type_name -> livekit.ParticipantInfo.State + 1, // 1: livekit.ParticipantInfo.state:type_name -> livekit.ParticipantInfo.State 7, // 2: livekit.ParticipantInfo.tracks:type_name -> livekit.TrackInfo - 1, // 3: livekit.TrackInfo.type:type_name -> livekit.TrackInfo.Type + 0, // 3: livekit.TrackInfo.type:type_name -> livekit.TrackType 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/proto/livekit/rtc.pb.go b/proto/livekit/rtc.pb.go index 6b0af4a13..d68bb45c3 100644 --- a/proto/livekit/rtc.pb.go +++ b/proto/livekit/rtc.pb.go @@ -32,9 +32,11 @@ type SignalRequest struct { // Types that are assignable to Message: // *SignalRequest_Offer - // *SignalRequest_Negotiate + // *SignalRequest_Answer // *SignalRequest_Trickle + // *SignalRequest_AddTrack // *SignalRequest_Mute + // *SignalRequest_RemoveTrack Message isSignalRequest_Message `protobuf_oneof:"message"` } @@ -84,55 +86,83 @@ func (x *SignalRequest) GetOffer() *SessionDescription { return nil } -func (x *SignalRequest) GetNegotiate() *SessionDescription { - if x, ok := x.GetMessage().(*SignalRequest_Negotiate); ok { - return x.Negotiate +func (x *SignalRequest) GetAnswer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalRequest_Answer); ok { + return x.Answer } return nil } -func (x *SignalRequest) GetTrickle() *Trickle { +func (x *SignalRequest) GetTrickle() *TrickleRequest { if x, ok := x.GetMessage().(*SignalRequest_Trickle); ok { return x.Trickle } return nil } -func (x *SignalRequest) GetMute() *MuteTrack { +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) GetRemoveTrack() *RemoveTrackRequest { + if x, ok := x.GetMessage().(*SignalRequest_RemoveTrack); ok { + return x.RemoveTrack + } + return nil +} + type isSignalRequest_Message interface { isSignalRequest_Message() } type SignalRequest_Offer struct { + // participant joining initially Offer *SessionDescription `protobuf:"bytes,1,opt,name=offer,proto3,oneof"` } -type SignalRequest_Negotiate struct { - Negotiate *SessionDescription `protobuf:"bytes,2,opt,name=negotiate,proto3,oneof"` +type SignalRequest_Answer struct { + // participant responding to server-issued offers + Answer *SessionDescription `protobuf:"bytes,2,opt,name=answer,proto3,oneof"` } type SignalRequest_Trickle struct { - Trickle *Trickle `protobuf:"bytes,3,opt,name=trickle,proto3,oneof"` + 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 *MuteTrack `protobuf:"bytes,4,opt,name=mute,proto3,oneof"` + Mute *MuteTrackRequest `protobuf:"bytes,5,opt,name=mute,proto3,oneof"` +} + +type SignalRequest_RemoveTrack struct { + RemoveTrack *RemoveTrackRequest `protobuf:"bytes,6,opt,name=remove_track,json=removeTrack,proto3,oneof"` } func (*SignalRequest_Offer) isSignalRequest_Message() {} -func (*SignalRequest_Negotiate) isSignalRequest_Message() {} +func (*SignalRequest_Answer) isSignalRequest_Message() {} func (*SignalRequest_Trickle) isSignalRequest_Message() {} +func (*SignalRequest_AddTrack) isSignalRequest_Message() {} + func (*SignalRequest_Mute) isSignalRequest_Message() {} +func (*SignalRequest_RemoveTrack) isSignalRequest_Message() {} + type SignalResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -141,7 +171,7 @@ type SignalResponse struct { // Types that are assignable to Message: // *SignalResponse_Join // *SignalResponse_Answer - // *SignalResponse_Negotiate + // *SignalResponse_Offer // *SignalResponse_Trickle // *SignalResponse_Update // *SignalResponse_TrackPublished @@ -201,14 +231,14 @@ func (x *SignalResponse) GetAnswer() *SessionDescription { return nil } -func (x *SignalResponse) GetNegotiate() *SessionDescription { - if x, ok := x.GetMessage().(*SignalResponse_Negotiate); ok { - return x.Negotiate +func (x *SignalResponse) GetOffer() *SessionDescription { + if x, ok := x.GetMessage().(*SignalResponse_Offer); ok { + return x.Offer } return nil } -func (x *SignalResponse) GetTrickle() *Trickle { +func (x *SignalResponse) GetTrickle() *TrickleRequest { if x, ok := x.GetMessage().(*SignalResponse_Trickle); ok { return x.Trickle } @@ -243,14 +273,14 @@ type SignalResponse_Answer struct { Answer *SessionDescription `protobuf:"bytes,2,opt,name=answer,proto3,oneof"` } -type SignalResponse_Negotiate struct { - // sent when a negotiated sd is available (could be either offer or answer) - Negotiate *SessionDescription `protobuf:"bytes,3,opt,name=negotiate,proto3,oneof"` +type SignalResponse_Offer struct { + // sent when server needs to negotiate, always offer + Offer *SessionDescription `protobuf:"bytes,3,opt,name=offer,proto3,oneof"` } type SignalResponse_Trickle struct { // sent when an ICE candidate is available - Trickle *Trickle `protobuf:"bytes,4,opt,name=trickle,proto3,oneof"` + Trickle *TrickleRequest `protobuf:"bytes,4,opt,name=trickle,proto3,oneof"` } type SignalResponse_Update struct { @@ -260,14 +290,14 @@ type SignalResponse_Update struct { type SignalResponse_TrackPublished struct { // sent to the participant when their track has been published - TrackPublished *TrackInfo `protobuf:"bytes,6,opt,name=trackPublished,proto3,oneof"` + TrackPublished *TrackInfo `protobuf:"bytes,6,opt,name=track_published,json=trackPublished,proto3,oneof"` } func (*SignalResponse_Join) isSignalResponse_Message() {} func (*SignalResponse_Answer) isSignalResponse_Message() {} -func (*SignalResponse_Negotiate) isSignalResponse_Message() {} +func (*SignalResponse_Offer) isSignalResponse_Message() {} func (*SignalResponse_Trickle) isSignalResponse_Message() {} @@ -275,16 +305,19 @@ func (*SignalResponse_Update) isSignalResponse_Message() {} func (*SignalResponse_TrackPublished) isSignalResponse_Message() {} -type Trickle struct { +type AddTrackRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CandidateInit string `protobuf:"bytes,1,opt,name=candidateInit,proto3" json:"candidateInit,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Type TrackType `protobuf:"varint,2,opt,name=type,proto3,enum=livekit.TrackType" json:"type,omitempty"` + // client ID of track, to match it when RTC track is received + Cid string `protobuf:"bytes,3,opt,name=cid,proto3" json:"cid,omitempty"` } -func (x *Trickle) Reset() { - *x = Trickle{} +func (x *AddTrackRequest) Reset() { + *x = AddTrackRequest{} if protoimpl.UnsafeEnabled { mi := &file_rtc_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -292,13 +325,13 @@ func (x *Trickle) Reset() { } } -func (x *Trickle) String() string { +func (x *AddTrackRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Trickle) ProtoMessage() {} +func (*AddTrackRequest) ProtoMessage() {} -func (x *Trickle) ProtoReflect() protoreflect.Message { +func (x *AddTrackRequest) ProtoReflect() protoreflect.Message { mi := &file_rtc_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -310,18 +343,126 @@ func (x *Trickle) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Trickle.ProtoReflect.Descriptor instead. -func (*Trickle) Descriptor() ([]byte, []int) { +// Deprecated: Use AddTrackRequest.ProtoReflect.Descriptor instead. +func (*AddTrackRequest) Descriptor() ([]byte, []int) { return file_rtc_proto_rawDescGZIP(), []int{2} } -func (x *Trickle) GetCandidateInit() string { +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 +} + +func (x *AddTrackRequest) GetCid() string { + if x != nil { + return x.Cid + } + return "" +} + +type TrickleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CandidateInit string `protobuf:"bytes,1,opt,name=candidateInit,proto3" json:"candidateInit,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 "" } +type RemoveTrackRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sid string `protobuf:"bytes,1,opt,name=sid,proto3" json:"sid,omitempty"` +} + +func (x *RemoveTrackRequest) Reset() { + *x = RemoveTrackRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_rtc_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveTrackRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveTrackRequest) ProtoMessage() {} + +func (x *RemoveTrackRequest) 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 RemoveTrackRequest.ProtoReflect.Descriptor instead. +func (*RemoveTrackRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{4} +} + +func (x *RemoveTrackRequest) GetSid() string { + if x != nil { + return x.Sid + } + return "" +} + type SessionDescription struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -334,7 +475,7 @@ type SessionDescription struct { func (x *SessionDescription) Reset() { *x = SessionDescription{} if protoimpl.UnsafeEnabled { - mi := &file_rtc_proto_msgTypes[3] + mi := &file_rtc_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -347,7 +488,7 @@ func (x *SessionDescription) String() string { func (*SessionDescription) ProtoMessage() {} func (x *SessionDescription) ProtoReflect() protoreflect.Message { - mi := &file_rtc_proto_msgTypes[3] + mi := &file_rtc_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -360,7 +501,7 @@ func (x *SessionDescription) ProtoReflect() protoreflect.Message { // Deprecated: Use SessionDescription.ProtoReflect.Descriptor instead. func (*SessionDescription) Descriptor() ([]byte, []int) { - return file_rtc_proto_rawDescGZIP(), []int{3} + return file_rtc_proto_rawDescGZIP(), []int{5} } func (x *SessionDescription) GetType() string { @@ -390,7 +531,7 @@ type JoinResponse struct { func (x *JoinResponse) Reset() { *x = JoinResponse{} if protoimpl.UnsafeEnabled { - mi := &file_rtc_proto_msgTypes[4] + mi := &file_rtc_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -403,7 +544,7 @@ func (x *JoinResponse) String() string { func (*JoinResponse) ProtoMessage() {} func (x *JoinResponse) ProtoReflect() protoreflect.Message { - mi := &file_rtc_proto_msgTypes[4] + mi := &file_rtc_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -416,7 +557,7 @@ func (x *JoinResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use JoinResponse.ProtoReflect.Descriptor instead. func (*JoinResponse) Descriptor() ([]byte, []int) { - return file_rtc_proto_rawDescGZIP(), []int{4} + return file_rtc_proto_rawDescGZIP(), []int{6} } func (x *JoinResponse) GetRoom() *RoomInfo { @@ -440,32 +581,32 @@ func (x *JoinResponse) GetOtherParticipants() []*ParticipantInfo { return nil } -type MuteTrack struct { +type MuteTrackRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrackSid string `protobuf:"bytes,1,opt,name=track_sid,json=trackSid,proto3" json:"track_sid,omitempty"` - Muted bool `protobuf:"varint,2,opt,name=muted,proto3" json:"muted,omitempty"` + 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 *MuteTrack) Reset() { - *x = MuteTrack{} +func (x *MuteTrackRequest) Reset() { + *x = MuteTrackRequest{} if protoimpl.UnsafeEnabled { - mi := &file_rtc_proto_msgTypes[5] + mi := &file_rtc_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *MuteTrack) String() string { +func (x *MuteTrackRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MuteTrack) ProtoMessage() {} +func (*MuteTrackRequest) ProtoMessage() {} -func (x *MuteTrack) ProtoReflect() protoreflect.Message { - mi := &file_rtc_proto_msgTypes[5] +func (x *MuteTrackRequest) 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 { @@ -476,19 +617,19 @@ func (x *MuteTrack) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MuteTrack.ProtoReflect.Descriptor instead. -func (*MuteTrack) Descriptor() ([]byte, []int) { - return file_rtc_proto_rawDescGZIP(), []int{5} +// Deprecated: Use MuteTrackRequest.ProtoReflect.Descriptor instead. +func (*MuteTrackRequest) Descriptor() ([]byte, []int) { + return file_rtc_proto_rawDescGZIP(), []int{7} } -func (x *MuteTrack) GetTrackSid() string { +func (x *MuteTrackRequest) GetSid() string { if x != nil { - return x.TrackSid + return x.Sid } return "" } -func (x *MuteTrack) GetMuted() bool { +func (x *MuteTrackRequest) GetMuted() bool { if x != nil { return x.Muted } @@ -506,7 +647,7 @@ type ParticipantUpdate struct { func (x *ParticipantUpdate) Reset() { *x = ParticipantUpdate{} if protoimpl.UnsafeEnabled { - mi := &file_rtc_proto_msgTypes[6] + mi := &file_rtc_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -519,7 +660,7 @@ func (x *ParticipantUpdate) String() string { func (*ParticipantUpdate) ProtoMessage() {} func (x *ParticipantUpdate) ProtoReflect() protoreflect.Message { - mi := &file_rtc_proto_msgTypes[6] + mi := &file_rtc_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -532,7 +673,7 @@ func (x *ParticipantUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use ParticipantUpdate.ProtoReflect.Descriptor instead. func (*ParticipantUpdate) Descriptor() ([]byte, []int) { - return file_rtc_proto_rawDescGZIP(), []int{6} + return file_rtc_proto_rawDescGZIP(), []int{8} } func (x *ParticipantUpdate) GetParticipants() []*ParticipantInfo { @@ -547,75 +688,91 @@ 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, 0xe4, 0x01, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x6f, 0x22, 0xe7, 0x02, 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, 0x3b, 0x0a, 0x09, 0x6e, 0x65, 0x67, 0x6f, - 0x74, 0x69, 0x61, 0x74, 0x65, 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, 0x09, 0x6e, 0x65, 0x67, 0x6f, - 0x74, 0x69, 0x61, 0x74, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, - 0x2e, 0x54, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x07, 0x74, 0x72, 0x69, 0x63, - 0x6b, 0x6c, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x4d, 0x75, 0x74, 0x65, - 0x54, 0x72, 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x04, 0x6d, 0x75, 0x74, 0x65, 0x42, 0x09, 0x0a, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xde, 0x02, 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, + 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, - 0x3b, 0x0a, 0x09, 0x6e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x65, 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, 0x09, 0x6e, 0x65, 0x67, 0x6f, 0x74, 0x69, 0x61, 0x74, 0x65, 0x12, 0x2c, 0x0a, 0x07, - 0x74, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 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, 0x3c, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, - 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, - 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x0e, - 0x74, 0x72, 0x61, 0x63, 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x42, 0x09, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2f, 0x0a, 0x07, 0x54, 0x72, 0x69, - 0x63, 0x6b, 0x6c, 0x65, 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, 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, 0xba, 0x01, 0x0a, 0x0c, 0x4a, 0x6f, 0x69, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x6d, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, - 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 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, + 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, 0x40, + 0x0a, 0x0c, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x52, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x48, 0x00, 0x52, 0x0b, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, + 0x42, 0x09, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xde, 0x02, 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, 0x3d, 0x0a, 0x0f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6c, 0x69, + 0x76, 0x65, 0x6b, 0x69, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x48, + 0x00, 0x52, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x64, 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, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 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, 0x10, 0x0a, 0x03, 0x63, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x22, 0x36, 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, 0x22, 0x26, 0x0a, 0x12, 0x52, 0x65, 0x6d, 0x6f, 0x76, 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, 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, 0xba, 0x01, 0x0a, 0x0c, 0x4a, 0x6f, + 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x6f, + 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x6b, + 0x69, 0x74, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 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, 0x11, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, - 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0a, 0x09, 0x4d, 0x75, 0x74, 0x65, 0x54, 0x72, 0x61, 0x63, 0x6b, - 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x53, 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, 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, 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, + 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, 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, 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, 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 ( @@ -630,39 +787,45 @@ func file_rtc_proto_rawDescGZIP() []byte { return file_rtc_proto_rawDescData } -var file_rtc_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_rtc_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_rtc_proto_goTypes = []interface{}{ (*SignalRequest)(nil), // 0: livekit.SignalRequest (*SignalResponse)(nil), // 1: livekit.SignalResponse - (*Trickle)(nil), // 2: livekit.Trickle - (*SessionDescription)(nil), // 3: livekit.SessionDescription - (*JoinResponse)(nil), // 4: livekit.JoinResponse - (*MuteTrack)(nil), // 5: livekit.MuteTrack - (*ParticipantUpdate)(nil), // 6: livekit.ParticipantUpdate - (*TrackInfo)(nil), // 7: livekit.TrackInfo - (*RoomInfo)(nil), // 8: livekit.RoomInfo - (*ParticipantInfo)(nil), // 9: livekit.ParticipantInfo + (*AddTrackRequest)(nil), // 2: livekit.AddTrackRequest + (*TrickleRequest)(nil), // 3: livekit.TrickleRequest + (*RemoveTrackRequest)(nil), // 4: livekit.RemoveTrackRequest + (*SessionDescription)(nil), // 5: livekit.SessionDescription + (*JoinResponse)(nil), // 6: livekit.JoinResponse + (*MuteTrackRequest)(nil), // 7: livekit.MuteTrackRequest + (*ParticipantUpdate)(nil), // 8: livekit.ParticipantUpdate + (*TrackInfo)(nil), // 9: livekit.TrackInfo + (TrackType)(0), // 10: livekit.TrackType + (*RoomInfo)(nil), // 11: livekit.RoomInfo + (*ParticipantInfo)(nil), // 12: livekit.ParticipantInfo } var file_rtc_proto_depIdxs = []int32{ - 3, // 0: livekit.SignalRequest.offer:type_name -> livekit.SessionDescription - 3, // 1: livekit.SignalRequest.negotiate:type_name -> livekit.SessionDescription - 2, // 2: livekit.SignalRequest.trickle:type_name -> livekit.Trickle - 5, // 3: livekit.SignalRequest.mute:type_name -> livekit.MuteTrack - 4, // 4: livekit.SignalResponse.join:type_name -> livekit.JoinResponse - 3, // 5: livekit.SignalResponse.answer:type_name -> livekit.SessionDescription - 3, // 6: livekit.SignalResponse.negotiate:type_name -> livekit.SessionDescription - 2, // 7: livekit.SignalResponse.trickle:type_name -> livekit.Trickle - 6, // 8: livekit.SignalResponse.update:type_name -> livekit.ParticipantUpdate - 7, // 9: livekit.SignalResponse.trackPublished:type_name -> livekit.TrackInfo - 8, // 10: livekit.JoinResponse.room:type_name -> livekit.RoomInfo - 9, // 11: livekit.JoinResponse.participant:type_name -> livekit.ParticipantInfo - 9, // 12: livekit.JoinResponse.other_participants:type_name -> livekit.ParticipantInfo - 9, // 13: livekit.ParticipantUpdate.participants:type_name -> livekit.ParticipantInfo - 14, // [14:14] is the sub-list for method output_type - 14, // [14:14] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 5, // 0: livekit.SignalRequest.offer:type_name -> livekit.SessionDescription + 5, // 1: livekit.SignalRequest.answer:type_name -> livekit.SessionDescription + 3, // 2: livekit.SignalRequest.trickle:type_name -> livekit.TrickleRequest + 2, // 3: livekit.SignalRequest.add_track:type_name -> livekit.AddTrackRequest + 7, // 4: livekit.SignalRequest.mute:type_name -> livekit.MuteTrackRequest + 4, // 5: livekit.SignalRequest.remove_track:type_name -> livekit.RemoveTrackRequest + 6, // 6: livekit.SignalResponse.join:type_name -> livekit.JoinResponse + 5, // 7: livekit.SignalResponse.answer:type_name -> livekit.SessionDescription + 5, // 8: livekit.SignalResponse.offer:type_name -> livekit.SessionDescription + 3, // 9: livekit.SignalResponse.trickle:type_name -> livekit.TrickleRequest + 8, // 10: livekit.SignalResponse.update:type_name -> livekit.ParticipantUpdate + 9, // 11: livekit.SignalResponse.track_published:type_name -> livekit.TrackInfo + 10, // 12: livekit.AddTrackRequest.type:type_name -> livekit.TrackType + 11, // 13: livekit.JoinResponse.room:type_name -> livekit.RoomInfo + 12, // 14: livekit.JoinResponse.participant:type_name -> livekit.ParticipantInfo + 12, // 15: livekit.JoinResponse.other_participants:type_name -> livekit.ParticipantInfo + 12, // 16: livekit.ParticipantUpdate.participants:type_name -> livekit.ParticipantInfo + 17, // [17:17] is the sub-list for method output_type + 17, // [17:17] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_rtc_proto_init() } @@ -697,7 +860,7 @@ func file_rtc_proto_init() { } } file_rtc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Trickle); i { + switch v := v.(*AddTrackRequest); i { case 0: return &v.state case 1: @@ -709,7 +872,7 @@ func file_rtc_proto_init() { } } file_rtc_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SessionDescription); i { + switch v := v.(*TrickleRequest); i { case 0: return &v.state case 1: @@ -721,7 +884,7 @@ func file_rtc_proto_init() { } } file_rtc_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JoinResponse); i { + switch v := v.(*RemoveTrackRequest); i { case 0: return &v.state case 1: @@ -733,7 +896,7 @@ func file_rtc_proto_init() { } } file_rtc_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MuteTrack); i { + switch v := v.(*SessionDescription); i { case 0: return &v.state case 1: @@ -745,6 +908,30 @@ func file_rtc_proto_init() { } } 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.(*MuteTrackRequest); 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.(*ParticipantUpdate); i { case 0: return &v.state @@ -759,14 +946,16 @@ func file_rtc_proto_init() { } file_rtc_proto_msgTypes[0].OneofWrappers = []interface{}{ (*SignalRequest_Offer)(nil), - (*SignalRequest_Negotiate)(nil), + (*SignalRequest_Answer)(nil), (*SignalRequest_Trickle)(nil), + (*SignalRequest_AddTrack)(nil), (*SignalRequest_Mute)(nil), + (*SignalRequest_RemoveTrack)(nil), } file_rtc_proto_msgTypes[1].OneofWrappers = []interface{}{ (*SignalResponse_Join)(nil), (*SignalResponse_Answer)(nil), - (*SignalResponse_Negotiate)(nil), + (*SignalResponse_Offer)(nil), (*SignalResponse_Trickle)(nil), (*SignalResponse_Update)(nil), (*SignalResponse_TrackPublished)(nil), @@ -777,7 +966,7 @@ func file_rtc_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rtc_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 9, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/model.proto b/proto/model.proto index 5f7628a58..0436ceb98 100644 --- a/proto/model.proto +++ b/proto/model.proto @@ -48,15 +48,16 @@ message ParticipantInfo { repeated TrackInfo tracks = 4; } +enum TrackType { + AUDIO = 0; + VIDEO = 1; + DATA = 2; +} + // describing message TrackInfo { - enum Type { - AUDIO = 0; - VIDEO = 1; - DATA = 2; - } string sid = 1; - Type type = 2; + TrackType type = 2; string name = 3; bool muted = 4; } diff --git a/proto/rtc.proto b/proto/rtc.proto index 263f3be20..baf141708 100644 --- a/proto/rtc.proto +++ b/proto/rtc.proto @@ -7,10 +7,14 @@ import "model.proto"; message SignalRequest { oneof message { + // participant joining initially SessionDescription offer = 1; - SessionDescription negotiate = 2; - Trickle trickle = 3; - MuteTrack mute = 4; + // participant responding to server-issued offers + SessionDescription answer = 2; + TrickleRequest trickle = 3; + AddTrackRequest add_track = 4; + MuteTrackRequest mute = 5; + RemoveTrackRequest remove_track = 6; } } @@ -20,20 +24,30 @@ message SignalResponse { JoinResponse join = 1; // sent when offer is answered SessionDescription answer = 2; - // sent when a negotiated sd is available (could be either offer or answer) - SessionDescription negotiate = 3; + // sent when server needs to negotiate, always offer + SessionDescription offer = 3; // sent when an ICE candidate is available - Trickle trickle = 4; + TrickleRequest trickle = 4; // sent when participants in the room has changed ParticipantUpdate update = 5; // sent to the participant when their track has been published - TrackInfo trackPublished = 6; + TrackInfo track_published = 6; } } -message Trickle { - string candidateInit = 1; +message AddTrackRequest { + string name = 1; + TrackType type = 2; + // client ID of track, to match it when RTC track is received + string cid = 3; +} +message TrickleRequest { + string candidateInit = 1; +} + +message RemoveTrackRequest { + string sid = 1; } message SessionDescription { @@ -47,8 +61,8 @@ message JoinResponse { repeated ParticipantInfo other_participants = 3; } -message MuteTrack { - string track_sid = 1; +message MuteTrackRequest { + string sid = 1; bool muted = 2; }