omnirtc-web 1.4.2-peiyou.0 → 1.4.2
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/es-omnirtc-web.js +525 -532
- package/dist/omnirtc-web.js +529 -536
- package/package.json +1 -1
- package/src/omni.d.ts +8 -10
package/dist/es-omnirtc-web.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Agora from 'agora-rtc-sdk-ng';
|
|
1
2
|
import VERTC, { StreamIndex, MirrorType, VideoRenderMode, MediaType, VideoSourceType, AudioSourceType, ConnectionState, RTCAutoPlayPolicy } from '@volcengine/rtc';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -83,21 +84,168 @@ var lib = function lib(token, options) {
|
|
|
83
84
|
var InvalidTokenError_1 = InvalidTokenError;
|
|
84
85
|
lib.InvalidTokenError = InvalidTokenError_1;
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
/*! *****************************************************************************
|
|
88
|
+
Copyright (c) Microsoft Corporation.
|
|
89
|
+
|
|
90
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
91
|
+
purpose with or without fee is hereby granted.
|
|
92
|
+
|
|
93
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
94
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
95
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
96
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
97
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
98
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
99
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
100
|
+
***************************************************************************** */
|
|
101
|
+
/* global Reflect, Promise */
|
|
102
|
+
|
|
103
|
+
var extendStatics = function(d, b) {
|
|
104
|
+
extendStatics = Object.setPrototypeOf ||
|
|
105
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
106
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
107
|
+
return extendStatics(d, b);
|
|
91
108
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
|
|
110
|
+
function __extends(d, b) {
|
|
111
|
+
extendStatics(d, b);
|
|
112
|
+
function __() { this.constructor = d; }
|
|
113
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var __assign = function() {
|
|
117
|
+
__assign = Object.assign || function __assign(t) {
|
|
118
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
119
|
+
s = arguments[i];
|
|
120
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
121
|
+
}
|
|
122
|
+
return t;
|
|
123
|
+
};
|
|
124
|
+
return __assign.apply(this, arguments);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function __decorate(decorators, target, key, desc) {
|
|
128
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
129
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
130
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
131
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
135
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
136
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
137
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
138
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
139
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
140
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function __generator(thisArg, body) {
|
|
145
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
146
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
147
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
148
|
+
function step(op) {
|
|
149
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
150
|
+
while (_) try {
|
|
151
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
152
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
153
|
+
switch (op[0]) {
|
|
154
|
+
case 0: case 1: t = op; break;
|
|
155
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
156
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
157
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
158
|
+
default:
|
|
159
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
160
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
161
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
162
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
163
|
+
if (t[2]) _.ops.pop();
|
|
164
|
+
_.trys.pop(); continue;
|
|
165
|
+
}
|
|
166
|
+
op = body.call(thisArg, _);
|
|
167
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
168
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function __values(o) {
|
|
173
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
174
|
+
if (m) return m.call(o);
|
|
175
|
+
if (o && typeof o.length === "number") return {
|
|
176
|
+
next: function () {
|
|
177
|
+
if (o && i >= o.length) o = void 0;
|
|
178
|
+
return { value: o && o[i++], done: !o };
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function __read(o, n) {
|
|
185
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
186
|
+
if (!m) return o;
|
|
187
|
+
var i = m.call(o), r, ar = [], e;
|
|
188
|
+
try {
|
|
189
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
190
|
+
}
|
|
191
|
+
catch (error) { e = { error: error }; }
|
|
192
|
+
finally {
|
|
193
|
+
try {
|
|
194
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
195
|
+
}
|
|
196
|
+
finally { if (e) throw e.error; }
|
|
197
|
+
}
|
|
198
|
+
return ar;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function __spread() {
|
|
202
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
203
|
+
ar = ar.concat(__read(arguments[i]));
|
|
204
|
+
return ar;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var Tools = /** @class */ (function () {
|
|
208
|
+
function Tools() {
|
|
209
|
+
}
|
|
210
|
+
Tools.asyncSleep = function (timeMs) {
|
|
211
|
+
return new Promise(function (resolve) {
|
|
212
|
+
setTimeout(resolve, timeMs);
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
Tools.randomString = function (length) {
|
|
216
|
+
var result = '';
|
|
217
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
218
|
+
var charactersLength = characters.length;
|
|
219
|
+
for (var i = 0; i < length; i++) {
|
|
220
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
};
|
|
224
|
+
Tools.getDiffTimeMs = function (oldTime) {
|
|
225
|
+
return Date.now() - oldTime;
|
|
226
|
+
};
|
|
227
|
+
Tools.fetch = function (url, data, method) {
|
|
228
|
+
if (method === void 0) { method = 'POST'; }
|
|
229
|
+
return new Promise(function (resolve, reject) {
|
|
230
|
+
var xhr = new XMLHttpRequest();
|
|
231
|
+
xhr.timeout = 3000;
|
|
232
|
+
xhr.open(method, url);
|
|
233
|
+
xhr.onreadystatechange = function () {
|
|
234
|
+
if (xhr.readyState < 4) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (xhr.status > 199 && xhr.status < 300) {
|
|
238
|
+
resolve();
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
reject();
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
xhr.send(data);
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
return Tools;
|
|
248
|
+
}());
|
|
101
249
|
|
|
102
250
|
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
103
251
|
|
|
@@ -2449,19 +2597,19 @@ validateRtpParameters(videoRtpParameters);var rtpParameters={mid:RTP_PROBATOR_MI
|
|
|
2449
2597
|
validateRtpParameters(rtpParameters);if(rtpParameters.codecs.length===0)return false;var firstMediaCodec=rtpParameters.codecs[0];return extendedRtpCapabilities.codecs.some(function(codec){return codec.remotePayloadType===firstMediaCodec.payloadType;});}var canReceive_1=canReceive;function isRtxCodec(codec){if(!codec)return false;return /.+\/rtx$/i.test(codec.mimeType);}function matchCodecs(aCodec,bCodec){var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$strict=_ref8.strict,strict=_ref8$strict===void 0?false:_ref8$strict,_ref8$modify=_ref8.modify,modify=_ref8$modify===void 0?false:_ref8$modify;var aMimeType=aCodec.mimeType.toLowerCase();var bMimeType=bCodec.mimeType.toLowerCase();if(aMimeType!==bMimeType)return false;if(aCodec.clockRate!==bCodec.clockRate)return false;if(aCodec.channels!==bCodec.channels)return false;// Per codec special checks.
|
|
2450
2598
|
switch(aMimeType){case'video/h264':{var aPacketizationMode=aCodec.parameters['packetization-mode']||0;var bPacketizationMode=bCodec.parameters['packetization-mode']||0;if(aPacketizationMode!==bPacketizationMode)return false;// If strict matching check profile-level-id.
|
|
2451
2599
|
if(strict){if(!h264ProfileLevelId.isSameProfile(aCodec.parameters,bCodec.parameters))return false;var selectedProfileLevelId;try{selectedProfileLevelId=h264ProfileLevelId.generateProfileLevelIdForAnswer(aCodec.parameters,bCodec.parameters);}catch(error){return false;}if(modify){if(selectedProfileLevelId){aCodec.parameters['profile-level-id']=selectedProfileLevelId;bCodec.parameters['profile-level-id']=selectedProfileLevelId;}else {delete aCodec.parameters['profile-level-id'];delete bCodec.parameters['profile-level-id'];}}}break;}case'video/vp9':{// If strict matching check profile-id.
|
|
2452
|
-
if(strict){var aProfileId=aCodec.parameters['profile-id']||0;var bProfileId=bCodec.parameters['profile-id']||0;if(aProfileId!==bProfileId)return false;}break;}}return true;}function matchHeaderExtensions(aExt,bExt){if(aExt.kind&&bExt.kind&&aExt.kind!==bExt.kind)return false;if(aExt.uri!==bExt.uri)return false;return true;}function reduceRtcpFeedback(codecA,codecB){var reducedRtcpFeedback=[];var _iterator21=_createForOfIteratorHelper$1(codecA.rtcpFeedback||[]),_step21;try{var _loop4=function _loop4(){var aFb=_step21.value;var matchingBFb=(codecB.rtcpFeedback||[]).find(function(bFb){return bFb.type===aFb.type&&(bFb.parameter===aFb.parameter||!bFb.parameter&&!aFb.parameter);});if(matchingBFb)reducedRtcpFeedback.push(matchingBFb);};for(_iterator21.s();!(_step21=_iterator21.n()).done;){_loop4();}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}return reducedRtcpFeedback;}var ortc=/*#__PURE__*/Object.defineProperty({validateRtpCapabilities:validateRtpCapabilities_1,validateRtpCodecCapability:validateRtpCodecCapability_1,validateRtcpFeedback:validateRtcpFeedback_1,validateRtpHeaderExtension:validateRtpHeaderExtension_1,validateRtpParameters:validateRtpParameters_1,validateRtpCodecParameters:validateRtpCodecParameters_1,validateRtpHeaderExtensionParameters:validateRtpHeaderExtensionParameters_1,validateRtpEncodingParameters:validateRtpEncodingParameters_1,validateRtcpParameters:validateRtcpParameters_1,validateSctpCapabilities:validateSctpCapabilities_1,validateNumSctpStreams:validateNumSctpStreams_1,validateSctpParameters:validateSctpParameters_1,validateSctpStreamParameters:validateSctpStreamParameters_1,getExtendedRtpCapabilities:getExtendedRtpCapabilities_1,getRecvRtpCapabilities:getRecvRtpCapabilities_1,getSendingRtpParameters:getSendingRtpParameters_1,getSendingRemoteRtpParameters:getSendingRemoteRtpParameters_1,reduceCodecs:reduceCodecs_1,generateProbatorRtpParameters:generateProbatorRtpParameters_1,canSend:canSend_1,canReceive:canReceive_1},'__esModule',{value:true});var __awaiter=commonjsGlobal$1&&commonjsGlobal$1.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}}function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);}step((generator=generator.apply(thisArg,_arguments||[])).next());});};var AwaitQueue=/*#__PURE__*/function(){function AwaitQueue(){_classCallCheck(this,AwaitQueue);var _ref9=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error},_ref9$ClosedErrorClas=_ref9.ClosedErrorClass,ClosedErrorClass=_ref9$ClosedErrorClas===void 0?Error:_ref9$ClosedErrorClas,_ref9$StoppedErrorCla=_ref9.StoppedErrorClass,StoppedErrorClass=_ref9$StoppedErrorCla===void 0?Error:_ref9$StoppedErrorCla,_ref9$RemovedTaskErro=_ref9.RemovedTaskErrorClass,RemovedTaskErrorClass=_ref9$RemovedTaskErro===void 0?Error:_ref9$RemovedTaskErro;// Closed flag.
|
|
2600
|
+
if(strict){var aProfileId=aCodec.parameters['profile-id']||0;var bProfileId=bCodec.parameters['profile-id']||0;if(aProfileId!==bProfileId)return false;}break;}}return true;}function matchHeaderExtensions(aExt,bExt){if(aExt.kind&&bExt.kind&&aExt.kind!==bExt.kind)return false;if(aExt.uri!==bExt.uri)return false;return true;}function reduceRtcpFeedback(codecA,codecB){var reducedRtcpFeedback=[];var _iterator21=_createForOfIteratorHelper$1(codecA.rtcpFeedback||[]),_step21;try{var _loop4=function _loop4(){var aFb=_step21.value;var matchingBFb=(codecB.rtcpFeedback||[]).find(function(bFb){return bFb.type===aFb.type&&(bFb.parameter===aFb.parameter||!bFb.parameter&&!aFb.parameter);});if(matchingBFb)reducedRtcpFeedback.push(matchingBFb);};for(_iterator21.s();!(_step21=_iterator21.n()).done;){_loop4();}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}return reducedRtcpFeedback;}var ortc=/*#__PURE__*/Object.defineProperty({validateRtpCapabilities:validateRtpCapabilities_1,validateRtpCodecCapability:validateRtpCodecCapability_1,validateRtcpFeedback:validateRtcpFeedback_1,validateRtpHeaderExtension:validateRtpHeaderExtension_1,validateRtpParameters:validateRtpParameters_1,validateRtpCodecParameters:validateRtpCodecParameters_1,validateRtpHeaderExtensionParameters:validateRtpHeaderExtensionParameters_1,validateRtpEncodingParameters:validateRtpEncodingParameters_1,validateRtcpParameters:validateRtcpParameters_1,validateSctpCapabilities:validateSctpCapabilities_1,validateNumSctpStreams:validateNumSctpStreams_1,validateSctpParameters:validateSctpParameters_1,validateSctpStreamParameters:validateSctpStreamParameters_1,getExtendedRtpCapabilities:getExtendedRtpCapabilities_1,getRecvRtpCapabilities:getRecvRtpCapabilities_1,getSendingRtpParameters:getSendingRtpParameters_1,getSendingRemoteRtpParameters:getSendingRemoteRtpParameters_1,reduceCodecs:reduceCodecs_1,generateProbatorRtpParameters:generateProbatorRtpParameters_1,canSend:canSend_1,canReceive:canReceive_1},'__esModule',{value:true});var __awaiter$2=commonjsGlobal$1&&commonjsGlobal$1.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}}function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);}step((generator=generator.apply(thisArg,_arguments||[])).next());});};var AwaitQueue=/*#__PURE__*/function(){function AwaitQueue(){_classCallCheck(this,AwaitQueue);var _ref9=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error},_ref9$ClosedErrorClas=_ref9.ClosedErrorClass,ClosedErrorClass=_ref9$ClosedErrorClas===void 0?Error:_ref9$ClosedErrorClas,_ref9$StoppedErrorCla=_ref9.StoppedErrorClass,StoppedErrorClass=_ref9$StoppedErrorCla===void 0?Error:_ref9$StoppedErrorCla,_ref9$RemovedTaskErro=_ref9.RemovedTaskErrorClass,RemovedTaskErrorClass=_ref9$RemovedTaskErro===void 0?Error:_ref9$RemovedTaskErro;// Closed flag.
|
|
2453
2601
|
this.closed=false;// Queue of pending tasks.
|
|
2454
2602
|
this.pendingTasks=[];// Error class used when rejecting a task due to AwaitQueue being closed.
|
|
2455
2603
|
this.ClosedErrorClass=Error;// Error class used when rejecting a task due to AwaitQueue being stopped.
|
|
2456
2604
|
this.StoppedErrorClass=Error;// Error class used when removing a pending task when calling removeTask().
|
|
2457
2605
|
this.RemovedTaskErrorClass=Error;this.ClosedErrorClass=ClosedErrorClass;this.StoppedErrorClass=StoppedErrorClass;this.RemovedTaskErrorClass=RemovedTaskErrorClass;}return _createClass(AwaitQueue,[{key:"size",get:function get(){return this.pendingTasks.length;}},{key:"close",value:function close(){if(this.closed)return;this.closed=true;var _iterator22=_createForOfIteratorHelper$1(this.pendingTasks),_step22;try{for(_iterator22.s();!(_step22=_iterator22.n()).done;){var pendingTask=_step22.value;pendingTask.stopped=true;pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed'));}// Enpty the pending tasks array.
|
|
2458
|
-
}catch(err){_iterator22.e(err);}finally{_iterator22.f();}this.pendingTasks.length=0;}},{key:"push",value:function push(task,name){return __awaiter(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee6(){var _this38=this;return regenerator.wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:if(!this.closed){_context7.next=2;break;}throw new this.ClosedErrorClass('AwaitQueue closed');case 2:if(!(typeof task!=='function')){_context7.next=4;break;}throw new TypeError('given task is not a function');case 4:if(!task.name&&name){try{Object.defineProperty(task,'name',{value:name});}catch(error){}}return _context7.abrupt("return",new Promise(function(resolve,reject){var pendingTask={task:task,name:name,resolve:resolve,reject:reject,stopped:false,enqueuedAt:new Date(),executedAt:undefined};// Append task to the queue.
|
|
2606
|
+
}catch(err){_iterator22.e(err);}finally{_iterator22.f();}this.pendingTasks.length=0;}},{key:"push",value:function push(task,name){return __awaiter$2(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee6(){var _this38=this;return regenerator.wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:if(!this.closed){_context7.next=2;break;}throw new this.ClosedErrorClass('AwaitQueue closed');case 2:if(!(typeof task!=='function')){_context7.next=4;break;}throw new TypeError('given task is not a function');case 4:if(!task.name&&name){try{Object.defineProperty(task,'name',{value:name});}catch(error){}}return _context7.abrupt("return",new Promise(function(resolve,reject){var pendingTask={task:task,name:name,resolve:resolve,reject:reject,stopped:false,enqueuedAt:new Date(),executedAt:undefined};// Append task to the queue.
|
|
2459
2607
|
_this38.pendingTasks.push(pendingTask);// And run it if this is the only task in the queue.
|
|
2460
2608
|
if(_this38.pendingTasks.length===1)_this38.next();}));case 6:case"end":return _context7.stop();}},_callee6,this);}));}},{key:"removeTask",value:function removeTask(idx){if(idx===0){throw new TypeError('cannot remove task with index 0');}var pendingTask=this.pendingTasks[idx];if(!pendingTask)return;this.pendingTasks.splice(idx,1);pendingTask.reject(new this.RemovedTaskErrorClass('task removed from the queue'));}},{key:"stop",value:function stop(){if(this.closed)return;var _iterator23=_createForOfIteratorHelper$1(this.pendingTasks),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var pendingTask=_step23.value;pendingTask.stopped=true;pendingTask.reject(new this.StoppedErrorClass('AwaitQueue stopped'));}// Enpty the pending tasks array.
|
|
2461
|
-
}catch(err){_iterator23.e(err);}finally{_iterator23.f();}this.pendingTasks.length=0;}},{key:"dump",value:function dump(){var now=new Date();var idx=0;return this.pendingTasks.map(function(pendingTask){return {idx:idx++,task:pendingTask.task,name:pendingTask.name,enqueuedTime:pendingTask.executedAt?pendingTask.executedAt.getTime()-pendingTask.enqueuedAt.getTime():now.getTime()-pendingTask.enqueuedAt.getTime(),executingTime:pendingTask.executedAt?now.getTime()-pendingTask.executedAt.getTime():0};});}},{key:"next",value:function next(){return __awaiter(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee7(){var pendingTask;return regenerator.wrap(function _callee7$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:// Take the first pending task.
|
|
2609
|
+
}catch(err){_iterator23.e(err);}finally{_iterator23.f();}this.pendingTasks.length=0;}},{key:"dump",value:function dump(){var now=new Date();var idx=0;return this.pendingTasks.map(function(pendingTask){return {idx:idx++,task:pendingTask.task,name:pendingTask.name,enqueuedTime:pendingTask.executedAt?pendingTask.executedAt.getTime()-pendingTask.enqueuedAt.getTime():now.getTime()-pendingTask.enqueuedAt.getTime(),executingTime:pendingTask.executedAt?now.getTime()-pendingTask.executedAt.getTime():0};});}},{key:"next",value:function next(){return __awaiter$2(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee7(){var pendingTask;return regenerator.wrap(function _callee7$(_context8){while(1)switch(_context8.prev=_context8.next){case 0:// Take the first pending task.
|
|
2462
2610
|
pendingTask=this.pendingTasks[0];if(pendingTask){_context8.next=3;break;}return _context8.abrupt("return");case 3:_context8.next=5;return this.executeTask(pendingTask);case 5:// Remove the first pending task (the completed one) from the queue.
|
|
2463
2611
|
this.pendingTasks.shift();// And continue.
|
|
2464
|
-
this.next();case 7:case"end":return _context8.stop();}},_callee7,this);}));}},{key:"executeTask",value:function executeTask(pendingTask){return __awaiter(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee8(){var result;return regenerator.wrap(function _callee8$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:if(!pendingTask.stopped){_context9.next=2;break;}return _context9.abrupt("return");case 2:pendingTask.executedAt=new Date();_context9.prev=3;_context9.next=6;return pendingTask.task();case 6:result=_context9.sent;if(!pendingTask.stopped){_context9.next=9;break;}return _context9.abrupt("return");case 9:// Resolve the task with the returned result (if any).
|
|
2612
|
+
this.next();case 7:case"end":return _context8.stop();}},_callee7,this);}));}},{key:"executeTask",value:function executeTask(pendingTask){return __awaiter$2(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee8(){var result;return regenerator.wrap(function _callee8$(_context9){while(1)switch(_context9.prev=_context9.next){case 0:if(!pendingTask.stopped){_context9.next=2;break;}return _context9.abrupt("return");case 2:pendingTask.executedAt=new Date();_context9.prev=3;_context9.next=6;return pendingTask.task();case 6:result=_context9.sent;if(!pendingTask.stopped){_context9.next=9;break;}return _context9.abrupt("return");case 9:// Resolve the task with the returned result (if any).
|
|
2465
2613
|
pendingTask.resolve(result);_context9.next=17;break;case 12:_context9.prev=12;_context9.t0=_context9["catch"](3);if(!pendingTask.stopped){_context9.next=16;break;}return _context9.abrupt("return");case 16:// Reject the task with its own error.
|
|
2466
2614
|
pendingTask.reject(_context9.t0);case 17:case"end":return _context9.stop();}},_callee8,null,[[3,12]]);}));}}]);}();var AwaitQueue_1=AwaitQueue;var lib$1=/*#__PURE__*/Object.defineProperty({AwaitQueue:AwaitQueue_1},'__esModule',{value:true});var logger$f=new Logger_1.Logger('Producer');var Producer=/*#__PURE__*/function(_EnhancedEventEmitter3){/**
|
|
2467
2615
|
* @emits transportclose
|
|
@@ -6005,215 +6153,49 @@ if(stream&&stream.getTracks){tracks=stream.getTracks();tracks.forEach(function(t
|
|
|
6005
6153
|
* > - 不建议频繁调用此方法。
|
|
6006
6154
|
*
|
|
6007
6155
|
* ``` javascript
|
|
6008
|
-
* const audioTrack = await CoreRTC.createMicrophoneAudioTrack({ microphoneId });
|
|
6009
|
-
* CoreRTC.checkAudioTrackIsActive(audioTrack).then(result => {
|
|
6010
|
-
* console.log(`${ microphoneLabel } is ${ result ? "available" : "unavailable" }`);
|
|
6011
|
-
* }).catch(e => {
|
|
6012
|
-
* console.log("check audio track error!", e);
|
|
6013
|
-
* });
|
|
6014
|
-
* ```
|
|
6015
|
-
*
|
|
6016
|
-
* @param track 需要进行检测的本地或远端音频轨道。
|
|
6017
|
-
*
|
|
6018
|
-
* @param timeout 音频轨道检测的超时时间,单位为毫秒,默认 5,000 毫秒。
|
|
6019
|
-
*
|
|
6020
|
-
* @returns Whether 传入该方法的音频轨道中的音量大小是否发生了变化:
|
|
6021
|
-
* - `true`: 音量大小有变化。对于麦克风音频轨道,说明音频采集设备采集到了声音。
|
|
6022
|
-
* - `false`: 音量大小未变化,说明音频采集设备没有采集到声音,或自定义音频轨道中没有音量变化,或音频轨道被 mute。
|
|
6023
|
-
*/},{key:"checkAudioTrackIsActive",value:function checkAudioTrackIsActive(track){var timeout=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5000;return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee252(){var _stream,context,source,analyser;return regenerator.wrap(function _callee252$(_context253){while(1)switch(_context253.prev=_context253.next){case 0:if(!(track&&track.track)){_context253.next=13;break;}_stream=new MediaStream();//创建一个媒体流
|
|
6024
|
-
_stream.addTrack(track.track);context=getAudioContext();source=context.createMediaStreamSource(_stream);analyser=context.createAnalyser();source.connect(analyser);analyser.minDecibels=-90;analyser.maxDecibels=-10;analyser.fftSize=256;return _context253.abrupt("return",new Promise(function(resolve){var max=0;var min=0;var num=0;var step=timeout/200;var timer=setInterval(function(){var dataArr=new Uint8Array(analyser.frequencyBinCount);analyser.getByteFrequencyData(dataArr);var mcVolume=dataArr.reduce(function(a,b){return a+b;})/analyser.frequencyBinCount;max=max>mcVolume?max:mcVolume;min=min<mcVolume?min:mcVolume;num=num+1;if(num>=step){clearInterval(timer);resolve(Boolean(max-min>AUDIO_AVAILABLE));}},200);}));case 13:return _context253.abrupt("return",false);case 14:case"end":return _context253.stop();}},_callee252);}));}},{key:"getListeners",value:function getListeners(event){return _superPropGet(CoreRTC,"listeners",this,3)([event]);}}]);}(EnhancedEventEmitter_2);/**
|
|
6025
|
-
* @ignore
|
|
6026
|
-
*/var coreRTC=new CoreRTC();/**
|
|
6027
|
-
* @ignore
|
|
6028
|
-
*/var cacheMap=new Map();/**
|
|
6029
|
-
* @ignore
|
|
6030
|
-
*/function getStringArrayBuffer(source){return axios({method:'get',url:source,responseType:'arraybuffer'}).then(function(resp){return resp.data;});}/**
|
|
6031
|
-
* @ignore
|
|
6032
|
-
*/function decodeAudioData(arrayBuffer){return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee253(){var audioCtxInstance;return regenerator.wrap(function _callee253$(_context254){while(1)switch(_context254.prev=_context254.next){case 0:audioCtxInstance=getAudioContext();return _context254.abrupt("return",new Promise(function(resolve,reject){audioCtxInstance.decodeAudioData(arrayBuffer,function(res){resolve(res);},function(err){reject(new CoreRTCError(CoreRTCErrorCode.DECODE_AUDIO_FILE_FAILED,typeof err==='string'?err:'decode audio file failed'));});}));case 2:case"end":return _context254.stop();}},_callee253);}));}/**
|
|
6033
|
-
* @ignore
|
|
6034
|
-
*/function getAudioBuffer(source,cacheOnlineFile){return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee254(){var arrayBuffer,cacheAudioBuffer,getFileArrayBuffer,audioBuffer;return regenerator.wrap(function _callee254$(_context255){while(1)switch(_context255.prev=_context255.next){case 0:if(!('string'==typeof source)){_context255.next=15;break;}cacheAudioBuffer=cacheMap.get(source);if(!cacheAudioBuffer){_context255.next=4;break;}return _context255.abrupt("return",cacheAudioBuffer);case 4:_context255.prev=4;_context255.next=7;return getStringArrayBuffer(source);case 7:arrayBuffer=_context255.sent;_context255.next=13;break;case 10:_context255.prev=10;_context255.t0=_context255["catch"](4);throw new CoreRTCError(CoreRTCErrorCode.CHECK_VIDEO_TRACK_ERROR,typeof _context255.t0==='string'?_context255.t0:'fetch audio file failed');case 13:_context255.next=19;break;case 15:getFileArrayBuffer=new Promise(function(resolve,reject){var fileReader=new FileReader();fileReader.addEventListener('load',function(res){if(res.target){resolve(res.target.result);}else {reject(new CoreRTCError(CoreRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR,'read local audio file error'));}});fileReader.addEventListener('error',function(){reject(new CoreRTCError(CoreRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR,'read local audio file error'));});fileReader.readAsArrayBuffer(source);});_context255.next=18;return getFileArrayBuffer;case 18:arrayBuffer=_context255.sent;case 19:_context255.next=21;return decodeAudioData(arrayBuffer);case 21:audioBuffer=_context255.sent;if('string'==typeof source&&cacheOnlineFile)cacheMap.set(source,audioBuffer);return _context255.abrupt("return",audioBuffer);case 24:case"end":return _context255.stop();}},_callee254,null,[[4,10]]);}));}
|
|
6035
|
-
|
|
6036
|
-
/*! *****************************************************************************
|
|
6037
|
-
Copyright (c) Microsoft Corporation.
|
|
6038
|
-
|
|
6039
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6040
|
-
purpose with or without fee is hereby granted.
|
|
6041
|
-
|
|
6042
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
6043
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
6044
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
6045
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
6046
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
6047
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
6048
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
6049
|
-
***************************************************************************** */
|
|
6050
|
-
/* global Reflect, Promise */
|
|
6051
|
-
|
|
6052
|
-
var extendStatics = function(d, b) {
|
|
6053
|
-
extendStatics = Object.setPrototypeOf ||
|
|
6054
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6055
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6056
|
-
return extendStatics(d, b);
|
|
6057
|
-
};
|
|
6058
|
-
|
|
6059
|
-
function __extends(d, b) {
|
|
6060
|
-
extendStatics(d, b);
|
|
6061
|
-
function __() { this.constructor = d; }
|
|
6062
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6063
|
-
}
|
|
6064
|
-
|
|
6065
|
-
var __assign = function() {
|
|
6066
|
-
__assign = Object.assign || function __assign(t) {
|
|
6067
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6068
|
-
s = arguments[i];
|
|
6069
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
6070
|
-
}
|
|
6071
|
-
return t;
|
|
6072
|
-
};
|
|
6073
|
-
return __assign.apply(this, arguments);
|
|
6074
|
-
};
|
|
6075
|
-
|
|
6076
|
-
function __decorate(decorators, target, key, desc) {
|
|
6077
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6078
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6079
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6080
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6081
|
-
}
|
|
6082
|
-
|
|
6083
|
-
function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
6084
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6085
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6086
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6087
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6088
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
6089
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6090
|
-
});
|
|
6091
|
-
}
|
|
6092
|
-
|
|
6093
|
-
function __generator(thisArg, body) {
|
|
6094
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
6095
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
6096
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6097
|
-
function step(op) {
|
|
6098
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
6099
|
-
while (_) try {
|
|
6100
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
6101
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
6102
|
-
switch (op[0]) {
|
|
6103
|
-
case 0: case 1: t = op; break;
|
|
6104
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
6105
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
6106
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
6107
|
-
default:
|
|
6108
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
6109
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
6110
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
6111
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
6112
|
-
if (t[2]) _.ops.pop();
|
|
6113
|
-
_.trys.pop(); continue;
|
|
6114
|
-
}
|
|
6115
|
-
op = body.call(thisArg, _);
|
|
6116
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
6117
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
6118
|
-
}
|
|
6119
|
-
}
|
|
6120
|
-
|
|
6121
|
-
function __values(o) {
|
|
6122
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
6123
|
-
if (m) return m.call(o);
|
|
6124
|
-
if (o && typeof o.length === "number") return {
|
|
6125
|
-
next: function () {
|
|
6126
|
-
if (o && i >= o.length) o = void 0;
|
|
6127
|
-
return { value: o && o[i++], done: !o };
|
|
6128
|
-
}
|
|
6129
|
-
};
|
|
6130
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
6131
|
-
}
|
|
6132
|
-
|
|
6133
|
-
function __read(o, n) {
|
|
6134
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
6135
|
-
if (!m) return o;
|
|
6136
|
-
var i = m.call(o), r, ar = [], e;
|
|
6137
|
-
try {
|
|
6138
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
6139
|
-
}
|
|
6140
|
-
catch (error) { e = { error: error }; }
|
|
6141
|
-
finally {
|
|
6142
|
-
try {
|
|
6143
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
6144
|
-
}
|
|
6145
|
-
finally { if (e) throw e.error; }
|
|
6146
|
-
}
|
|
6147
|
-
return ar;
|
|
6148
|
-
}
|
|
6149
|
-
|
|
6150
|
-
function __spread() {
|
|
6151
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
6152
|
-
ar = ar.concat(__read(arguments[i]));
|
|
6153
|
-
return ar;
|
|
6154
|
-
}
|
|
6155
|
-
|
|
6156
|
-
var defineProperty = createCommonjsModule(function (module) {
|
|
6157
|
-
function _defineProperty(e, r, t) {
|
|
6158
|
-
return (r = toPropertyKey_1(r)) in e ? Object.defineProperty(e, r, {
|
|
6159
|
-
value: t,
|
|
6160
|
-
enumerable: !0,
|
|
6161
|
-
configurable: !0,
|
|
6162
|
-
writable: !0
|
|
6163
|
-
}) : e[r] = t, e;
|
|
6164
|
-
}
|
|
6165
|
-
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
6166
|
-
});
|
|
6167
|
-
var _defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty);
|
|
6168
|
-
|
|
6169
|
-
var AgoraRTC = /*#__PURE__*/_createClass(function AgoraRTC() {
|
|
6170
|
-
_classCallCheck(this, AgoraRTC);
|
|
6171
|
-
throw new Error('AgoraRTC is not available in this environment.');
|
|
6172
|
-
});
|
|
6173
|
-
_defineProperty(AgoraRTC, "VERSION", null);
|
|
6156
|
+
* const audioTrack = await CoreRTC.createMicrophoneAudioTrack({ microphoneId });
|
|
6157
|
+
* CoreRTC.checkAudioTrackIsActive(audioTrack).then(result => {
|
|
6158
|
+
* console.log(`${ microphoneLabel } is ${ result ? "available" : "unavailable" }`);
|
|
6159
|
+
* }).catch(e => {
|
|
6160
|
+
* console.log("check audio track error!", e);
|
|
6161
|
+
* });
|
|
6162
|
+
* ```
|
|
6163
|
+
*
|
|
6164
|
+
* @param track 需要进行检测的本地或远端音频轨道。
|
|
6165
|
+
*
|
|
6166
|
+
* @param timeout 音频轨道检测的超时时间,单位为毫秒,默认 5,000 毫秒。
|
|
6167
|
+
*
|
|
6168
|
+
* @returns Whether 传入该方法的音频轨道中的音量大小是否发生了变化:
|
|
6169
|
+
* - `true`: 音量大小有变化。对于麦克风音频轨道,说明音频采集设备采集到了声音。
|
|
6170
|
+
* - `false`: 音量大小未变化,说明音频采集设备没有采集到声音,或自定义音频轨道中没有音量变化,或音频轨道被 mute。
|
|
6171
|
+
*/},{key:"checkAudioTrackIsActive",value:function checkAudioTrackIsActive(track){var timeout=arguments.length>1&&arguments[1]!==undefined?arguments[1]:5000;return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee252(){var _stream,context,source,analyser;return regenerator.wrap(function _callee252$(_context253){while(1)switch(_context253.prev=_context253.next){case 0:if(!(track&&track.track)){_context253.next=13;break;}_stream=new MediaStream();//创建一个媒体流
|
|
6172
|
+
_stream.addTrack(track.track);context=getAudioContext();source=context.createMediaStreamSource(_stream);analyser=context.createAnalyser();source.connect(analyser);analyser.minDecibels=-90;analyser.maxDecibels=-10;analyser.fftSize=256;return _context253.abrupt("return",new Promise(function(resolve){var max=0;var min=0;var num=0;var step=timeout/200;var timer=setInterval(function(){var dataArr=new Uint8Array(analyser.frequencyBinCount);analyser.getByteFrequencyData(dataArr);var mcVolume=dataArr.reduce(function(a,b){return a+b;})/analyser.frequencyBinCount;max=max>mcVolume?max:mcVolume;min=min<mcVolume?min:mcVolume;num=num+1;if(num>=step){clearInterval(timer);resolve(Boolean(max-min>AUDIO_AVAILABLE));}},200);}));case 13:return _context253.abrupt("return",false);case 14:case"end":return _context253.stop();}},_callee252);}));}},{key:"getListeners",value:function getListeners(event){return _superPropGet(CoreRTC,"listeners",this,3)([event]);}}]);}(EnhancedEventEmitter_2);/**
|
|
6173
|
+
* @ignore
|
|
6174
|
+
*/var coreRTC=new CoreRTC();/**
|
|
6175
|
+
* @ignore
|
|
6176
|
+
*/var cacheMap=new Map();/**
|
|
6177
|
+
* @ignore
|
|
6178
|
+
*/function getStringArrayBuffer(source){return axios({method:'get',url:source,responseType:'arraybuffer'}).then(function(resp){return resp.data;});}/**
|
|
6179
|
+
* @ignore
|
|
6180
|
+
*/function decodeAudioData(arrayBuffer){return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee253(){var audioCtxInstance;return regenerator.wrap(function _callee253$(_context254){while(1)switch(_context254.prev=_context254.next){case 0:audioCtxInstance=getAudioContext();return _context254.abrupt("return",new Promise(function(resolve,reject){audioCtxInstance.decodeAudioData(arrayBuffer,function(res){resolve(res);},function(err){reject(new CoreRTCError(CoreRTCErrorCode.DECODE_AUDIO_FILE_FAILED,typeof err==='string'?err:'decode audio file failed'));});}));case 2:case"end":return _context254.stop();}},_callee253);}));}/**
|
|
6181
|
+
* @ignore
|
|
6182
|
+
*/function getAudioBuffer(source,cacheOnlineFile){return __awaiter$1(this,void 0,void 0,/*#__PURE__*/regenerator.mark(function _callee254(){var arrayBuffer,cacheAudioBuffer,getFileArrayBuffer,audioBuffer;return regenerator.wrap(function _callee254$(_context255){while(1)switch(_context255.prev=_context255.next){case 0:if(!('string'==typeof source)){_context255.next=15;break;}cacheAudioBuffer=cacheMap.get(source);if(!cacheAudioBuffer){_context255.next=4;break;}return _context255.abrupt("return",cacheAudioBuffer);case 4:_context255.prev=4;_context255.next=7;return getStringArrayBuffer(source);case 7:arrayBuffer=_context255.sent;_context255.next=13;break;case 10:_context255.prev=10;_context255.t0=_context255["catch"](4);throw new CoreRTCError(CoreRTCErrorCode.CHECK_VIDEO_TRACK_ERROR,typeof _context255.t0==='string'?_context255.t0:'fetch audio file failed');case 13:_context255.next=19;break;case 15:getFileArrayBuffer=new Promise(function(resolve,reject){var fileReader=new FileReader();fileReader.addEventListener('load',function(res){if(res.target){resolve(res.target.result);}else {reject(new CoreRTCError(CoreRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR,'read local audio file error'));}});fileReader.addEventListener('error',function(){reject(new CoreRTCError(CoreRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR,'read local audio file error'));});fileReader.readAsArrayBuffer(source);});_context255.next=18;return getFileArrayBuffer;case 18:arrayBuffer=_context255.sent;case 19:_context255.next=21;return decodeAudioData(arrayBuffer);case 21:audioBuffer=_context255.sent;if('string'==typeof source&&cacheOnlineFile)cacheMap.set(source,audioBuffer);return _context255.abrupt("return",audioBuffer);case 24:case"end":return _context255.stop();}},_callee254,null,[[4,10]]);}));}
|
|
6174
6183
|
|
|
6175
|
-
var
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
return result;
|
|
6191
|
-
};
|
|
6192
|
-
Tools.getDiffTimeMs = function (oldTime) {
|
|
6193
|
-
return Date.now() - oldTime;
|
|
6194
|
-
};
|
|
6195
|
-
Tools.fetch = function (url, data, method) {
|
|
6196
|
-
if (method === void 0) { method = 'POST'; }
|
|
6197
|
-
return new Promise(function (resolve, reject) {
|
|
6198
|
-
var xhr = new XMLHttpRequest();
|
|
6199
|
-
xhr.timeout = 3000;
|
|
6200
|
-
xhr.open(method, url);
|
|
6201
|
-
xhr.onreadystatechange = function () {
|
|
6202
|
-
if (xhr.readyState < 4) {
|
|
6203
|
-
return;
|
|
6204
|
-
}
|
|
6205
|
-
if (xhr.status > 199 && xhr.status < 300) {
|
|
6206
|
-
resolve();
|
|
6207
|
-
}
|
|
6208
|
-
else {
|
|
6209
|
-
reject();
|
|
6210
|
-
}
|
|
6211
|
-
};
|
|
6212
|
-
xhr.send(data);
|
|
6213
|
-
});
|
|
6214
|
-
};
|
|
6215
|
-
return Tools;
|
|
6216
|
-
}());
|
|
6184
|
+
var StaticConfig = {
|
|
6185
|
+
agentVersion: "OmniRTC_Web_V1.4.2",
|
|
6186
|
+
logVersion: 1,
|
|
6187
|
+
serviceType: 320,
|
|
6188
|
+
logBackendUrl: "https://rtc-logs.magic-school.com/stream.gif"
|
|
6189
|
+
};
|
|
6190
|
+
var RTCEngineType;
|
|
6191
|
+
(function (RTCEngineType) {
|
|
6192
|
+
RTCEngineType[RTCEngineType["Agora"] = 1] = "Agora";
|
|
6193
|
+
RTCEngineType[RTCEngineType["Tencent"] = 2] = "Tencent";
|
|
6194
|
+
RTCEngineType[RTCEngineType["XRTC"] = 3] = "XRTC";
|
|
6195
|
+
RTCEngineType[RTCEngineType["Zego"] = 6] = "Zego";
|
|
6196
|
+
RTCEngineType[RTCEngineType["Core"] = 7] = "Core";
|
|
6197
|
+
RTCEngineType[RTCEngineType["VolcEngine"] = 8] = "VolcEngine";
|
|
6198
|
+
})(RTCEngineType || (RTCEngineType = {}));
|
|
6217
6199
|
|
|
6218
6200
|
var eventemitter3 = createCommonjsModule(function (module) {
|
|
6219
6201
|
|
|
@@ -6687,7 +6669,7 @@ var StatisticDynamicHelper = /** @class */ (function (_super) {
|
|
|
6687
6669
|
}
|
|
6688
6670
|
};
|
|
6689
6671
|
StatisticDynamicHelper.prototype.getStatsLoop = function () {
|
|
6690
|
-
return __awaiter
|
|
6672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6691
6673
|
var _this = this;
|
|
6692
6674
|
return __generator(this, function (_a) {
|
|
6693
6675
|
switch (_a.label) {
|
|
@@ -6716,7 +6698,7 @@ var StatisticDynamicHelper = /** @class */ (function (_super) {
|
|
|
6716
6698
|
});
|
|
6717
6699
|
};
|
|
6718
6700
|
StatisticDynamicHelper.prototype.startMainLoop = function () {
|
|
6719
|
-
return __awaiter
|
|
6701
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6720
6702
|
var localStats, videoStats, audioStats, avgStatsMap, _a, _b, _c, senderId, audioArray, remoteAudioStats, _d, _e, _f, senderId, videoArray, remoteVideoStats, remoteStatsArray, _g, _h, senderId, value;
|
|
6721
6703
|
var e_1, _j, e_2, _k, e_3, _l;
|
|
6722
6704
|
return __generator(this, function (_m) {
|
|
@@ -8162,7 +8144,7 @@ var StatisticLog = /** @class */ (function (_super) {
|
|
|
8162
8144
|
this.sendQueue.push(frame);
|
|
8163
8145
|
};
|
|
8164
8146
|
StatisticLog.prototype.run = function () {
|
|
8165
|
-
return __awaiter
|
|
8147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8166
8148
|
var frame;
|
|
8167
8149
|
var _this = this;
|
|
8168
8150
|
return __generator(this, function (_a) {
|
|
@@ -8260,7 +8242,7 @@ var LogFrame = /** @class */ (function (_super) {
|
|
|
8260
8242
|
};
|
|
8261
8243
|
};
|
|
8262
8244
|
LogFrame.prototype.send = function (publicUserInfo, commonInfo) {
|
|
8263
|
-
return __awaiter
|
|
8245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8264
8246
|
var success, data, e_1;
|
|
8265
8247
|
return __generator(this, function (_a) {
|
|
8266
8248
|
switch (_a.label) {
|
|
@@ -8317,74 +8299,36 @@ function getStreamLogType(audio, video) {
|
|
|
8317
8299
|
}
|
|
8318
8300
|
}
|
|
8319
8301
|
|
|
8320
|
-
var
|
|
8321
|
-
function Emitter() {
|
|
8322
|
-
this._emitter = new eventemitter3();
|
|
8323
|
-
}
|
|
8324
|
-
Emitter.prototype.on = function (event, listener) {
|
|
8325
|
-
this._emitter.on(event, listener);
|
|
8326
|
-
};
|
|
8327
|
-
Emitter.prototype.once = function (event, listener) {
|
|
8328
|
-
this._emitter.once(event, listener);
|
|
8329
|
-
};
|
|
8330
|
-
Emitter.prototype.off = function (event, listener) {
|
|
8331
|
-
this._emitter.off(event, listener);
|
|
8332
|
-
};
|
|
8333
|
-
Emitter.prototype.removeAllListeners = function (event) {
|
|
8334
|
-
this._emitter.removeAllListeners(event);
|
|
8335
|
-
};
|
|
8336
|
-
Emitter.prototype.getListeners = function (event) {
|
|
8337
|
-
return this._emitter.listeners(event);
|
|
8338
|
-
};
|
|
8339
|
-
Emitter.prototype.emit = function (event) {
|
|
8340
|
-
var _a;
|
|
8341
|
-
var args = [];
|
|
8342
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
8343
|
-
args[_i - 1] = arguments[_i];
|
|
8344
|
-
}
|
|
8345
|
-
(_a = this._emitter).emit.apply(_a, __spread([event], args));
|
|
8346
|
-
};
|
|
8347
|
-
return Emitter;
|
|
8348
|
-
}());
|
|
8349
|
-
|
|
8350
|
-
var Client = /** @class */ (function (_super) {
|
|
8351
|
-
__extends(Client, _super);
|
|
8302
|
+
var Client = /** @class */ (function () {
|
|
8352
8303
|
function Client(client, _a) {
|
|
8353
|
-
var appId = _a.appId, roomId = _a.roomId, userId = _a.userId, token = _a.token, type = _a.type,
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
_this._reconnectTimes = 0; // 重连次数
|
|
8357
|
-
_this._userMap = new Map();
|
|
8304
|
+
var appId = _a.appId, roomId = _a.roomId, userId = _a.userId, token = _a.token, type = _a.type, plan = _a.plan;
|
|
8305
|
+
this.reconnectTimestamp = 0; // 开始重连的时间戳
|
|
8306
|
+
this.reconnectTimes = 0; // 重连次数
|
|
8358
8307
|
// for log
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
_this._prefix = prefix;
|
|
8308
|
+
this.roomState = 'init';
|
|
8309
|
+
this._appId = appId;
|
|
8310
|
+
this._roomId = roomId;
|
|
8311
|
+
this._userId = userId;
|
|
8312
|
+
this._token = token;
|
|
8313
|
+
this._client = client;
|
|
8314
|
+
this._type = type;
|
|
8315
|
+
this._plan = plan;
|
|
8316
|
+
this._statisticLog = new StatisticLog();
|
|
8369
8317
|
switch (type) {
|
|
8370
8318
|
case RTCEngineType.Agora:
|
|
8371
|
-
|
|
8319
|
+
this._engineVersion = Agora.VERSION;
|
|
8372
8320
|
break;
|
|
8373
8321
|
case RTCEngineType.Core:
|
|
8374
|
-
|
|
8322
|
+
this._engineVersion = coreRTC.VERSION;
|
|
8375
8323
|
break;
|
|
8376
8324
|
case RTCEngineType.VolcEngine:
|
|
8377
|
-
|
|
8325
|
+
this._engineVersion = VERTC.getSdkVersion();
|
|
8378
8326
|
break;
|
|
8379
|
-
// case RTCEngineType.Agora:
|
|
8380
|
-
// this._engineVersion = Agora.VERSION;
|
|
8381
|
-
// break;
|
|
8382
8327
|
default:
|
|
8383
|
-
|
|
8328
|
+
this._engineVersion = null;
|
|
8384
8329
|
break;
|
|
8385
8330
|
}
|
|
8386
|
-
|
|
8387
|
-
return _this;
|
|
8331
|
+
bindListeners(this);
|
|
8388
8332
|
}
|
|
8389
8333
|
Object.defineProperty(Client.prototype, "connectionState", {
|
|
8390
8334
|
get: function () {
|
|
@@ -8421,6 +8365,21 @@ var Client = /** @class */ (function (_super) {
|
|
|
8421
8365
|
enumerable: false,
|
|
8422
8366
|
configurable: true
|
|
8423
8367
|
});
|
|
8368
|
+
Client.prototype.on = function (event, listener) {
|
|
8369
|
+
return this._client.on(event, listener);
|
|
8370
|
+
};
|
|
8371
|
+
Client.prototype.once = function (event, listener) {
|
|
8372
|
+
return this._client.once(event, listener);
|
|
8373
|
+
};
|
|
8374
|
+
Client.prototype.off = function (event, listener) {
|
|
8375
|
+
return this._client.off(event, listener);
|
|
8376
|
+
};
|
|
8377
|
+
Client.prototype.removeAllListeners = function (event) {
|
|
8378
|
+
this._client.removeAllListeners(event);
|
|
8379
|
+
if (!event || event === 'connection-state-change') {
|
|
8380
|
+
bindListeners(this);
|
|
8381
|
+
}
|
|
8382
|
+
};
|
|
8424
8383
|
Client.prototype.join = function () {
|
|
8425
8384
|
var _this = this;
|
|
8426
8385
|
// @ts-ignore
|
|
@@ -8513,7 +8472,7 @@ var Client = /** @class */ (function (_super) {
|
|
|
8513
8472
|
});
|
|
8514
8473
|
};
|
|
8515
8474
|
Client.prototype.unpublish = function (tracks) {
|
|
8516
|
-
return __awaiter
|
|
8475
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8517
8476
|
var localTracks;
|
|
8518
8477
|
var _this = this;
|
|
8519
8478
|
return __generator(this, function (_a) {
|
|
@@ -8539,14 +8498,10 @@ var Client = /** @class */ (function (_super) {
|
|
|
8539
8498
|
});
|
|
8540
8499
|
});
|
|
8541
8500
|
};
|
|
8542
|
-
|
|
8543
|
-
Client.prototype.subscribe = function (streamId, mediaType) {
|
|
8501
|
+
Client.prototype.subscribe = function (user, mediaType) {
|
|
8544
8502
|
var _this = this;
|
|
8545
8503
|
var startTime = Date.now();
|
|
8546
|
-
|
|
8547
|
-
var flag = streamId.split('_')[3];
|
|
8548
|
-
// @ts-ignore
|
|
8549
|
-
return this._client.subscribe(user, mediaType, flag).then(function (track) {
|
|
8504
|
+
return this._client.subscribe(user, mediaType).then(function (track) {
|
|
8550
8505
|
track.on('first-frame-decoded', function () {
|
|
8551
8506
|
_this._statisticLog.emit('first-frame', FirstFrame[track.trackMediaType], track.getUserId());
|
|
8552
8507
|
});
|
|
@@ -8589,12 +8544,9 @@ var Client = /** @class */ (function (_super) {
|
|
|
8589
8544
|
return track;
|
|
8590
8545
|
});
|
|
8591
8546
|
};
|
|
8592
|
-
Client.prototype.unsubscribe = function (
|
|
8547
|
+
Client.prototype.unsubscribe = function (user, mediaType) {
|
|
8593
8548
|
var _this = this;
|
|
8594
|
-
|
|
8595
|
-
var flag = streamId.split('_')[3];
|
|
8596
|
-
// @ts-ignore
|
|
8597
|
-
return this._client.unsubscribe(user, mediaType, flag).then(function () {
|
|
8549
|
+
return this._client.unsubscribe(user, mediaType).then(function () {
|
|
8598
8550
|
_this._statisticLog.emit('unsubscribed', null, mediaType === 'audio', mediaType === 'video', user.uid);
|
|
8599
8551
|
return;
|
|
8600
8552
|
});
|
|
@@ -8683,114 +8635,191 @@ var Client = /** @class */ (function (_super) {
|
|
|
8683
8635
|
Client.prototype.getRemoteVideoStats = function () {
|
|
8684
8636
|
return this._client.getRemoteVideoStats();
|
|
8685
8637
|
};
|
|
8686
|
-
Client.prototype.
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
break;
|
|
8702
|
-
}
|
|
8703
|
-
case 'IP_BANNED':
|
|
8704
|
-
case 'CHANNEL_BANNED':
|
|
8705
|
-
case 'UID_BANNED': {
|
|
8706
|
-
reason = StatisticLog.DisconnectReason.SERVER;
|
|
8707
|
-
stateReason = 'banned_by_server';
|
|
8708
|
-
break;
|
|
8709
|
-
}
|
|
8638
|
+
Client.prototype.getListeners = function (event) {
|
|
8639
|
+
return this._client.getListeners(event);
|
|
8640
|
+
};
|
|
8641
|
+
return Client;
|
|
8642
|
+
}());
|
|
8643
|
+
var bindListeners = function (client) {
|
|
8644
|
+
client.on('connection-state-change', function (curState, revState, msg) {
|
|
8645
|
+
if (curState === 'DISCONNECTED') {
|
|
8646
|
+
var reason = '', stateReason = '';
|
|
8647
|
+
switch (msg) {
|
|
8648
|
+
case 'SERVER_ERROR':
|
|
8649
|
+
case 'NETWORK_ERROR': {
|
|
8650
|
+
reason = StatisticLog.DisconnectReason.NETWORK;
|
|
8651
|
+
stateReason = 'interrupted';
|
|
8652
|
+
break;
|
|
8710
8653
|
}
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8654
|
+
case 'LEAVE': {
|
|
8655
|
+
reason = StatisticLog.DisconnectReason.CLIENT;
|
|
8656
|
+
stateReason = 'leave_channel';
|
|
8657
|
+
break;
|
|
8658
|
+
}
|
|
8659
|
+
case 'IP_BANNED':
|
|
8660
|
+
case 'CHANNEL_BANNED':
|
|
8661
|
+
case 'UID_BANNED': {
|
|
8662
|
+
reason = StatisticLog.DisconnectReason.SERVER;
|
|
8663
|
+
stateReason = 'banned_by_server';
|
|
8664
|
+
break;
|
|
8715
8665
|
}
|
|
8716
8666
|
}
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
if (curState === 'CONNECTED' && revState === 'RECONNECTING') {
|
|
8722
|
-
_this._statisticLog.emit('joined', false, 0, 1);
|
|
8723
|
-
_this._statisticLog.emit('reconnected', _this._reconnectTimestamp, Date.now(), _this._reconnectTimes);
|
|
8724
|
-
}
|
|
8725
|
-
_this.emit('connection-state-change', curState, msg);
|
|
8726
|
-
});
|
|
8727
|
-
this._client.on('user-joined', function (user) {
|
|
8728
|
-
_this.emit('user-joined', user);
|
|
8729
|
-
});
|
|
8730
|
-
this._client.on('user-left', function (user, reason) {
|
|
8731
|
-
_this.emit('user-left', user, reason);
|
|
8732
|
-
});
|
|
8733
|
-
this._client.on('user-published', function (user, mediaType, flag) {
|
|
8734
|
-
var userId = user.uid;
|
|
8735
|
-
if (_this._type === RTCEngineType.Agora) {
|
|
8736
|
-
flag = streamFlagMap[userId >>> 30];
|
|
8737
|
-
userId = parseAgoraUserId(userId, flag);
|
|
8738
|
-
}
|
|
8739
|
-
if (_this._type === RTCEngineType.Core) {
|
|
8740
|
-
flag = 'main';
|
|
8741
|
-
}
|
|
8742
|
-
var streamId = _this._prefix + "_" + _this._roomId + "_" + userId + "_" + flag;
|
|
8743
|
-
_this._userMap.set(streamId, user);
|
|
8744
|
-
// @ts-ignore
|
|
8745
|
-
_this.emit('user-published', user, mediaType, streamId);
|
|
8746
|
-
});
|
|
8747
|
-
this._client.on('user-unpublished', function (user, mediaType, flag) {
|
|
8748
|
-
var userId = user.uid;
|
|
8749
|
-
if (_this._type === RTCEngineType.Agora) {
|
|
8750
|
-
flag = streamFlagMap[userId >>> 30];
|
|
8751
|
-
userId = parseAgoraUserId(userId, flag);
|
|
8752
|
-
}
|
|
8753
|
-
if (_this._type === RTCEngineType.Core) {
|
|
8754
|
-
flag = 'main';
|
|
8667
|
+
client._statisticLog.emit('connection-state', OmniConnectionState.Disconnected, stateReason);
|
|
8668
|
+
client._statisticLog.emit('disconnected', reason, '');
|
|
8669
|
+
if (client._statisticLog && reason !== StatisticLog.DisconnectReason.NETWORK) {
|
|
8670
|
+
client._statisticLog.stop();
|
|
8755
8671
|
}
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
}
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
this.
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
this.
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8672
|
+
}
|
|
8673
|
+
if (curState === 'RECONNECTING') {
|
|
8674
|
+
client.reconnectTimestamp = Date.now();
|
|
8675
|
+
client.reconnectTimes += 1;
|
|
8676
|
+
}
|
|
8677
|
+
if (curState === 'CONNECTED' && revState === 'RECONNECTING') {
|
|
8678
|
+
client._statisticLog.emit('joined', false, 0, 1);
|
|
8679
|
+
client._statisticLog.emit('reconnected', client.reconnectTimestamp, Date.now(), client.reconnectTimes);
|
|
8680
|
+
}
|
|
8681
|
+
});
|
|
8682
|
+
};
|
|
8683
|
+
|
|
8684
|
+
var AgoraRTC = /** @class */ (function () {
|
|
8685
|
+
function AgoraRTC(_a) {
|
|
8686
|
+
var appId = _a.appId, roomId = _a.roomId, userId = _a.userId, sdkToken = _a.sdkToken, plan = _a.plan;
|
|
8687
|
+
this.VERSION = Agora.VERSION;
|
|
8688
|
+
// constructor() {
|
|
8689
|
+
this._appId = appId;
|
|
8690
|
+
this._roomId = roomId;
|
|
8691
|
+
this._userId = userId;
|
|
8692
|
+
this._token = sdkToken;
|
|
8693
|
+
this._plan = plan;
|
|
8694
|
+
Agora.setLogLevel(3);
|
|
8695
|
+
}
|
|
8696
|
+
AgoraRTC.prototype.createClient = function (config) {
|
|
8697
|
+
var client = Agora.createClient(config);
|
|
8698
|
+
// @ts-ignore
|
|
8699
|
+
return new Client(client, {
|
|
8700
|
+
appId: this._appId,
|
|
8701
|
+
roomId: this._roomId,
|
|
8702
|
+
userId: this._userId,
|
|
8703
|
+
token: this._token,
|
|
8704
|
+
plan: this._plan,
|
|
8705
|
+
type: RTCEngineType.Agora
|
|
8781
8706
|
});
|
|
8782
8707
|
};
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8708
|
+
AgoraRTC.prototype.createBufferSourceAudioTrack = function (config) {
|
|
8709
|
+
return Agora.createBufferSourceAudioTrack(config);
|
|
8710
|
+
};
|
|
8711
|
+
AgoraRTC.prototype.createCameraVideoTrack = function (config) {
|
|
8712
|
+
return Agora.createCameraVideoTrack(config);
|
|
8713
|
+
};
|
|
8714
|
+
AgoraRTC.prototype.createCustomAudioTrack = function (config) {
|
|
8715
|
+
return Agora.createCustomAudioTrack(config);
|
|
8716
|
+
};
|
|
8717
|
+
AgoraRTC.prototype.createCustomVideoTrack = function (config) {
|
|
8718
|
+
return Agora.createCustomVideoTrack(config);
|
|
8719
|
+
};
|
|
8720
|
+
AgoraRTC.prototype.createMicrophoneAndCameraTracks = function (audioConfig, videoConfig) {
|
|
8721
|
+
return Agora.createMicrophoneAndCameraTracks(audioConfig, videoConfig);
|
|
8722
|
+
};
|
|
8723
|
+
AgoraRTC.prototype.createMicrophoneAudioTrack = function (config) {
|
|
8724
|
+
return Agora.createMicrophoneAudioTrack(config);
|
|
8725
|
+
};
|
|
8726
|
+
AgoraRTC.prototype.createScreenVideoTrack = function (config, withAudio) {
|
|
8727
|
+
return Agora.createScreenVideoTrack(config, withAudio);
|
|
8728
|
+
};
|
|
8729
|
+
AgoraRTC.prototype.getSupportedCodec = function () {
|
|
8730
|
+
return Agora.getSupportedCodec();
|
|
8731
|
+
};
|
|
8732
|
+
AgoraRTC.prototype.checkSystemRequirements = function () {
|
|
8733
|
+
return Agora.checkSystemRequirements();
|
|
8734
|
+
};
|
|
8735
|
+
AgoraRTC.prototype.getDevices = function (skipPermissionCheck) {
|
|
8736
|
+
return Agora.getDevices(skipPermissionCheck);
|
|
8737
|
+
};
|
|
8738
|
+
AgoraRTC.prototype.getMicrophones = function (skipPermissionCheck) {
|
|
8739
|
+
return Agora.getMicrophones(skipPermissionCheck);
|
|
8740
|
+
};
|
|
8741
|
+
AgoraRTC.prototype.getCameras = function (skipPermissionCheck) {
|
|
8742
|
+
return Agora.getCameras(skipPermissionCheck);
|
|
8743
|
+
};
|
|
8744
|
+
AgoraRTC.prototype.getPlaybackDevices = function (skipPermissionCheck) {
|
|
8745
|
+
return Agora.getPlaybackDevices(skipPermissionCheck);
|
|
8746
|
+
};
|
|
8747
|
+
AgoraRTC.prototype.getElectronScreenSources = function (type) {
|
|
8748
|
+
return Agora.getElectronScreenSources(type);
|
|
8749
|
+
};
|
|
8750
|
+
AgoraRTC.prototype.setLogLevel = function (level) {
|
|
8751
|
+
return Agora.setLogLevel(level);
|
|
8752
|
+
};
|
|
8753
|
+
AgoraRTC.prototype.enableLogUpload = function () {
|
|
8754
|
+
return Agora.enableLogUpload();
|
|
8755
|
+
};
|
|
8756
|
+
AgoraRTC.prototype.disableLogUpload = function () {
|
|
8757
|
+
return Agora.disableLogUpload();
|
|
8758
|
+
};
|
|
8759
|
+
AgoraRTC.prototype.checkVideoTrackIsActive = function (track, timeout) {
|
|
8760
|
+
return Agora.checkVideoTrackIsActive(track, timeout);
|
|
8761
|
+
};
|
|
8762
|
+
AgoraRTC.prototype.checkAudioTrackIsActive = function (track, timeout) {
|
|
8763
|
+
return Agora.checkAudioTrackIsActive(track, timeout);
|
|
8764
|
+
};
|
|
8765
|
+
Object.defineProperty(AgoraRTC.prototype, "onCameraChanged", {
|
|
8766
|
+
get: function () {
|
|
8767
|
+
return Agora.onCameraChanged;
|
|
8768
|
+
},
|
|
8769
|
+
set: function (value) {
|
|
8770
|
+
Agora.onCameraChanged = value;
|
|
8771
|
+
},
|
|
8772
|
+
enumerable: false,
|
|
8773
|
+
configurable: true
|
|
8774
|
+
});
|
|
8775
|
+
Object.defineProperty(AgoraRTC.prototype, "onMicrophoneChanged", {
|
|
8776
|
+
get: function () {
|
|
8777
|
+
return Agora.onMicrophoneChanged;
|
|
8778
|
+
},
|
|
8779
|
+
set: function (value) {
|
|
8780
|
+
Agora.onMicrophoneChanged = value;
|
|
8781
|
+
},
|
|
8782
|
+
enumerable: false,
|
|
8783
|
+
configurable: true
|
|
8784
|
+
});
|
|
8785
|
+
Object.defineProperty(AgoraRTC.prototype, "onPlaybackDeviceChanged", {
|
|
8786
|
+
get: function () {
|
|
8787
|
+
return Agora.onPlaybackDeviceChanged;
|
|
8788
|
+
},
|
|
8789
|
+
set: function (value) {
|
|
8790
|
+
Agora.onPlaybackDeviceChanged = value;
|
|
8791
|
+
},
|
|
8792
|
+
enumerable: false,
|
|
8793
|
+
configurable: true
|
|
8794
|
+
});
|
|
8795
|
+
Object.defineProperty(AgoraRTC.prototype, "onAudioAutoplayFailed", {
|
|
8796
|
+
get: function () {
|
|
8797
|
+
return Agora.onAudioAutoplayFailed;
|
|
8798
|
+
},
|
|
8799
|
+
set: function (value) {
|
|
8800
|
+
Agora.onAudioAutoplayFailed = value;
|
|
8801
|
+
},
|
|
8802
|
+
enumerable: false,
|
|
8803
|
+
configurable: true
|
|
8804
|
+
});
|
|
8805
|
+
Object.defineProperty(AgoraRTC.prototype, "onAutoplayFailed", {
|
|
8806
|
+
get: function () {
|
|
8807
|
+
return Agora.onAutoplayFailed;
|
|
8808
|
+
},
|
|
8809
|
+
set: function (value) {
|
|
8810
|
+
Agora.onAutoplayFailed = value;
|
|
8811
|
+
},
|
|
8812
|
+
enumerable: false,
|
|
8813
|
+
configurable: true
|
|
8814
|
+
});
|
|
8815
|
+
AgoraRTC.prototype.setArea = function (area) {
|
|
8816
|
+
return Agora.setArea(area);
|
|
8817
|
+
};
|
|
8818
|
+
AgoraRTC.prototype.processExternalMediaAEC = function (element) {
|
|
8819
|
+
return Agora.processExternalMediaAEC(element);
|
|
8820
|
+
};
|
|
8821
|
+
return AgoraRTC;
|
|
8822
|
+
}());
|
|
8794
8823
|
|
|
8795
8824
|
var CoreRTC$1 = /** @class */ (function () {
|
|
8796
8825
|
function CoreRTC(_a) {
|
|
@@ -8812,7 +8841,6 @@ var CoreRTC$1 = /** @class */ (function () {
|
|
|
8812
8841
|
token: this._token,
|
|
8813
8842
|
plan: this._plan,
|
|
8814
8843
|
type: RTCEngineType.Core,
|
|
8815
|
-
prefix: config.streamPrefix,
|
|
8816
8844
|
});
|
|
8817
8845
|
};
|
|
8818
8846
|
CoreRTC.prototype.createBufferSourceAudioTrack = function (config) {
|
|
@@ -9081,7 +9109,7 @@ function log(clsName) {
|
|
|
9081
9109
|
sdk_api_name: '中间层-函数调用',
|
|
9082
9110
|
message: "\u4E2D\u95F4\u5C42-" + clsName + "." + name,
|
|
9083
9111
|
from_encapsulation_layer: true,
|
|
9084
|
-
encapsulation_layer_built_timestamp: '2025/8/13
|
|
9112
|
+
encapsulation_layer_built_timestamp: '2025/8/13 16:12:05',
|
|
9085
9113
|
});
|
|
9086
9114
|
}
|
|
9087
9115
|
}
|
|
@@ -10851,7 +10879,7 @@ var VolcVideoPlayer = /** @class */ (function (_super) {
|
|
|
10851
10879
|
};
|
|
10852
10880
|
// 播放视频
|
|
10853
10881
|
VolcVideoPlayer.prototype.playVideo = function (mediaStreamTrack) {
|
|
10854
|
-
return __awaiter
|
|
10882
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10855
10883
|
var vDom, ms;
|
|
10856
10884
|
var _this = this;
|
|
10857
10885
|
return __generator(this, function (_a) {
|
|
@@ -11237,7 +11265,7 @@ var AudioLevelFetcher = /** @class */ (function () {
|
|
|
11237
11265
|
};
|
|
11238
11266
|
AudioLevelFetcher.prototype.resume = function () {
|
|
11239
11267
|
var _a;
|
|
11240
|
-
return __awaiter
|
|
11268
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11241
11269
|
return __generator(this, function (_b) {
|
|
11242
11270
|
switch (_b.label) {
|
|
11243
11271
|
case 0: return [4 /*yield*/, ((_a = this._ctx) === null || _a === void 0 ? void 0 : _a.resume().catch(function (e) {
|
|
@@ -11461,7 +11489,7 @@ var VolcAudioPlayer = /** @class */ (function (_super) {
|
|
|
11461
11489
|
// 插入promise
|
|
11462
11490
|
ret = ret.then(function () {
|
|
11463
11491
|
return new Promise(function (resolve) {
|
|
11464
|
-
setTimeout(function () { return __awaiter
|
|
11492
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
11465
11493
|
var _a;
|
|
11466
11494
|
return __generator(this, function (_b) {
|
|
11467
11495
|
switch (_b.label) {
|
|
@@ -11578,7 +11606,7 @@ var VolcAudioPlayer = /** @class */ (function (_super) {
|
|
|
11578
11606
|
// rawRTCMediaStreamTrack RTC 收到的 原始 mediaStreamTrack
|
|
11579
11607
|
// mediaStreamTrack 经过 Web Audio 放大的 mediaStreamTrack
|
|
11580
11608
|
VolcAudioPlayer.prototype.playAudio = function (mediaStreamTrack, rawRTCMediaStreamTrack) {
|
|
11581
|
-
return __awaiter
|
|
11609
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11582
11610
|
var aDom, ms;
|
|
11583
11611
|
var _this = this;
|
|
11584
11612
|
return __generator(this, function (_a) {
|
|
@@ -11705,15 +11733,12 @@ var VolcAudioPlayer = /** @class */ (function (_super) {
|
|
|
11705
11733
|
});
|
|
11706
11734
|
};
|
|
11707
11735
|
VolcAudioPlayer.prototype.setPlaybackDevice = function (deviceId) {
|
|
11708
|
-
return __awaiter
|
|
11736
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11709
11737
|
var devices, audioDeviceIds;
|
|
11710
11738
|
return __generator(this, function (_a) {
|
|
11711
11739
|
switch (_a.label) {
|
|
11712
11740
|
case 0:
|
|
11713
11741
|
printLocal('setPlaybackDevice', "setPlaybackDevice: " + deviceId);
|
|
11714
|
-
if (!deviceId) {
|
|
11715
|
-
return [2 /*return*/];
|
|
11716
|
-
}
|
|
11717
11742
|
return [4 /*yield*/, VERTC.enumerateAudioPlaybackDevices()];
|
|
11718
11743
|
case 1:
|
|
11719
11744
|
devices = _a.sent();
|
|
@@ -12060,7 +12085,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12060
12085
|
this._stopPublishingWhenTrackEnded();
|
|
12061
12086
|
};
|
|
12062
12087
|
VolcLocalTrack.prototype._trackMuteHandler = function () {
|
|
12063
|
-
return __awaiter
|
|
12088
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12064
12089
|
return __generator(this, function (_a) {
|
|
12065
12090
|
switch (_a.label) {
|
|
12066
12091
|
case 0:
|
|
@@ -12130,7 +12155,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12130
12155
|
};
|
|
12131
12156
|
VolcLocalTrack.prototype._startCapturing = function () {
|
|
12132
12157
|
var _a, _b, _c, _d;
|
|
12133
|
-
return __awaiter
|
|
12158
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12134
12159
|
return __generator(this, function (_e) {
|
|
12135
12160
|
switch (_e.label) {
|
|
12136
12161
|
case 0:
|
|
@@ -12166,7 +12191,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12166
12191
|
};
|
|
12167
12192
|
VolcLocalTrack.prototype._stopCapturing = function () {
|
|
12168
12193
|
var _a, _b, _c, _d;
|
|
12169
|
-
return __awaiter
|
|
12194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12170
12195
|
return __generator(this, function (_e) {
|
|
12171
12196
|
switch (_e.label) {
|
|
12172
12197
|
case 0:
|
|
@@ -12194,7 +12219,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12194
12219
|
};
|
|
12195
12220
|
VolcLocalTrack.prototype._startScreenCapturing = function () {
|
|
12196
12221
|
var _a, _b, _c, _d;
|
|
12197
|
-
return __awaiter
|
|
12222
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12198
12223
|
return __generator(this, function (_e) {
|
|
12199
12224
|
switch (_e.label) {
|
|
12200
12225
|
case 0:
|
|
@@ -12234,7 +12259,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12234
12259
|
};
|
|
12235
12260
|
VolcLocalTrack.prototype._stopScreenCapturing = function () {
|
|
12236
12261
|
var _a, _b;
|
|
12237
|
-
return __awaiter
|
|
12262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12238
12263
|
return __generator(this, function (_c) {
|
|
12239
12264
|
switch (_c.label) {
|
|
12240
12265
|
case 0:
|
|
@@ -12251,7 +12276,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12251
12276
|
};
|
|
12252
12277
|
VolcLocalTrack.prototype.setEnabled = function (enabled) {
|
|
12253
12278
|
var _a;
|
|
12254
|
-
return __awaiter
|
|
12279
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12255
12280
|
var msg;
|
|
12256
12281
|
return __generator(this, function (_b) {
|
|
12257
12282
|
switch (_b.label) {
|
|
@@ -12270,7 +12295,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12270
12295
|
});
|
|
12271
12296
|
};
|
|
12272
12297
|
VolcLocalTrack.prototype._checkStatus = function () {
|
|
12273
|
-
return __awaiter
|
|
12298
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12274
12299
|
return __generator(this, function (_a) {
|
|
12275
12300
|
if (this.isScreen) {
|
|
12276
12301
|
return [2 /*return*/, this._checkStatusForScreen()];
|
|
@@ -12283,7 +12308,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12283
12308
|
};
|
|
12284
12309
|
VolcLocalTrack.prototype._checkStatusForMain = function () {
|
|
12285
12310
|
var _a, _b;
|
|
12286
|
-
return __awaiter
|
|
12311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12287
12312
|
var mediaType;
|
|
12288
12313
|
return __generator(this, function (_c) {
|
|
12289
12314
|
switch (_c.label) {
|
|
@@ -12322,7 +12347,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12322
12347
|
};
|
|
12323
12348
|
VolcLocalTrack.prototype._stopPublishingWhenTrackEnded = function () {
|
|
12324
12349
|
var _a, _b;
|
|
12325
|
-
return __awaiter
|
|
12350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12326
12351
|
var mediaType;
|
|
12327
12352
|
return __generator(this, function (_c) {
|
|
12328
12353
|
switch (_c.label) {
|
|
@@ -12358,7 +12383,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12358
12383
|
VolcLocalTrack.prototype._refreshPlayAfterTrackUpdated = function () { };
|
|
12359
12384
|
VolcLocalTrack.prototype._checkStatusForScreen = function () {
|
|
12360
12385
|
var _a, _b;
|
|
12361
|
-
return __awaiter
|
|
12386
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12362
12387
|
var mediaType;
|
|
12363
12388
|
return __generator(this, function (_c) {
|
|
12364
12389
|
switch (_c.label) {
|
|
@@ -12397,7 +12422,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12397
12422
|
};
|
|
12398
12423
|
VolcLocalTrack.prototype.setMuted = function (muted) {
|
|
12399
12424
|
var _a;
|
|
12400
|
-
return __awaiter
|
|
12425
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12401
12426
|
var msg;
|
|
12402
12427
|
return __generator(this, function (_b) {
|
|
12403
12428
|
switch (_b.label) {
|
|
@@ -12446,7 +12471,7 @@ var VolcLocalTrack = /** @class */ (function (_super) {
|
|
|
12446
12471
|
// getStats(): LocalVideoTrackStats | LocalAudioTrackStats {}
|
|
12447
12472
|
VolcLocalTrack.prototype.close = function () {
|
|
12448
12473
|
var _a, _b, _c, _d, _e, _f;
|
|
12449
|
-
return __awaiter
|
|
12474
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12450
12475
|
var _g, _h, _j;
|
|
12451
12476
|
return __generator(this, function (_k) {
|
|
12452
12477
|
switch (_k.label) {
|
|
@@ -12846,7 +12871,7 @@ var VolcCameraVideoTrack = /** @class */ (function (_super) {
|
|
|
12846
12871
|
}
|
|
12847
12872
|
VolcCameraVideoTrack.prototype.setDevice = function (deviceId) {
|
|
12848
12873
|
var _a, _b, _c, _d;
|
|
12849
|
-
return __awaiter
|
|
12874
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12850
12875
|
var needResumePlay;
|
|
12851
12876
|
return __generator(this, function (_e) {
|
|
12852
12877
|
switch (_e.label) {
|
|
@@ -12886,7 +12911,7 @@ var VolcCameraVideoTrack = /** @class */ (function (_super) {
|
|
|
12886
12911
|
});
|
|
12887
12912
|
};
|
|
12888
12913
|
VolcCameraVideoTrack.prototype.setEncoderConfiguration = function (config) {
|
|
12889
|
-
return __awaiter
|
|
12914
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12890
12915
|
var videoEncoderConfig;
|
|
12891
12916
|
return __generator(this, function (_a) {
|
|
12892
12917
|
switch (_a.label) {
|
|
@@ -13018,7 +13043,6 @@ var VolcLocalAudioTrack = /** @class */ (function (_super) {
|
|
|
13018
13043
|
};
|
|
13019
13044
|
// 获取本地音频轨道的音量等级。返回音量等级值,范围 [0, 1],1 代表理论最大音量。
|
|
13020
13045
|
// https://rtcdocs.magic-school.com/api/web/classes/track_LocalAudioTrack.LocalAudioTrack.html#getvolumelevel
|
|
13021
|
-
// @log('VolcLocalAudioTrack')
|
|
13022
13046
|
VolcLocalAudioTrack.prototype.getVolumeLevel = function () {
|
|
13023
13047
|
// htmlMediaElement 元素音量等级
|
|
13024
13048
|
// return this._domElement ? this._domElement.volume : 0;
|
|
@@ -13060,7 +13084,7 @@ var VolcLocalAudioTrack = /** @class */ (function (_super) {
|
|
|
13060
13084
|
}
|
|
13061
13085
|
};
|
|
13062
13086
|
VolcLocalAudioTrack.prototype.setPlaybackDevice = function (deviceId) {
|
|
13063
|
-
return __awaiter
|
|
13087
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13064
13088
|
var monitor;
|
|
13065
13089
|
return __generator(this, function (_a) {
|
|
13066
13090
|
switch (_a.label) {
|
|
@@ -13106,6 +13130,9 @@ var VolcLocalAudioTrack = /** @class */ (function (_super) {
|
|
|
13106
13130
|
__decorate([
|
|
13107
13131
|
log('VolcLocalAudioTrack')
|
|
13108
13132
|
], VolcLocalAudioTrack.prototype, "setVolume", null);
|
|
13133
|
+
__decorate([
|
|
13134
|
+
log('VolcLocalAudioTrack')
|
|
13135
|
+
], VolcLocalAudioTrack.prototype, "getVolumeLevel", null);
|
|
13109
13136
|
__decorate([
|
|
13110
13137
|
log('VolcLocalAudioTrack')
|
|
13111
13138
|
], VolcLocalAudioTrack.prototype, "play", null);
|
|
@@ -13137,7 +13164,7 @@ var VolcMicrophoneAudioTrack = /** @class */ (function (_super) {
|
|
|
13137
13164
|
return _this;
|
|
13138
13165
|
}
|
|
13139
13166
|
VolcMicrophoneAudioTrack.prototype.setDevice = function (deviceId) {
|
|
13140
|
-
return __awaiter
|
|
13167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13141
13168
|
return __generator(this, function (_a) {
|
|
13142
13169
|
switch (_a.label) {
|
|
13143
13170
|
case 0:
|
|
@@ -13279,7 +13306,6 @@ var VolcRemoteAudioTrack = /** @class */ (function (_super) {
|
|
|
13279
13306
|
};
|
|
13280
13307
|
// 获取远端音频轨道的音量等级。返回音量等级值,范围 [0, 1],1 代表理论最大音量。
|
|
13281
13308
|
// https://rtcdocs.magic-school.com/api/web/classes/track_RemoteAudioTrack.RemoteAudioTrack.html#getvolumelevel
|
|
13282
|
-
// @log('VolcRemoteAudioTrack')
|
|
13283
13309
|
VolcRemoteAudioTrack.prototype.getVolumeLevel = function () {
|
|
13284
13310
|
// htmlMediaElement 元素音量等级
|
|
13285
13311
|
// return this._domElement ? this._domElement.volume : 0;
|
|
@@ -13304,7 +13330,7 @@ var VolcRemoteAudioTrack = /** @class */ (function (_super) {
|
|
|
13304
13330
|
this._volumeLevel = val;
|
|
13305
13331
|
};
|
|
13306
13332
|
VolcRemoteAudioTrack.prototype.setPlaybackDevice = function (deviceId) {
|
|
13307
|
-
return __awaiter
|
|
13333
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13308
13334
|
var monitor;
|
|
13309
13335
|
return __generator(this, function (_a) {
|
|
13310
13336
|
switch (_a.label) {
|
|
@@ -13395,6 +13421,9 @@ var VolcRemoteAudioTrack = /** @class */ (function (_super) {
|
|
|
13395
13421
|
__decorate([
|
|
13396
13422
|
log('VolcRemoteAudioTrack')
|
|
13397
13423
|
], VolcRemoteAudioTrack.prototype, "_playerEventHandler", null);
|
|
13424
|
+
__decorate([
|
|
13425
|
+
log('VolcRemoteAudioTrack')
|
|
13426
|
+
], VolcRemoteAudioTrack.prototype, "getVolumeLevel", null);
|
|
13398
13427
|
__decorate([
|
|
13399
13428
|
log('VolcRemoteAudioTrack')
|
|
13400
13429
|
], VolcRemoteAudioTrack.prototype, "setVolumeLevel", null);
|
|
@@ -13659,7 +13688,7 @@ var RTCRemoteUser = /** @class */ (function () {
|
|
|
13659
13688
|
return RTCRemoteUser;
|
|
13660
13689
|
}());
|
|
13661
13690
|
|
|
13662
|
-
var handleVideoTrackInitConfig = function (engine, config, forPublish, cameraVideoTrack) { return __awaiter
|
|
13691
|
+
var handleVideoTrackInitConfig = function (engine, config, forPublish, cameraVideoTrack) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13663
13692
|
var videoEncoderConfig;
|
|
13664
13693
|
return __generator(this, function (_a) {
|
|
13665
13694
|
switch (_a.label) {
|
|
@@ -13705,7 +13734,7 @@ var handleVideoTrackInitConfig = function (engine, config, forPublish, cameraVid
|
|
|
13705
13734
|
}
|
|
13706
13735
|
});
|
|
13707
13736
|
}); };
|
|
13708
|
-
var handleAudioTrackInitConfig = function (engine, config, forPublish) { return __awaiter
|
|
13737
|
+
var handleAudioTrackInitConfig = function (engine, config, forPublish) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13709
13738
|
var mediaTrackConstraints, audioEncodeConfig;
|
|
13710
13739
|
return __generator(this, function (_a) {
|
|
13711
13740
|
switch (_a.label) {
|
|
@@ -13757,7 +13786,7 @@ var handleAudioTrackInitConfig = function (engine, config, forPublish) { return
|
|
|
13757
13786
|
}
|
|
13758
13787
|
});
|
|
13759
13788
|
}); };
|
|
13760
|
-
var handleScreenVideoTrackInitConfig = function (engine, config) { return __awaiter
|
|
13789
|
+
var handleScreenVideoTrackInitConfig = function (engine, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13761
13790
|
var screenVideoEncoderConfig;
|
|
13762
13791
|
return __generator(this, function (_a) {
|
|
13763
13792
|
switch (_a.label) {
|
|
@@ -13776,7 +13805,7 @@ var handleScreenVideoTrackInitConfig = function (engine, config) { return __awai
|
|
|
13776
13805
|
}
|
|
13777
13806
|
});
|
|
13778
13807
|
}); };
|
|
13779
|
-
var handleExternalVideoTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter
|
|
13808
|
+
var handleExternalVideoTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13780
13809
|
var mediaStreamTrack, currSettings, externalVideoEncoderConfig;
|
|
13781
13810
|
return __generator(this, function (_a) {
|
|
13782
13811
|
switch (_a.label) {
|
|
@@ -13809,7 +13838,7 @@ var handleExternalVideoTrackInitConfig = function (engine, config, applyForPubli
|
|
|
13809
13838
|
}
|
|
13810
13839
|
});
|
|
13811
13840
|
}); };
|
|
13812
|
-
var handleExternalScreenVideoTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter
|
|
13841
|
+
var handleExternalScreenVideoTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13813
13842
|
var mediaStreamTrack, currSettings, externalVideoEncoderConfig;
|
|
13814
13843
|
return __generator(this, function (_a) {
|
|
13815
13844
|
switch (_a.label) {
|
|
@@ -13841,7 +13870,7 @@ var handleExternalScreenVideoTrackInitConfig = function (engine, config, applyFo
|
|
|
13841
13870
|
}
|
|
13842
13871
|
});
|
|
13843
13872
|
}); };
|
|
13844
|
-
var handleExternalAudioTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter
|
|
13873
|
+
var handleExternalAudioTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13845
13874
|
var audioEncodeConfig, mediaTrackConstraints;
|
|
13846
13875
|
return __generator(this, function (_a) {
|
|
13847
13876
|
switch (_a.label) {
|
|
@@ -13868,7 +13897,7 @@ var handleExternalAudioTrackInitConfig = function (engine, config, applyForPubli
|
|
|
13868
13897
|
});
|
|
13869
13898
|
}); };
|
|
13870
13899
|
// screen-audio 和 audio external track 编码控制没有区别
|
|
13871
|
-
var handleExternalScreenAudioTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter
|
|
13900
|
+
var handleExternalScreenAudioTrackInitConfig = function (engine, config, applyForPublish) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13872
13901
|
var audioEncodeConfig, mediaTrackConstraints;
|
|
13873
13902
|
return __generator(this, function (_a) {
|
|
13874
13903
|
switch (_a.label) {
|
|
@@ -14177,11 +14206,11 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14177
14206
|
var remoteUser = this._remoteUserMap[userId];
|
|
14178
14207
|
if (hasPublishVideo) {
|
|
14179
14208
|
remoteUser.hasVideo = true;
|
|
14180
|
-
this.emit('user-published', remoteUser, 'video'
|
|
14209
|
+
this.emit('user-published', remoteUser, 'video');
|
|
14181
14210
|
}
|
|
14182
14211
|
if (hasPublishAudio) {
|
|
14183
14212
|
remoteUser.hasAudio = true;
|
|
14184
|
-
this.emit('user-published', remoteUser, 'audio'
|
|
14213
|
+
this.emit('user-published', remoteUser, 'audio');
|
|
14185
14214
|
}
|
|
14186
14215
|
};
|
|
14187
14216
|
VolcClient.prototype._onUserPublishScreenHandler = function (e) {
|
|
@@ -14194,11 +14223,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14194
14223
|
var remoteUser = this._remoteUserMap[userId];
|
|
14195
14224
|
if (hasPublishVideo) {
|
|
14196
14225
|
remoteUser.hasScreen = true;
|
|
14197
|
-
this.emit('user-published', remoteUser, '
|
|
14198
|
-
}
|
|
14199
|
-
if (hasPublishAudio) {
|
|
14200
|
-
// 本期暂不支持屏幕共享音频, 所以不做处理
|
|
14201
|
-
this.emit('user-published', remoteUser, 'audio', 'sub');
|
|
14226
|
+
this.emit('user-published', remoteUser, 'screen');
|
|
14202
14227
|
}
|
|
14203
14228
|
};
|
|
14204
14229
|
VolcClient.prototype._onUserUnpublishStreamHandler = function (e) {
|
|
@@ -14211,11 +14236,11 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14211
14236
|
var remoteUser = this._remoteUserMap[userId];
|
|
14212
14237
|
if (hasUnpublishAudio) {
|
|
14213
14238
|
remoteUser.hasAudio = false;
|
|
14214
|
-
this.emit('user-unpublished', remoteUser, 'audio'
|
|
14239
|
+
this.emit('user-unpublished', remoteUser, 'audio');
|
|
14215
14240
|
}
|
|
14216
14241
|
if (hasUnpublishVideo) {
|
|
14217
14242
|
remoteUser.hasVideo = false;
|
|
14218
|
-
this.emit('user-unpublished', remoteUser, 'video'
|
|
14243
|
+
this.emit('user-unpublished', remoteUser, 'video');
|
|
14219
14244
|
}
|
|
14220
14245
|
};
|
|
14221
14246
|
VolcClient.prototype._onUserUnpublishScreenHandler = function (e) {
|
|
@@ -14228,11 +14253,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14228
14253
|
var remoteUser = this._remoteUserMap[userId];
|
|
14229
14254
|
if (hasUnpublishVideo) {
|
|
14230
14255
|
remoteUser.hasScreen = false;
|
|
14231
|
-
this.emit('user-unpublished', remoteUser, '
|
|
14232
|
-
}
|
|
14233
|
-
if (hasUnpublishAudio) {
|
|
14234
|
-
// 本期暂不支持屏幕共享音频, 所以不做处理
|
|
14235
|
-
this.emit('user-unpublished', remoteUser, 'audio', 'sub');
|
|
14256
|
+
this.emit('user-unpublished', remoteUser, 'screen');
|
|
14236
14257
|
}
|
|
14237
14258
|
};
|
|
14238
14259
|
VolcClient.prototype._onError = function (e) {
|
|
@@ -14285,7 +14306,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14285
14306
|
// on(event: string, listener: Function): void;
|
|
14286
14307
|
// P0
|
|
14287
14308
|
VolcClient.prototype.join = function () {
|
|
14288
|
-
return __awaiter
|
|
14309
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14289
14310
|
var _this_1 = this;
|
|
14290
14311
|
return __generator(this, function (_a) {
|
|
14291
14312
|
recoverVolcUsedAPIs();
|
|
@@ -14338,7 +14359,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14338
14359
|
};
|
|
14339
14360
|
// P0
|
|
14340
14361
|
VolcClient.prototype.leave = function () {
|
|
14341
|
-
return __awaiter
|
|
14362
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14342
14363
|
var _this_1 = this;
|
|
14343
14364
|
return __generator(this, function (_a) {
|
|
14344
14365
|
volcCommonStatus.hasJoinRoom = false;
|
|
@@ -14361,7 +14382,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14361
14382
|
});
|
|
14362
14383
|
};
|
|
14363
14384
|
VolcClient.prototype._prepareForPublishCameraVideo = function (cameraVideoTrack) {
|
|
14364
|
-
return __awaiter
|
|
14385
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14365
14386
|
return __generator(this, function (_a) {
|
|
14366
14387
|
switch (_a.label) {
|
|
14367
14388
|
case 0:
|
|
@@ -14377,7 +14398,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14377
14398
|
});
|
|
14378
14399
|
};
|
|
14379
14400
|
VolcClient.prototype._prepareForPublishMicrophoneAudio = function (microphoneAudioTrack) {
|
|
14380
|
-
return __awaiter
|
|
14401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14381
14402
|
return __generator(this, function (_a) {
|
|
14382
14403
|
switch (_a.label) {
|
|
14383
14404
|
case 0:
|
|
@@ -14396,7 +14417,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14396
14417
|
});
|
|
14397
14418
|
};
|
|
14398
14419
|
VolcClient.prototype._prepareForPublishScreenVideo = function (screenVideoTrack) {
|
|
14399
|
-
return __awaiter
|
|
14420
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14400
14421
|
return __generator(this, function (_a) {
|
|
14401
14422
|
switch (_a.label) {
|
|
14402
14423
|
case 0:
|
|
@@ -14416,7 +14437,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14416
14437
|
});
|
|
14417
14438
|
};
|
|
14418
14439
|
VolcClient.prototype._prepareForPublishScreenAudio = function (screenAudioTrack) {
|
|
14419
|
-
return __awaiter
|
|
14440
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14420
14441
|
return __generator(this, function (_a) {
|
|
14421
14442
|
switch (_a.label) {
|
|
14422
14443
|
case 0:
|
|
@@ -14431,7 +14452,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14431
14452
|
});
|
|
14432
14453
|
};
|
|
14433
14454
|
VolcClient.prototype._prepareForPublishExternalVideo = function (externalVideo) {
|
|
14434
|
-
return __awaiter
|
|
14455
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14435
14456
|
return __generator(this, function (_a) {
|
|
14436
14457
|
switch (_a.label) {
|
|
14437
14458
|
case 0:
|
|
@@ -14453,7 +14474,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14453
14474
|
});
|
|
14454
14475
|
};
|
|
14455
14476
|
VolcClient.prototype._prepareForPublishExternalAudio = function (externalAudio) {
|
|
14456
|
-
return __awaiter
|
|
14477
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14457
14478
|
return __generator(this, function (_a) {
|
|
14458
14479
|
switch (_a.label) {
|
|
14459
14480
|
case 0:
|
|
@@ -14475,7 +14496,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14475
14496
|
});
|
|
14476
14497
|
};
|
|
14477
14498
|
VolcClient.prototype._prepareForPublishExternalScreenVideo = function (externalScreenVideo) {
|
|
14478
|
-
return __awaiter
|
|
14499
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14479
14500
|
return __generator(this, function (_a) {
|
|
14480
14501
|
switch (_a.label) {
|
|
14481
14502
|
case 0:
|
|
@@ -14498,7 +14519,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14498
14519
|
});
|
|
14499
14520
|
};
|
|
14500
14521
|
VolcClient.prototype._prepareForPublishExternalScreenAudio = function (externalScreenAudio) {
|
|
14501
|
-
return __awaiter
|
|
14522
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14502
14523
|
return __generator(this, function (_a) {
|
|
14503
14524
|
switch (_a.label) {
|
|
14504
14525
|
case 0:
|
|
@@ -14521,7 +14542,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14521
14542
|
});
|
|
14522
14543
|
};
|
|
14523
14544
|
VolcClient.prototype._prepareForUnPublishCameraVideo = function () {
|
|
14524
|
-
return __awaiter
|
|
14545
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14525
14546
|
return __generator(this, function (_a) {
|
|
14526
14547
|
switch (_a.label) {
|
|
14527
14548
|
case 0:
|
|
@@ -14535,7 +14556,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14535
14556
|
});
|
|
14536
14557
|
};
|
|
14537
14558
|
VolcClient.prototype._prepareForUnPublishMicrophoneAudio = function () {
|
|
14538
|
-
return __awaiter
|
|
14559
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14539
14560
|
return __generator(this, function (_a) {
|
|
14540
14561
|
switch (_a.label) {
|
|
14541
14562
|
case 0:
|
|
@@ -14549,7 +14570,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14549
14570
|
});
|
|
14550
14571
|
};
|
|
14551
14572
|
VolcClient.prototype._prepareForUnPublishScreenVideo = function () {
|
|
14552
|
-
return __awaiter
|
|
14573
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14553
14574
|
return __generator(this, function (_a) {
|
|
14554
14575
|
switch (_a.label) {
|
|
14555
14576
|
case 0:
|
|
@@ -14564,7 +14585,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14564
14585
|
});
|
|
14565
14586
|
};
|
|
14566
14587
|
VolcClient.prototype._prepareForUnPublishScreenAudio = function () {
|
|
14567
|
-
return __awaiter
|
|
14588
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14568
14589
|
return __generator(this, function (_a) {
|
|
14569
14590
|
switch (_a.label) {
|
|
14570
14591
|
case 0:
|
|
@@ -14579,7 +14600,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14579
14600
|
});
|
|
14580
14601
|
};
|
|
14581
14602
|
VolcClient.prototype._prepareForUnPublishExternalVideo = function () {
|
|
14582
|
-
return __awaiter
|
|
14603
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14583
14604
|
return __generator(this, function (_a) {
|
|
14584
14605
|
switch (_a.label) {
|
|
14585
14606
|
case 0:
|
|
@@ -14593,7 +14614,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14593
14614
|
});
|
|
14594
14615
|
};
|
|
14595
14616
|
VolcClient.prototype._prepareForUnPublishExternalAudio = function () {
|
|
14596
|
-
return __awaiter
|
|
14617
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14597
14618
|
return __generator(this, function (_a) {
|
|
14598
14619
|
switch (_a.label) {
|
|
14599
14620
|
case 0:
|
|
@@ -14607,7 +14628,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14607
14628
|
});
|
|
14608
14629
|
};
|
|
14609
14630
|
VolcClient.prototype._prepareForUnPublishExternalScreenVideo = function () {
|
|
14610
|
-
return __awaiter
|
|
14631
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14611
14632
|
return __generator(this, function (_a) {
|
|
14612
14633
|
switch (_a.label) {
|
|
14613
14634
|
case 0:
|
|
@@ -14622,7 +14643,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14622
14643
|
});
|
|
14623
14644
|
};
|
|
14624
14645
|
VolcClient.prototype._prepareForUnPublishExternalScreenAudio = function () {
|
|
14625
|
-
return __awaiter
|
|
14646
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14626
14647
|
return __generator(this, function (_a) {
|
|
14627
14648
|
switch (_a.label) {
|
|
14628
14649
|
case 0:
|
|
@@ -14638,7 +14659,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14638
14659
|
};
|
|
14639
14660
|
// P0
|
|
14640
14661
|
VolcClient.prototype.publish = function (tracks) {
|
|
14641
|
-
return __awaiter
|
|
14662
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14642
14663
|
var trackList, includeVideo, includeAudio, includeScreenVideo, includeScreenAudio, includeVideoExternal, includeAudioExternal, includeScreenVideoExternal, includeScreenAudioExternal, shouldPublishVideo, shouldPublishAudio, shouldPublishScreenVideo, shouldPublishScreenAudio, shouldPublishExternalVideo, shouldPublishExternalAudio, shouldPublishExternalScreenVideo, shouldPublishExternalScreenAudio, mediaType, mediaTypeForScreen, mediaTypeExternal, mediaTypeForScreenExternal;
|
|
14643
14664
|
return __generator(this, function (_a) {
|
|
14644
14665
|
switch (_a.label) {
|
|
@@ -14848,7 +14869,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
14848
14869
|
* @returns
|
|
14849
14870
|
*/
|
|
14850
14871
|
VolcClient.prototype.unpublish = function (tracks) {
|
|
14851
|
-
return __awaiter
|
|
14872
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14852
14873
|
var prevPublishedTrack, trackList, includeVideo, includeAudio, includeScreenVideo, includeScreenAudio, includeVideoExternal, includeAudioExternal, includeScreenVideoExternal, includeScreenAudioExternal, mediaType, mediaTypeForScreen, mediaTypeExternal, mediaTypeForScreenExternal;
|
|
14853
14874
|
var _this_1 = this;
|
|
14854
14875
|
return __generator(this, function (_a) {
|
|
@@ -15011,8 +15032,8 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15011
15032
|
});
|
|
15012
15033
|
});
|
|
15013
15034
|
};
|
|
15014
|
-
VolcClient.prototype.subscribe = function (user, mediaType
|
|
15015
|
-
return __awaiter
|
|
15035
|
+
VolcClient.prototype.subscribe = function (user, mediaType) {
|
|
15036
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15016
15037
|
var mType, track;
|
|
15017
15038
|
return __generator(this, function (_a) {
|
|
15018
15039
|
switch (_a.label) {
|
|
@@ -15020,20 +15041,21 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15020
15041
|
mType = {
|
|
15021
15042
|
video: MediaType.VIDEO,
|
|
15022
15043
|
audio: MediaType.AUDIO,
|
|
15044
|
+
screen: MediaType.VIDEO,
|
|
15023
15045
|
}[mediaType];
|
|
15024
|
-
if (!(
|
|
15046
|
+
if (!(mediaType === 'video' || mediaType === 'audio')) return [3 /*break*/, 2];
|
|
15025
15047
|
return [4 /*yield*/, this._engine.subscribeStream(String(user.uid), mType)];
|
|
15026
15048
|
case 1:
|
|
15027
15049
|
_a.sent();
|
|
15028
15050
|
return [3 /*break*/, 4];
|
|
15029
15051
|
case 2:
|
|
15030
|
-
if (!(
|
|
15052
|
+
if (!(mediaType === 'screen')) return [3 /*break*/, 4];
|
|
15031
15053
|
return [4 /*yield*/, this._engine.subscribeScreen(String(user.uid), mType)];
|
|
15032
15054
|
case 3:
|
|
15033
15055
|
_a.sent();
|
|
15034
15056
|
_a.label = 4;
|
|
15035
15057
|
case 4:
|
|
15036
|
-
if (mediaType === 'video'
|
|
15058
|
+
if (mediaType === 'video') {
|
|
15037
15059
|
track = new VolcRemoteVideoTrack();
|
|
15038
15060
|
track.engine = this._engine;
|
|
15039
15061
|
track.track = this._engine.getRemoteStreamTrack(String(user.uid), StreamIndex.STREAM_INDEX_MAIN, 'video');
|
|
@@ -15041,7 +15063,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15041
15063
|
user.videoTrack = track;
|
|
15042
15064
|
this._stats.remoteVideo.startSubscribe(user);
|
|
15043
15065
|
}
|
|
15044
|
-
if (mediaType === 'audio'
|
|
15066
|
+
else if (mediaType === 'audio') {
|
|
15045
15067
|
track = new VolcRemoteAudioTrack();
|
|
15046
15068
|
track.engine = this._engine;
|
|
15047
15069
|
track.track = this._engine.getRemoteStreamTrack(String(user.uid), StreamIndex.STREAM_INDEX_MAIN, 'audio');
|
|
@@ -15049,7 +15071,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15049
15071
|
user.audioTrack = track;
|
|
15050
15072
|
this._stats.remoteAudio.startSubscribe(user);
|
|
15051
15073
|
}
|
|
15052
|
-
if (mediaType === '
|
|
15074
|
+
else if (mediaType === 'screen') {
|
|
15053
15075
|
track = new VolcRemoteVideoTrack();
|
|
15054
15076
|
track.engine = this._engine;
|
|
15055
15077
|
track.track = this._engine.getRemoteStreamTrack(String(user.uid), StreamIndex.STREAM_INDEX_SCREEN, 'video');
|
|
@@ -15057,14 +15079,6 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15057
15079
|
track.isScreen = true;
|
|
15058
15080
|
user.screenTrack = track;
|
|
15059
15081
|
}
|
|
15060
|
-
if (mediaType === 'audio' && flag === 'sub') {
|
|
15061
|
-
track = new VolcRemoteAudioTrack();
|
|
15062
|
-
track.engine = this._engine;
|
|
15063
|
-
track.track = this._engine.getRemoteStreamTrack(String(user.uid), StreamIndex.STREAM_INDEX_SCREEN, 'audio');
|
|
15064
|
-
track.setUserId(user.uid);
|
|
15065
|
-
track.isScreen = true;
|
|
15066
|
-
user.screenAudioTrack = track;
|
|
15067
|
-
}
|
|
15068
15082
|
return [2 /*return*/, track];
|
|
15069
15083
|
}
|
|
15070
15084
|
});
|
|
@@ -15081,13 +15095,13 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15081
15095
|
// error?: OmniRTCError;
|
|
15082
15096
|
// }[]>;
|
|
15083
15097
|
// P0
|
|
15084
|
-
VolcClient.prototype.unsubscribe = function (user, mediaType
|
|
15085
|
-
return __awaiter
|
|
15098
|
+
VolcClient.prototype.unsubscribe = function (user, mediaType) {
|
|
15099
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15086
15100
|
var mType;
|
|
15087
15101
|
return __generator(this, function (_a) {
|
|
15088
15102
|
switch (_a.label) {
|
|
15089
15103
|
case 0:
|
|
15090
|
-
if (mediaType === 'video'
|
|
15104
|
+
if (mediaType === 'video') {
|
|
15091
15105
|
mType = MediaType.VIDEO;
|
|
15092
15106
|
if (user.videoTrack) {
|
|
15093
15107
|
user.videoTrack.track = undefined;
|
|
@@ -15096,7 +15110,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15096
15110
|
this._stats.remoteVideo.stopSubscribe(user);
|
|
15097
15111
|
return [2 /*return*/, this._engine.unsubscribeStream(String(user.uid), mType)];
|
|
15098
15112
|
}
|
|
15099
|
-
if (mediaType === 'audio'
|
|
15113
|
+
if (mediaType === 'audio') {
|
|
15100
15114
|
mType = MediaType.AUDIO;
|
|
15101
15115
|
if (user.audioTrack) {
|
|
15102
15116
|
user.audioTrack.track = undefined;
|
|
@@ -15105,7 +15119,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15105
15119
|
this._stats.remoteAudio.stopSubscribe(user);
|
|
15106
15120
|
return [2 /*return*/, this._engine.unsubscribeStream(String(user.uid), mType)];
|
|
15107
15121
|
}
|
|
15108
|
-
if (mediaType === '
|
|
15122
|
+
if (mediaType === 'screen') {
|
|
15109
15123
|
mType = MediaType.VIDEO;
|
|
15110
15124
|
if (user.screenTrack) {
|
|
15111
15125
|
user.screenTrack.track = undefined;
|
|
@@ -15113,15 +15127,7 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15113
15127
|
user.screenTrack = undefined;
|
|
15114
15128
|
return [2 /*return*/, this._engine.unsubscribeScreen(String(user.uid), mType)];
|
|
15115
15129
|
}
|
|
15116
|
-
if (mediaType
|
|
15117
|
-
mType = MediaType.AUDIO;
|
|
15118
|
-
if (user.screenAudioTrack) {
|
|
15119
|
-
user.screenAudioTrack.track = undefined;
|
|
15120
|
-
}
|
|
15121
|
-
user.screenAudioTrack = undefined;
|
|
15122
|
-
return [2 /*return*/, this._engine.unsubscribeScreen(String(user.uid), mType)];
|
|
15123
|
-
}
|
|
15124
|
-
if (!(!mediaType && flag === 'main')) return [3 /*break*/, 2];
|
|
15130
|
+
if (!!mediaType) return [3 /*break*/, 3];
|
|
15125
15131
|
mType = MediaType.AUDIO_AND_VIDEO;
|
|
15126
15132
|
if (user.videoTrack) {
|
|
15127
15133
|
user.videoTrack.track = undefined;
|
|
@@ -15136,23 +15142,11 @@ var VolcClient = /** @class */ (function (_super) {
|
|
|
15136
15142
|
return [4 /*yield*/, this._engine.unsubscribeStream(String(user.uid), mType)];
|
|
15137
15143
|
case 1:
|
|
15138
15144
|
_a.sent();
|
|
15139
|
-
_a.label = 2;
|
|
15140
|
-
case 2:
|
|
15141
|
-
if (!(!mediaType && flag === 'sub')) return [3 /*break*/, 4];
|
|
15142
|
-
mType = MediaType.AUDIO_AND_VIDEO;
|
|
15143
|
-
if (user.screenTrack) {
|
|
15144
|
-
user.screenTrack.track = undefined;
|
|
15145
|
-
}
|
|
15146
|
-
if (user.screenAudioTrack) {
|
|
15147
|
-
user.screenAudioTrack.track = undefined;
|
|
15148
|
-
}
|
|
15149
|
-
user.screenTrack = undefined;
|
|
15150
|
-
user.screenAudioTrack = undefined;
|
|
15151
15145
|
return [4 /*yield*/, this._engine.unsubscribeScreen(String(user.uid), mType)];
|
|
15152
|
-
case
|
|
15146
|
+
case 2:
|
|
15153
15147
|
_a.sent();
|
|
15154
|
-
_a.label =
|
|
15155
|
-
case
|
|
15148
|
+
_a.label = 3;
|
|
15149
|
+
case 3: return [2 /*return*/];
|
|
15156
15150
|
}
|
|
15157
15151
|
});
|
|
15158
15152
|
});
|
|
@@ -15525,7 +15519,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15525
15519
|
// }
|
|
15526
15520
|
// P0
|
|
15527
15521
|
VolcCoreRTC.prototype.createCameraVideoTrack = function (config) {
|
|
15528
|
-
return __awaiter
|
|
15522
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15529
15523
|
var localVideoTrack, cameraVideoTrack;
|
|
15530
15524
|
return __generator(this, function (_a) {
|
|
15531
15525
|
switch (_a.label) {
|
|
@@ -15583,7 +15577,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15583
15577
|
};
|
|
15584
15578
|
// P0
|
|
15585
15579
|
VolcCoreRTC.prototype.createMicrophoneAndCameraTracks = function (audioConfig, videoConfig) {
|
|
15586
|
-
return __awaiter
|
|
15580
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15587
15581
|
var localAudioTrack, localVideoTrack, microphoneAudioTrack, cameraVideoTrack;
|
|
15588
15582
|
return __generator(this, function (_a) {
|
|
15589
15583
|
switch (_a.label) {
|
|
@@ -15635,7 +15629,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15635
15629
|
};
|
|
15636
15630
|
// P0
|
|
15637
15631
|
VolcCoreRTC.prototype.createMicrophoneAudioTrack = function (config) {
|
|
15638
|
-
return __awaiter
|
|
15632
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15639
15633
|
var localAudioTrack, res;
|
|
15640
15634
|
return __generator(this, function (_a) {
|
|
15641
15635
|
switch (_a.label) {
|
|
@@ -15669,7 +15663,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15669
15663
|
};
|
|
15670
15664
|
// P0
|
|
15671
15665
|
VolcCoreRTC.prototype.createScreenVideoTrack = function (config, withAudio) {
|
|
15672
|
-
return __awaiter
|
|
15666
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15673
15667
|
var _a, selfBrowserSurface, localVideoTrack, localAudioTrack, screenVideoTrack, screenAudioTrack;
|
|
15674
15668
|
return __generator(this, function (_b) {
|
|
15675
15669
|
switch (_b.label) {
|
|
@@ -15707,7 +15701,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15707
15701
|
};
|
|
15708
15702
|
// P0
|
|
15709
15703
|
VolcCoreRTC.prototype.getSupportedCodec = function () {
|
|
15710
|
-
return __awaiter
|
|
15704
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15711
15705
|
var videoCodecs, res;
|
|
15712
15706
|
return __generator(this, function (_a) {
|
|
15713
15707
|
switch (_a.label) {
|
|
@@ -15729,7 +15723,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15729
15723
|
};
|
|
15730
15724
|
// P0, skipPermissionCheck 可以不考虑
|
|
15731
15725
|
VolcCoreRTC.prototype.getDevices = function (skipPermissionCheck) {
|
|
15732
|
-
return __awaiter
|
|
15726
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15733
15727
|
var devices;
|
|
15734
15728
|
return __generator(this, function (_a) {
|
|
15735
15729
|
switch (_a.label) {
|
|
@@ -15744,7 +15738,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15744
15738
|
};
|
|
15745
15739
|
// P0, skipPermissionCheck 可以不考虑
|
|
15746
15740
|
VolcCoreRTC.prototype.getMicrophones = function (skipPermissionCheck) {
|
|
15747
|
-
return __awaiter
|
|
15741
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15748
15742
|
var devices, audioInputs;
|
|
15749
15743
|
return __generator(this, function (_a) {
|
|
15750
15744
|
switch (_a.label) {
|
|
@@ -15760,7 +15754,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15760
15754
|
};
|
|
15761
15755
|
// P0, skipPermissionCheck 可以不考虑
|
|
15762
15756
|
VolcCoreRTC.prototype.getCameras = function (skipPermissionCheck) {
|
|
15763
|
-
return __awaiter
|
|
15757
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15764
15758
|
var devices, videoInputs;
|
|
15765
15759
|
return __generator(this, function (_a) {
|
|
15766
15760
|
switch (_a.label) {
|
|
@@ -15795,7 +15789,7 @@ var VolcCoreRTC = /** @class */ (function () {
|
|
|
15795
15789
|
};
|
|
15796
15790
|
// P0, skipPermissionCheck 可以不考虑
|
|
15797
15791
|
VolcCoreRTC.prototype.getPlaybackDevices = function (skipPermissionCheck) {
|
|
15798
|
-
return __awaiter
|
|
15792
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
15799
15793
|
var devices, audioOutputs;
|
|
15800
15794
|
return __generator(this, function (_a) {
|
|
15801
15795
|
switch (_a.label) {
|
|
@@ -16037,7 +16031,6 @@ var VolcCoreRTCWrapper = /** @class */ (function () {
|
|
|
16037
16031
|
token: this._token,
|
|
16038
16032
|
plan: this._plan,
|
|
16039
16033
|
type: RTCEngineType.VolcEngine,
|
|
16040
|
-
prefix: config.streamPrefix,
|
|
16041
16034
|
});
|
|
16042
16035
|
};
|
|
16043
16036
|
// P1 下一期实现
|
|
@@ -16239,14 +16232,14 @@ function getRTCInstance(token, extraInfo) {
|
|
|
16239
16232
|
var data = lib(token);
|
|
16240
16233
|
console.log('token data: ', data);
|
|
16241
16234
|
switch (data.type) {
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
|
|
16247
|
-
|
|
16248
|
-
|
|
16249
|
-
|
|
16235
|
+
case RTCEngineType.Agora:
|
|
16236
|
+
return new AgoraRTC({
|
|
16237
|
+
appId: data.appid,
|
|
16238
|
+
roomId: data.roomStr,
|
|
16239
|
+
userId: data.user,
|
|
16240
|
+
sdkToken: data.attachToken || data.token,
|
|
16241
|
+
plan: data.planid,
|
|
16242
|
+
});
|
|
16250
16243
|
case RTCEngineType.Core:
|
|
16251
16244
|
return new CoreRTC$1({
|
|
16252
16245
|
appId: data.appid,
|