Update examples to only generate SDP when candidates are done gathering

This commit is contained in:
Sean DuBois
2018-08-11 00:23:40 -07:00
parent 02e72796d4
commit d9e6b8b61f
8 changed files with 29 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ go get github.com/pions/webrtc/examples/data-channels
``` ```
### Open data-channels example page ### Open data-channels example page
[jsfiddle.net](https://jsfiddle.net/gh/get/library/pure/pions/webrtc/tree/master/examples/data-channels/jsfiddle) [jsfiddle.net](http://jsfiddle.net/9tsx15mg/1/)
### Run data-channels, with your browsers SessionDescription as stdin ### Run data-channels, with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser's session description, copy that and: In the jsfiddle the top textarea is your browser's session description, copy that and:

View File

@@ -11,12 +11,14 @@ sendChannel.onopen = () => console.log('sendChannel has opened')
sendChannel.onmessage = e => log(`sendChannel got '${e.data}'`) sendChannel.onmessage = e => log(`sendChannel got '${e.data}'`)
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState) pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
pc.onicecandidate = event => {
if (event.candidate === null) {
document.getElementById('localSessionDescription').value = btoa(pc.localDescription.sdp)
}
}
pc.onnegotiationneeded = e => pc.onnegotiationneeded = e =>
pc.createOffer({ }).then(d => { pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
document.getElementById('localSessionDescription').value = btoa(d.sdp)
return pc.setLocalDescription(d)
}).catch(log)
window.sendMessage = () => { window.sendMessage = () => {
let message = document.getElementById('message').value let message = document.getElementById('message').value

View File

@@ -10,12 +10,14 @@ navigator.mediaDevices.getUserMedia({video: true, audio: true})
.catch(log) .catch(log)
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState) pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
pc.onicecandidate = event => {
if (event.candidate === null) {
document.getElementById('localSessionDescription').value = btoa(pc.localDescription.sdp)
}
}
pc.onnegotiationneeded = e => pc.onnegotiationneeded = e =>
pc.createOffer().then(d => { pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
document.getElementById('localSessionDescription').value = btoa(d.sdp)
return pc.setLocalDescription(d)
}).catch(log)
window.startSession = () => { window.startSession = () => {
let sd = document.getElementById('remoteSessionDescription').value let sd = document.getElementById('remoteSessionDescription').value

View File

@@ -14,7 +14,7 @@ go get github.com/pions/webrtc/examples/gstreamer-send
``` ```
### Open gstreamer-send example page ### Open gstreamer-send example page
[jsfiddle.net](https://jsfiddle.net/gh/get/library/pure/pions/webrtc/tree/master/examples/gstreamer-send/jsfiddle) you should see two text-areas and a 'Start Session' button [jsfiddle.net](https://jsfiddle.net/Laf7ujeo/5/) you should see two text-areas and a 'Start Session' button
### Run gstreamer-send with your browsers SessionDescription as stdin ### Run gstreamer-send with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser, copy that and: In the jsfiddle the top textarea is your browser, copy that and:

View File

@@ -15,10 +15,13 @@ pc.ontrack = function (event) {
} }
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState) pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(d => { pc.onicecandidate = event => {
document.getElementById('localSessionDescription').value = btoa(d.sdp) if (event.candidate === null) {
return pc.setLocalDescription(d) document.getElementById('localSessionDescription').value = btoa(pc.localDescription.sdp)
}).catch(log) }
}
pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(d => pc.setLocalDescription(d)).catch(log)
window.startSession = () => { window.startSession = () => {
let sd = document.getElementById('remoteSessionDescription').value let sd = document.getElementById('remoteSessionDescription').value

View File

@@ -8,7 +8,7 @@ go get github.com/pions/webrtc/examples/save-to-disk
``` ```
### Open save-to-disk example page ### Open save-to-disk example page
[jsfiddle.net](https://jsfiddle.net/usd3xmtz/2/) you should see your Webcam, two text-areas and a 'Start Session' button [jsfiddle.net](https://jsfiddle.net/dyj8qpek/) you should see your Webcam, two text-areas and a 'Start Session' button
### Run save-to-disk, with your browsers SessionDescription as stdin ### Run save-to-disk, with your browsers SessionDescription as stdin
In the jsfiddle the top textarea is your browser, copy that and: In the jsfiddle the top textarea is your browser, copy that and:

View File

@@ -10,12 +10,14 @@ navigator.mediaDevices.getUserMedia({video: true, audio: true})
.catch(log) .catch(log)
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState) pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
pc.onicecandidate = event => {
if (event.candidate === null) {
document.getElementById('localSessionDescription').value = btoa(pc.localDescription.sdp)
}
}
pc.onnegotiationneeded = e => pc.onnegotiationneeded = e =>
pc.createOffer().then(d => { pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
document.getElementById('localSessionDescription').value = btoa(d.sdp)
return pc.setLocalDescription(d)
}).catch(log)
window.startSession = () => { window.startSession = () => {
let sd = document.getElementById('remoteSessionDescription').value let sd = document.getElementById('remoteSessionDescription').value

View File

@@ -12,7 +12,7 @@ func (p *port) sendRTP(packet *rtp.Packet, dst net.Addr) {
p.m.certPairLock.RLock() p.m.certPairLock.RLock()
defer p.m.certPairLock.RUnlock() defer p.m.certPairLock.RUnlock()
if p.m.certPair == nil { if p.m.certPair == nil {
fmt.Printf("Tried to send SRTP packet but no DTLS state to handle it %v \n", p.m.certPair) fmt.Println("Tried to send SRTP packet but no DTLS state to handle it")
return return
} }