hls.js 1.5.14-0.canary.10520 → 1.5.14-0.canary.10524

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
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.67.1"
132
132
  },
133
- "version": "1.5.14-0.canary.10520"
133
+ "version": "1.5.14-0.canary.10524"
134
134
  }
@@ -174,7 +174,11 @@ class BaseAudioDemuxer implements Demuxer {
174
174
  };
175
175
  }
176
176
 
177
- destroy() {}
177
+ destroy() {
178
+ this.cachedData = null;
179
+ // @ts-ignore
180
+ this._audioTrack = this._id3Track = undefined;
181
+ }
178
182
  }
179
183
 
180
184
  /**
@@ -194,7 +194,16 @@ class MP4Demuxer implements Demuxer {
194
194
  );
195
195
  }
196
196
 
197
- destroy() {}
197
+ destroy() {
198
+ // @ts-ignore
199
+ this.config = null;
200
+ this.remainderData = null;
201
+ this.videoTrack =
202
+ this.audioTrack =
203
+ this.id3Track =
204
+ this.txtTrack =
205
+ undefined;
206
+ }
198
207
  }
199
208
 
200
209
  export default MP4Demuxer;
@@ -63,7 +63,6 @@ class TSDemuxer implements Demuxer {
63
63
  private pmtParsed: boolean = false;
64
64
  private audioCodec?: string;
65
65
  private videoCodec?: string;
66
- private _duration: number = 0;
67
66
  private _pmtId: number = -1;
68
67
 
69
68
  private _videoTrack?: DemuxedVideoTrack;
@@ -182,6 +181,7 @@ class TSDemuxer implements Demuxer {
182
181
  this._pmtId = -1;
183
182
 
184
183
  this._videoTrack = TSDemuxer.createTrack('video') as DemuxedVideoTrack;
184
+ this._videoTrack.duration = trackDuration;
185
185
  this._audioTrack = TSDemuxer.createTrack(
186
186
  'audio',
187
187
  trackDuration,
@@ -195,7 +195,6 @@ class TSDemuxer implements Demuxer {
195
195
  this.remainderData = null;
196
196
  this.audioCodec = audioCodec;
197
197
  this.videoCodec = videoCodec;
198
- this._duration = trackDuration;
199
198
  }
200
199
 
201
200
  public resetTimeStamp() {}
@@ -305,13 +304,7 @@ class TSDemuxer implements Demuxer {
305
304
  }
306
305
  }
307
306
  if (this.videoParser !== null) {
308
- this.videoParser.parsePES(
309
- videoTrack,
310
- textTrack,
311
- pes,
312
- false,
313
- this._duration,
314
- );
307
+ this.videoParser.parsePES(videoTrack, textTrack, pes, false);
315
308
  }
316
309
  }
317
310
 
@@ -502,7 +495,6 @@ class TSDemuxer implements Demuxer {
502
495
  textTrack as DemuxedUserdataTrack,
503
496
  pes,
504
497
  true,
505
- this._duration,
506
498
  );
507
499
  videoTrack.pesData = null;
508
500
  }
@@ -590,7 +582,21 @@ class TSDemuxer implements Demuxer {
590
582
  }
591
583
 
592
584
  public destroy() {
593
- this._duration = 0;
585
+ if (this.observer) {
586
+ this.observer.removeAllListeners();
587
+ }
588
+ // @ts-ignore
589
+ this.config = this.logger = this.observer = null;
590
+ this.aacOverFlow =
591
+ this.videoParser =
592
+ this.remainderData =
593
+ this.sampleAes =
594
+ null;
595
+ this._videoTrack =
596
+ this._audioTrack =
597
+ this._id3Track =
598
+ this._txtTrack =
599
+ undefined;
594
600
  }
595
601
 
596
602
  private parseAACPES(track: DemuxedAudioTrack, pes: PES) {
@@ -15,10 +15,8 @@ class AvcVideoParser extends BaseVideoParser {
15
15
  textTrack: DemuxedUserdataTrack,
16
16
  pes: PES,
17
17
  endOfSegment: boolean,
18
- duration: number,
19
18
  ) {
20
19
  const units = this.parseNALu(track, pes.data, endOfSegment);
21
- const debug = false;
22
20
  let VideoSample = this.VideoSample;
23
21
  let push: boolean;
24
22
  let spsfound = false;
@@ -33,7 +31,6 @@ class AvcVideoParser extends BaseVideoParser {
33
31
  false,
34
32
  pes.pts,
35
33
  pes.dts,
36
- '',
37
34
  );
38
35
  }
39
36
 
@@ -76,14 +73,8 @@ class AvcVideoParser extends BaseVideoParser {
76
73
  true,
77
74
  pes.pts,
78
75
  pes.dts,
79
- '',
80
76
  );
81
77
  }
82
-
83
- if (debug) {
84
- VideoSample.debug += 'NDR ';
85
- }
86
-
87
78
  VideoSample.frame = true;
88
79
  VideoSample.key = iskey;
89
80
 
@@ -103,23 +94,15 @@ class AvcVideoParser extends BaseVideoParser {
103
94
  true,
104
95
  pes.pts,
105
96
  pes.dts,
106
- '',
107
97
  );
108
98
  }
109
99
 
110
- if (debug) {
111
- VideoSample.debug += 'IDR ';
112
- }
113
-
114
100
  VideoSample.key = true;
115
101
  VideoSample.frame = true;
116
102
  break;
117
103
  // SEI
118
104
  case 6: {
119
105
  push = true;
120
- if (debug && VideoSample) {
121
- VideoSample.debug += 'SEI ';
122
- }
123
106
  parseSEIMessageFromNALu(
124
107
  unit.data,
125
108
  1,
@@ -132,9 +115,6 @@ class AvcVideoParser extends BaseVideoParser {
132
115
  case 7: {
133
116
  push = true;
134
117
  spsfound = true;
135
- if (debug && VideoSample) {
136
- VideoSample.debug += 'SPS ';
137
- }
138
118
  const sps = unit.data;
139
119
  const config = this.readSPS(sps);
140
120
  if (
@@ -148,7 +128,6 @@ class AvcVideoParser extends BaseVideoParser {
148
128
  track.height = config.height;
149
129
  track.pixelRatio = config.pixelRatio;
150
130
  track.sps = [sps];
151
- track.duration = duration;
152
131
  const codecarray = sps.subarray(1, 4);
153
132
  let codecstring = 'avc1.';
154
133
  for (let i = 0; i < 3; i++) {
@@ -166,9 +145,6 @@ class AvcVideoParser extends BaseVideoParser {
166
145
  // PPS
167
146
  case 8:
168
147
  push = true;
169
- if (debug && VideoSample) {
170
- VideoSample.debug += 'PPS ';
171
- }
172
148
 
173
149
  track.pps = [unit.data];
174
150
 
@@ -177,16 +153,17 @@ class AvcVideoParser extends BaseVideoParser {
177
153
  case 9:
178
154
  push = true;
179
155
  track.audFound = true;
180
- if (VideoSample) {
156
+ if (VideoSample?.frame) {
181
157
  this.pushAccessUnit(VideoSample, track);
158
+ VideoSample = null;
159
+ }
160
+ if (!VideoSample) {
161
+ VideoSample = this.VideoSample = this.createVideoSample(
162
+ false,
163
+ pes.pts,
164
+ pes.dts,
165
+ );
182
166
  }
183
-
184
- VideoSample = this.VideoSample = this.createVideoSample(
185
- false,
186
- pes.pts,
187
- pes.dts,
188
- debug ? 'AUD ' : '',
189
- );
190
167
  break;
191
168
  // Filler Data
192
169
  case 12:
@@ -194,9 +171,6 @@ class AvcVideoParser extends BaseVideoParser {
194
171
  break;
195
172
  default:
196
173
  push = false;
197
- if (VideoSample) {
198
- VideoSample.debug += 'unknown NAL ' + unit.type + ' ';
199
- }
200
174
 
201
175
  break;
202
176
  }
@@ -6,7 +6,6 @@ import type {
6
6
  VideoSampleUnit,
7
7
  } from '../../types/demuxer';
8
8
  import type { PES } from '../tsdemuxer';
9
- import { logger } from '../../utils/logger';
10
9
  import { appendUint8Array } from '../../utils/mp4-tools';
11
10
 
12
11
  abstract class BaseVideoParser {
@@ -16,7 +15,6 @@ abstract class BaseVideoParser {
16
15
  key: boolean,
17
16
  pts: number | undefined,
18
17
  dts: number | undefined,
19
- debug: string,
20
18
  ): ParsedVideoSample {
21
19
  return {
22
20
  key,
@@ -24,7 +22,6 @@ abstract class BaseVideoParser {
24
22
  pts,
25
23
  dts,
26
24
  units: [],
27
- debug,
28
25
  length: 0,
29
26
  };
30
27
  }
@@ -66,11 +63,6 @@ abstract class BaseVideoParser {
66
63
  }
67
64
  videoTrack.samples.push(VideoSample as VideoSample);
68
65
  }
69
- if (VideoSample.debug.length) {
70
- logger.log(
71
- VideoSample.pts + '/' + VideoSample.dts + ':' + VideoSample.debug,
72
- );
73
- }
74
66
  }
75
67
 
76
68
  abstract parsePES(
@@ -78,7 +70,6 @@ abstract class BaseVideoParser {
78
70
  textTrack: DemuxedUserdataTrack,
79
71
  pes: PES,
80
72
  last: boolean,
81
- duration: number,
82
73
  );
83
74
 
84
75
  protected abstract getNALuType(data: Uint8Array, offset: number): number;
@@ -17,10 +17,8 @@ class HevcVideoParser extends BaseVideoParser {
17
17
  textTrack: DemuxedUserdataTrack,
18
18
  pes: PES,
19
19
  endOfSegment: boolean,
20
- duration: number,
21
20
  ) {
22
21
  const units = this.parseNALu(track, pes.data, endOfSegment);
23
- const debug = false;
24
22
  let VideoSample = this.VideoSample;
25
23
  let push: boolean;
26
24
  let spsfound = false;
@@ -35,7 +33,6 @@ class HevcVideoParser extends BaseVideoParser {
35
33
  false,
36
34
  pes.pts,
37
35
  pes.dts,
38
- '',
39
36
  );
40
37
  }
41
38
 
@@ -57,12 +54,8 @@ class HevcVideoParser extends BaseVideoParser {
57
54
  false,
58
55
  pes.pts,
59
56
  pes.dts,
60
- '',
61
57
  );
62
58
  }
63
- if (debug) {
64
- VideoSample.debug += 'NDR ';
65
- }
66
59
  VideoSample.frame = true;
67
60
  push = true;
68
61
  break;
@@ -86,14 +79,9 @@ class HevcVideoParser extends BaseVideoParser {
86
79
  true,
87
80
  pes.pts,
88
81
  pes.dts,
89
- '',
90
82
  );
91
83
  }
92
84
 
93
- if (debug) {
94
- VideoSample.debug += 'RAP ';
95
- }
96
-
97
85
  VideoSample.key = true;
98
86
  VideoSample.frame = true;
99
87
  break;
@@ -113,13 +101,9 @@ class HevcVideoParser extends BaseVideoParser {
113
101
  true,
114
102
  pes.pts,
115
103
  pes.dts,
116
- '',
117
104
  );
118
105
  }
119
106
 
120
- if (debug) {
121
- VideoSample.debug += 'IDR ';
122
- }
123
107
  VideoSample.key = true;
124
108
  VideoSample.frame = true;
125
109
  break;
@@ -127,9 +111,6 @@ class HevcVideoParser extends BaseVideoParser {
127
111
  // SEI
128
112
  case 39:
129
113
  push = true;
130
- if (debug && VideoSample) {
131
- VideoSample.debug += 'SEI ';
132
- }
133
114
  parseSEIMessageFromNALu(
134
115
  unit.data,
135
116
  2, // NALu header size
@@ -141,9 +122,6 @@ class HevcVideoParser extends BaseVideoParser {
141
122
  // VPS
142
123
  case 32:
143
124
  push = true;
144
- if (debug && VideoSample) {
145
- VideoSample.debug += 'VPS ';
146
- }
147
125
  if (!track.vps) {
148
126
  const config = this.readVPS(unit.data);
149
127
  track.params = { ...config };
@@ -156,9 +134,6 @@ class HevcVideoParser extends BaseVideoParser {
156
134
  case 33:
157
135
  push = true;
158
136
  spsfound = true;
159
- if (debug && VideoSample) {
160
- VideoSample.debug += 'SPS ';
161
- }
162
137
  if (typeof track.params === 'object') {
163
138
  if (
164
139
  track.vps !== undefined &&
@@ -174,7 +149,6 @@ class HevcVideoParser extends BaseVideoParser {
174
149
  track.width = config.width;
175
150
  track.height = config.height;
176
151
  track.pixelRatio = config.pixelRatio;
177
- track.duration = duration;
178
152
  track.codec = config.codecString;
179
153
  track.sps = [];
180
154
  for (const prop in config.params) {
@@ -190,7 +164,6 @@ class HevcVideoParser extends BaseVideoParser {
190
164
  true,
191
165
  pes.pts,
192
166
  pes.dts,
193
- '',
194
167
  );
195
168
  }
196
169
  VideoSample.key = true;
@@ -199,9 +172,6 @@ class HevcVideoParser extends BaseVideoParser {
199
172
  // PPS
200
173
  case 34:
201
174
  push = true;
202
- if (debug && VideoSample) {
203
- VideoSample.debug += 'PPS ';
204
- }
205
175
  if (typeof track.params === 'object') {
206
176
  if (!track.pps) {
207
177
  track.pps = [];
@@ -220,22 +190,21 @@ class HevcVideoParser extends BaseVideoParser {
220
190
  case 35:
221
191
  push = true;
222
192
  track.audFound = true;
223
- if (VideoSample) {
193
+ if (VideoSample?.frame) {
224
194
  this.pushAccessUnit(VideoSample, track);
195
+ VideoSample = null;
196
+ }
197
+ if (!VideoSample) {
198
+ VideoSample = this.VideoSample = this.createVideoSample(
199
+ false,
200
+ pes.pts,
201
+ pes.dts,
202
+ );
225
203
  }
226
- VideoSample = this.VideoSample = this.createVideoSample(
227
- false,
228
- pes.pts,
229
- pes.dts,
230
- debug ? 'AUD ' : '',
231
- );
232
204
  break;
233
205
 
234
206
  default:
235
207
  push = false;
236
- if (VideoSample) {
237
- VideoSample.debug += 'unknown or irrelevant NAL ' + unit.type + ' ';
238
- }
239
208
  break;
240
209
  }
241
210
  if (VideoSample && push) {
@@ -125,7 +125,6 @@ export interface VideoSample {
125
125
  key: boolean;
126
126
  frame: boolean;
127
127
  units: VideoSampleUnit[];
128
- debug: string;
129
128
  length: number;
130
129
  }
131
130