mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Add StandardJS workflow
Been running these locally only.
This commit is contained in:
17
.github/workflows/standardjs.yaml
vendored
Normal file
17
.github/workflows/standardjs.yaml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: StandardJS
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
|
jobs:
|
||||||
|
StandardJS:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
- run: npm install standard
|
||||||
|
- run: npx standard
|
@@ -1,10 +1,10 @@
|
|||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
var log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('logs').innerHTML += msg + '<br>'
|
document.getElementById('logs').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
window.createSession = isPublisher => {
|
window.createSession = isPublisher => {
|
||||||
let pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
@@ -21,7 +21,7 @@ window.createSession = isPublisher => {
|
|||||||
if (isPublisher) {
|
if (isPublisher) {
|
||||||
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
|
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
|
||||||
.then(stream => {
|
.then(stream => {
|
||||||
stream.getTracks().forEach(track => pc.addTrack(track, stream));
|
stream.getTracks().forEach(track => pc.addTrack(track, stream))
|
||||||
document.getElementById('video1').srcObject = stream
|
document.getElementById('video1').srcObject = stream
|
||||||
pc.createOffer()
|
pc.createOffer()
|
||||||
.then(d => pc.setLocalDescription(d))
|
.then(d => pc.setLocalDescription(d))
|
||||||
@@ -34,7 +34,7 @@ window.createSession = isPublisher => {
|
|||||||
.catch(log)
|
.catch(log)
|
||||||
|
|
||||||
pc.ontrack = function (event) {
|
pc.ontrack = function (event) {
|
||||||
var el = document.getElementById('video1')
|
const el = document.getElementById('video1')
|
||||||
el.srcObject = event.streams[0]
|
el.srcObject = event.streams[0]
|
||||||
el.autoplay = true
|
el.autoplay = true
|
||||||
el.controls = true
|
el.controls = true
|
||||||
@@ -42,7 +42,7 @@ window.createSession = isPublisher => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
@@ -55,21 +55,21 @@ window.createSession = isPublisher => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.copySDP = () => {
|
window.copySDP = () => {
|
||||||
const browserSDP = document.getElementById('localSessionDescription')
|
const browserSDP = document.getElementById('localSessionDescription')
|
||||||
|
|
||||||
browserSDP.focus()
|
browserSDP.focus()
|
||||||
browserSDP.select()
|
browserSDP.select()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const successful = document.execCommand('copy')
|
const successful = document.execCommand('copy')
|
||||||
const msg = successful ? 'successful' : 'unsuccessful'
|
const msg = successful ? 'successful' : 'unsuccessful'
|
||||||
log('Copying SDP was ' + msg)
|
log('Copying SDP was ' + msg)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log('Unable to copy SDP ' + err)
|
log('Unable to copy SDP ' + err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let btns = document.getElementsByClassName('createSessionButton')
|
const btns = document.getElementsByClassName('createSessionButton')
|
||||||
for (let i = 0; i < btns.length; i++) {
|
for (let i = 0; i < btns.length; i++) {
|
||||||
btns[i].style = 'display: none'
|
btns[i].style = 'display: none'
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
|
||||||
let pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
let log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('logs').innerHTML += msg + '<br>'
|
document.getElementById('logs').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
let sendChannel = pc.createDataChannel('foo')
|
const sendChannel = pc.createDataChannel('foo')
|
||||||
sendChannel.onclose = () => console.log('sendChannel has closed')
|
sendChannel.onclose = () => console.log('sendChannel has closed')
|
||||||
sendChannel.onopen = () => console.log('sendChannel has opened')
|
sendChannel.onopen = () => console.log('sendChannel has opened')
|
||||||
sendChannel.onmessage = e => log(`Message from DataChannel '${sendChannel.label}' payload '${e.data}'`)
|
sendChannel.onmessage = e => log(`Message from DataChannel '${sendChannel.label}' payload '${e.data}'`)
|
||||||
@@ -27,7 +27,7 @@ pc.onnegotiationneeded = e =>
|
|||||||
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
||||||
|
|
||||||
window.sendMessage = () => {
|
window.sendMessage = () => {
|
||||||
let message = document.getElementById('message').value
|
const message = document.getElementById('message').value
|
||||||
if (message === '') {
|
if (message === '') {
|
||||||
return alert('Message must not be empty')
|
return alert('Message must not be empty')
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ window.sendMessage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
|
@@ -3,17 +3,17 @@
|
|||||||
// cipherKey that video is encrypted with
|
// cipherKey that video is encrypted with
|
||||||
const cipherKey = 0xAA
|
const cipherKey = 0xAA
|
||||||
|
|
||||||
let pc = new RTCPeerConnection({encodedInsertableStreams: true, forceEncodedVideoInsertableStreams: true})
|
const pc = new RTCPeerConnection({ encodedInsertableStreams: true, forceEncodedVideoInsertableStreams: true })
|
||||||
let log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('div').innerHTML += msg + '<br>'
|
document.getElementById('div').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offer to receive 1 video
|
// Offer to receive 1 video
|
||||||
let transceiver = pc.addTransceiver('video')
|
const transceiver = pc.addTransceiver('video')
|
||||||
|
|
||||||
// The API has seen two iterations, support both
|
// The API has seen two iterations, support both
|
||||||
// In the future this will just be `createEncodedStreams`
|
// In the future this will just be `createEncodedStreams`
|
||||||
let receiverStreams = getInsertableStream(transceiver)
|
const receiverStreams = getInsertableStream(transceiver)
|
||||||
|
|
||||||
// boolean controlled by checkbox to enable/disable encryption
|
// boolean controlled by checkbox to enable/disable encryption
|
||||||
let applyDecryption = true
|
let applyDecryption = true
|
||||||
@@ -24,8 +24,8 @@ window.toggleDecryption = () => {
|
|||||||
// Loop that is called for each video frame
|
// Loop that is called for each video frame
|
||||||
const reader = receiverStreams.readable.getReader()
|
const reader = receiverStreams.readable.getReader()
|
||||||
const writer = receiverStreams.writable.getWriter()
|
const writer = receiverStreams.writable.getWriter()
|
||||||
reader.read().then(function processVideo({ done, value }) {
|
reader.read().then(function processVideo ({ done, value }) {
|
||||||
let decrypted = new DataView(value.data)
|
const decrypted = new DataView(value.data)
|
||||||
|
|
||||||
if (applyDecryption) {
|
if (applyDecryption) {
|
||||||
for (let i = 0; i < decrypted.buffer.byteLength; i++) {
|
for (let i = 0; i < decrypted.buffer.byteLength; i++) {
|
||||||
@@ -41,7 +41,7 @@ reader.read().then(function processVideo({ done, value }) {
|
|||||||
// Fire when remote video arrives
|
// Fire when remote video arrives
|
||||||
pc.ontrack = function (event) {
|
pc.ontrack = function (event) {
|
||||||
document.getElementById('remote-video').srcObject = event.streams[0]
|
document.getElementById('remote-video').srcObject = event.streams[0]
|
||||||
document.getElementById('remote-video').style = ""
|
document.getElementById('remote-video').style = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate SDP field when finished gathering
|
// Populate SDP field when finished gathering
|
||||||
@@ -54,7 +54,7 @@ pc.onicecandidate = event => {
|
|||||||
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
@@ -68,8 +68,8 @@ window.startSession = () => {
|
|||||||
|
|
||||||
// DOM code to show banner if insertable streams not supported
|
// DOM code to show banner if insertable streams not supported
|
||||||
let insertableStreamsSupported = true
|
let insertableStreamsSupported = true
|
||||||
let updateSupportBanner = () => {
|
const updateSupportBanner = () => {
|
||||||
let el = document.getElementById('no-support-banner')
|
const el = document.getElementById('no-support-banner')
|
||||||
if (insertableStreamsSupported && el) {
|
if (insertableStreamsSupported && el) {
|
||||||
el.style = 'display: none'
|
el.style = 'display: none'
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ let updateSupportBanner = () => {
|
|||||||
document.addEventListener('DOMContentLoaded', updateSupportBanner)
|
document.addEventListener('DOMContentLoaded', updateSupportBanner)
|
||||||
|
|
||||||
// Shim to support both versions of API
|
// Shim to support both versions of API
|
||||||
function getInsertableStream(transceiver) {
|
function getInsertableStream (transceiver) {
|
||||||
let insertableStreams = null
|
let insertableStreams = null
|
||||||
if (transceiver.receiver.createEncodedVideoStreams) {
|
if (transceiver.receiver.createEncodedVideoStreams) {
|
||||||
insertableStreams = transceiver.receiver.createEncodedVideoStreams()
|
insertableStreams = transceiver.receiver.createEncodedVideoStreams()
|
||||||
@@ -88,7 +88,7 @@ function getInsertableStream(transceiver) {
|
|||||||
if (!insertableStreams) {
|
if (!insertableStreams) {
|
||||||
insertableStreamsSupported = false
|
insertableStreamsSupported = false
|
||||||
updateSupportBanner()
|
updateSupportBanner()
|
||||||
throw 'Insertable Streams are not supported'
|
throw new Error('Insertable Streams are not supported')
|
||||||
}
|
}
|
||||||
|
|
||||||
return insertableStreams
|
return insertableStreams
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
|
||||||
let pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
var log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('logs').innerHTML += msg + '<br>'
|
document.getElementById('logs').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
|
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
|
||||||
.then(stream => {
|
.then(stream => {
|
||||||
stream.getTracks().forEach(track => pc.addTrack(track, stream));
|
stream.getTracks().forEach(track => pc.addTrack(track, stream))
|
||||||
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
|
||||||
}).catch(log)
|
}).catch(log)
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ pc.onicecandidate = event => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pc.ontrack = function (event) {
|
pc.ontrack = function (event) {
|
||||||
var el = document.createElement(event.track.kind)
|
const el = document.createElement(event.track.kind)
|
||||||
el.srcObject = event.streams[0]
|
el.srcObject = event.streams[0]
|
||||||
el.autoplay = true
|
el.autoplay = true
|
||||||
el.controls = true
|
el.controls = true
|
||||||
@@ -33,7 +33,7 @@ pc.ontrack = function (event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
@@ -59,4 +59,3 @@ window.copySDP = () => {
|
|||||||
log('Unable to copy SDP ' + err)
|
log('Unable to copy SDP ' + err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
|
||||||
let pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
var log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('logs').innerHTML += msg + '<br>'
|
document.getElementById('logs').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ pc.onicecandidate = event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
|
||||||
let pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
var log = msg => {
|
const log = msg => {
|
||||||
document.getElementById('logs').innerHTML += msg + '<br>'
|
document.getElementById('logs').innerHTML += msg + '<br>'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ pc.onicecandidate = event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
let sd = document.getElementById('remoteSessionDescription').value
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === '') {
|
if (sd === '') {
|
||||||
return alert('Session Description must not be empty')
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
|
@@ -1,95 +1,95 @@
|
|||||||
|
/* eslint-env browser */
|
||||||
|
|
||||||
// Create peer conn
|
// Create peer conn
|
||||||
const pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [{
|
||||||
{
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
urls: "stun:stun.l.google.com:19302",
|
}]
|
||||||
},
|
})
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
pc.oniceconnectionstatechange = (e) => {
|
pc.oniceconnectionstatechange = (e) => {
|
||||||
console.log("connection state change", pc.iceConnectionState);
|
console.log('connection state change', pc.iceConnectionState)
|
||||||
};
|
}
|
||||||
pc.onicecandidate = (event) => {
|
pc.onicecandidate = (event) => {
|
||||||
if (event.candidate === null) {
|
if (event.candidate === null) {
|
||||||
document.getElementById("localSessionDescription").value = btoa(
|
document.getElementById('localSessionDescription').value = btoa(
|
||||||
JSON.stringify(pc.localDescription)
|
JSON.stringify(pc.localDescription)
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
pc.onnegotiationneeded = (e) =>
|
pc.onnegotiationneeded = (e) =>
|
||||||
pc
|
pc
|
||||||
.createOffer()
|
.createOffer()
|
||||||
.then((d) => pc.setLocalDescription(d))
|
.then((d) => pc.setLocalDescription(d))
|
||||||
.catch(console.error);
|
.catch(console.error)
|
||||||
|
|
||||||
pc.ontrack = (event) => {
|
pc.ontrack = (event) => {
|
||||||
console.log("Got track event", event);
|
console.log('Got track event', event)
|
||||||
let video = document.createElement("video");
|
const video = document.createElement('video')
|
||||||
video.srcObject = event.streams[0];
|
video.srcObject = event.streams[0]
|
||||||
video.autoplay = true;
|
video.autoplay = true
|
||||||
video.width = "500";
|
video.width = '500'
|
||||||
let label = document.createElement("div");
|
const label = document.createElement('div')
|
||||||
label.textContent = event.streams[0].id;
|
label.textContent = event.streams[0].id
|
||||||
document.getElementById("serverVideos").appendChild(label);
|
document.getElementById('serverVideos').appendChild(label)
|
||||||
document.getElementById("serverVideos").appendChild(video);
|
document.getElementById('serverVideos').appendChild(video)
|
||||||
};
|
}
|
||||||
|
|
||||||
navigator.mediaDevices
|
navigator.mediaDevices
|
||||||
.getUserMedia({
|
.getUserMedia({
|
||||||
video: {
|
video: {
|
||||||
width: {
|
width: {
|
||||||
ideal: 4096,
|
ideal: 4096
|
||||||
},
|
},
|
||||||
height: {
|
height: {
|
||||||
ideal: 2160,
|
ideal: 2160
|
||||||
},
|
},
|
||||||
frameRate: {
|
frameRate: {
|
||||||
ideal: 60,
|
ideal: 60,
|
||||||
min: 10,
|
min: 10
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
audio: false,
|
audio: false
|
||||||
})
|
})
|
||||||
.then((stream) => {
|
.then((stream) => {
|
||||||
document.getElementById("browserVideo").srcObject = stream;
|
document.getElementById('browserVideo').srcObject = stream
|
||||||
pc.addTransceiver(stream.getVideoTracks()[0], {
|
pc.addTransceiver(stream.getVideoTracks()[0], {
|
||||||
direction: "sendonly",
|
direction: 'sendonly',
|
||||||
streams: [stream],
|
streams: [stream],
|
||||||
sendEncodings: [
|
sendEncodings: [
|
||||||
// for firefox order matters... first high resolution, then scaled resolutions...
|
// for firefox order matters... first high resolution, then scaled resolutions...
|
||||||
{
|
{
|
||||||
rid: "f",
|
rid: 'f'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rid: "h",
|
rid: 'h',
|
||||||
scaleResolutionDownBy: 2.0,
|
scaleResolutionDownBy: 2.0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rid: "q",
|
rid: 'q',
|
||||||
scaleResolutionDownBy: 4.0,
|
scaleResolutionDownBy: 4.0
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
});
|
})
|
||||||
pc.addTransceiver("video");
|
pc.addTransceiver('video')
|
||||||
pc.addTransceiver("video");
|
pc.addTransceiver('video')
|
||||||
pc.addTransceiver("video");
|
pc.addTransceiver('video')
|
||||||
});
|
})
|
||||||
|
|
||||||
window.startSession = () => {
|
window.startSession = () => {
|
||||||
const sd = document.getElementById("remoteSessionDescription").value;
|
const sd = document.getElementById('remoteSessionDescription').value
|
||||||
if (sd === "") {
|
if (sd === '') {
|
||||||
return alert("Session Description must not be empty");
|
return alert('Session Description must not be empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("answer", JSON.parse(atob(sd)));
|
console.log('answer', JSON.parse(atob(sd)))
|
||||||
pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd))));
|
pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd))))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(e);
|
alert(e)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
window.copySDP = () => {
|
window.copySDP = () => {
|
||||||
const browserSDP = document.getElementById('localSessionDescription')
|
const browserSDP = document.getElementById('localSessionDescription')
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-env browser */
|
||||||
|
|
||||||
// Create peer conn
|
// Create peer conn
|
||||||
const pc = new RTCPeerConnection({
|
const pc = new RTCPeerConnection({
|
||||||
@@ -38,7 +39,7 @@ requestAnimationFrame(() => drawCircle(document.getElementById('canvasOne').getC
|
|||||||
requestAnimationFrame(() => drawCircle(document.getElementById('canvasTwo').getContext('2d'), '#cf635f', 0))
|
requestAnimationFrame(() => drawCircle(document.getElementById('canvasTwo').getContext('2d'), '#cf635f', 0))
|
||||||
requestAnimationFrame(() => drawCircle(document.getElementById('canvasThree').getContext('2d'), '#46c240', 0))
|
requestAnimationFrame(() => drawCircle(document.getElementById('canvasThree').getContext('2d'), '#46c240', 0))
|
||||||
|
|
||||||
function drawCircle(ctx, color, angle) {
|
function drawCircle (ctx, color, angle) {
|
||||||
// Background
|
// Background
|
||||||
ctx.clearRect(0, 0, 200, 200)
|
ctx.clearRect(0, 0, 200, 200)
|
||||||
ctx.fillStyle = '#eeeeee'
|
ctx.fillStyle = '#eeeeee'
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
// This file adds RTCPeerConnection to the global context, making Node.js more
|
// This file adds RTCPeerConnection to the global context, making Node.js more
|
||||||
// closely match the browser API for WebRTC.
|
// closely match the browser API for WebRTC.
|
||||||
|
|
||||||
const wrtc = require("wrtc");
|
const wrtc = require('wrtc')
|
||||||
|
|
||||||
global.window = {
|
global.window = {
|
||||||
RTCPeerConnection: wrtc.RTCPeerConnection
|
RTCPeerConnection: wrtc.RTCPeerConnection
|
||||||
};
|
}
|
||||||
|
|
||||||
global.RTCPeerConnection = wrtc.RTCPeerConnection;
|
global.RTCPeerConnection = wrtc.RTCPeerConnection
|
||||||
|
Reference in New Issue
Block a user