From cda4e55e4767a170a36ecca441691f09a6f946e4 Mon Sep 17 00:00:00 2001 From: Collin Miller Date: Tue, 27 Feb 2024 22:02:10 -0600 Subject: [PATCH] Adds check to emit fragments on keyframe boundaries when rapAlignement is set --- src/isofile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/isofile.js b/src/isofile.js index a56b4786..cae2d0f7 100644 --- a/src/isofile.js +++ b/src/isofile.js @@ -449,9 +449,11 @@ ISOFile.prototype.processSamples = function(last) { /* The fragment could not be created because the media data is not there (not downloaded), wait for it */ break; } + var nextSample = trak.samples[trak.nextSample]; + var emitForRapBoundary = fragTrak.rapAlignement && nextSample && nextSample.is_sync; /* A fragment is created by sample, but the segment is the accumulation in the buffer of these fragments. It is flushed only as requested by the application (nb_samples) to avoid too many callbacks */ - if (trak.nextSample % fragTrak.nb_samples === 0 || (last || trak.nextSample >= trak.samples.length)) { + if (emitForRapBoundary || trak.nextSample % fragTrak.nb_samples === 0 || (last || trak.nextSample >= trak.samples.length)) { Log.info("ISOFile", "Sending fragmented data on track #"+fragTrak.id+" for samples ["+Math.max(0,trak.nextSample-fragTrak.nb_samples)+","+(trak.nextSample-1)+"]"); Log.info("ISOFile", "Sample data size in memory: "+this.getAllocatedSampleDataSize()); if (this.onSegment) {