Skip to content

Commit

Permalink
Implement utility function for making an instance of Array
Browse files Browse the repository at this point in the history
  • Loading branch information
Korilakkuma committed Jun 5, 2018
1 parent 2306a46 commit e131eda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/remux/mp4-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
*/

// import Hex from '../utils/hex';
import makeArrayFromArrayLike from '../utils/make-array-from-array-like';

const UINT32_MAX = Math.pow(2, 32) - 1;

const copyAsArray = typeof Array.from === 'function' ? Array.from : Array.prototype.slice.call;

class MP4 {
static init () {
MP4.types = {
Expand Down Expand Up @@ -336,7 +335,7 @@ class MP4 {
len = data.byteLength;
sps.push((len >>> 8) & 0xFF);
sps.push((len & 0xFF));
sps = sps.concat(copyAsArray(data)); // SPS
sps = sps.concat(makeArrayFromArrayLike(data)); // SPS
}

// assemble the PPSs
Expand All @@ -345,7 +344,7 @@ class MP4 {
len = data.byteLength;
pps.push((len >>> 8) & 0xFF);
pps.push((len & 0xFF));
pps = pps.concat(copyAsArray(data));
pps = pps.concat(makeArrayFromArrayLike(data));
}

let avcc = MP4.box(MP4.types.avcC, new Uint8Array([
Expand Down
5 changes: 5 additions & 0 deletions src/utils/make-array-from-array-like.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const MakeArrayFromArrayLike = typeof Array.from === 'function' ? Array.from : Array.prototype.slice.call;

export default MakeArrayFromArrayLike;

0 comments on commit e131eda

Please sign in to comment.