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
10 changes: 7 additions & 3 deletions src/utils/webrtc/simplewebrtc/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ Peer.prototype.sendDirectly = function(channel, messageType, payload) {
}
this.logger.log('sending via datachannel', channel, messageType, message)
const dc = this.getDataChannel(channel)
if (!dc) {
return false
}
if (dc.readyState !== 'open') {
if (!Object.prototype.hasOwnProperty.call(this.pendingDCMessages, channel)) {
this.pendingDCMessages[channel] = []
Expand Down Expand Up @@ -598,6 +601,9 @@ Peer.prototype.getDataChannel = function(name, opts) {
if (!webrtcSupport.supportDataChannel) {
return this.emit('error', new Error('createDataChannel not supported'))
}
if (!this.enableDataChannels) {
return null
}
let channel = this.channels[name]
opts || (opts = {})
if (channel) {
Expand Down Expand Up @@ -635,9 +641,7 @@ Peer.prototype.start = function() {
// a) create a datachannel a priori
// b) do a renegotiation later to add the SCTP m-line
// Let's do (a) first...
if (this.enableDataChannels) {
this.getDataChannel('simplewebrtc')
}
this.getDataChannel('simplewebrtc')

this.offer(this.receiveMedia)
}
Expand Down
24 changes: 18 additions & 6 deletions src/utils/webrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,11 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local
const sendDataChannelToAll = function(channel, message, payload) {
// If running with MCU, the message must be sent through the
// publishing peer and will be distributed by the MCU to subscribers.
if (ownPeer && signaling.hasFeature && signaling.hasFeature('mcu')) {
ownPeer.sendDirectly(channel, message, payload)
if (signaling.hasFeature && signaling.hasFeature('mcu')) {
if (ownPeer) {
ownPeer.sendDirectly(channel, message, payload)
}

return
}
webrtc.sendDirectlyToAll(channel, message, payload)
Expand Down Expand Up @@ -1169,6 +1172,15 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local
} else {
callParticipantModel.setScreenPeer(peer)
}

// The SIP bridge publisher does not have data channels, so they
// need to be explicitly disabled in the subscriber. Otherwise it
// would try to open them, which would cause an endless loop of
// renegotiations, as after a negotiation the data channels will
// still not be opened, which will trigger a negotiation again.
if (callParticipantModel.get('internal')) {
peer.enableDataChannels = false
}
}

if (peer.type === 'video') {
Expand All @@ -1182,10 +1194,10 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local

setHandlerForNegotiationNeeded(peer)

// Make sure required data channels exist for all peers. This
// is required for peers that get created by SimpleWebRTC from
// received "Offer" messages. Otherwise the "channelMessage"
// will not be called.
// Make sure required data channels exist for all peers (that have
// not disabled them). This is required for peers that get created
// by SimpleWebRTC from received "Offer" messages. Otherwise the
// "channelMessage" will not be called.
peer.getDataChannel('status')
}
})
Expand Down