Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DC messages #870

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/go-sql-driver/mysql v1.7.1
github.com/gorilla/mux v1.8.1
github.com/grafana/pyroscope-go/godeltaprof v0.1.7
github.com/grafana/pyroscope-go/godeltaprof v0.1.8
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.9
github.com/mattermost/calls-offloader v0.8.1-0.20240925183132-f81d68d229b8
Expand All @@ -24,7 +24,7 @@ require (
github.com/mattermost/mattermost-plugin-calls/server/public v0.0.3
github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef7b4
github.com/mattermost/morph v1.1.0
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc
github.com/mattermost/squirrel v0.2.0
github.com/pkg/errors v0.9.1
github.com/rudderlabs/analytics-go v3.3.3+incompatible
Expand Down Expand Up @@ -76,7 +76,7 @@ require (
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect
Expand Down
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/grafana/pyroscope-go/godeltaprof v0.1.7 h1:C11j63y7gymiW8VugJ9ZW0pWfxTZugdSJyC48olk5KY=
github.com/grafana/pyroscope-go/godeltaprof v0.1.7/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
Expand Down Expand Up @@ -335,9 +335,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
Expand Down Expand Up @@ -380,8 +379,8 @@ github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef
github.com/mattermost/mattermost/server/public v0.1.5-0.20240613070149-4b0ae20ef7b4/go.mod h1:PDPb/iqzJJ5ZvK/m70oDF55AXN/cOvVFj96Yu4e6j+Q=
github.com/mattermost/morph v1.1.0 h1:Q9vrJbeM3s2jfweGheq12EFIzdNp9a/6IovcbvOQ6Cw=
github.com/mattermost/morph v1.1.0/go.mod h1:gD+EaqX2UMyyuzmF4PFh4r33XneQ8Nzi+0E8nXjMa3A=
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4 h1:LJ0Omi68S1lTE4TGaypohNFB30YblqFJquTww9pGotY=
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4/go.mod h1:twellAs4hvfjDI/8PIq5viG5ej2zoBzvTGzFscbjKZc=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc h1:KTdzXsjcrnawYH2uNwLW8WVe0vyYmuC8ckpR83Cj7Sg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/mattermost/squirrel v0.2.0 h1:8ZWeyf+MWQ2cL7hu9REZgLtz2IJi51qqZEovI3T3TT8=
github.com/mattermost/squirrel v0.2.0/go.mod h1:NPPtk+CdpWre4GxMGoOpzEVFVc0ZoEFyJBZGCtn9nSU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down
35 changes: 35 additions & 0 deletions lt/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ func (u *User) Speak(text string) chan struct{} {
}

func (u *User) onConnect() {
// Waiting a second before transmitting to avoid
// the known race between incoming and outgoing track.
// This is needed as pion doesn't support perfect negotiation yet.
time.Sleep(time.Second)
Comment on lines +471 to +474
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using DC further exacerbated the impact of signaling conflicts, so I had to add this to make it usable. Browsers are not affected as they support perfect negotiation (SDP rollback).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. 👍

if u.cfg.Unmuted {
go u.transmitAudio()
} else if u.cfg.Speak {
Expand Down Expand Up @@ -509,6 +513,33 @@ func (u *User) getCallsConfig() (map[string]any, error) {
return config, nil
}

func (u *User) handleTrack(ctx any) error {
m, ok := ctx.(map[string]any)
if !ok || m == nil {
return fmt.Errorf("failed to convert map")
}

track, ok := m["track"].(*webrtc.TrackRemote)
if !ok || track == nil {
return fmt.Errorf("failed to convert track")
}

// We don't currently do anything with the packets but we should still read
// them to properly calculate client stats.
buf := make([]byte, receiveMTU)
for {
_, _, readErr := track.Read(buf)
if readErr != nil {
if !errors.Is(readErr, io.EOF) {
u.log.Error("failed to read RTP packet for track",
slog.String("err", readErr.Error()),
slog.String("trackID", track.ID()))
}
return nil
}
}
}

func (u *User) Connect(stopCh chan struct{}) error {
u.log.Debug("connecting user")

Expand Down Expand Up @@ -605,10 +636,14 @@ func (u *User) Connect(stopCh chan struct{}) error {
ChannelID: u.cfg.ChannelID,
EnableAV1: enableAV1,
EnableDCSignaling: enableDCSignaling,
EnableRTCMonitor: true,
}, client.WithLogger(u.log))
if err != nil {
return fmt.Errorf("failed to create calls client: %w", err)
}
if err := callsClient.On(client.RTCTrackEvent, u.handleTrack); err != nil {
return fmt.Errorf("failed to add track handler: %w", err)
}

u.callsClient = callsClient

Expand Down
2 changes: 1 addition & 1 deletion lt/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aws/aws-sdk-go v1.50.3
github.com/hajimehoshi/go-mp3 v0.3.4
github.com/mattermost/mattermost/server/public v0.0.12
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc
github.com/pion/rtp v1.8.6
github.com/pion/webrtc/v3 v3.2.41
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302
Expand Down
4 changes: 2 additions & 2 deletions lt/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/mattermost/logr/v2 v2.0.21 h1:CMHsP+nrbRlEC4g7BwOk1GAnMtHkniFhlSQPXy5
github.com/mattermost/logr/v2 v2.0.21/go.mod h1:kZkB/zqKL9e+RY5gB3vGpsyenC+TpuiOenjMkvJJbzc=
github.com/mattermost/mattermost/server/public v0.0.12 h1:iunc9q4/XkArOrndEUn73uFw6v9TOEXEtp6Nm6Iv218=
github.com/mattermost/mattermost/server/public v0.0.12/go.mod h1:Bk+atJcELCIk9Yeq5FoqTr+gra9704+X4amrlwlTgSc=
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4 h1:LJ0Omi68S1lTE4TGaypohNFB30YblqFJquTww9pGotY=
github.com/mattermost/rtcd v0.17.2-0.20240927182949-3c0ace432dc4/go.mod h1:twellAs4hvfjDI/8PIq5viG5ej2zoBzvTGzFscbjKZc=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc h1:KTdzXsjcrnawYH2uNwLW8WVe0vyYmuC8ckpR83Cj7Sg=
github.com/mattermost/rtcd v0.17.2-0.20241009214839-a44d499cefcc/go.mod h1:FVyFLa+7dWImCZ+0g9xoc/1fMRKMuXs6yAZP1mDKBIg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
102 changes: 102 additions & 0 deletions server/mocks/github.com/mattermost/rtcd/service/rtc/mock_Metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions standalone/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
"extract": "formatjs extract 'src/**/*.{ts,tsx}' --ignore 'src/**/*.d.ts' --out-file i18n/temp.json --id-interpolation-pattern '[sha512:contenthash:base64:6]' && formatjs compile 'i18n/temp.json' --out-file i18n/en.json && rm i18n/temp.json"
},
"dependencies": {
"@mattermost/calls-common": "github:mattermost/calls-common#93c0c8b657f66d16434854e26391c79113aa9a71",
"@mattermost/calls-common": "github:mattermost/calls-common#8d2b13bd2f10847a4be461dd4225fef2ade06ab9",
"@mattermost/compass-icons": "0.1.31",
"@msgpack/msgpack": "2.7.1",
"bootstrap": "3.4.1",
"core-js": "3.26.1",
"luxon": "3.3.0",
"pako": "2.0.4",
"react": "17.0.2",
"react-bootstrap": "github:mattermost/react-bootstrap#c6957962364e0818a51bbfd13e89919903b422d6",
"react-dom": "17.0.2",
Expand Down
30 changes: 21 additions & 9 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading