(map)
| 250 | } |
| 251 | |
| 252 | _addVideoLayer(map) { |
| 253 | let url = this.videoDomId || this.url; |
| 254 | const extent = this.extent || this.timeParams[0].extent; |
| 255 | const poly = polygon([ |
| 256 | [...extent, extent[0]] |
| 257 | ]); |
| 258 | let result = bbox(poly); |
| 259 | let that = this; |
| 260 | let srcPixelCoords = [0, 0, that.videoWidth, 0, that.videoWidth, that.videoHeight, 0, that.videoHeight]; |
| 261 | if (this.clipRegion.length) { |
| 262 | srcPixelCoords = []; |
| 263 | this.clipRegion.forEach((coord) => { |
| 264 | srcPixelCoords.push(coord[0]); |
| 265 | srcPixelCoords.push(coord[1]); |
| 266 | }); |
| 267 | } |
| 268 | let srcTri = this.cv.matFromArray(4, 1, this.cv.CV_32FC2, |
| 269 | srcPixelCoords |
| 270 | ); |
| 271 | that.dsize = that.timeParams[that.beginIndex].dsize; |
| 272 | let dstTri = that.timeParams[that.beginIndex].dstTri; |
| 273 | let canvas = document.createElement('canvas'); |
| 274 | let { clipMat, dst1 } = this._updateMask(canvas, that.timeParams[that.beginIndex].realHeight, that.timeParams[that.beginIndex].ratio); |
| 275 | let count = 0; |
| 276 | const videoEle = this.video.tech().el(); |
| 277 | let current = 0; |
| 278 | if (this.videoParameters.length > 1 && videoEle && videoEle.requestVideoFrameCallback) { |
| 279 | const updateCanvas = (now, metadata) => { |
| 280 | current = metadata.mediaTime; |
| 281 | videoEle.requestVideoFrameCallback(updateCanvas); |
| 282 | }; |
| 283 | |
| 284 | videoEle.requestVideoFrameCallback(updateCanvas); |
| 285 | } |
| 286 | map.addSource(this.layerId, { |
| 287 | type: 'video', |
| 288 | urls: [url], |
| 289 | drawImageCallback(frame) { |
| 290 | if (that.videoParameters.length > 1) { |
| 291 | let time = current || that.video.currentTime(); |
| 292 | let res = that.finder.findNearest(time); |
| 293 | if (res) { |
| 294 | count = res.value; |
| 295 | } |
| 296 | |
| 297 | if (count) { |
| 298 | let curData = that.timeParams[count]; |
| 299 | count = 0; |
| 300 | if (curData) { |
| 301 | that.dsize = curData.dsize; |
| 302 | dstTri = curData.dstTri; |
| 303 | result = curData.result; |
| 304 | setTimeout(() => { |
| 305 | that.map.getSource(that.layerId).setCoordinates([ |
| 306 | [result[0], result[3]], |
| 307 | [result[2], result[3]], |
| 308 | [result[2], result[1]], |
| 309 | [result[0], result[1]] |
no test coverage detected