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-45894] Allow signaling through data channel #156

Merged
merged 4 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
423 changes: 219 additions & 204 deletions client/api_test.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions client/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (

func (c *Client) joinCall() error {
if err := c.SendWS(wsEventJoin, CallJoinMessage{
ChannelID: c.cfg.ChannelID,
JobID: c.cfg.JobID,
AV1Support: c.cfg.EnableAV1,
ChannelID: c.cfg.ChannelID,
JobID: c.cfg.JobID,
AV1Support: c.cfg.EnableAV1,
DCSignaling: c.cfg.EnableDCSignaling,
}, false); err != nil {
return fmt.Errorf("failed to send ws msg: %w", err)
}
Expand Down
7 changes: 6 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ type Client struct {

// WebRTC
pc *webrtc.PeerConnection
dc *webrtc.DataChannel
dc atomic.Pointer[webrtc.DataChannel]
iceCh chan webrtc.ICECandidateInit
receivers map[string][]*webrtc.RTPReceiver
voiceSender *webrtc.RTPSender
screenTransceivers []*webrtc.RTPTransceiver
rtcMon *rtcMonitor

state int32

Expand Down Expand Up @@ -225,6 +226,10 @@ func (c *Client) emit(eventType EventType, ctx any) {
func (c *Client) close() {
atomic.StoreInt32(&c.state, clientStateClosed)

if c.rtcMon != nil {
c.rtcMon.Stop()
}

if c.pc != nil {
if err := c.pc.Close(); err != nil {
c.log.Error("failed to close peer connection", slog.String("err", err.Error()))
Expand Down
5 changes: 5 additions & 0 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ type Config struct {
// EnableAV1 controls whether the client should advertise support
// for receiving the AV1 codec.
EnableAV1 bool
// EnableDCSignaling controls whether the client should use data channels
// for signaling of media tracks.
EnableDCSignaling bool
// EnableRTCMonitor controls whether the RTC monitor component should be enabled.
EnableRTCMonitor bool

wsURL string
}
Expand Down
14 changes: 8 additions & 6 deletions client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,19 @@ func setupTestHelper(tb testing.TB, channelName string) *TestHelper {
}

th.adminClient, err = New(Config{
SiteURL: th.apiURL,
AuthToken: th.adminAPIClient.AuthToken,
ChannelID: channelID,
SiteURL: th.apiURL,
AuthToken: th.adminAPIClient.AuthToken,
ChannelID: channelID,
EnableRTCMonitor: true,
}, WithLogger(logger))
require.NoError(tb, err)
require.NotNil(tb, th.adminClient)

th.userClient, err = New(Config{
SiteURL: th.apiURL,
AuthToken: th.userAPIClient.AuthToken,
ChannelID: channelID,
SiteURL: th.apiURL,
AuthToken: th.userAPIClient.AuthToken,
ChannelID: channelID,
EnableRTCMonitor: true,
}, WithLogger(logger))
require.NoError(tb, err)
require.NotNil(tb, th.userClient)
Expand Down
Loading