Best JavaScript code snippet using wpt
DecodeWorker.js
Source:DecodeWorker.js
...143144 while (bOpenMode && bOpenStream)145 {146 //console.log("DecodeWorker-InputData-getFrameData 3-1 sysTime:"+ (new Date().getMonth()+1) + "-" + new Date().getDate() + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + "." + new Date().getMilliseconds());147 var ret = getFrameData(funGetFrameData);148 //console.log("DecodeWorker-InputData-getFrameData 3-2 sysTime:"+ (new Date().getMonth()+1) + "-" + new Date().getDate() + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + "." + new Date().getMilliseconds()+",ret:"+ret);149 // var ret = getFrameData();150151 // ç´å°è·åè§é¢å¸§ææ°æ®ä¸è¶³ä¸ºæ¢152 if (PLAYM4_VIDEO_FRAME === ret || PLAYM4_NEED_MORE_DATA === ret)153 {154 break;155 }156 }157 break;158159 case "SetSecretKey":160 var keyLen = eventData.nKeyLen;161 var pKeyData = Module._malloc(keyLen);162 if (pKeyData === null) {163 return;164 }165 var nKeySize = eventData.data.length166 var bufData = stringToBytes (eventData.data);167 var aKeyData = Module.HEAPU8.subarray(pKeyData, pKeyData + keyLen);168 aKeyData.set(new Uint8Array(bufData));169170 res = Module._SetSecretKey(eventData.nKeyType, pKeyData, keyLen, nKeySize);171 if (res !== HK_TRUE) {172 postMessage({'function': "SetSecretKey", 'errorCode': res});173 Module._free(pKeyData);174 pKeyData = null;175 return;176 }177178 Module._free(pKeyData);179 pKeyData = null;180 break;181182 case "GetBMP":183 var nBMPWidth = eventData.width;184 var nBMPHeight = eventData.height;185 var pYUVData = eventData.data;186 var nYUVSize = nBMPWidth * nBMPHeight * 3 / 2;187 var oBMPCropRect = eventData.rect;188189 var pDataYUV = Module._malloc(nYUVSize);190 if (pDataYUV === null) {191 return;192 }193194 Module.writeArrayToMemory(new Uint8Array(pYUVData, 0, nYUVSize), pDataYUV);195196 // åé
BMP空é´197 var nBmpSize = nBMPWidth * nBMPHeight * 4 + 60;198 var pBmpData = Module._malloc(nBmpSize);199 var pBmpSize = Module._malloc(4);200 if (pBmpData === null || pBmpSize === null) {201 Module._free(pDataYUV);202 pDataYUV = null;203204 if (pBmpData != null) {205 Module._free(pBmpData);206 pBmpData = null;207 }208209 if (pBmpSize != null) {210 Module._free(pBmpSize);211 pBmpSize = null;212 }213 return;214 }215216 Module._memset(pBmpSize, nBmpSize, 4); // é²æ¢bmpæªå¾åºç°è¾å
¥æ°æ®è¿å¤§çé误ç 217218 res = Module._GetBMP(pDataYUV, nYUVSize, pBmpData, pBmpSize,219 oBMPCropRect.left, oBMPCropRect.top, oBMPCropRect.right, oBMPCropRect.bottom);220 if (res !== HK_TRUE) {221 postMessage({'function': "GetBMP", 'errorCode': res});222 Module._free(pDataYUV);223 pDataYUV = null;224 Module._free(pBmpData);225 pBmpData = null;226 Module._free(pBmpSize);227 pBmpSize = null;228 return;229 }230231 // è·åBMPå¾ç大å°232 var nBmpDataSize = Module.getValue(pBmpSize, "i32");233234 // è·åBMPå¾çæ°æ®235 var aBmpData = new Uint8Array(nBmpDataSize);236 aBmpData.set(Module.HEAPU8.subarray(pBmpData, pBmpData + nBmpDataSize));237238 postMessage({'function': "GetBMP", 'data': aBmpData, 'errorCode': res}, [aBmpData.buffer]);239240 if (pDataYUV != null) {241 Module._free(pDataYUV);242 pDataYUV = null;243 }244 if (pBmpData != null) {245 Module._free(pBmpData);246 pBmpData = null;247 }248 if (pBmpSize != null) {249 Module._free(pBmpSize);250 pBmpSize = null;251 }252 break;253254 case "GetJPEG":255 var nJpegWidth = eventData.width;256 var nJpegHeight = eventData.height;257 var pYUVData1 = eventData.data;258 var nYUVSize1 = nJpegWidth * nJpegHeight * 3 / 2;259 var oJpegCropRect = eventData.rect;260261 var pDataYUV1 = Module._malloc(nYUVSize1);262 if (pDataYUV1 === null) {263 return;264 }265266 Module.writeArrayToMemory(new Uint8Array(pYUVData1, 0, nYUVSize1), pDataYUV1);267268 // åé
JPEG空é´269 var pJpegData = Module._malloc(nYUVSize1);270 var pJpegSize = Module._malloc(4);271 if (pJpegData === null || pJpegSize === null) {272 if (pJpegData != null) {273 Module._free(pJpegData);274 pJpegData = null;275 }276277 if (pJpegSize != null) {278 Module._free(pJpegSize);279 pJpegSize = null;280 }281282 if (pDataYUV1 != null) {283 Module._free(pDataYUV1);284 pDataYUV1 = null;285 }286 return;287 }288289 Module.setValue(pJpegSize, nJpegWidth * nJpegHeight * 2, "i32"); // JPEGæå¾ï¼è¾å
¥ç¼å²é¿åº¦ä¸å°äºå½å帧YUV大å°290291 res = Module._GetJPEG(pDataYUV1, nYUVSize1, pJpegData, pJpegSize,292 oJpegCropRect.left, oJpegCropRect.top, oJpegCropRect.right, oJpegCropRect.bottom);293 if (res !== HK_TRUE) {294 postMessage({'function': "GetJPEG", 'errorCode': res});295 if (pJpegData != null) {296 Module._free(pJpegData);297 pJpegData = null;298 }299300 if (pJpegSize != null) {301 Module._free(pJpegSize);302 pJpegSize = null;303 }304305 if (pDataYUV1 != null) {306 Module._free(pDataYUV1);307 pDataYUV1 = null;308 }309 return;310 }311312 // è·åJPEGå¾ç大å°313 var nJpegSize = Module.getValue(pJpegSize, "i32");314315 // è·åJPEGå¾çæ°æ®316 var aJpegData = new Uint8Array(nJpegSize);317 aJpegData.set(Module.HEAPU8.subarray(pJpegData, pJpegData + nJpegSize));318319 postMessage({'function': "GetJPEG", 'data': aJpegData, 'errorCode': res}, [aJpegData.buffer]);320321 ajpegSizeData = null;322 aJpegData = null;323324 if (pDataYUV1 != null) {325 Module._free(pDataYUV1);326 pDataYUV1 = null;327 }328 if (pJpegData != null) {329 Module._free(pJpegData);330 pJpegData = null;331 }332 if (pJpegSize != null) {333 Module._free(pJpegSize);334 pJpegSize = null;335 }336 break;337338 case "SetDecodeFrameType":339 var nFrameType = eventData.data;340 res = Module._SetDecodeFrameType(nFrameType);341 if (res !== HK_TRUE) {342 postMessage({'function': "SetDecodeFrameType", 'errorCode': res});343 return;344 }345 break;346347 case "DisplayRegion":348 var nRegionNum = eventData.nRegionNum;349 var srcRect = eventData.srcRect;350 var hDestWnd = eventData.hDestWnd;351 var bEnable = eventData.bEnable;352353 res = Module._SetDisplayRegion(nRegionNum, srcRect, hDestWnd, bEnable);354 if (res !== HK_TRUE) {355 postMessage({'function': "DisplayRegion", 'errorCode': res});356 return;357 }358 break;359360 case "CloseStream":361 res = Module._CloseStream();362 if (res !== HK_TRUE) {363 postMessage({'function': "CloseStream", 'errorCode': res});364 return;365 }366 break;367368 case "SetIFrameDecInterval":369 Module._SetIFrameDecInterval(eventData.data);370 break;371372 default:373 break;374 }375 };376377 function getOSDTime(oFrameInfo) {378 var iYear = oFrameInfo.year;379 var iMonth = oFrameInfo.month;380 var iDay = oFrameInfo.day;381 var iHour = oFrameInfo.hour;382 var iMinute = oFrameInfo.minute;383 var iSecond = oFrameInfo.second;384385 if (iMonth < 10) {386 iMonth = "0" + iMonth;387 }388 if (iDay < 10) {389 iDay = "0" + iDay;390 }391 if (iHour < 10) {392 iHour = "0" + iHour;393 }394 if (iMinute < 10) {395 iMinute = "0" + iMinute;396 }397 if (iSecond < 10) {398 iSecond = "0" + iSecond;399 }400401 return iYear + "-" + iMonth + "-" + iDay + " " + iHour + ":" + iMinute + ":" + iSecond;402 }403404 // è·å帧æ°æ®405 function getFrameData(fun)406 {407 // function getFrameData() {408 // è·å帧æ°æ®409 // var res = Module._GetFrameData();410 var res = fun();411412 if (res === HK_TRUE)413 {414 var oFrameInfo = Module._GetFrameInfo();415 //console.log("")416 //console.log("getFrameData-ok:%d %d %d %d %d %d \n", oFrameInfo.year, oFrameInfo.month, oFrameInfo.day, oFrameInfo.hour, oFrameInfo.minute, oFrameInfo.second);417418 switch (oFrameInfo.frameType)419 {420 case AUDIO_TYPE:421 var iSize = oFrameInfo.frameSize;
...
index.ts
Source:index.ts
...295 const frameBuffer = buffer.slice(startOfFrame);296 if (isPadding(frameBuffer)) {297 break;298 }299 const frame = getFrameData(frameBuffer);300 if (this.frames[frame.name]) {301 if (!Array.isArray(this.frames[frame.name])) {302 this.frames[frame.name] = [this.frames[frame.name] as FrameData];303 }304 (this.frames[frame.name] as FrameData[]).push(frame);305 } else {306 this.frames[frame.name] = frame;307 }308 startOfFrame += ID3FrameOffsets.END_OF_HEADER + frame.length;309 }310 }311 private getFrameData(name: string): any {312 const frame = this.frames[name];313 if (Array.isArray(frame)) {314 return frame.map(entry => entry.data);315 }316 return frame ? frame.data : undefined;317 }318 get ufid(): { ownerIdentifier: string; identifier: Buffer } {319 return this.getFrameData('UFID');320 }321 get genre(): string {322 let genre = this.getFrameData('TCON') as string;323 if (genre) {324 const idx = parseInt(genre.replace(/[\(\)]/g, ''), 10);325 if (idx <= ID3v1Genres.length) {326 genre = ID3v1Genres[idx];327 }328 }329 return genre;330 }331 get track(): string {332 return this.getFrameData('TRCK');333 }334 get album(): string {335 return this.getFrameData('TALB');336 }337 get title(): string {338 return this.getFrameData('TIT2');339 }340 get year(): string {341 return this.getFrameData('TDRC') || this.getFrameData('TYER');342 }343 get artist(): string {344 return this.getFrameData('TPE1');345 }346 get popularimeter(): { email: string; rating: number; counter?: number } {347 return this.getFrameData('POPM');348 }349 get length(): string {350 return this.getFrameData('TLEN');351 }352 get set(): string {353 return this.getFrameData('TPOS');354 }355 get text():356 | { description: string; value: string }357 | { description: string; value: string }[] {358 return this.getFrameData('TXXX');359 }...
connector.js
Source:connector.js
...49};505152Connector.prototype.thisFrame = function(f) {53 var tf = this.getFrameData();54 return tf.number == f.number || (tf.name.length && tf.name == f.name);55};565758// handle incoming messages59Connector.prototype.handleMessage = function(msg, callback) {60 if (msg._frame && !this.thisFrame(msg._frame)) 61 return;62 if (msg.topic in this.handlers)63 this.handlers[msg.topic].forEach( function(handler) {64 handler(msg.data, callback);65 });66};6768Connector.prototype.onMessage = function(msg, sendResponse) {69 if (msg._frame && !this.thisFrame(msg._frame))70 return;71 if (this.message_handlers.has(msg.topic))72 this.message_handlers.get(msg.topic)(msg.data, sendResponse);73}747576// register handlers for specific messages77// callback's prototype is function(msg)78Connector.prototype.registerHandler = function(topic, handler) {79 if (!(topic in this.handlers))80 this.handlers[topic] = new Array();81 this.handlers[topic].push(handler);82};8384Connector.prototype.addHandler = function(topic, handler) {85 console.assert(!this.message_handlers.has(topic), "addHandler, topic "+86 topic+" already has handler");87 this.message_handlers.set(topic, handler);88}8990// remove specified handler91Connector.prototype.unregisterHandler = function(topic, callback) {92 var i = this.handlers[topic].indexOf(handler);93 if ( i != -1 )94 this.handlers[topic].splice(i, 1);95};9697Connector.prototype.removeHandler = function(topic) {98 if (!this.message_handlers.has(topic))99 return;100 this.message_handlers.delete(topic);101};102103104// post message to extension script105Connector.prototype.postMessage = function(topic, data, callback) {106 if (data) {107 data._frame = this.getFrameData();108 } else {109 data = {_frame: this.getFrameData()};110 }111112 if (callback)113 chrome.extension.sendRequest({topic: topic, data: data}, callback);114 else115 chrome.extension.sendRequest({topic: topic, data: data});116};117118Connector.prototype.sendMessage = function(topic, data) {119 if (data) {120 data._frame = this.getFrameData();121 } else {122 data = {_frame: this.getFrameData()};123 }124 125 return new Promise(function(resolve, reject) {126 chrome.runtime.sendMessage(127 {topic: topic, data: data},128 function(data) {129 if (chrome.runtime.lastError)130 reject(chrome.runtime.lastError);131 else132 resolve(data);133 });134 });135};136
...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getFrameData('160422_9A_1R5', function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9wpt.getLocations(function(err, data) {10 if (err) return console.error(err);11 console.log(data);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15wpt.getLocations(function(err, data) {16 if (err) return console.error(err);17 console.log(data);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getTesters(function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getTestStatus('160422_9A_1R5', function(err, data) {28 if (err) return console.error(err);29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');
Using AI Code Generation
1var frameData = wptbPreviewFrame.getFrameData();2console.log(frameData);3### Using wptbPreviewFrame.getFrameData() method4### Using wptbPreviewFrame.setData() method5### Using wptbPreviewFrame.setHtml() method6### Using wptbPreviewFrame.setTable() method7- `table` (object) - Object with the following properties:8### Using wptbPreviewFrame.setTableFromHtml() method9### Using wptbPreviewFrame.setTableFromData() method10### Using wptbPreviewFrame.setTableFromWptbId() method11The `wptbPreviewFrame.setTableFromWptbId()` method is used to set the HTML code and data of the table in the preview frame based on the `
Using AI Code Generation
1function test() {2 var el = document.getElementById('wptb-element-draggable-1');3 var frameData = el.getFrameData();4 console.log(frameData);5}6### 2.2.2 getFrameData() method7{8}9### 2.2.3 getFrameData() method example10function test() {11 var el = document.getElementById('wptb-element-draggable-1');12 var frameData = el.getFrameData();13 console.log(frameData);14}15### 2.2.4 getFrameData() method example16function test() {17 var el = document.getElementById('wptb-element-draggable-1');18 var frameData = el.getFrameData();19 console.log(frameData);20}21### 2.2.5 getFrameData() method example22function test() {23 var el = document.getElementById('wptb-element-draggable-1');24 var frameData = el.getFrameData();25 console.log(frameData);26}27### 2.2.6 getFrameData() method example
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getFrameData("170308_5E_1e4e4b4c7d4f9f4e7c4f3e8f3e3e3b4", function(err, data) {4 if (err) return console.error(err);5 console.log(data.data);6});
Using AI Code Generation
1var wpt = require('webpagetest');2var wptdriver = new wpt('www.webpagetest.org');3wptdriver.getTestResults('170202_7P_6c5f6d5c6a1ebf7a0c8a1d7d0c9f3f0a', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!