Skip to content

Commit

Permalink
demuxer/remuxer: reduce nb of args of demuxer.append()
Browse files Browse the repository at this point in the history
  • Loading branch information
mangui committed Feb 15, 2017
1 parent 0125f4e commit aa78ffc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 33 deletions.
13 changes: 5 additions & 8 deletions src/demux/aacdemuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import ID3 from '../demux/id3';
this.remuxer = remuxer;
}

resetInitSegment() {
this._aacTrack = {container : 'audio/adts', type: 'audio', id :-1, sequenceNumber: 0, isAAC : true , samples : [], len : 0};
resetInitSegment(initSegment,level,sn,audioCodec,videoCodec, duration) {
this._aacTrack = {container : 'audio/adts', type: 'audio', id :-1, sequenceNumber: 0, isAAC : true , samples : [], len : 0, manifestCodec : audioCodec, duration : duration};
}

//
resetTimeStamp() {
}

Expand All @@ -39,7 +38,7 @@ import ID3 from '../demux/id3';


// feed incoming data to the front of the parsing pipeline
push(data, initSegment, audioCodec, videoCodec, timeOffset, cc, level, sn, contiguous, duration,accurateTimeOffset, defaultInitPTS) {
append(data, timeOffset, cc, level, sn, contiguous,accurateTimeOffset) {
var track,
id3 = new ID3(data),
pts = 90*id3.timeStamp,
Expand All @@ -55,13 +54,11 @@ import ID3 from '../demux/id3';
}

if (!track.audiosamplerate) {
config = ADTS.getAudioConfig(this.observer,data, offset, audioCodec);
config = ADTS.getAudioConfig(this.observer,data, offset, track.manifestCodec);
track.config = config.config;
track.audiosamplerate = config.samplerate;
track.channelCount = config.channelCount;
track.codec = config.codec;
track.manifestCodec = config.manifestCodec;
track.duration = duration;
logger.log(`parsed codec:${track.codec},rate:${config.samplerate},nb channel:${config.channelCount}`);
}
frameIndex = 0;
Expand Down Expand Up @@ -94,7 +91,7 @@ import ID3 from '../demux/id3';
break;
}
}
this.remuxer.remux(level, sn , cc, track,{samples : []}, {samples : [ { pts: pts, dts : pts, unit : id3.payload} ]}, { samples: [] }, timeOffset, contiguous,accurateTimeOffset, defaultInitPTS);
this.remuxer.remux(level, sn , cc, track,{samples : []}, {samples : [ { pts: pts, dts : pts, unit : id3.payload} ]}, { samples: [] }, timeOffset, contiguous,accurateTimeOffset);
}

destroy() {
Expand Down
10 changes: 5 additions & 5 deletions src/demux/demuxer-inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ class DemuxerInline {
const remuxer = this.remuxer;
if (cc !== this.lastCC) {
logger.log(`${id}:discontinuity detected`);
demuxer.resetInitSegment(initSegment,level,sn,audioCodec,videoCodec);
demuxer.resetInitSegment(initSegment,level,sn,audioCodec,videoCodec,duration);
remuxer.resetInitSegment();
demuxer.resetTimeStamp();
remuxer.resetTimeStamp();
remuxer.resetTimeStamp(defaultInitPTS);
this.lastCC = cc;
}
if (level !== this.lastLevel) {
logger.log(`${id}:level switch detected`);
demuxer.resetInitSegment(initSegment,level,sn,audioCodec,videoCodec);
logger.log(`${id}:switch detected`);
demuxer.resetInitSegment(initSegment,level,sn,audioCodec,videoCodec,duration);
remuxer.resetInitSegment();
this.lastLevel = level;
} else if (sn === (this.lastSN+1)) {
contiguous = true;
}
this.lastSN = sn;
this.cc = cc;
demuxer.push(data,initSegment,audioCodec,videoCodec,timeOffset,cc,level,sn,contiguous, duration,accurateTimeOffset,defaultInitPTS);
demuxer.append(data,timeOffset,cc,level,sn,contiguous,accurateTimeOffset);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/demux/mp4demuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import Event from '../events';

}

resetInitSegment(initSegment,level,sn,audioCodec,videoCodec) {
resetInitSegment(initSegment,level,sn,audioCodec,videoCodec, duration) {
//jshint unused:false
const initData = this.initData = MP4Demuxer.parseInitSegment(initSegment);
var tracks = {};
if (initData.audio) {
Expand Down Expand Up @@ -210,10 +211,10 @@ static startDTS(initData, fragment) {
}

// feed incoming data to the front of the parsing pipeline
push(data, initSegment, audioCodec, videoCodec, timeOffset, cc, level, sn, contiguous, duration,accurateTimeOffset, defaultInitPTS) {
append(data, timeOffset, cc, level, sn, contiguous,accurateTimeOffset) {
const initData = this.initData;
const startDTS = MP4Demuxer.startDTS(initData,data);
this.remuxer.remux(level, sn , cc, initData.audio, initData.video, null, null, startDTS, contiguous,accurateTimeOffset, defaultInitPTS,data);
this.remuxer.remux(level, sn , cc, initData.audio, initData.video, null, null, startDTS, contiguous,accurateTimeOffset,data);
}

destroy() {
Expand Down
15 changes: 6 additions & 9 deletions src/demux/tsdemuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
}

resetInitSegment() {
resetInitSegment(initSegment,level,sn,audioCodec,videoCodec, duration) {
this.pmtParsed = false;
this._pmtId = -1;
this._avcTrack = {container : 'video/mp2t', type: 'video', id :-1, sequenceNumber: 0, samples : [], len : 0, dropped : 0};
Expand All @@ -46,22 +46,19 @@
this.aacOverFlow = null;
this.aacLastPTS = null;
this.avcSample = null;
this.audioCodec = audioCodec;
this.videoCodec = videoCodec;
this._duration = duration;
}

resetTimeStamp() {
}

// feed incoming data to the front of the parsing pipeline
push(data, initSegment, audioCodec, videoCodec, timeOffset, cc, level, sn, contiguous, duration,accurateTimeOffset,defaultInitPTS) {
append(data, timeOffset, cc, level, sn, contiguous,accurateTimeOffset) {
var start, len = data.length, stt, pid, atf, offset,pes,
unknownPIDs = false;

this.audioCodec = audioCodec;
this.videoCodec = videoCodec;
this._duration = duration;
this.contiguous = contiguous;


var pmtParsed = this.pmtParsed,
avcTrack = this._avcTrack,
audioTrack = this._audioTrack,
Expand Down Expand Up @@ -220,7 +217,7 @@
// either id3Data null or PES truncated, keep it for next frag parsing
id3Track.pesData = id3Data;
}
this.remuxer.remux(level, sn, cc, audioTrack, avcTrack, id3Track, this._txtTrack, timeOffset, contiguous, accurateTimeOffset, defaultInitPTS);
this.remuxer.remux(level, sn, cc, audioTrack, avcTrack, id3Track, this._txtTrack, timeOffset, contiguous, accurateTimeOffset);
}

destroy() {
Expand Down
10 changes: 3 additions & 7 deletions src/remux/mp4-remuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,22 @@ class MP4Remuxer {
destroy() {
}

resetTimeStamp() {
this._initPTS = this._initDTS = undefined;
resetTimeStamp(defaultTimeStamp) {
this._initPTS = this._initDTS = defaultTimeStamp;
}

resetInitSegment() {
this.ISGenerated = false;
}

remux(level,sn,cc,audioTrack,videoTrack,id3Track,textTrack,timeOffset, contiguous,accurateTimeOffset,defaultInitPTS) {
remux(level,sn,cc,audioTrack,videoTrack,id3Track,textTrack,timeOffset, contiguous,accurateTimeOffset) {
this.level = level;
this.sn = sn;
// generate Init Segment if needed
if (!this.ISGenerated) {
this.generateIS(audioTrack,videoTrack,timeOffset,cc);
}

if((defaultInitPTS!==null)){
this._initPTS=this._initDTS= defaultInitPTS;
}

if (this.ISGenerated) {
// Purposefully remuxing audio before video, so that remuxVideo can use nextAudioPts, which is
// calculated in remuxAudio.
Expand Down
2 changes: 1 addition & 1 deletion src/remux/passthrough-remuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PassThroughRemuxer {
resetInitSegment() {
}

remux(level,sn,cc,audioTrack,videoTrack,id3Track,textTrack,timeOffset, contiguous,accurateTimeOffset,defaultInitPTS,rawData) {
remux(level,sn,cc,audioTrack,videoTrack,id3Track,textTrack,timeOffset, contiguous,accurateTimeOffset,rawData) {
var observer = this.observer;
var streamType = '';
if (audioTrack) {
Expand Down

0 comments on commit aa78ffc

Please sign in to comment.