@havue/solutions 1.0.0 → 1.1.1

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.
@@ -37,21 +37,30 @@ export type RenderEvents = {
37
37
  export declare class Render extends EventBus<RenderEvents> {
38
38
  /** video元素 */
39
39
  private _videoEl;
40
- /** pixi.js 实例 */
41
40
  /** mp4box 实例 */
42
41
  private _mp4box;
43
- /** 接收到的socket消息 视频数据buffer数组 */
44
- private _bufsQueue;
42
+ /** mp4box onFragment获取的视频数据buffer数组 */
43
+ private _audioBufsQueue;
44
+ private _videoBufsQueue;
45
45
  /** MediaSource 实例 */
46
46
  private _mediaSource;
47
47
  /** SourceBuffer 实例 */
48
- private _sourceBuffer;
48
+ private _audioSourceBuffer;
49
+ private _videoSourceBuffer;
50
+ private _audioTrackId;
51
+ private _videoTrackId;
49
52
  /** 用于MediaSource的mimeType */
50
53
  private _mimeType;
54
+ private _audioMimeType;
55
+ private _videoMimeType;
51
56
  /** 是否暂停播放 */
52
57
  private _paused;
53
58
  private _options;
54
59
  private _cacheAnimationID;
60
+ /** fmp4初始化片段是否已经添加 */
61
+ private _isAudioInitSegmentAdded;
62
+ private _isVideoInitSegmentAdded;
63
+ private _offset;
55
64
  constructor(options?: Partial<RenderConstructorOptionType>);
56
65
  get muted(): boolean;
57
66
  set muted(val: boolean);
@@ -72,6 +81,7 @@ export declare class Render extends EventBus<RenderEvents> {
72
81
  * @param info mp4box解析信息
73
82
  */
74
83
  private _onMp4boxReady;
84
+ private _onSegment;
75
85
  /**
76
86
  * 初始化视频元素
77
87
  */
@@ -86,6 +96,7 @@ export declare class Render extends EventBus<RenderEvents> {
86
96
  * @returns
87
97
  */
88
98
  private _setupMSE;
99
+ private _setupSourceBuffer;
89
100
  /**
90
101
  * 将_bufsQueue中的数据添加到SourceBuffer中
91
102
  * @returns
@@ -98,6 +109,7 @@ export declare class Render extends EventBus<RenderEvents> {
98
109
  /** 重置解析的视频mime type */
99
110
  resetMimeType(): void;
100
111
  private destroyMediaSource;
112
+ destroyMp4box(): void;
101
113
  /**
102
114
  * 销毁
103
115
  */
@@ -0,0 +1,2 @@
1
+ import MP4Box from 'mp4box';
2
+ export default MP4Box;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@havue/solutions",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Javascript class for special scene",
5
5
  "keywords": [
6
6
  "havue",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "lodash": "^4.17.21",
20
- "@havue/shared": "^1.0.0",
21
- "@havue/bc-connect": "^1.0.0",
22
- "@havue/ws-video-manager": "^1.0.0"
20
+ "@havue/shared": "^1.1.1",
21
+ "@havue/ws-video-manager": "^1.1.1",
22
+ "@havue/bc-connect": "^1.1.1"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public",
@@ -37,21 +37,30 @@ export type RenderEvents = {
37
37
  export declare class Render extends EventBus<RenderEvents> {
38
38
  /** video元素 */
39
39
  private _videoEl;
40
- /** pixi.js 实例 */
41
40
  /** mp4box 实例 */
42
41
  private _mp4box;
43
- /** 接收到的socket消息 视频数据buffer数组 */
44
- private _bufsQueue;
42
+ /** mp4box onFragment获取的视频数据buffer数组 */
43
+ private _audioBufsQueue;
44
+ private _videoBufsQueue;
45
45
  /** MediaSource 实例 */
46
46
  private _mediaSource;
47
47
  /** SourceBuffer 实例 */
48
- private _sourceBuffer;
48
+ private _audioSourceBuffer;
49
+ private _videoSourceBuffer;
50
+ private _audioTrackId;
51
+ private _videoTrackId;
49
52
  /** 用于MediaSource的mimeType */
50
53
  private _mimeType;
54
+ private _audioMimeType;
55
+ private _videoMimeType;
51
56
  /** 是否暂停播放 */
52
57
  private _paused;
53
58
  private _options;
54
59
  private _cacheAnimationID;
60
+ /** fmp4初始化片段是否已经添加 */
61
+ private _isAudioInitSegmentAdded;
62
+ private _isVideoInitSegmentAdded;
63
+ private _offset;
55
64
  constructor(options?: Partial<RenderConstructorOptionType>);
56
65
  get muted(): boolean;
57
66
  set muted(val: boolean);
@@ -72,6 +81,7 @@ export declare class Render extends EventBus<RenderEvents> {
72
81
  * @param info mp4box解析信息
73
82
  */
74
83
  private _onMp4boxReady;
84
+ private _onSegment;
75
85
  /**
76
86
  * 初始化视频元素
77
87
  */
@@ -86,6 +96,7 @@ export declare class Render extends EventBus<RenderEvents> {
86
96
  * @returns
87
97
  */
88
98
  private _setupMSE;
99
+ private _setupSourceBuffer;
89
100
  /**
90
101
  * 将_bufsQueue中的数据添加到SourceBuffer中
91
102
  * @returns
@@ -98,6 +109,7 @@ export declare class Render extends EventBus<RenderEvents> {
98
109
  /** 重置解析的视频mime type */
99
110
  resetMimeType(): void;
100
111
  private destroyMediaSource;
112
+ destroyMp4box(): void;
101
113
  /**
102
114
  * 销毁
103
115
  */
@@ -0,0 +1,2 @@
1
+ import MP4Box from 'mp4box';
2
+ export default MP4Box;
@@ -7235,6 +7235,57 @@ var mp4box_all = {};
7235
7235
  }
7236
7236
  })(mp4box_all);
7237
7237
  const MP4Box = /* @__PURE__ */ getDefaultExportFromCjs(mp4box_all);
7238
+ function ExtendMp4box() {
7239
+ const MP4BoxFile = MP4Box.createFile().constructor;
7240
+ MP4BoxFile.prototype.removeUsedSamples = function(id) {
7241
+ const track = this.getTrackById(id);
7242
+ const samples = track.samples;
7243
+ const lastSample = samples[samples.length - 1];
7244
+ lastSample.data = null;
7245
+ lastSample.description = null;
7246
+ lastSample.alreadyRead = 0;
7247
+ track.samples = [];
7248
+ track.samples.push(lastSample);
7249
+ track.nextSample = track.samples.length;
7250
+ this.boxes = [];
7251
+ this.mdats = [];
7252
+ this.moofs = [];
7253
+ this.lastMoofIndex = 0;
7254
+ };
7255
+ MP4BoxFile.prototype.destroy = function() {
7256
+ if (this.stream) {
7257
+ this.stream.buffers = [];
7258
+ this.stream.bufferIndex = -1;
7259
+ this.stream = null;
7260
+ }
7261
+ this.boxes = [];
7262
+ this.mdats = [];
7263
+ this.moofs = [];
7264
+ this.isProgressive = false;
7265
+ this.moovStartFound = false;
7266
+ this.onMoovStart = null;
7267
+ this.moovStartSent = false;
7268
+ this.onReady = null;
7269
+ this.readySent = false;
7270
+ this.onSegment = null;
7271
+ this.onSamples = null;
7272
+ this.onError = null;
7273
+ this.sampleListBuilt = false;
7274
+ this.fragmentedTracks = [];
7275
+ this.extractedTracks = [];
7276
+ this.isFragmentationInitialized = false;
7277
+ this.sampleProcessingStarted = false;
7278
+ this.nextMoofNumber = 0;
7279
+ this.itemListBuilt = false;
7280
+ this.onSidx = null;
7281
+ this.sidxSent = false;
7282
+ this.moov = null;
7283
+ this.ftyp = null;
7284
+ this.items = [];
7285
+ this.entity_groups = [];
7286
+ };
7287
+ }
7288
+ ExtendMp4box();
7238
7289
  const WS_VIDEO_RENDER_DEFAULT_OPTIONS = Object.freeze({
7239
7290
  liveMaxLatency: 0.3,
7240
7291
  maxCacheBufByte: 200 * 1024,
@@ -7263,24 +7314,33 @@ class Render extends EventBus {
7263
7314
  super();
7264
7315
  /** video元素 */
7265
7316
  __publicField(this, "_videoEl");
7266
- /** pixi.js 实例 */
7267
- // private _pixiApp: Application | null = null
7268
7317
  /** mp4box 实例 */
7269
7318
  __publicField(this, "_mp4box", MP4Box.createFile());
7270
- /** 接收到的socket消息 视频数据buffer数组 */
7271
- __publicField(this, "_bufsQueue", []);
7319
+ /** mp4box onFragment获取的视频数据buffer数组 */
7320
+ __publicField(this, "_audioBufsQueue", []);
7321
+ __publicField(this, "_videoBufsQueue", []);
7272
7322
  /** MediaSource 实例 */
7273
7323
  __publicField(this, "_mediaSource");
7274
7324
  /** SourceBuffer 实例 */
7275
- __publicField(this, "_sourceBuffer");
7325
+ __publicField(this, "_audioSourceBuffer");
7326
+ __publicField(this, "_videoSourceBuffer");
7327
+ __publicField(this, "_audioTrackId");
7328
+ __publicField(this, "_videoTrackId");
7276
7329
  /** 用于MediaSource的mimeType */
7277
7330
  __publicField(this, "_mimeType", "");
7331
+ __publicField(this, "_audioMimeType", "");
7332
+ __publicField(this, "_videoMimeType", "");
7278
7333
  /** 是否暂停播放 */
7279
7334
  __publicField(this, "_paused", false);
7280
7335
  __publicField(this, "_options");
7281
7336
  __publicField(this, "_cacheAnimationID");
7337
+ /** fmp4初始化片段是否已经添加 */
7338
+ __publicField(this, "_isAudioInitSegmentAdded", false);
7339
+ __publicField(this, "_isVideoInitSegmentAdded", false);
7340
+ __publicField(this, "_offset", 0);
7282
7341
  this._options = options ? Object.assign({}, WS_VIDEO_RENDER_DEFAULT_OPTIONS, options) : WS_VIDEO_RENDER_DEFAULT_OPTIONS;
7283
7342
  this._mp4box.onReady = this._onMp4boxReady.bind(this);
7343
+ this._mp4box.onSegment = this._onSegment.bind(this);
7284
7344
  this._setupVideo();
7285
7345
  }
7286
7346
  get muted() {
@@ -7318,33 +7378,15 @@ class Render extends EventBus {
7318
7378
  * @param buf
7319
7379
  */
7320
7380
  appendMediaBuffer(bufs) {
7321
- var _a;
7322
7381
  if (this._paused) {
7323
7382
  return;
7324
7383
  }
7325
- if (!this._sourceBuffer) {
7326
- const buf = bufs[0];
7327
- buf.fileStart = 0;
7328
- this._mp4box.appendBuffer(buf);
7329
- }
7330
- this._bufsQueue.push(...bufs);
7331
- if (this._sourceBuffer && !((_a = this._videoEl) == null ? void 0 : _a.paused) && this._bufsQueue.length > 2) {
7332
- const len = this._bufsQueue.length;
7333
- const maxTotal = this._options.maxCacheBufByte;
7334
- let lastIndex = len - 1;
7335
- let total = 0;
7336
- for (let i2 = len - 1; i2 > 0; i2--) {
7337
- total += this._bufsQueue[i2].byteLength;
7338
- lastIndex = i2;
7339
- if (total >= maxTotal) {
7340
- this._bufsQueue = this._bufsQueue.slice(lastIndex);
7341
- break;
7342
- }
7343
- }
7344
- }
7345
- this._cacheAnimationID && cancelAnimationFrame(this._cacheAnimationID);
7346
- this._cacheAnimationID = void 0;
7347
- this._cache();
7384
+ bufs.forEach((b) => {
7385
+ b.fileStart = this._offset;
7386
+ this._offset += b.byteLength;
7387
+ this._mp4box.appendBuffer(b);
7388
+ });
7389
+ return;
7348
7390
  }
7349
7391
  /**
7350
7392
  * mp4box解析完成
@@ -7352,7 +7394,6 @@ class Render extends EventBus {
7352
7394
  */
7353
7395
  _onMp4boxReady(info) {
7354
7396
  console.log("onMp4boxReady", info);
7355
- this._mp4box.flush();
7356
7397
  if (!info.isFragmented) {
7357
7398
  console.error("not fragmented mp4");
7358
7399
  return;
@@ -7364,10 +7405,66 @@ class Render extends EventBus {
7364
7405
  width,
7365
7406
  height
7366
7407
  });
7408
+ const audioTrack = info.audioTracks[0];
7409
+ const videoTrack = info.videoTracks[0];
7410
+ if (audioTrack) {
7411
+ this._audioMimeType = `audio/mp4; codecs="${audioTrack.codec}"`;
7412
+ this._audioTrackId = audioTrack.id;
7413
+ this._mp4box.setSegmentOptions(audioTrack.id, void 0, {
7414
+ nbSamples: 100
7415
+ });
7416
+ }
7417
+ if (videoTrack) {
7418
+ this._videoMimeType = `video/mp4; codecs="${videoTrack.codec}"`;
7419
+ this._videoTrackId = videoTrack.id;
7420
+ this._mp4box.setSegmentOptions(videoTrack.id, void 0, {
7421
+ nbSamples: 100
7422
+ });
7423
+ }
7424
+ const initSegments = this._mp4box.initializeSegmentation();
7425
+ for (const seg of initSegments) {
7426
+ if (audioTrack && seg.id === audioTrack.id) {
7427
+ this._audioBufsQueue.push(seg.buffer);
7428
+ } else if (videoTrack && seg.id === videoTrack.id) {
7429
+ this._videoBufsQueue.push(seg.buffer);
7430
+ }
7431
+ }
7367
7432
  } catch (error) {
7368
7433
  console.error(error);
7369
7434
  }
7370
7435
  this._setupMSE();
7436
+ this._mp4box.start();
7437
+ }
7438
+ _onSegment(id, __, buffer, sampleNumber) {
7439
+ var _a;
7440
+ const isAudio = id === this._audioTrackId;
7441
+ const isVideo = id === this._videoTrackId;
7442
+ const bufQueue = isAudio ? this._audioBufsQueue : isVideo ? this._videoBufsQueue : null;
7443
+ if (!bufQueue) {
7444
+ return;
7445
+ }
7446
+ const sourceBuffer = isVideo ? this._videoSourceBuffer : this._audioSourceBuffer;
7447
+ bufQueue.push(buffer);
7448
+ this._mp4box.releaseUsedSamples(id, sampleNumber);
7449
+ this._mp4box.removeUsedSamples(id);
7450
+ const segmentAdded = isAudio ? this._isAudioInitSegmentAdded : this._isVideoInitSegmentAdded;
7451
+ if (segmentAdded && sourceBuffer && !((_a = this._videoEl) == null ? void 0 : _a.paused) && bufQueue.length > 2) {
7452
+ const len = bufQueue.length;
7453
+ const maxTotal = this._options.maxCacheBufByte;
7454
+ let lastIndex = len - 1;
7455
+ let total = 0;
7456
+ for (let i2 = len - 1; i2 > 0; i2--) {
7457
+ total += bufQueue[i2].byteLength;
7458
+ lastIndex = i2;
7459
+ if (total >= maxTotal) {
7460
+ bufQueue.splice(0, lastIndex);
7461
+ break;
7462
+ }
7463
+ }
7464
+ }
7465
+ this._cacheAnimationID && cancelAnimationFrame(this._cacheAnimationID);
7466
+ this._cacheAnimationID = void 0;
7467
+ this._cache(isVideo);
7371
7468
  }
7372
7469
  /**
7373
7470
  * 初始化视频元素
@@ -7452,30 +7549,45 @@ class Render extends EventBus {
7452
7549
  URL.revokeObjectURL(this._videoEl.src);
7453
7550
  this._videoEl.src = URL.createObjectURL(this._mediaSource);
7454
7551
  this._mediaSource.addEventListener("sourceopen", () => {
7455
- const sourceBuffer = this._sourceBuffer = this._mediaSource.addSourceBuffer(this._mimeType);
7456
- sourceBuffer.mode = "sequence";
7457
- sourceBuffer.onupdateend = () => {
7458
- var _a, _b, _c;
7459
- if (!this._videoEl || !sourceBuffer || ((_a = this._mediaSource) == null ? void 0 : _a.readyState) !== "open" || ![...this._mediaSource.sourceBuffers].includes(sourceBuffer)) {
7460
- return;
7461
- }
7462
- const currentTime = this._videoEl.currentTime;
7463
- if (sourceBuffer.buffered.length > 0) {
7464
- let bufferedLen = sourceBuffer.buffered.length;
7465
- const needDelBuf = bufferedLen > 1;
7466
- if (needDelBuf && currentTime) {
7467
- const lastIndex = bufferedLen - 1;
7468
- if (currentTime < sourceBuffer.buffered.start(lastIndex)) {
7469
- this._videoEl.currentTime = sourceBuffer.buffered.start(lastIndex);
7470
- }
7471
- const delBufEnd = sourceBuffer.buffered.end(lastIndex - 1);
7472
- if (!this._sourceBuffer.updating && currentTime > delBufEnd) {
7473
- (_b = this._sourceBuffer) == null ? void 0 : _b.remove(0, delBufEnd);
7474
- }
7552
+ if (!this._mediaSource) {
7553
+ return;
7554
+ }
7555
+ if (this._audioMimeType) {
7556
+ this._audioSourceBuffer = this._mediaSource.addSourceBuffer(this._audioMimeType);
7557
+ this._audioSourceBuffer.mode = "sequence";
7558
+ this._setupSourceBuffer(this._audioSourceBuffer, false);
7559
+ }
7560
+ if (this._videoMimeType) {
7561
+ this._videoSourceBuffer = this._mediaSource.addSourceBuffer(this._videoMimeType);
7562
+ this._videoSourceBuffer.mode = "sequence";
7563
+ this._setupSourceBuffer(this._videoSourceBuffer, true);
7564
+ }
7565
+ });
7566
+ }
7567
+ _setupSourceBuffer(sourceBuffer, isVideo = false) {
7568
+ sourceBuffer.onupdateend = () => {
7569
+ var _a;
7570
+ if (!this._videoEl || !sourceBuffer || ((_a = this._mediaSource) == null ? void 0 : _a.readyState) !== "open" || ![...this._mediaSource.sourceBuffers].includes(sourceBuffer)) {
7571
+ return;
7572
+ }
7573
+ const currentTime = this._videoEl.currentTime;
7574
+ if (sourceBuffer.buffered.length > 0) {
7575
+ let bufferedLen = sourceBuffer.buffered.length;
7576
+ const needDelBuf = bufferedLen > 1;
7577
+ if (needDelBuf && currentTime) {
7578
+ const lastIndex = bufferedLen - 1;
7579
+ if (currentTime < sourceBuffer.buffered.start(lastIndex)) {
7580
+ this._videoEl.currentTime = sourceBuffer.buffered.start(lastIndex);
7475
7581
  }
7476
- bufferedLen = sourceBuffer.buffered.length;
7477
- const start = sourceBuffer.buffered.start(bufferedLen - 1);
7478
- const end = sourceBuffer.buffered.end(bufferedLen - 1);
7582
+ const delBufEnd = sourceBuffer.buffered.end(lastIndex - 1);
7583
+ if (!sourceBuffer.updating && currentTime > delBufEnd) {
7584
+ sourceBuffer == null ? void 0 : sourceBuffer.remove(0, delBufEnd);
7585
+ }
7586
+ }
7587
+ bufferedLen = sourceBuffer.buffered.length;
7588
+ const start = sourceBuffer.buffered.start(bufferedLen - 1);
7589
+ const end = sourceBuffer.buffered.end(bufferedLen - 1);
7590
+ if (isVideo) {
7479
7591
  if (!currentTime && start) {
7480
7592
  this._videoEl.currentTime = start;
7481
7593
  }
@@ -7485,33 +7597,35 @@ class Render extends EventBus {
7485
7597
  this._videoEl.currentTime = end - 0.1;
7486
7598
  }
7487
7599
  }
7488
- if (!this._sourceBuffer.updating && currentTime - start > this._options.maxCache) {
7489
- (_c = this._sourceBuffer) == null ? void 0 : _c.remove(0, currentTime - this._options.maxCache / 2);
7490
- }
7491
7600
  }
7492
- };
7493
- });
7601
+ if (!sourceBuffer.updating && currentTime - start > this._options.maxCache) {
7602
+ sourceBuffer == null ? void 0 : sourceBuffer.remove(0, currentTime - this._options.maxCache / 2);
7603
+ }
7604
+ }
7605
+ };
7494
7606
  }
7495
7607
  /**
7496
7608
  * 将_bufsQueue中的数据添加到SourceBuffer中
7497
7609
  * @returns
7498
7610
  */
7499
- _cache() {
7611
+ _cache(isVideo = false) {
7500
7612
  if (!this._videoEl) {
7501
7613
  return;
7502
7614
  }
7503
- if (!this._mediaSource || !this._sourceBuffer || this._sourceBuffer.updating || !this._bufsQueue.length || this._mediaSource.readyState !== "open") {
7504
- this._cacheAnimationID === void 0 && (this._cacheAnimationID = requestAnimationFrame(() => this._cache()));
7615
+ const queue = isVideo ? this._videoBufsQueue : this._audioBufsQueue;
7616
+ const sourceBuffer = isVideo ? this._videoSourceBuffer : this._audioSourceBuffer;
7617
+ if (!this._mediaSource || !sourceBuffer || sourceBuffer.updating || !queue.length || this._mediaSource.readyState !== "open") {
7618
+ this._cacheAnimationID === void 0 && (this._cacheAnimationID = requestAnimationFrame(() => this._cache(isVideo)));
7505
7619
  return;
7506
7620
  }
7507
7621
  if (this._videoEl.error) {
7508
7622
  this._setupMSE();
7509
- return this._cacheAnimationID === void 0 && (this._cacheAnimationID = requestAnimationFrame(() => this._cache()));
7623
+ return this._cacheAnimationID === void 0 && (this._cacheAnimationID = requestAnimationFrame(() => this._cache(isVideo)));
7510
7624
  }
7511
7625
  this._cacheAnimationID = void 0;
7512
7626
  let frame;
7513
- if (this._bufsQueue.length > 1) {
7514
- const freeBuffer = this._bufsQueue.splice(0, this._bufsQueue.length);
7627
+ if (queue.length > 1) {
7628
+ const freeBuffer = queue.splice(0, queue.length);
7515
7629
  const length = freeBuffer.map((e) => e.byteLength).reduce((a, b) => a + b, 0);
7516
7630
  const buffer = new Uint8Array(length);
7517
7631
  let offset = 0;
@@ -7522,10 +7636,15 @@ class Render extends EventBus {
7522
7636
  }
7523
7637
  frame = buffer;
7524
7638
  } else {
7525
- frame = new Uint8Array(this._bufsQueue.shift() || []);
7639
+ frame = new Uint8Array(queue.shift() || []);
7526
7640
  }
7527
7641
  if (frame) {
7528
- this._sourceBuffer.appendBuffer(frame);
7642
+ if (isVideo) {
7643
+ !this._isVideoInitSegmentAdded && (this._isVideoInitSegmentAdded = true);
7644
+ } else {
7645
+ !this._isAudioInitSegmentAdded && (this._isAudioInitSegmentAdded = true);
7646
+ }
7647
+ sourceBuffer.appendBuffer(frame);
7529
7648
  }
7530
7649
  }
7531
7650
  /**
@@ -7539,13 +7658,14 @@ class Render extends EventBus {
7539
7658
  }
7540
7659
  /** 重置解析的视频mime type */
7541
7660
  resetMimeType() {
7661
+ this.destroyMp4box();
7542
7662
  this.destroyMediaSource();
7543
7663
  if (this._videoEl) {
7544
7664
  this._videoEl.src = "";
7545
7665
  }
7546
7666
  this._mp4box = MP4Box.createFile();
7547
7667
  this._mp4box.onReady = this._onMp4boxReady.bind(this);
7548
- this._bufsQueue.length = 0;
7668
+ this._mp4box.onSegment = this._onSegment.bind(this);
7549
7669
  }
7550
7670
  destroyMediaSource() {
7551
7671
  var _a;
@@ -7555,21 +7675,41 @@ class Render extends EventBus {
7555
7675
  this._videoEl.src = "";
7556
7676
  }
7557
7677
  if (this._mediaSource.readyState === "open") {
7558
- if (this._sourceBuffer) {
7559
- this._sourceBuffer.abort();
7560
- this._mediaSource.removeSourceBuffer(this._sourceBuffer);
7678
+ if (this._audioSourceBuffer) {
7679
+ this._audioSourceBuffer.abort();
7680
+ this._mediaSource.removeSourceBuffer(this._audioSourceBuffer);
7681
+ }
7682
+ if (this._videoSourceBuffer) {
7683
+ this._videoSourceBuffer.abort();
7684
+ this._mediaSource.removeSourceBuffer(this._videoSourceBuffer);
7561
7685
  }
7562
7686
  this._mediaSource.endOfStream();
7563
7687
  }
7564
7688
  this._mediaSource = void 0;
7565
- this._sourceBuffer = void 0;
7689
+ this._audioSourceBuffer = void 0;
7690
+ this._videoSourceBuffer = void 0;
7566
7691
  }
7567
7692
  }
7693
+ destroyMp4box() {
7694
+ this._audioTrackId = void 0;
7695
+ this._videoTrackId = void 0;
7696
+ this._mimeType = "";
7697
+ this._audioMimeType = "";
7698
+ this._videoMimeType = "";
7699
+ this._isAudioInitSegmentAdded = false;
7700
+ this._isVideoInitSegmentAdded = false;
7701
+ this._audioBufsQueue.length = 0;
7702
+ this._videoBufsQueue.length = 0;
7703
+ this._offset = 0;
7704
+ this._mp4box.stop();
7705
+ this._mp4box.flush();
7706
+ this._mp4box.destroy();
7707
+ this._mp4box = null;
7708
+ }
7568
7709
  /**
7569
7710
  * 销毁
7570
7711
  */
7571
7712
  destroy() {
7572
- this._bufsQueue = [];
7573
7713
  if (this._videoEl) {
7574
7714
  this._videoEl.pause();
7575
7715
  this._videoEl.currentTime = 0;
@@ -7580,9 +7720,9 @@ class Render extends EventBus {
7580
7720
  this._videoEl.src = "";
7581
7721
  this._videoEl = void 0;
7582
7722
  }
7583
- this._mimeType = "";
7584
7723
  this._cacheAnimationID && cancelAnimationFrame(this._cacheAnimationID);
7585
7724
  this._cacheAnimationID = void 0;
7725
+ this.destroyMp4box();
7586
7726
  this.destroyMediaSource();
7587
7727
  }
7588
7728
  }