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

More filter fixes.

This commit is contained in:
Juliusz Chroboczek 2021-01-13 17:07:40 +01:00
parent 8120a30725
commit c6ed27c100

View file

@ -878,16 +878,22 @@ Filter.prototype.draw = function() {
this.timer = setInterval(() => this.draw(), 1000 / this.frameRate); this.timer = setInterval(() => this.draw(), 1000 / this.frameRate);
} }
} }
this.count++;
let ok = this.definition.f.call(this, this.video, let ok = false;
try {
ok = this.definition.f.call(this, this.video,
this.video.videoWidth, this.video.videoWidth,
this.video.videoHeight, this.video.videoHeight,
this.context); this.context);
} catch(e) {
console.error(e);
}
if(ok && !this.fixedFramerate) { if(ok && !this.fixedFramerate) {
/** @ts-ignore */ /** @ts-ignore */
this.captureStream.getTracks()[0].requestFrame(); this.captureStream.getTracks()[0].requestFrame();
} }
this.count++;
}; };
Filter.prototype.stop = function() { Filter.prototype.stop = function() {
@ -905,6 +911,8 @@ Filter.prototype.stop = function() {
function setFilter(c, f) { function setFilter(c, f) {
if(!f) { if(!f) {
let filter = c.userdata.filter; let filter = c.userdata.filter;
if(!filter)
return null;
if(!(filter instanceof Filter)) if(!(filter instanceof Filter))
throw new Error('userdata.filter is not a filter'); throw new Error('userdata.filter is not a filter');
if(c.userdata.filter) { if(c.userdata.filter) {
@ -940,8 +948,10 @@ let filters = {
f: function(src, width, height, ctx) { f: function(src, width, height, ctx) {
if(!(ctx instanceof CanvasRenderingContext2D)) if(!(ctx instanceof CanvasRenderingContext2D))
throw new Error('bad context type'); throw new Error('bad context type');
if(ctx.canvas.width !== width || ctx.canvas.height !== height) {
ctx.canvas.width = width; ctx.canvas.width = width;
ctx.canvas.height = height; ctx.canvas.height = height;
}
ctx.scale(-1, 1); ctx.scale(-1, 1);
ctx.drawImage(src, -width, 0); ctx.drawImage(src, -width, 0);
ctx.resetTransform(); ctx.resetTransform();
@ -953,8 +963,10 @@ let filters = {
f: function(src, width, height, ctx) { f: function(src, width, height, ctx) {
if(!(ctx instanceof CanvasRenderingContext2D)) if(!(ctx instanceof CanvasRenderingContext2D))
throw new Error('bad context type'); throw new Error('bad context type');
if(ctx.canvas.width !== width || ctx.canvas.height !== height) {
ctx.canvas.width = width; ctx.canvas.width = width;
ctx.canvas.height = height; ctx.canvas.height = height;
}
ctx.scale(1, -1); ctx.scale(1, -1);
ctx.drawImage(src, 0, -height); ctx.drawImage(src, 0, -height);
ctx.resetTransform(); ctx.resetTransform();
@ -1178,6 +1190,7 @@ async function addFileMedia(file) {
* @param {Stream} c * @param {Stream} c
*/ */
function stopUpMedia(c) { function stopUpMedia(c) {
setFilter(c, null);
if(!c.stream) if(!c.stream)
return; return;
c.stream.getTracks().forEach(t => { c.stream.getTracks().forEach(t => {