Skip to content

Commit

Permalink
use map instead of forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Jan 23, 2023
1 parent f575b2a commit 92a9243
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/mp4/probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,22 +377,15 @@ getTracks = function(init) {
*/
getEmsgID3 = function(segmentData, ptOffset = 0) {
var emsgBoxes = findBox(segmentData, ['emsg']);
var emsgID3Data = [];
emsgBoxes.forEach(function(data) {
var boxData = new Uint8Array(data);
var parsedBox = emsg.parseEmsgBox(boxData);
var pts = emsg.scaleTime(parsedBox.presentation_time,
parsedBox.timescale,
parsedBox.presentation_time_delta,
ptOffset);
var duration = emsg.scaleTime(parsedBox.event_duration, parsedBox.timescale);
emsgID3Data.push({
pts,
duration,
data: parsedBox.message_data,
});
return emsgBoxes.map((data) => {
var boxData = new Uint8Array(data);
var parsedBox = emsg.parseEmsgBox(boxData);
return {
pts: emsg.scaleTime(parsedBox.presentation_time, parsedBox.timescale, parsedBox.presentation_time_delta, ptOffset),
duration: emsg.scaleTime(parsedBox.event_duration, parsedBox.timescale),
data: parsedBox.message_data
};
});
return emsgID3Data;
};

module.exports = {
Expand Down

0 comments on commit 92a9243

Please sign in to comment.