Skip to content

Commit

Permalink
ie 11 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Dec 4, 2020
1 parent 54090c7 commit 72d581a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
18 changes: 12 additions & 6 deletions src/byte-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@ export const toUint8 = function(bytes) {

export const toHexString = function(bytes) {
bytes = toUint8(bytes);
let str = '';

return bytes.reduce(function(acc, b) {
return acc + padStart(b.toString(16), 2, '0');
}, '');
for (let i = 0; i < bytes.length; i++) {
str += padStart(bytes[i].toString(16), 2, '0');
}

return str;
};

export const toBinaryString = function(bytes) {
bytes = toUint8(bytes);
let str = '';

for (let i = 0; i < bytes.length; i++) {
str += padStart(bytes[i].toString(2), 8, '0');
}

return bytes.reduce(function(acc, b) {
return acc + padStart(b.toString(2), 8, '0');
}, '');
return str;
};
const BigInt = window.BigInt || Number;

Expand Down
16 changes: 9 additions & 7 deletions src/codec-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ export const getHvcCodec = function(bytes) {

codec += levelId;

const constraints = constraintIds.reduce((acc, v) => {
let constraints = '';

for (let i = 0; i < constraintIds.length; i++) {
const v = constraintIds[i];

if (v) {
if (acc) {
acc += '.';
if (constraints) {
constraints += '.';
}
acc += v.toString(16);
constraints += v.toString(16);
}

return acc;
}, '');
}

if (constraints) {
codec += `.${constraints}`;
Expand Down
4 changes: 2 additions & 2 deletions test/container.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ const h265seq = toUint8([
0x00, 0x00, 0x00, 0x01
]);

const h264shortnal = Array.prototype.slice.call(testData.h264.slice());
const h264shortnal = Array.prototype.slice.call(testData.h264);

// remove 0x00 from the front
h264shortnal.splice(0, 1);
// remove 0x00 from the back
h264shortnal.splice(h264shortnal.length - 2, 1);

const h265shortnal = Array.prototype.slice.call(testData.h265.slice());
const h265shortnal = Array.prototype.slice.call(testData.h265);

// remove 0x00 from the front
h265shortnal.splice(0, 1);
Expand Down

0 comments on commit 72d581a

Please sign in to comment.