Commit a565d55a authored by Linshizhi's avatar Linshizhi

Implement Muxer.

parent 66b85de2
This diff is collapsed.
This diff is collapsed.
let isInited = false;
let isBridged = false;
const SLEEP_INTERVAL = 100;
const SPIN_TIMEOUT = 500;
// Read H264 Encode Group definitions
self.importScripts('/src/workers/defs.js');
// Load wasm encoder
self.importScripts('/src/mp4encoder.js');
createMP4Encoder().then(m => {
encoder = m;
});
// Init // Init
onmessage = e => { onmessage = async e => {
await main(e.data);
}
async function main(msg) {
if (!isEncGrpMsg(msg)) return;
switch (typeOfMsg(msg)) {
case MESSAGE_TYPE.INIT:
if (!isInited) await init();
break;
case MESSAGE_TYPE.BRIDGE:
if (!isBridged) await bridging();
break;
case MESSAGE_TYPE.DATA:
await steps();
break;
case MESSAGE_TYPE.DESTROY:
break;
}
}
async function init(msg) {}
async function bridge(msg) {}
async function steps() {
let timeout = SPIN_TIMEOUT;
src.setPriv(MSG.PRIV_FLAGS.EXECUTING);
while (timeout > 0) {
if (await step() === false && retryCount >= 0) {
timeout -= SLEEP_INTERVAL;
await sleep(SLEEP_INTERVAL);
}
}
src.unsetPriv(MSG.PRIV_FLAGS.EXECUTING);
} }
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