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

[MM-61426] Migrate to pion v4 #161

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"
)

const (
Expand Down
10 changes: 9 additions & 1 deletion client/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -938,11 +938,13 @@ func TestAPIScreenShareAndVoice(t *testing.T) {

var packets int
adminVoiceTrackCh := make(chan struct{})
readerDoneCh := make(chan struct{})
err = th.userClient.On(RTCTrackEvent, func(ctx any) error {
m := ctx.(map[string]any)
track := m["track"].(*webrtc.TrackRemote)
if track.Kind() == webrtc.RTPCodecTypeAudio {
go func() {
defer close(readerDoneCh)
for {
_, _, readErr := track.ReadRTP()
if readErr != nil {
Expand Down Expand Up @@ -1038,6 +1040,12 @@ func TestAPIScreenShareAndVoice(t *testing.T) {
require.Fail(t, "timed out waiting for close event")
}

select {
case <-readerDoneCh:
case <-time.After(waitTimeout):
require.Fail(t, "timed out waiting for reader to be done")
}

require.Greater(t, packets, 10)
}

Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/mattermost/mattermost/server/public/model"

"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"
)

type EventHandler func(ctx any) error
Expand Down
8 changes: 4 additions & 4 deletions client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

"github.com/pion/rtp"
"github.com/pion/rtp/codecs"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3/pkg/media"
"github.com/pion/webrtc/v3/pkg/media/ivfreader"
"github.com/pion/webrtc/v3/pkg/media/oggreader"
"github.com/pion/webrtc/v4"
"github.com/pion/webrtc/v4/pkg/media"
"github.com/pion/webrtc/v4/pkg/media/ivfreader"
"github.com/pion/webrtc/v4/pkg/media/oggreader"

"github.com/stretchr/testify/require"
)
Expand Down
20 changes: 11 additions & 9 deletions client/rtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/pion/interceptor"
"github.com/pion/interceptor/pkg/stats"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"
)

const (
Expand Down Expand Up @@ -191,15 +191,17 @@ func (c *Client) initRTCSession() error {

i := interceptor.Registry{}

statsInterceptorFactory, err := stats.NewInterceptor()
if err != nil {
return fmt.Errorf("failed to create stats interceptor: %w", err)
}
var statsGetter stats.Getter
statsInterceptorFactory.OnNewPeerConnection(func(_ string, g stats.Getter) {
statsGetter = g
})
i.Add(statsInterceptorFactory)
if c.cfg.EnableRTCMonitor {
streamer45 marked this conversation as resolved.
Show resolved Hide resolved
statsInterceptorFactory, err := stats.NewInterceptor()
if err != nil {
return fmt.Errorf("failed to create stats interceptor: %w", err)
}
statsInterceptorFactory.OnNewPeerConnection(func(_ string, g stats.Getter) {
statsGetter = g
})
i.Add(statsInterceptorFactory)
}

if err := webrtc.RegisterDefaultInterceptors(&m, &i); err != nil {
return fmt.Errorf("failed to register default interceptors: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion client/rtc_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/pion/interceptor/pkg/stats"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"
)

type rtcMonitor struct {
Expand Down
2 changes: 1 addition & 1 deletion client/rtc_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

"github.com/pion/interceptor/pkg/stats"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"

"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion client/rtc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v4"
"github.com/stretchr/testify/require"
)

Expand Down
35 changes: 18 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/mattermost/mattermost/server/public v0.0.12
github.com/pborman/uuid v1.2.1
github.com/pion/ice/v2 v2.3.25
github.com/pion/interceptor v0.1.29
github.com/pion/ice/v4 v4.0.2
github.com/pion/interceptor v0.1.37
github.com/pion/logging v0.2.2
github.com/pion/rtcp v1.2.14
github.com/pion/rtp v1.8.6
github.com/pion/stun v0.6.1
github.com/pion/webrtc/v3 v3.2.41
github.com/pion/rtp v1.8.9
github.com/pion/stun/v3 v3.0.0
github.com/pion/webrtc/v4 v4.0.1
github.com/prometheus/client_golang v1.15.0
github.com/prometheus/procfs v0.9.0
github.com/stretchr/testify v1.9.0
github.com/vmihailenco/msgpack/v5 v5.4.1
golang.org/x/crypto v0.24.0
golang.org/x/sys v0.21.0
golang.org/x/crypto v0.28.0
golang.org/x/sys v0.26.0
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
)

replace github.com/pion/interceptor v0.1.29 => github.com/streamer45/interceptor v0.0.0-20240411210059-c7d42d2dafc1
replace github.com/pion/interceptor v0.1.37 => github.com/streamer45/interceptor v0.0.0-20241030214225-50b187d839be

require (
github.com/abcum/lcp v0.0.0-20201209214815-7a3f3840be81 // indirect
Expand All @@ -47,15 +47,15 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pion/datachannel v1.5.6 // indirect
github.com/pion/dtls/v2 v2.2.11 // indirect
github.com/pion/mdns v0.0.12 // indirect
github.com/pion/datachannel v1.5.9 // indirect
github.com/pion/dtls/v3 v3.0.3 // indirect
github.com/pion/mdns/v2 v2.0.7 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/sctp v1.8.16 // indirect
github.com/pion/sctp v1.8.33 // indirect
github.com/pion/sdp/v3 v3.0.9 // indirect
github.com/pion/srtp/v2 v2.0.18 // indirect
github.com/pion/transport/v2 v2.2.4 // indirect
github.com/pion/turn/v2 v2.1.6 // indirect
github.com/pion/srtp/v3 v3.0.4 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pion/turn/v4 v4.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/plar/go-adaptive-radix-tree v1.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -67,9 +67,10 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/wiggin77/merror v1.0.5 // indirect
github.com/wiggin77/srslog v1.0.1 // indirect
github.com/wlynxg/anet v0.0.5 // indirect
golang.org/x/exp v0.0.0-20200908183739-ae8ad444f925 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading