hls.js 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -135,5 +135,5 @@
135
135
  "url-toolkit": "2.2.5",
136
136
  "wrangler": "3.114.9"
137
137
  },
138
- "version": "1.6.3"
138
+ "version": "1.6.4"
139
139
  }
@@ -723,68 +723,68 @@ export function getSampleData(
723
723
  const sampleCount = readUint32(trun, 4);
724
724
  const sampleIndex = trackTimes.sampleCount;
725
725
  trackTimes.sampleCount += sampleCount;
726
- if (track.type === ElementaryStreamTypes.VIDEO) {
727
- const dataOffsetPresent = trun[3] & 0x01;
728
- const firstSampleFlagsPresent = trun[3] & 0x04;
729
- const sampleDurationPresent = trun[2] & 0x01;
730
- const sampleSizePresent = trun[2] & 0x02;
731
- const sampleFlagsPresent = trun[2] & 0x04;
732
- const sampleCompositionTimeOffsetPresent = trun[2] & 0x08;
733
- let offset = 8;
734
- let remaining = sampleCount;
735
- if (dataOffsetPresent) {
726
+ // Get duration from samples
727
+ const dataOffsetPresent = trun[3] & 0x01;
728
+ const firstSampleFlagsPresent = trun[3] & 0x04;
729
+ const sampleDurationPresent = trun[2] & 0x01;
730
+ const sampleSizePresent = trun[2] & 0x02;
731
+ const sampleFlagsPresent = trun[2] & 0x04;
732
+ const sampleCompositionTimeOffsetPresent = trun[2] & 0x08;
733
+ let offset = 8;
734
+ let remaining = sampleCount;
735
+ if (dataOffsetPresent) {
736
+ offset += 4;
737
+ }
738
+ if (firstSampleFlagsPresent && sampleCount) {
739
+ const isNonSyncSample = trun[offset + 1] & 0x01;
740
+ if (!isNonSyncSample && trackTimes.keyFrameIndex === undefined) {
741
+ trackTimes.keyFrameIndex = sampleIndex;
742
+ }
743
+ offset += 4;
744
+ if (sampleDurationPresent) {
745
+ sampleDuration = readUint32(trun, offset);
736
746
  offset += 4;
747
+ } else {
748
+ sampleDuration = defaultSampleDuration;
737
749
  }
738
- if (firstSampleFlagsPresent && sampleCount) {
739
- const isNonSyncSample = trun[offset + 1] & 0x01;
740
- if (!isNonSyncSample && trackTimes.keyFrameIndex === undefined) {
741
- trackTimes.keyFrameIndex = sampleIndex;
742
- }
750
+ if (sampleSizePresent) {
743
751
  offset += 4;
744
- if (sampleDurationPresent) {
745
- sampleDuration = readUint32(trun, offset);
746
- offset += 4;
747
- } else {
748
- sampleDuration = defaultSampleDuration;
749
- }
750
- if (sampleSizePresent) {
751
- offset += 4;
752
- }
753
- if (sampleCompositionTimeOffsetPresent) {
754
- offset += 4;
755
- }
756
- sampleDTS += sampleDuration;
757
- rawDuration += sampleDuration;
758
- remaining--;
759
752
  }
760
- while (remaining--) {
761
- if (sampleDurationPresent) {
762
- sampleDuration = readUint32(trun, offset);
763
- offset += 4;
764
- } else {
765
- sampleDuration = defaultSampleDuration;
766
- }
767
- if (sampleSizePresent) {
768
- offset += 4;
769
- }
770
- if (sampleFlagsPresent) {
771
- const isNonSyncSample = trun[offset + 1] & 0x01;
772
- if (!isNonSyncSample) {
773
- if (trackTimes.keyFrameIndex === undefined) {
774
- trackTimes.keyFrameIndex =
775
- trackTimes.sampleCount - (remaining + 1);
776
- trackTimes.keyFrameStart = sampleDTS;
777
- }
753
+ if (sampleCompositionTimeOffsetPresent) {
754
+ offset += 4;
755
+ }
756
+ sampleDTS += sampleDuration;
757
+ rawDuration += sampleDuration;
758
+ remaining--;
759
+ }
760
+ while (remaining--) {
761
+ if (sampleDurationPresent) {
762
+ sampleDuration = readUint32(trun, offset);
763
+ offset += 4;
764
+ } else {
765
+ sampleDuration = defaultSampleDuration;
766
+ }
767
+ if (sampleSizePresent) {
768
+ offset += 4;
769
+ }
770
+ if (sampleFlagsPresent) {
771
+ const isNonSyncSample = trun[offset + 1] & 0x01;
772
+ if (!isNonSyncSample) {
773
+ if (trackTimes.keyFrameIndex === undefined) {
774
+ trackTimes.keyFrameIndex =
775
+ trackTimes.sampleCount - (remaining + 1);
776
+ trackTimes.keyFrameStart = sampleDTS;
778
777
  }
779
- offset += 4;
780
- }
781
- if (sampleCompositionTimeOffsetPresent) {
782
- offset += 4;
783
778
  }
784
- sampleDTS += sampleDuration;
785
- rawDuration += sampleDuration;
779
+ offset += 4;
786
780
  }
787
- } else {
781
+ if (sampleCompositionTimeOffsetPresent) {
782
+ offset += 4;
783
+ }
784
+ sampleDTS += sampleDuration;
785
+ rawDuration += sampleDuration;
786
+ }
787
+ if (!rawDuration && defaultSampleDuration) {
788
788
  rawDuration += defaultSampleDuration * sampleCount;
789
789
  }
790
790
  }