mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 07:06:51 +08:00
Update examples to only generate SDP when candidates are done gathering
This commit is contained in:
@@ -8,7 +8,7 @@ go get github.com/pions/webrtc/examples/save-to-disk
|
||||
```
|
||||
|
||||
### 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
|
||||
In the jsfiddle the top textarea is your browser, copy that and:
|
||||
|
@@ -10,12 +10,14 @@ navigator.mediaDevices.getUserMedia({video: true, audio: true})
|
||||
.catch(log)
|
||||
|
||||
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.createOffer().then(d => {
|
||||
document.getElementById('localSessionDescription').value = btoa(d.sdp)
|
||||
return pc.setLocalDescription(d)
|
||||
}).catch(log)
|
||||
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
||||
|
||||
window.startSession = () => {
|
||||
let sd = document.getElementById('remoteSessionDescription').value
|
||||
|
Reference in New Issue
Block a user