Detect when a video stream fails from the server (#307)
It's not clear /what/ is breaking the connection, but this will add retry when it does. The term 'muted' here is a bit hard to grok, it's a read-only indication of the *peer*'s state https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/muted Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io>
This commit is contained in:
@ -206,11 +206,11 @@ export class EngineConnection extends EventTarget {
|
|||||||
this.pc.addEventListener('icecandidate', (event) => {
|
this.pc.addEventListener('icecandidate', (event) => {
|
||||||
if (!this.pc || !this.websocket) return
|
if (!this.pc || !this.websocket) return
|
||||||
if (event.candidate === null) {
|
if (event.candidate === null) {
|
||||||
console.log('sent sdp_offer')
|
// console.log('sent sdp_offer')
|
||||||
this.send({
|
// this.send({
|
||||||
type: 'sdp_offer',
|
// type: 'sdp_offer',
|
||||||
offer: this.pc.localDescription,
|
// offer: this.pc.localDescription,
|
||||||
})
|
// })
|
||||||
} else {
|
} else {
|
||||||
console.log('sending trickle ice candidate')
|
console.log('sending trickle ice candidate')
|
||||||
const { candidate } = event
|
const { candidate } = event
|
||||||
@ -243,7 +243,7 @@ export class EngineConnection extends EventTarget {
|
|||||||
// TODO(paultag): This ought to be both controllable, as well as something
|
// TODO(paultag): This ought to be both controllable, as well as something
|
||||||
// like exponential backoff to have some grace on the backend, as well as
|
// like exponential backoff to have some grace on the backend, as well as
|
||||||
// fix responsiveness for clients that had a weird network hiccup.
|
// fix responsiveness for clients that had a weird network hiccup.
|
||||||
const connectionTimeoutMs = 5000
|
const connectionTimeoutMs = 3000
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.isReady()) {
|
if (this.isReady()) {
|
||||||
@ -428,6 +428,13 @@ export class EngineCommandManager {
|
|||||||
|
|
||||||
let mediaStream = customEvent.detail.mediaStream
|
let mediaStream = customEvent.detail.mediaStream
|
||||||
console.log('received track', mediaStream)
|
console.log('received track', mediaStream)
|
||||||
|
|
||||||
|
mediaStream.getVideoTracks()[0].addEventListener('mute', () => {
|
||||||
|
console.log('peer is not sending video to us')
|
||||||
|
this.engineConnection?.close()
|
||||||
|
this.engineConnection?.connect()
|
||||||
|
})
|
||||||
|
|
||||||
setMediaStream(mediaStream)
|
setMediaStream(mediaStream)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user