mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Allow filters to maintain state.
This commit is contained in:
parent
769c698894
commit
2eb61d877f
1 changed files with 8 additions and 0 deletions
|
@ -800,6 +800,8 @@ async function setMaxVideoThroughput(c, bps) {
|
||||||
* @property {string} [description]
|
* @property {string} [description]
|
||||||
* @property {string} [contextType]
|
* @property {string} [contextType]
|
||||||
* @property {Object} [contextAttributes]
|
* @property {Object} [contextAttributes]
|
||||||
|
* @property {(this: Filter, ctx: RenderingContext) => void} [init]
|
||||||
|
* @property {(this: Filter) => void} [cleanup]
|
||||||
* @property {(this: Filter, src: CanvasImageSource, width: number, height: number, ctx: RenderingContext) => boolean} f
|
* @property {(this: Filter, src: CanvasImageSource, width: number, height: number, ctx: RenderingContext) => boolean} f
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -838,6 +840,8 @@ function Filter(stream, definition) {
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
this.fixedFramerate = false;
|
this.fixedFramerate = false;
|
||||||
|
/** @type {Object} */
|
||||||
|
this.userdata = {}
|
||||||
|
|
||||||
/** @ts-ignore */
|
/** @ts-ignore */
|
||||||
this.captureStream = this.canvas.captureStream(0);
|
this.captureStream = this.canvas.captureStream(0);
|
||||||
|
@ -859,6 +863,8 @@ function Filter(stream, definition) {
|
||||||
this.video.srcObject = stream;
|
this.video.srcObject = stream;
|
||||||
this.video.muted = true;
|
this.video.muted = true;
|
||||||
this.video.play();
|
this.video.play();
|
||||||
|
if(this.definition.init)
|
||||||
|
this.definition.init.call(this, this.context);
|
||||||
this.timer = setInterval(() => this.draw(), 1000 / this.frameRate);
|
this.timer = setInterval(() => this.draw(), 1000 / this.frameRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,6 +908,8 @@ Filter.prototype.stop = function() {
|
||||||
this.captureStream.getTracks()[0].stop();
|
this.captureStream.getTracks()[0].stop();
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
|
if(this.definition.cleanup)
|
||||||
|
this.definition.cleanup.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue