Skip to content

Commit

Permalink
dedupe addstream
Browse files Browse the repository at this point in the history
  • Loading branch information
cjb committed Dec 8, 2015
1 parent a05e544 commit 1013709
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions js/serverless-webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ pc1.onicecandidate = function (e) {
}
}

pc1.onaddstream = function (e) {
console.log('in pc1.onaddstream', e.stream)
function handleOnaddstream (e) {
console.log('Got remote stream', e.stream)
var el = document.getElementById('remoteVideo')
el.autoplay = true
attachMediaStream(el, e.stream)
}

pc1.onaddstream = handleOnaddstream

function handleOnconnection () {
console.log('Datachannel connected')
writeToChatLog('Datachannel connected', 'text-success')
Expand Down Expand Up @@ -279,8 +281,9 @@ function handleOfferFromPC1 (offerDesc) {

pc2.onicecandidate = function (e) {
console.log('ICE candidate (pc2)', e)
if (e.candidate == null)
if (e.candidate == null) {
$('#localAnswer').html(JSON.stringify(pc2.localDescription))
}
}

pc2.onsignalingstatechange = onsignalingstatechange
Expand All @@ -291,13 +294,7 @@ function handleCandidateFromPC1 (iceCandidate) {
pc2.addIceCandidate(iceCandidate)
}

pc2.onaddstream = function (e) {
console.log('Got remote stream', e.stream)
var el = document.getElementById('remoteVideo')
el.autoplay = true
attachMediaStream(el, e.stream)
}

pc2.onaddstream = handleOnaddstream
pc2.onconnection = handleOnconnection

function getTimestamp () {
Expand Down

0 comments on commit 1013709

Please sign in to comment.