hls.js 1.5.12-0.canary.10352 → 1.5.12-0.canary.10353
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/dist/hls.js +30 -28
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +27 -25
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +27 -25
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +30 -28
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +1 -1
- package/src/demux/video/avc-video-parser.ts +3 -3
- package/src/demux/video/base-video-parser.ts +24 -20
- package/src/demux/video/hevc-video-parser.ts +3 -3
- package/src/types/demuxer.ts +0 -1
package/package.json
CHANGED
@@ -14,10 +14,10 @@ class AvcVideoParser extends BaseVideoParser {
|
|
14
14
|
track: DemuxedVideoTrack,
|
15
15
|
textTrack: DemuxedUserdataTrack,
|
16
16
|
pes: PES,
|
17
|
-
|
17
|
+
endOfSegment: boolean,
|
18
18
|
duration: number,
|
19
19
|
) {
|
20
|
-
const units = this.parseNALu(track, pes.data,
|
20
|
+
const units = this.parseNALu(track, pes.data, endOfSegment);
|
21
21
|
const debug = false;
|
22
22
|
let VideoSample = this.VideoSample;
|
23
23
|
let push: boolean;
|
@@ -206,7 +206,7 @@ class AvcVideoParser extends BaseVideoParser {
|
|
206
206
|
}
|
207
207
|
});
|
208
208
|
// if last PES packet, push samples
|
209
|
-
if (
|
209
|
+
if (endOfSegment && VideoSample) {
|
210
210
|
this.pushAccessUnit(VideoSample, track);
|
211
211
|
this.VideoSample = null;
|
212
212
|
}
|
@@ -29,6 +29,22 @@ abstract class BaseVideoParser {
|
|
29
29
|
};
|
30
30
|
}
|
31
31
|
|
32
|
+
protected getLastNalUnit(
|
33
|
+
samples: VideoSample[],
|
34
|
+
): VideoSampleUnit | undefined {
|
35
|
+
let VideoSample = this.VideoSample;
|
36
|
+
let lastUnit: VideoSampleUnit | undefined;
|
37
|
+
// try to fallback to previous sample if current one is empty
|
38
|
+
if (!VideoSample || VideoSample.units.length === 0) {
|
39
|
+
VideoSample = samples[samples.length - 1];
|
40
|
+
}
|
41
|
+
if (VideoSample?.units) {
|
42
|
+
const units = VideoSample.units;
|
43
|
+
lastUnit = units[units.length - 1];
|
44
|
+
}
|
45
|
+
return lastUnit;
|
46
|
+
}
|
47
|
+
|
32
48
|
protected pushAccessUnit(
|
33
49
|
VideoSample: ParsedVideoSample,
|
34
50
|
videoTrack: DemuxedVideoTrack,
|
@@ -70,7 +86,7 @@ abstract class BaseVideoParser {
|
|
70
86
|
protected parseNALu(
|
71
87
|
track: DemuxedVideoTrack,
|
72
88
|
array: Uint8Array,
|
73
|
-
|
89
|
+
endOfSegment: boolean,
|
74
90
|
): Array<{
|
75
91
|
data: Uint8Array;
|
76
92
|
type: number;
|
@@ -118,10 +134,6 @@ abstract class BaseVideoParser {
|
|
118
134
|
data: array.subarray(lastUnitStart, overflow),
|
119
135
|
type: lastUnitType,
|
120
136
|
};
|
121
|
-
if (track.lastNalu) {
|
122
|
-
units.push(track.lastNalu);
|
123
|
-
track.lastNalu = null;
|
124
|
-
}
|
125
137
|
// logger.log('pushing NALU, type/size:' + unit.type + '/' + unit.data.byteLength);
|
126
138
|
units.push(unit);
|
127
139
|
} else {
|
@@ -129,7 +141,7 @@ abstract class BaseVideoParser {
|
|
129
141
|
// first check if start code delimiter is overlapping between 2 PES packets,
|
130
142
|
// ie it started in last packet (lastState not zero)
|
131
143
|
// and ended at the beginning of this PES packet (i <= 4 - lastState)
|
132
|
-
const lastUnit = track.
|
144
|
+
const lastUnit = this.getLastNalUnit(track.samples);
|
133
145
|
if (lastUnit) {
|
134
146
|
if (lastState && i <= 4 - lastState) {
|
135
147
|
// start delimiter overlapping between PES packets
|
@@ -152,8 +164,6 @@ abstract class BaseVideoParser {
|
|
152
164
|
array.subarray(0, overflow),
|
153
165
|
);
|
154
166
|
lastUnit.state = 0;
|
155
|
-
units.push(lastUnit);
|
156
|
-
track.lastNalu = null;
|
157
167
|
}
|
158
168
|
}
|
159
169
|
}
|
@@ -178,21 +188,15 @@ abstract class BaseVideoParser {
|
|
178
188
|
type: lastUnitType,
|
179
189
|
state: state,
|
180
190
|
};
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
// logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
|
187
|
-
}
|
188
|
-
} else if (units.length === 0) {
|
189
|
-
// no NALu found
|
191
|
+
units.push(unit);
|
192
|
+
// logger.log('pushing NALU, type/size/state:' + unit.type + '/' + unit.data.byteLength + '/' + state);
|
193
|
+
}
|
194
|
+
// no NALu found
|
195
|
+
if (units.length === 0) {
|
190
196
|
// append pes.data to previous NAL unit
|
191
|
-
const lastUnit = track.
|
197
|
+
const lastUnit = this.getLastNalUnit(track.samples);
|
192
198
|
if (lastUnit) {
|
193
199
|
lastUnit.data = appendUint8Array(lastUnit.data, array);
|
194
|
-
units.push(lastUnit);
|
195
|
-
track.lastNalu = null;
|
196
200
|
}
|
197
201
|
}
|
198
202
|
track.naluState = state;
|
@@ -16,10 +16,10 @@ class HevcVideoParser extends BaseVideoParser {
|
|
16
16
|
track: DemuxedVideoTrack,
|
17
17
|
textTrack: DemuxedUserdataTrack,
|
18
18
|
pes: PES,
|
19
|
-
|
19
|
+
endOfSegment: boolean,
|
20
20
|
duration: number,
|
21
21
|
) {
|
22
|
-
const units = this.parseNALu(track, pes.data,
|
22
|
+
const units = this.parseNALu(track, pes.data, endOfSegment);
|
23
23
|
const debug = false;
|
24
24
|
let VideoSample = this.VideoSample;
|
25
25
|
let push: boolean;
|
@@ -244,7 +244,7 @@ class HevcVideoParser extends BaseVideoParser {
|
|
244
244
|
}
|
245
245
|
});
|
246
246
|
// if last PES packet, push samples
|
247
|
-
if (
|
247
|
+
if (endOfSegment && VideoSample) {
|
248
248
|
this.pushAccessUnit(VideoSample, track);
|
249
249
|
this.VideoSample = null;
|
250
250
|
}
|
package/src/types/demuxer.ts
CHANGED