Skip to content
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
25 changes: 4 additions & 21 deletions clientcore/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"sync"
"time"

"github.com/pion/transport/v3/stdnet"
"github.com/pion/webrtc/v4"

"github.com/getlantern/broflake/common"
Expand Down Expand Up @@ -61,28 +60,12 @@ func NewConsumerWebRTC(options *WebRTCOptions, wg *sync.WaitGroup) *WorkerFSM {
},
}

// // Example custom DTLS settings
// settingEngine := &webrtc.SettingEngine{}
// settingEngine.SetDTLSEllipticCurves(elliptic.P256, elliptic.P384, elliptic.X25519)
// webrtcAPI := webrtc.NewAPI(webrtc.WithSettingEngine(*settingEngine))
// peerConnection, err := webrtcAPI.NewPeerConnection(config)

// Set the network interface for WebRTC. If none is provided, use the default stdnet.Net
// that webrtc would use anyway.
rtcNet := options.Net
if rtcNet == nil {
var err error
rtcNet, err = stdnet.NewNet()
if err != nil {
common.Debugf("Error initializing stdnet.Net: %v", err)
return 0, []any{}
}
api, err := newWebRTCAPI(options.Net)
if err != nil {
common.Debugf("Error creating WebRTC API: %v", err)
return 0, []any{}
}

settingEngine := &webrtc.SettingEngine{}
settingEngine.SetNet(rtcNet)
api := webrtc.NewAPI(webrtc.WithSettingEngine(*settingEngine))

// Construct the RTCPeerConnection
peerConnection, err := api.NewPeerConnection(config)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion clientcore/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type WebRTCOptions struct {
Patience time.Duration
ErrorBackoff time.Duration
ConsumerSessionID string
Net transport.Net
// 'Net' is currently only respected by the WebRTC *consumer*, and it won't work for Wasm builds!
Net transport.Net
}

func NewDefaultWebRTCOptions() *WebRTCOptions {
Expand Down
2 changes: 1 addition & 1 deletion clientcore/ui_default_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type UIImpl struct {
UI
BroflakeEngine *BroflakeEngine
BroflakeEngine *BroflakeEngine
OnConnectionChangeFunc ConnectionChangeFunc
}

Expand Down
22 changes: 22 additions & 0 deletions clientcore/webrtc_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build !wasm

package clientcore

import (
"github.com/pion/transport/v3"
"github.com/pion/transport/v3/stdnet"
"github.com/pion/webrtc/v4"
)

func newWebRTCAPI(net transport.Net) (*webrtc.API, error) {
if net == nil {
var err error
net, err = stdnet.NewNet()
if err != nil {
return nil, err
}
}
se := &webrtc.SettingEngine{}
se.SetNet(net)
return webrtc.NewAPI(webrtc.WithSettingEngine(*se)), nil
}
13 changes: 13 additions & 0 deletions clientcore/webrtc_api_js.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build wasm

package clientcore

import (
"github.com/pion/transport/v3"
"github.com/pion/webrtc/v4"
)

func newWebRTCAPI(_ transport.Net) (*webrtc.API, error) {
panic("Congratulations, you found the unimplemented WebRTC consumer transport injector for Wasm builds!")
return webrtc.NewAPI(), nil
}
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common

// Must be a valid semver
const Version = "v2.1.6"
const Version = "v2.1.7"
Binary file modified ui/public/widget.wasm
Binary file not shown.