agora-rte-sdk 2.9.30 → 2.9.32

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.
@@ -260,7 +260,7 @@ var RtcAdapterWeb = exports.RtcAdapterWeb = (_dec = _log.Log.attach({
260
260
  }, {
261
261
  key: "setupPreviewLocalVideo",
262
262
  value: function setupPreviewLocalVideo(canvas) {
263
- this.previewCameraThread.canvas = canvas;
263
+ this.previewCameraThread.setCanvas(canvas);
264
264
  this.previewCameraThread.run();
265
265
  return 0;
266
266
  }
@@ -268,10 +268,10 @@ var RtcAdapterWeb = exports.RtcAdapterWeb = (_dec = _log.Log.attach({
268
268
  key: "setupLocalVideo",
269
269
  value: function setupLocalVideo(canvas, videoSourceType) {
270
270
  if (videoSourceType === _track.AgoraRteVideoSourceType.Camera) {
271
- this.cameraThread.canvas = canvas;
271
+ this.cameraThread.setCanvas(canvas);
272
272
  this.cameraThread.run();
273
273
  } else {
274
- this.screenThread.canvas = canvas;
274
+ this.screenThread.setCanvas(canvas);
275
275
  this.screenThread.run();
276
276
  }
277
277
  return 0;
@@ -19,7 +19,9 @@ export declare class AgoraRteCameraThread extends AgoraRteMediaTrackThread {
19
19
  cameraEnable: boolean;
20
20
  private _deviceId?;
21
21
  private _deviceChanged;
22
+ private _canvasChanged;
22
23
  private setCameraTrackState;
24
+ setCanvas(canvas: AgoraRtcVideoCanvas): void;
23
25
  setDevice(deviceId: string): void;
24
26
  onExecution(): Promise<void>;
25
27
  }
@@ -29,7 +31,9 @@ export declare class AgoraRtePreviewCameraThread extends AgoraRteMediaTrackThrea
29
31
  cameraEnable: boolean;
30
32
  private _deviceId?;
31
33
  private _deviceChanged;
34
+ private _canvasChanged;
32
35
  private setCameraTrackState;
36
+ setCanvas(canvas: AgoraRtcVideoCanvas): void;
33
37
  setDevice(deviceId: string): void;
34
38
  onExecution(): Promise<void>;
35
39
  }
@@ -66,8 +70,10 @@ export declare class AgoraRteScreenShareThread extends AgoraRteMediaTrackThread
66
70
  screenEnable: boolean;
67
71
  trackState: AgoraRteMediaSourceState;
68
72
  loopbackDeviceState: AgoraRteMediaSourceState;
73
+ private _canvasChanged;
69
74
  get playing(): boolean | undefined;
70
75
  setScreenShareTrackState(state: AgoraRteMediaSourceState, withAudio: boolean, reason?: number): void;
76
+ setCanvas(canvas: AgoraRtcVideoCanvas): void;
71
77
  onExecution(): Promise<void>;
72
78
  }
73
79
  export declare class AgoraRtePublishThreadMain extends AgoraRteThread {
@@ -147,6 +147,7 @@ var AgoraRteCameraThread = exports.AgoraRteCameraThread = (_dec = _log.Log.attac
147
147
  _this3.cameraEnable = false;
148
148
  _this3._deviceId = void 0;
149
149
  _this3._deviceChanged = false;
150
+ _this3._canvasChanged = false;
150
151
  return _this3;
151
152
  }
152
153
  (0, _createClass2["default"])(AgoraRteCameraThread, [{
@@ -158,6 +159,12 @@ var AgoraRteCameraThread = exports.AgoraRteCameraThread = (_dec = _log.Log.attac
158
159
  this.trackState = state;
159
160
  this.emit(_control.AgoraMediaControlEventType.trackStateChanged, state, _track.AgoraRteVideoSourceType.Camera, reason);
160
161
  }
162
+ }, {
163
+ key: "setCanvas",
164
+ value: function setCanvas(canvas) {
165
+ this.canvas = canvas;
166
+ this._canvasChanged = true;
167
+ }
161
168
  }, {
162
169
  key: "setDevice",
163
170
  value: function setDevice(deviceId) {
@@ -256,20 +263,21 @@ var AgoraRteCameraThread = exports.AgoraRteCameraThread = (_dec = _log.Log.attac
256
263
  _this4.setCameraTrackState(_type.AgoraRteMediaSourceState.error);
257
264
  return _context.abrupt("return", 0);
258
265
  case 39:
266
+ if (!(_this4.track && !_this4._canvasChanged && (_this4.canvas && _this4.canvas.view && _this4.track.isPlaying || !_this4.canvas || !_this4.canvas.view))) {
267
+ _context.next = 42;
268
+ break;
269
+ }
270
+ // ok to sleep
271
+ _this4.logger.info('complete thread run');
272
+ return _context.abrupt("return", 0);
273
+ case 42:
259
274
  if (_this4.track && _this4.canvas && _this4.canvas.view) {
260
275
  _this4.track.play(_this4.canvas.view, {
261
276
  fit: _this4.canvas.renderMode === _type.AGRenderMode.fill ? 'cover' : 'contain'
262
277
  });
278
+ _this4._canvasChanged = false;
263
279
  }
264
280
  _this4.pipeProcessors();
265
- if (!(_this4.track && (_this4.canvas && _this4.canvas.view && _this4.track.isPlaying || !_this4.canvas || !_this4.canvas.view))) {
266
- _context.next = 44;
267
- break;
268
- }
269
- // ok to sleep
270
- _this4.logger.info('complete thread run');
271
- return _context.abrupt("return", 0);
272
- case 44:
273
281
  _context.next = 50;
274
282
  break;
275
283
  case 46:
@@ -346,6 +354,7 @@ var AgoraRtePreviewCameraThread = exports.AgoraRtePreviewCameraThread = (_dec2 =
346
354
  _this5.cameraEnable = false;
347
355
  _this5._deviceId = void 0;
348
356
  _this5._deviceChanged = false;
357
+ _this5._canvasChanged = false;
349
358
  return _this5;
350
359
  }
351
360
  (0, _createClass2["default"])(AgoraRtePreviewCameraThread, [{
@@ -357,6 +366,12 @@ var AgoraRtePreviewCameraThread = exports.AgoraRtePreviewCameraThread = (_dec2 =
357
366
  this.trackState = state;
358
367
  this.emit(_control.AgoraMediaControlEventType.trackStateChanged, state, _track.AgoraRteVideoSourceType.Camera, reason);
359
368
  }
369
+ }, {
370
+ key: "setCanvas",
371
+ value: function setCanvas(canvas) {
372
+ this.canvas = canvas;
373
+ this._canvasChanged = true;
374
+ }
360
375
  }, {
361
376
  key: "setDevice",
362
377
  value: function setDevice(deviceId) {
@@ -455,20 +470,21 @@ var AgoraRtePreviewCameraThread = exports.AgoraRtePreviewCameraThread = (_dec2 =
455
470
  case 38:
456
471
  _this6.logger.info("camera started");
457
472
  case 39:
473
+ if (!(_this6.track && !_this6._canvasChanged && (_this6.canvas && _this6.canvas.view && _this6.track.isPlaying || !_this6.canvas || !_this6.canvas.view))) {
474
+ _context3.next = 42;
475
+ break;
476
+ }
477
+ // ok to sleep
478
+ _this6.logger.info('complete thread run');
479
+ return _context3.abrupt("return", 0);
480
+ case 42:
458
481
  if (_this6.track && _this6.canvas && _this6.canvas.view) {
459
482
  _this6.track.play(_this6.canvas.view, {
460
483
  fit: _this6.canvas.renderMode === _type.AGRenderMode.fill ? 'cover' : 'contain'
461
484
  });
485
+ _this6._canvasChanged = false;
462
486
  }
463
487
  _this6.pipeProcessors();
464
- if (!(_this6.track && (_this6.canvas && _this6.canvas.view && _this6.track.isPlaying || !_this6.canvas || !_this6.canvas.view))) {
465
- _context3.next = 44;
466
- break;
467
- }
468
- // ok to sleep
469
- _this6.logger.info('complete thread run');
470
- return _context3.abrupt("return", 0);
471
- case 44:
472
488
  _context3.next = 50;
473
489
  break;
474
490
  case 46:
@@ -1051,12 +1067,13 @@ var AgoraRteScreenShareThread = exports.AgoraRteScreenShareThread = (_dec5 = _lo
1051
1067
  _this14.screenEnable = false;
1052
1068
  _this14.trackState = _type.AgoraRteMediaSourceState.stopped;
1053
1069
  _this14.loopbackDeviceState = _type.AgoraRteMediaSourceState.stopped;
1070
+ _this14._canvasChanged = false;
1054
1071
  return _this14;
1055
1072
  }
1056
1073
  (0, _createClass2["default"])(AgoraRteScreenShareThread, [{
1057
1074
  key: "playing",
1058
1075
  get: function get() {
1059
- return this.track && this.track.isPlaying && (!this.audioTrack || this.audioTrack && this.audioTrack.isPlaying);
1076
+ return this.track && !this._canvasChanged && this.track.isPlaying;
1060
1077
  }
1061
1078
  }, {
1062
1079
  key: "setScreenShareTrackState",
@@ -1067,6 +1084,12 @@ var AgoraRteScreenShareThread = exports.AgoraRteScreenShareThread = (_dec5 = _lo
1067
1084
  this.trackState = state;
1068
1085
  this.emit(_control.AgoraMediaControlEventType.trackStateChanged, state, _track.AgoraRteVideoSourceType.ScreenShare, reason, withAudio);
1069
1086
  }
1087
+ }, {
1088
+ key: "setCanvas",
1089
+ value: function setCanvas(canvas) {
1090
+ this.canvas = canvas;
1091
+ this._canvasChanged = true;
1092
+ }
1070
1093
  }, {
1071
1094
  key: "onExecution",
1072
1095
  value: function () {
@@ -1158,19 +1181,18 @@ var AgoraRteScreenShareThread = exports.AgoraRteScreenShareThread = (_dec5 = _lo
1158
1181
  case 35:
1159
1182
  _this15.logger.info("screenshare started");
1160
1183
  case 36:
1161
- if (_this15.track && _this15.canvas && _this15.canvas.view) {
1162
- _this15.track.play(_this15.canvas.view);
1163
- }
1164
-
1165
- // do not play local audioTrack as it causes echo
1166
1184
  if (!(!_this15.canvas || _this15.canvas && _this15.playing)) {
1167
- _context10.next = 40;
1185
+ _context10.next = 39;
1168
1186
  break;
1169
1187
  }
1170
1188
  _this15.logger.info('complete thread run');
1171
1189
  // ok to sleep
1172
1190
  return _context10.abrupt("return", 0);
1173
- case 40:
1191
+ case 39:
1192
+ if (_this15.track && _this15.canvas && _this15.canvas.view) {
1193
+ _this15.track.play(_this15.canvas.view);
1194
+ _this15._canvasChanged = false;
1195
+ }
1174
1196
  _context10.next = 47;
1175
1197
  break;
1176
1198
  case 42:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-rte-sdk",
3
- "version": "2.9.30",
3
+ "version": "2.9.32",
4
4
  "description": "SDK for building interactive scenarios",
5
5
  "author": "agora.io",
6
6
  "license": "ISC",
@@ -74,4 +74,4 @@
74
74
  "dexie": "3.0.3",
75
75
  "dayjs": "1.10.4"
76
76
  }
77
- }
77
+ }