const StageLayering = require('../engine/stage-layering'); class Video { constructor (runtime) { this.runtime = runtime; /** * @typedef VideoProvider * @property {Function} enableVideo - Requests camera access from the user, and upon success, * enables the video feed * @property {Function} disableVideo - Turns off the video feed * @property {Function} getFrame - Return frame data from the video feed in * specified dimensions, format, and mirroring. */ this.provider = null; /** * Id representing a Scratch Renderer skin the video is rendered to for * previewing. * @type {number} */ this._skinId = -1; /** * The Scratch Renderer Skin object. * @type {Skin} */ this._skin = null; /** * Id for a drawable using the video's skin that will render as a video * preview. * @type {Drawable} */ this._drawable = -1; /** * Store the last state of the video transparency ghost effect * @type {number} */ this._ghost = 0; } static get FORMAT_IMAGE_DATA () { return 'image-data'; } static get FORMAT_CANVAS () { return 'canvas'; } /** * Dimensions the video stream is analyzed at after its rendered to the * sample canvas. * @type {Array.} */ static get DIMENSIONS () { return [480, 360]; } /** * Order preview drawable is inserted at in the renderer. * @type {number} */ static get ORDER () { return 1; } /** * Set a video provider for this device. A default implementation of * a video provider can be found in scratch-gui/src/lib/video/video-provider * @param {VideoProvider} provider - Video provider to use */ setProvider (provider) { this.provider = provider; } /** * Request video be enabled. Sets up video, creates video skin and enables preview. * * ioDevices.video.requestVideo() * * @return {Promise.