Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2022-08-04 07:36:51 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2022-08-11 11:37:03 +0300
commit1e1c4bc35908e51833c99388bb2622c2f3f5813c (patch)
tree7f3d33bef3cdfe85f1de1c763bb59adba1704f38 /src
parent837a336ef5f03b83d7754a3f8861b0ea97901deb (diff)
Render canvas several times
Sometimes Chromium does not render one or more frames to the stream captured from a canvas, so the canvas is now rendered several times and for a longer period to try to avoid that issue. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/utils/media/pipeline/BlackVideoEnforcer.js15
-rw-r--r--src/utils/media/pipeline/BlackVideoEnforcer.spec.js3
2 files changed, 16 insertions, 2 deletions
diff --git a/src/utils/media/pipeline/BlackVideoEnforcer.js b/src/utils/media/pipeline/BlackVideoEnforcer.js
index eeb2f781a..76dcd3af8 100644
--- a/src/utils/media/pipeline/BlackVideoEnforcer.js
+++ b/src/utils/media/pipeline/BlackVideoEnforcer.js
@@ -121,19 +121,29 @@ export default class BlackVideoEnforcer extends TrackSinkSource {
outputCanvasContext.fillStyle = 'black'
outputCanvasContext.fillRect(0, 0, outputCanvasElement.width, outputCanvasElement.height)
+ // Sometimes Chromium does not render one or more frames to the stream
+ // captured from a canvas, so repeat the drawing several times for
+ // several seconds to work around that.
+ this._renderInterval = setInterval(() => {
+ outputCanvasContext.fillRect(0, 0, outputCanvasElement.width, outputCanvasElement.height)
+ }, 100)
+
this._setOutputTrack('default', this._outputStream.getVideoTracks()[0])
this._disableOrRemoveOutputTrackTimeout = setTimeout(() => {
clearTimeout(this._disableOrRemoveOutputTrackTimeout)
this._disableOrRemoveOutputTrackTimeout = null
+ clearInterval(this._renderInterval)
+ this._renderInterval = null
+
if (this.getInputTrack()) {
this._setOutputTrackEnabled('default', false)
} else {
this._stopBlackVideo()
this._setOutputTrack('default', null)
}
- }, 1000)
+ }, 5000)
}
_stopBlackVideo() {
@@ -144,6 +154,9 @@ export default class BlackVideoEnforcer extends TrackSinkSource {
clearTimeout(this._disableOrRemoveOutputTrackTimeout)
this._disableOrRemoveOutputTrackTimeout = null
+ clearInterval(this._renderInterval)
+ this._renderInterval = null
+
this._outputStream.getTracks().forEach(track => {
this._disableRemoveTrackWhenEnded(track)
diff --git a/src/utils/media/pipeline/BlackVideoEnforcer.spec.js b/src/utils/media/pipeline/BlackVideoEnforcer.spec.js
index 1a83426ce..70c20f1da 100644
--- a/src/utils/media/pipeline/BlackVideoEnforcer.spec.js
+++ b/src/utils/media/pipeline/BlackVideoEnforcer.spec.js
@@ -135,13 +135,14 @@ describe('BlackVideoEnforcer', () => {
afterEach(() => {
clearTimeout(blackVideoEnforcer._disableOrRemoveOutputTrackTimeout)
+ clearInterval(blackVideoEnforcer._renderInterval)
})
afterAll(() => {
jest.restoreAllMocks()
})
- const DISABLE_OR_REMOVE_TIMEOUT = 1000
+ const DISABLE_OR_REMOVE_TIMEOUT = 5000
const STOPPED = true