diff --git a/custom_components/webrtc/utils.py b/custom_components/webrtc/utils.py index a126438..811a4a3 100644 --- a/custom_components/webrtc/utils.py +++ b/custom_components/webrtc/utils.py @@ -25,7 +25,7 @@ DOMAIN = "webrtc" -BINARY_VERSION = "1.8.4" +BINARY_VERSION = "1.9.4" SYSTEM = { "Windows": {"AMD64": "go2rtc_win64.zip", "ARM64": "go2rtc_win_arm64.zip"}, diff --git a/custom_components/webrtc/www/video-rtc.js b/custom_components/webrtc/www/video-rtc.js index 5341db7..f04a1bf 100644 --- a/custom_components/webrtc/www/video-rtc.js +++ b/custom_components/webrtc/www/video-rtc.js @@ -19,7 +19,7 @@ export class VideoRTC extends HTMLElement { super(); this.DISCONNECT_TIMEOUT = 5000; - this.RECONNECT_TIMEOUT = 30000; + this.RECONNECT_TIMEOUT = 15000; this.CODECS = [ 'avc1.640029', // H.264 high 4.1 (Chromecast 1st and 2nd Gen) @@ -70,6 +70,7 @@ export class VideoRTC extends HTMLElement { * @type {RTCConfiguration} */ this.pcConfig = { + bundlePolicy: 'max-bundle', iceServers: [{urls: 'stun:stun.l.google.com:19302'}], sdpSemantics: 'unified-plan', // important for Chromecast 1 }; @@ -248,6 +249,11 @@ export class VideoRTC extends HTMLElement { this.appendChild(this.video); + this.video.addEventListener('error', ev => { + console.warn(ev); + if (this.ws) this.ws.close(); // run reconnect for broken MSE stream + }); + // all Safari lies about supported audio codecs const m = window.navigator.userAgent.match(/Version\/(\d+).+Safari/); if (m) { @@ -487,7 +493,9 @@ export class VideoRTC extends HTMLElement { pc.addEventListener('connectionstatechange', () => { if (pc.connectionState === 'connected') { - const tracks = pc.getReceivers().map(receiver => receiver.track); + const tracks = pc.getTransceivers() + .filter(tr => tr.currentDirection === 'recvonly') // skip inactive + .map(tr => tr.receiver.track); /** @type {HTMLVideoElement} */ const video2 = document.createElement('video'); video2.addEventListener('loadeddata', () => this.onpcvideo(video2), {once: true}); diff --git a/custom_components/webrtc/www/webrtc-camera.js b/custom_components/webrtc/www/webrtc-camera.js index fd9f9e1..d9a250b 100644 --- a/custom_components/webrtc/www/webrtc-camera.js +++ b/custom_components/webrtc/www/webrtc-camera.js @@ -1,5 +1,5 @@ /** Chrome 63+, Safari 11.1+ */ -import {VideoRTC} from './video-rtc.js?v=1.8.0'; +import {VideoRTC} from './video-rtc.js?v=1.9.4'; import {DigitalPTZ} from './digital-ptz.js?v=3.3.0'; class WebRTCCamera extends VideoRTC {