Skip to content

Commit

Permalink
fix: on flush if a pmt has not been emitted and we have one, emit it (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jun 24, 2021
1 parent f7d0a5b commit 67b4aab
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/m2ts/m2ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ TransportParseStream.STREAM_TYPES = {
ElementaryStream = function() {
var
self = this,
segmentHadPmt = false,
// PES packet fragments
video = {
data: [],
Expand Down Expand Up @@ -488,6 +489,8 @@ ElementaryStream = function() {
});
}

segmentHadPmt = true;

self.trigger('data', event);
}
})[data.type]();
Expand Down Expand Up @@ -519,6 +522,42 @@ ElementaryStream = function() {
};

this.flush = function() {
// if on flush we haven't had a pmt emitted
// and we have a pmt to emit. emit the pmt
// so that we trigger a trackinfo downstream.
if (!segmentHadPmt && programMapTable) {
var
pmt = {
type: 'metadata',
tracks: []
};
// translate audio and video streams to tracks
if (programMapTable.video !== null) {
pmt.tracks.push({
timelineStartInfo: {
baseMediaDecodeTime: 0
},
id: +programMapTable.video,
codec: 'avc',
type: 'video'
});
}

if (programMapTable.audio !== null) {
pmt.tracks.push({
timelineStartInfo: {
baseMediaDecodeTime: 0
},
id: +programMapTable.audio,
codec: 'adts',
type: 'audio'
});
}

self.trigger('data', pmt);
}

segmentHadPmt = false;
this.flushStreams_();
this.trigger('done');
};
Expand Down

0 comments on commit 67b4aab

Please sign in to comment.