1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-24 17:45:58 +01:00

Split out startup from Filter prototype.

This commit is contained in:
Juliusz Chroboczek 2024-11-16 23:49:49 +01:00
parent 82a94f9500
commit b54119d508

View file

@ -1071,7 +1071,9 @@ function Filter(stream, definition) {
this.userdata = {} this.userdata = {}
/** @type {MediaStream} */ /** @type {MediaStream} */
this.captureStream = this.canvas.captureStream(0); this.captureStream = this.canvas.captureStream(0);
}
Filter.prototype.start = function() {
/** @ts-ignore */ /** @ts-ignore */
if(!this.captureStream.getTracks()[0].requestFrame) { if(!this.captureStream.getTracks()[0].requestFrame) {
console.warn('captureFrame not supported, using fixed framerate'); console.warn('captureFrame not supported, using fixed framerate');
@ -1087,7 +1089,7 @@ function Filter(stream, definition) {
if(t.kind != 'video') if(t.kind != 'video')
this.outputStream.addTrack(t); this.outputStream.addTrack(t);
}); });
this.video.srcObject = stream; this.video.srcObject = this.inputStream;
this.video.muted = true; this.video.muted = true;
this.video.play(); this.video.play();
if(this.definition.init) if(this.definition.init)
@ -1169,6 +1171,7 @@ function setFilter(c) {
return; return;
let filter = new Filter(c.stream, c.userdata.filterDefinition); let filter = new Filter(c.stream, c.userdata.filterDefinition);
filter.start();
c.setStream(filter.outputStream); c.setStream(filter.outputStream);
c.userdata.filter = filter; c.userdata.filter = filter;
} }