Skip to content

Commit

Permalink
feat: log key id with state
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Jun 15, 2024
1 parent 848ca93 commit bc87a31
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions eme-logger-mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,29 @@
if (pssh) window.postMessage({ type: '38405bbb-36ef-454d-8b32-346f9564c978', log: pssh }, '*');
return _target.apply(_this, _args);
});

function arrayBufferToHex(arrayBuffer) {
if (typeof arrayBuffer !== 'object' || arrayBuffer === null || typeof arrayBuffer.byteLength !== 'number') {
throw new TypeError('Expected input to be an ArrayBuffer');
}
var view = new Uint8Array(arrayBuffer);
var result = '';
var value;
for (var i = 0; i < view.length; i++) {
value = view[i].toString(16);
result += value.length === 1 ? '0' + value : value;
}
return result;
}

proxy(MediaKeySession.prototype, 'update', async (_target, _this, _args) => {
setTimeout(() => {
const statuses = Array.from(_this.keyStatuses);
for (const [kidBuffer, state] of statuses) {
const kid = arrayBufferToHex(kidBuffer);
console.log(`KID:STATE -> ${kid}:${state}`);
}
}, 3000);
return _target.apply(_this, _args);
});
})();
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Streamyx",
"version": "0.0.3",
"version": "0.0.4",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
Expand Down

0 comments on commit bc87a31

Please sign in to comment.