Commit c6ed27c1 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

More filter fixes.

parent 8120a307
...@@ -878,16 +878,22 @@ Filter.prototype.draw = function() { ...@@ -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() { ...@@ -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 = { ...@@ -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');
ctx.canvas.width = width; if(ctx.canvas.width !== width || ctx.canvas.height !== height) {
ctx.canvas.height = height; ctx.canvas.width = width;
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 = { ...@@ -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');
ctx.canvas.width = width; if(ctx.canvas.width !== width || ctx.canvas.height !== height) {
ctx.canvas.height = height; ctx.canvas.width = width;
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) { ...@@ -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 => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment