Significa "Web Real-Time Communication" y es un proyecto open-source que les brinda a los navegadores web y aplicaciones móbiles la capacidad de tener comunicación "real-time" a través de interfaces de comunicación sencillas. La comunicación se establece "peer-to-peer" permitiendo la transmisión de audio y video sin necesidad de instalar ninguna aplicación extra.
const mediaStream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
const pc = new RTCPeerConnection()
pc.addStream(mediaStream)
pc.ontrack = event => {
// Catch the stream and put it on the web.
}
pc.onicecandidate = event => {
// Send ICE to the other client.
}
const description = await pc.createOffer({ offerToReceiveVideo: 1 })
await pc.setLocalDescription(description)
// Send the offer to the other clint
// The description from the other client is received.
pc.setRemoteDescription(SDP)
// It's received much ICE from the other client.
pc.addIceCandidate(new RTCIceCandidate(ICE))
const mediaStream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
const pc = new RTCPeerConnection()
pc.addStream(mediaStream)
pc.ontrack = event => {
// Catch the stream and put it on the web.
}
pc.onicecandidate = event => {
// Send ICE to the other client.
}
await pc.setRemoteDescription(SDP) // The SDP from the other client.
const description = await pc.createAnswer()
await pc.setLocalDescription(description)
// Send the answer to the other clint
// It's received much ICE from the other client.
pc.addIceCandidate(new RTCIceCandidate(ICE))