OvenPlayer/dist/RTCTransformWorker.worker.worker.js

2 lines
1.8 KiB
JavaScript

!function(){function t(t,r=""){return Array.from(t,(t=>("0"+(255&t).toString(16)).slice(-2))).join(r)}function r(r){const e=t(r);return[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,24),e.slice(24,32)].join("-")}function e(r){const e=t(r);return parseInt(e,16)}function n(t,r){for(;r<t.byteLength-4;){if(0===t[r]&&0===t[r+1]&&(1===t[r+2]||0===t[r+2]&&1===t[r+3]))return r;r+=1}return-1}function a(){return new TransformStream({start(){},flush(){},async transform(a,s){(function(t){let r=0;const e=[];for(;r<t.byteLength-4;){const a=n(t,r);if(!(a>=r))break;{const s=n(t,a+(1===t[a+2]?3:4)+1);if(!(s>a)){e.push(t.subarray(a));break}e.push(t.subarray(a,s)),r=s}}return e})(new Uint8Array(a.data)).forEach((n=>{const a=1===n[2]?3:4;if(6==(31&n[a])){const s=function(t){const r=[];let e=0;const n=128===t[t.length-1]?t.length-1:t.length;for(;e<n;){let n=0;for(;255===t[e];)n+=255,e++;n+=t[e++];let a=0;for(;255===t[e];)a+=255,e++;a+=t[e++];const s=t.slice(e,e+a);return e+=a,r.push({type:n,size:a,payload:s}),{type:n,size:a,payload:s}}return r}(function(t){const r=[];for(let e=0;e<t.length;e++)e>2&&0===t[e-2]&&0===t[e-1]&&3===t[e]||r.push(t[e]);return new Uint8Array(r)}(n.subarray(a+1))),o={nalu:n,sei:s};"464d4c475241494e434f4c4f55524201"===t(s.payload.subarray(0,16))?postMessage({action:"sei",data:{...o,registered:!0,uuid:r(s.payload.subarray(0,16)),timecode:e(s.payload.subarray(16,24)),userdata:s.payload.subarray(24)}}):postMessage({action:"sei",data:{...o,registered:!1}})}})),s.enqueue(a)}})}function s({readable:t,writable:r},e){t.pipeThrough(e).pipeTo(r)}addEventListener("rtctransform",(t=>{s(t.transformer,a())})),addEventListener("message",(t=>{const{action:r}=t.data;"rtctransform"===r&&s(t.data,a())}))}();
//# sourceMappingURL=RTCTransformWorker.worker.worker.js.map