agora-rte-sdk 2.8.21 → 2.8.30

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.
Files changed (47) hide show
  1. package/dist/index.js +2 -2
  2. package/lib/core/decorator/handlers/log-handler.d.ts +2 -0
  3. package/lib/core/decorator/handlers/log-handler.js +34 -0
  4. package/lib/core/decorator/log/log-serializer.d.ts +7 -0
  5. package/lib/core/decorator/log/log-serializer.js +38 -0
  6. package/lib/core/decorator/utils.d.ts +2 -0
  7. package/lib/core/decorator/utils.js +19 -0
  8. package/lib/core/logger/index.d.ts +1 -0
  9. package/lib/core/logger/index.js +16 -0
  10. package/lib/core/logger/log.worker.js +4 -2
  11. package/lib/core/media/control.d.ts +11 -8
  12. package/lib/core/media/control.js +42 -32
  13. package/lib/core/media/player.d.ts +9 -0
  14. package/lib/core/media/player.js +36 -0
  15. package/lib/core/media/track.d.ts +8 -1
  16. package/lib/core/media/track.js +18 -0
  17. package/lib/core/media/type.d.ts +113 -0
  18. package/lib/core/media/type.js +31 -0
  19. package/lib/core/rtc/adapter/base.d.ts +5 -5
  20. package/lib/core/rtc/adapter/electron/device.d.ts +0 -1
  21. package/lib/core/rtc/adapter/electron/device.js +0 -5
  22. package/lib/core/rtc/adapter/electron/index.d.ts +5 -5
  23. package/lib/core/rtc/adapter/electron/index.js +18 -24
  24. package/lib/core/rtc/adapter/web/client.d.ts +7 -5
  25. package/lib/core/rtc/adapter/web/client.js +33 -28
  26. package/lib/core/rtc/adapter/web/device.d.ts +0 -1
  27. package/lib/core/rtc/adapter/web/device.js +0 -5
  28. package/lib/core/rtc/adapter/web/dispatcher.d.ts +61 -0
  29. package/lib/core/rtc/adapter/web/dispatcher.js +166 -0
  30. package/lib/core/rtc/adapter/web/index.d.ts +9 -5
  31. package/lib/core/rtc/adapter/web/index.js +25 -16
  32. package/lib/core/rtc/adapter/web/thread.d.ts +18 -11
  33. package/lib/core/rtc/adapter/web/thread.js +241 -133
  34. package/lib/core/rtc/index.d.ts +5 -4
  35. package/lib/core/rtc/index.js +12 -12
  36. package/lib/core/rtc/type.d.ts +0 -4
  37. package/lib/core/services/api.d.ts +4 -0
  38. package/lib/core/services/api.js +29 -0
  39. package/lib/core/utils/decorator.d.ts +2 -0
  40. package/lib/core/utils/decorator.js +65 -0
  41. package/lib/index.d.ts +3 -1
  42. package/lib/index.js +24 -17
  43. package/lib/scene/index.d.ts +1 -0
  44. package/lib/scene/index.js +23 -13
  45. package/lib/scene/state-sync.d.ts +21 -0
  46. package/lib/scene/state-sync.js +169 -0
  47. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import { InvocationEvent } from '../type';
2
+ export declare const createLogHandler: (level: 'info' | 'warn' | 'error') => (evt: InvocationEvent) => void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createLogHandler = void 0;
8
+ require("core-js/modules/es.date.to-string.js");
9
+ require("core-js/modules/es.array.concat.js");
10
+ var _logger = require("../../logger");
11
+ var _type = require("../type");
12
+ var noop = function noop() {};
13
+ var createLogHandler = function createLogHandler(level) {
14
+ var log = _logger.Logger[level] || noop;
15
+ return function (evt) {
16
+ if (evt.type === _type.InvocationEventType.pre) {
17
+ var _evt$arguments;
18
+ evt.context.start = new Date().getTime();
19
+ var message = ["[".concat(evt["class"], "] >>> [").concat(evt.method, "]")];
20
+ ((_evt$arguments = evt.arguments) === null || _evt$arguments === void 0 ? void 0 : _evt$arguments.length) && message.push(', args:', evt.arguments);
21
+ //@ts-ignore
22
+ log.apply(void 0, message);
23
+ } else {
24
+ var elapsed = new Date().getTime() - evt.context.start;
25
+ var _message = ["[".concat(evt["class"], "] <<< [").concat(evt.method, "]")];
26
+ evt["return"] && _message.push(', return:', evt["return"]);
27
+ evt.error && _message.push(', err:', evt.error);
28
+ _message.push(", Time elapsed: ".concat(elapsed, "ms"));
29
+ //@ts-ignore
30
+ log.apply(void 0, _message);
31
+ }
32
+ };
33
+ };
34
+ exports.createLogHandler = createLogHandler;
@@ -0,0 +1,7 @@
1
+ interface Serializer {
2
+ match(obj: any): boolean;
3
+ serialize(obj: any): string;
4
+ }
5
+ export declare const addSerializer: (serializer: Serializer) => void;
6
+ export declare const serialize: (data: unknown) => unknown;
7
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.serialize = exports.addSerializer = void 0;
8
+ require("core-js/modules/es.function.name.js");
9
+ require("core-js/modules/es.array.find.js");
10
+ require("core-js/modules/es.regexp.exec.js");
11
+ require("core-js/modules/es.string.match.js");
12
+ var serializers = [];
13
+ var fileSerializer = {
14
+ match: function match(obj) {
15
+ return obj instanceof File;
16
+ },
17
+ serialize: function serialize(file) {
18
+ return JSON.stringify({
19
+ filename: file.name,
20
+ size: file.size
21
+ });
22
+ }
23
+ };
24
+ serializers.push(fileSerializer);
25
+ var addSerializer = function addSerializer(serializer) {
26
+ serializers.push(serializer);
27
+ };
28
+ exports.addSerializer = addSerializer;
29
+ var serialize = function serialize(data) {
30
+ var serializer = serializers.find(function (serializer) {
31
+ return serializer.match(data);
32
+ });
33
+ if (serializer) {
34
+ return serializer.serialize(data);
35
+ }
36
+ return data;
37
+ };
38
+ exports.serialize = serialize;
@@ -0,0 +1,2 @@
1
+ export declare const addIgnoredMethodsToPrototype: (prototype: any, ignoredMethods: string[]) => void;
2
+ export declare const isIgnoredMethod: (prototype: any, method: string) => any;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.isIgnoredMethod = exports.addIgnoredMethodsToPrototype = void 0;
8
+ require("core-js/modules/es.array.concat.js");
9
+ require("core-js/modules/es.array.index-of.js");
10
+ var addIgnoredMethodsToPrototype = function addIgnoredMethodsToPrototype(prototype, ignoredMethods) {
11
+ var methods = prototype.__$$ignoreMethods || [];
12
+ methods = methods.concat(ignoredMethods);
13
+ prototype.__$$ignoreMethods = methods;
14
+ };
15
+ exports.addIgnoredMethodsToPrototype = addIgnoredMethodsToPrototype;
16
+ var isIgnoredMethod = function isIgnoredMethod(prototype, method) {
17
+ return prototype.__$$ignoreMethods && prototype.__$$ignoreMethods.indexOf(method) > -1;
18
+ };
19
+ exports.isIgnoredMethod = isIgnoredMethod;
@@ -26,6 +26,7 @@ export declare class Logger {
26
26
  static info(...args: unknown[]): void;
27
27
  static error(...args: unknown[]): void;
28
28
  static originConsole: Console;
29
+ static setMaxRecords(maxRecords: number): void;
29
30
  debug(...args: unknown[]): void;
30
31
  info(...args: unknown[]): void;
31
32
  warn(...args: unknown[]): void;
@@ -61,6 +61,7 @@ var _configs = require("../../configs");
61
61
  var _db = require("./db");
62
62
  var _log2 = _interopRequireDefault(require("worker-loader?inline=no-fallback!./log.worker"));
63
63
  var _type = require("../../type");
64
+ var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
64
65
  var _logLevelMap;
65
66
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
66
67
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -176,6 +177,21 @@ var Logger = /*#__PURE__*/function () {
176
177
  var _Logger$logger4;
177
178
  (_Logger$logger4 = Logger.logger).error.apply(_Logger$logger4, arguments);
178
179
  }
180
+ }, {
181
+ key: "setMaxRecords",
182
+ value: function setMaxRecords(maxRecords) {
183
+ if ((0, _isNumber["default"])(maxRecords)) {
184
+ console.log("[logger] set maxRecords to ".concat(maxRecords));
185
+ Logger.thread.postMessage({
186
+ type: 'setting',
187
+ data: {
188
+ maxRecords: maxRecords
189
+ }
190
+ });
191
+ } else {
192
+ console.warn("[logger] cannot set maxRecords to an invalid number :".concat(maxRecords));
193
+ }
194
+ }
179
195
  }, {
180
196
  key: "setupConsoleHijack",
181
197
  value: function setupConsoleHijack() {
@@ -34,7 +34,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
34
34
  console.log("[worker] log worker initialzied");
35
35
  var ctx = self;
36
36
  var mutex = new _mutex.Mutex();
37
- var MAX_RECORDS = 50000;
37
+ var maxRecords = 50000;
38
38
  var logs = [];
39
39
  var log = function log() {
40
40
  var _console;
@@ -55,7 +55,7 @@ var debouncedWriting = (0, _debounce["default"])(function () {
55
55
  return _db.db.logs.count();
56
56
  case 6:
57
57
  count = _context.sent;
58
- exceedNo = logscopy.length + count - MAX_RECORDS;
58
+ exceedNo = logscopy.length + count - maxRecords;
59
59
  if (!(exceedNo > 0)) {
60
60
  _context.next = 12;
61
61
  break;
@@ -112,6 +112,8 @@ ctx.onmessage = /*#__PURE__*/function () {
112
112
  timestamp: "".concat(now)
113
113
  });
114
114
  debouncedWriting();
115
+ } else if (evt.data && evt.data.type === 'setting') {
116
+ maxRecords = evt.data.data.maxRecords || 50000;
115
117
  }
116
118
  case 1:
117
119
  case "end":
@@ -1,7 +1,8 @@
1
1
  import { AGEventEmitter } from '../utils/events';
2
2
  import { AGRtcManager } from '../rtc';
3
3
  import { AgoraRteCameraVideoTrack, AgoraRteStreamMediaTrack, AgoraRteMicrophoneAudioTrack, AgoraRteScreenShareTrack } from './track';
4
- import { AGAudioRawDataConfig, AGBeautyEffect, AGRtcDeviceInfo, AGScreenShareDevice } from '../../';
4
+ import { AGBeautyEffect, AGRtcDeviceInfo, AGScreenShareDevice } from '../../';
5
+ import { AgoraRteStreamPlayer } from './player';
5
6
  export declare enum AgoraMediaControlEventType {
6
7
  cameraListChanged = "camera-list-changed",
7
8
  localAudioVolume = "local-audio-volume",
@@ -13,20 +14,25 @@ export declare enum AgoraMediaControlEventType {
13
14
  recordingDeviceListChanged = "recording-device-list-changed",
14
15
  localAudioPlaybackVolumeIndicator = "start-test-audio-playback-volume-indicator",
15
16
  audioPlaybackStateChanged = "audio-playback-state-changed",
16
- localAudioFrame = "local-audio-frame",
17
17
  localTrackBeforeDestroy = "local-track-before-destroy",
18
18
  videoAutoPlayFailed = "video-auto-play-failed"
19
19
  }
20
20
  export declare class AgoraMediaControl extends AGEventEmitter {
21
- camera?: AgoraRteCameraVideoTrack;
22
- microphone?: AgoraRteMicrophoneAudioTrack;
23
- screen?: AgoraRteScreenShareTrack;
21
+ private _camera?;
22
+ private _microphone?;
23
+ private _screen?;
24
+ private _player?;
24
25
  private _rtc;
25
26
  constructor(rtc: AGRtcManager);
27
+ get camera(): AgoraRteCameraVideoTrack | undefined;
28
+ get microphone(): AgoraRteMicrophoneAudioTrack | undefined;
29
+ get screen(): AgoraRteScreenShareTrack | undefined;
30
+ get player(): AgoraRteStreamPlayer | undefined;
26
31
  private _addEventListener;
27
32
  createCameraVideoTrack(): AgoraRteCameraVideoTrack;
28
33
  createMicrophoneAudioTrack(): AgoraRteMicrophoneAudioTrack;
29
34
  createScreenShareTrack(): AgoraRteScreenShareTrack;
35
+ createStreamPlayer(): AgoraRteStreamPlayer;
30
36
  getVideoCameraList(): AGRtcDeviceInfo[];
31
37
  getAudioRecordingList(): AGRtcDeviceInfo[];
32
38
  getAudioPlaybackList(): AGRtcDeviceInfo[];
@@ -38,10 +44,7 @@ export declare class AgoraMediaControl extends AGEventEmitter {
38
44
  stopAudioRecordingDeviceTest(): number;
39
45
  startAudioPlaybackDeviceTest(url: string): number;
40
46
  stopAudioPlaybackDeviceTest(): number;
41
- setAudioFrameCallback(): number;
42
- stopAudioFrameCallback(): number;
43
47
  setBeautyEffectOptions(enable: boolean, options: AGBeautyEffect): number;
44
- setAudioRawDataConfig(config: AGAudioRawDataConfig): number;
45
48
  createStreamMediaTrack(): AgoraRteStreamMediaTrack;
46
49
  takeSnapshot(channel: string, streamUuid: number, filePath: string): Promise<void | import("../rtc/type").AGSnapshotInfo>;
47
50
  getCurrentFrameData(channelName: string, streamUuid: string, isLocal: boolean): ImageData;
@@ -15,6 +15,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _events = require("../utils/events");
17
17
  var _track = require("./track");
18
+ var _player = require("./player");
18
19
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
19
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
21
  var AgoraMediaControlEventType;
@@ -30,7 +31,6 @@ exports.AgoraMediaControlEventType = AgoraMediaControlEventType;
30
31
  AgoraMediaControlEventType["recordingDeviceListChanged"] = "recording-device-list-changed";
31
32
  AgoraMediaControlEventType["localAudioPlaybackVolumeIndicator"] = "start-test-audio-playback-volume-indicator";
32
33
  AgoraMediaControlEventType["audioPlaybackStateChanged"] = "audio-playback-state-changed";
33
- AgoraMediaControlEventType["localAudioFrame"] = "local-audio-frame";
34
34
  AgoraMediaControlEventType["localTrackBeforeDestroy"] = "local-track-before-destroy";
35
35
  AgoraMediaControlEventType["videoAutoPlayFailed"] = "video-auto-play-failed";
36
36
  })(AgoraMediaControlEventType || (exports.AgoraMediaControlEventType = AgoraMediaControlEventType = {}));
@@ -41,15 +41,36 @@ var AgoraMediaControl = /*#__PURE__*/function (_AGEventEmitter) {
41
41
  var _this;
42
42
  (0, _classCallCheck2["default"])(this, AgoraMediaControl);
43
43
  _this = _super.call(this);
44
- _this.camera = void 0;
45
- _this.microphone = void 0;
46
- _this.screen = void 0;
44
+ _this._camera = void 0;
45
+ _this._microphone = void 0;
46
+ _this._screen = void 0;
47
+ _this._player = void 0;
47
48
  _this._rtc = void 0;
48
49
  _this._rtc = rtc;
49
50
  _this._addEventListener(rtc);
50
51
  return _this;
51
52
  }
52
53
  (0, _createClass2["default"])(AgoraMediaControl, [{
54
+ key: "camera",
55
+ get: function get() {
56
+ return this._camera;
57
+ }
58
+ }, {
59
+ key: "microphone",
60
+ get: function get() {
61
+ return this._microphone;
62
+ }
63
+ }, {
64
+ key: "screen",
65
+ get: function get() {
66
+ return this._screen;
67
+ }
68
+ }, {
69
+ key: "player",
70
+ get: function get() {
71
+ return this._player;
72
+ }
73
+ }, {
53
74
  key: "_addEventListener",
54
75
  value: function _addEventListener(rtc) {
55
76
  var _this2 = this;
@@ -100,10 +121,6 @@ var AgoraMediaControl = /*#__PURE__*/function (_AGEventEmitter) {
100
121
  rtc.getAudioDeviceManager().onLocalAudioPlaybackTestVolumeChanged(function (volume) {
101
122
  _this2.emit(AgoraMediaControlEventType.localAudioPlaybackVolumeIndicator, volume);
102
123
  });
103
- // 本地原始音频数据(PCM)
104
- rtc.getAudioDeviceManager().onAudioFrame(function (buffer) {
105
- _this2.emit(AgoraMediaControlEventType.localAudioFrame, buffer);
106
- });
107
124
  // local screenshare
108
125
  rtc.onLocalScreenShareTrackStateChanged(function () {
109
126
  for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
@@ -116,26 +133,34 @@ var AgoraMediaControl = /*#__PURE__*/function (_AGEventEmitter) {
116
133
  }, {
117
134
  key: "createCameraVideoTrack",
118
135
  value: function createCameraVideoTrack() {
119
- if (!this.camera) {
120
- this.camera = new _track.AgoraRteCameraVideoTrack(this._rtc);
136
+ if (!this._camera) {
137
+ this._camera = new _track.AgoraRteCameraVideoTrack(this._rtc);
121
138
  }
122
- return this.camera;
139
+ return this._camera;
123
140
  }
124
141
  }, {
125
142
  key: "createMicrophoneAudioTrack",
126
143
  value: function createMicrophoneAudioTrack() {
127
- if (!this.microphone) {
128
- this.microphone = new _track.AgoraRteMicrophoneAudioTrack(this._rtc);
144
+ if (!this._microphone) {
145
+ this._microphone = new _track.AgoraRteMicrophoneAudioTrack(this._rtc);
129
146
  }
130
- return this.microphone;
147
+ return this._microphone;
131
148
  }
132
149
  }, {
133
150
  key: "createScreenShareTrack",
134
151
  value: function createScreenShareTrack() {
135
- if (!this.screen) {
136
- this.screen = new _track.AgoraRteScreenShareTrack(this._rtc);
152
+ if (!this._screen) {
153
+ this._screen = new _track.AgoraRteScreenShareTrack(this._rtc);
137
154
  }
138
- return this.screen;
155
+ return this._screen;
156
+ }
157
+ }, {
158
+ key: "createStreamPlayer",
159
+ value: function createStreamPlayer() {
160
+ if (!this._player) {
161
+ this._player = new _player.AgoraRteStreamPlayer(this._rtc);
162
+ }
163
+ return this._player;
139
164
  }
140
165
  }, {
141
166
  key: "getVideoCameraList",
@@ -192,26 +217,11 @@ var AgoraMediaControl = /*#__PURE__*/function (_AGEventEmitter) {
192
217
  value: function stopAudioPlaybackDeviceTest() {
193
218
  return this._rtc.stopAudioPlaybackDeviceTest();
194
219
  }
195
- }, {
196
- key: "setAudioFrameCallback",
197
- value: function setAudioFrameCallback() {
198
- return this._rtc.setAudioFrameCallback();
199
- }
200
- }, {
201
- key: "stopAudioFrameCallback",
202
- value: function stopAudioFrameCallback() {
203
- return this._rtc.stopAudioFrameCallback();
204
- }
205
220
  }, {
206
221
  key: "setBeautyEffectOptions",
207
222
  value: function setBeautyEffectOptions(enable, options) {
208
223
  return this._rtc.setBeautyEffectOptions(enable, options);
209
224
  }
210
- }, {
211
- key: "setAudioRawDataConfig",
212
- value: function setAudioRawDataConfig(config) {
213
- return this._rtc.setAudioRawDataConfig(config);
214
- }
215
225
  }, {
216
226
  key: "createStreamMediaTrack",
217
227
  value: function createStreamMediaTrack() {
@@ -0,0 +1,9 @@
1
+ import { AGRtcManager } from '../rtc';
2
+ import { AgoraRteAudioRawDataConfig, AgoraRtePlayAudioRawDataObserver } from './type';
3
+ export declare class AgoraRteStreamPlayer {
4
+ private _rtc;
5
+ constructor(rtc: AGRtcManager);
6
+ setAudioRawDataConfig(config: AgoraRteAudioRawDataConfig): void;
7
+ addAudioRawDataObserver(observer: AgoraRtePlayAudioRawDataObserver): void;
8
+ removeAudioRawDataObserver(observer: AgoraRtePlayAudioRawDataObserver): void;
9
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.AgoraRteStreamPlayer = void 0;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _type = require("./type");
12
+ var AgoraRteStreamPlayer = /*#__PURE__*/function () {
13
+ function AgoraRteStreamPlayer(rtc) {
14
+ (0, _classCallCheck2["default"])(this, AgoraRteStreamPlayer);
15
+ this._rtc = void 0;
16
+ this._rtc = rtc;
17
+ }
18
+ (0, _createClass2["default"])(AgoraRteStreamPlayer, [{
19
+ key: "setAudioRawDataConfig",
20
+ value: function setAudioRawDataConfig(config) {
21
+ this._rtc.setAudioRawDataConfig(config, _type.AgoraRteAudioRawDataPosition.beforeMixed);
22
+ }
23
+ }, {
24
+ key: "addAudioRawDataObserver",
25
+ value: function addAudioRawDataObserver(observer) {
26
+ this._rtc.addAudioRawDataObserver(observer, _type.AgoraRteAudioRawDataPosition.beforeMixed);
27
+ }
28
+ }, {
29
+ key: "removeAudioRawDataObserver",
30
+ value: function removeAudioRawDataObserver(observer) {
31
+ this._rtc.removeAudioRawDataObserver(observer, _type.AgoraRteAudioRawDataPosition.beforeMixed);
32
+ }
33
+ }]);
34
+ return AgoraRteStreamPlayer;
35
+ }();
36
+ exports.AgoraRteStreamPlayer = AgoraRteStreamPlayer;
@@ -1,8 +1,9 @@
1
1
  import { IBaseProcessor } from 'agora-rte-extension';
2
- import { AgoraRteMediaSourceState, AGScreenShareType } from '../..';
2
+ import { AgoraRteAudioRawDataConfig, AgoraRteMediaSourceState, AGScreenShareType } from '../..';
3
3
  import { AGRtcManager } from '../rtc';
4
4
  import { AgoraMediaPlayerCanvas, AgoraRtcVideoCanvas } from '../rtc/canvas';
5
5
  import { StreamMediaPlayer } from '../media-player';
6
+ import { AgoraRteRecordAudioRawDataObserver } from './type';
6
7
  export declare enum AgoraRteVideoSourceType {
7
8
  None = 0,
8
9
  Camera = 1,
@@ -19,6 +20,9 @@ export declare enum AgoraRteMediaPublishState {
19
20
  Unpublished = 0,
20
21
  Published = 1
21
22
  }
23
+ /**
24
+ *
25
+ */
22
26
  export declare abstract class AgoraRteMediaTrack {
23
27
  videoSourceType: AgoraRteVideoSourceType;
24
28
  audioSourceType: AgoraRteAudioSourceType;
@@ -63,6 +67,9 @@ export declare class AgoraRteMicrophoneAudioTrack extends AgoraRteMediaTrack {
63
67
  removeProcessors(): number;
64
68
  setRecordingDevice(deviceId: string): number;
65
69
  setPlaybackDevice(deviceId: string): number;
70
+ setAudioRawDataConfig(config: AgoraRteAudioRawDataConfig): void;
71
+ addAudioRawDataObserver(observer: AgoraRteRecordAudioRawDataObserver): void;
72
+ removeAudioRawDataObserver(observer: AgoraRteRecordAudioRawDataObserver): void;
66
73
  start(): number;
67
74
  stop(): number;
68
75
  }
@@ -33,6 +33,9 @@ exports.AgoraRteAudioSourceType = AgoraRteAudioSourceType;
33
33
  AgoraRteAudioSourceType[AgoraRteAudioSourceType["MediaPlayer"] = 3] = "MediaPlayer";
34
34
  })(AgoraRteAudioSourceType || (exports.AgoraRteAudioSourceType = AgoraRteAudioSourceType = {}));
35
35
  var AgoraRteMediaPublishState;
36
+ /**
37
+ *
38
+ */
36
39
  exports.AgoraRteMediaPublishState = AgoraRteMediaPublishState;
37
40
  (function (AgoraRteMediaPublishState) {
38
41
  AgoraRteMediaPublishState[AgoraRteMediaPublishState["Unpublished"] = 0] = "Unpublished";
@@ -205,6 +208,21 @@ var AgoraRteMicrophoneAudioTrack = /*#__PURE__*/function (_AgoraRteMediaTrack3)
205
208
  value: function setPlaybackDevice(deviceId) {
206
209
  return this.rtc.setAudioPlaybackDevice(deviceId);
207
210
  }
211
+ }, {
212
+ key: "setAudioRawDataConfig",
213
+ value: function setAudioRawDataConfig(config) {
214
+ this.rtc.setAudioRawDataConfig(config, _.AgoraRteAudioRawDataPosition.record);
215
+ }
216
+ }, {
217
+ key: "addAudioRawDataObserver",
218
+ value: function addAudioRawDataObserver(observer) {
219
+ this.rtc.addAudioRawDataObserver(observer, _.AgoraRteAudioRawDataPosition.record);
220
+ }
221
+ }, {
222
+ key: "removeAudioRawDataObserver",
223
+ value: function removeAudioRawDataObserver(observer) {
224
+ this.rtc.removeAudioRawDataObserver(observer, _.AgoraRteAudioRawDataPosition.record);
225
+ }
208
226
  }, {
209
227
  key: "start",
210
228
  value: function start() {
@@ -0,0 +1,113 @@
1
+ /**
2
+ * 音频裸数据回调参数
3
+ */
4
+ /** @en
5
+ * Audio raw data callback parameter
6
+ */
7
+ export interface AgoraRteAudioRawDataConfig {
8
+ /**
9
+ * 每次回调返回的音频数据长度
10
+ */
11
+ /** @en
12
+ * The length of audio data returned in each callback
13
+ */
14
+ frameSize?: 256 | 512 | 1024 | 2048 | 4096 | 8192 | 16384;
15
+ /**
16
+ * 音频数据的采样率
17
+ */
18
+ /** @en
19
+ * Sampling rate of audio data
20
+ */
21
+ sampleRate?: number;
22
+ /**
23
+ * 是否启用立体音
24
+ */
25
+ /** @en
26
+ * Whether to enable stereo.
27
+ */
28
+ stereo?: boolean;
29
+ }
30
+ /**
31
+ * 音频的输出位置
32
+ */
33
+ /** @en
34
+ * The audio output position
35
+ */
36
+ export declare enum AgoraRteAudioRawDataPosition {
37
+ /**
38
+ * 录制后
39
+ */
40
+ /** @en
41
+ * After recording
42
+ */
43
+ record = 2,
44
+ /**
45
+ * 多条音频流混合成一路即将播放的音频流前
46
+ */
47
+ /** @en
48
+ * Before multiple audio streams are blended into one stream to be played
49
+ */
50
+ beforeMixed = 8
51
+ }
52
+ /**
53
+ * 音频录制数据
54
+ */
55
+ /** @en
56
+ * Audio recording data
57
+ */
58
+ export declare type AgoraRteAudioRawData = {
59
+ /**
60
+ * 音频裸数据
61
+ * @param buffer
62
+ */
63
+ /** @en
64
+ * Audio raw data
65
+ * @param buffer
66
+ */
67
+ buffer: AudioBuffer;
68
+ };
69
+ /**
70
+ * 音频裸数据观察者(本地录音设备)
71
+ */
72
+ /** @en
73
+ * Audio raw data observer(local recording device)
74
+ */
75
+ export interface AgoraRteRecordAudioRawDataObserver {
76
+ /**
77
+ * 本地录制音频裸数据回调
78
+ * @param rawData
79
+ */
80
+ /** @en
81
+ * Local audio stream raw data callback
82
+ * @param rawData
83
+ */
84
+ onAudioRawDataRecored(rawData: AgoraRteAudioRawData): void;
85
+ }
86
+ /**
87
+ * 音频裸数据观察者(远端流)
88
+ */
89
+ /** @en
90
+ * Audio raw data observer(remote streams)
91
+ */
92
+ export interface AgoraRtePlayAudioRawDataObserver {
93
+ /**
94
+ * 远端音频流裸数据回调
95
+ * @param rawData
96
+ * @param streamUuid
97
+ * @param sceneId
98
+ */
99
+ /** @en
100
+ * Remote audio stream raw data callback
101
+ * @param rawData
102
+ * @param streamUuid
103
+ * @param sceneId
104
+ */
105
+ onAudioRawDataBeforeMixed(rawData: AgoraRteAudioRawData, streamUuid: string, sceneId: string): void;
106
+ }
107
+ /**
108
+ * 音频裸数据观察者
109
+ */
110
+ /** @en
111
+ * Audio raw data observer
112
+ */
113
+ export declare type AgoraRteAudioRawDataObserver = AgoraRteRecordAudioRawDataObserver & AgoraRtePlayAudioRawDataObserver;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AgoraRteAudioRawDataPosition = void 0;
8
+ /**
9
+ * 音频裸数据回调参数
10
+ */
11
+ /** @en
12
+ * Audio raw data callback parameter
13
+ */
14
+ /**
15
+ * 音频的输出位置
16
+ */
17
+ /** @en
18
+ * The audio output position
19
+ */
20
+ var AgoraRteAudioRawDataPosition;
21
+ /**
22
+ * 音频录制数据
23
+ */
24
+ /** @en
25
+ * Audio recording data
26
+ */
27
+ exports.AgoraRteAudioRawDataPosition = AgoraRteAudioRawDataPosition;
28
+ (function (AgoraRteAudioRawDataPosition) {
29
+ AgoraRteAudioRawDataPosition[AgoraRteAudioRawDataPosition["record"] = 2] = "record";
30
+ AgoraRteAudioRawDataPosition[AgoraRteAudioRawDataPosition["beforeMixed"] = 8] = "beforeMixed";
31
+ })(AgoraRteAudioRawDataPosition || (exports.AgoraRteAudioRawDataPosition = AgoraRteAudioRawDataPosition = {}));