diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fccf28f5..0f41a2027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## THE CHANGELOG +#### 3.0.1-rc.3 + - fix multiple channel render bug + - remove `Types` from export, you can import enum or class by `import {} from 'react-native-agora'` + - optimize ts code and doc + #### 3.0.1-rc.2 - add `startPreview` `stopPreview` diff --git a/README.md b/README.md index c6783341e..c0b5b807e 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,19 @@ [![npm](https://img.shields.io/npm/v/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) [![npm](https://img.shields.io/npm/dm/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) [![npm](https://img.shields.io/npm/dt/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) -[![npm](https://img.shields.io/npm/l/react-native-agora.svg)](https://github.com/syanbo/react-native-agora/blob/master/LICENSE) -[![join chat](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/react-native-agora/community) +[![npm](https://img.shields.io/npm/l/react-native-agora.svg)](LICENSE) -The *react-native-agora* is an open-source wrapper for React Native developers. +[中文](README.zh.md) This SDK takes advantage of React Native and Agora RTC Video SDK on Android && iOS. +## Community Contributor + +The community developer [Syanbo](https://github.com/syanbo) developed 1.0 version React Native SDK based on the Agora Native SDK from 2016 to 2017. As the community's demand for React Native SDK keeps growing, Agora has achieved official cooperation with Syanbo, this project now is officially maintained by Agora. Thanks to Syanbo for his long-term contributions to React Native SDK. + +## Release Note +[Changelog](CHANGELOG.md) + ## Installation ### Installing (React Native >= 0.60.0) @@ -24,10 +30,9 @@ or npm i --save react-native-agora ``` -Go to your ios folder and run: +Go to your **ios** folder and run: ```shell script -cd ios pod install ``` @@ -35,6 +40,8 @@ pod install [Native Modules are now Autolinked.](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) +[Migrating to Swift.](https://github.com/AgoraIO-Community/react-native-agora/blob/master/docs/v3/installation.ios.md#step-1-migrating-to-swift) + ### Installing (React Native == 0.59.x) Install `react-native-agora`(^3.0.0): @@ -92,7 +99,7 @@ The error log: [!] The 'xxx' target has libraries with conflicting names: libcrypto.a. ``` -You should disable Flipper, you can found it in the Podfile, and comment the code about Flipper in AppDelegate +You should disable Flipper, you can found it in the Podfile, and comment the code about Flipper in AppDelegate. ``` # Enables Flipper. @@ -141,7 +148,7 @@ Source: https://github.com/facebook/react-native/issues/25154 ## Resources * Complete [API Doc](https://docs.agora.io/en/) at the Developer Center -* [File bugs about this sample](https://github.com/syanbo/react-native-agora/issues) +* [File bugs about this sample](https://github.com/AgoraIO-Community/react-native-agora/issues) * [React Native Getting Started](https://facebook.github.io/react-native/docs/getting-started.html) License diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 000000000..0e29159c3 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,175 @@ +# react-native-agora + +[![npm](https://img.shields.io/npm/v/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) +[![npm](https://img.shields.io/npm/dm/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) +[![npm](https://img.shields.io/npm/dt/react-native-agora.svg)](https://www.npmjs.com/package/react-native-agora) +[![npm](https://img.shields.io/npm/l/react-native-agora.svg)](LICENSE) + +[English](README.md) + +此 SDK 基于 React Native 和 Agora Android 和 iOS 的视频 SDK 实现。 + +## 社区贡献者 + +声网社区开发者 [Syanbo](https://github.com/syanbo) 于 2016 年 - 2017 年期间,基于声网 Native SDK 独自完成了最初的 1.0 版本 React Native SDK。随着社区对于 React Native SDK 的需求增长,声网官方与 Syanbo 达成正式合作关系,目前该项目由声网官方进行更新维护。感谢 Syanbo 对于该项目长期以来的贡献。 + +## 发版说明 +[变更日志](CHANGELOG.md) + +## 集成文档 + +### 安装在 (React Native >= 0.60.0) + +安装 `react-native-agora`(^3.0.0): + +```shell script +yarn add react-native-agora +``` +或者 +```shell script +npm i --save react-native-agora +``` + +前往你的 **ios** 目录并执行: + +```shell script +pod install +``` + +**_ 重要信息 _** + +[原生模块现在已经是自动链接](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) + +[迁移至Swift](https://github.com/AgoraIO-Community/react-native-agora/blob/master/docs/v3/installation.ios.md#step-1-migrating-to-swift) + +### 安装在 (React Native == 0.59.x) + +安装 `react-native-agora`(^3.0.0): + +```shell script +yarn add react-native-agora +``` +或者 +```shell script +npm i --save react-native-agora +``` + +**_ 重要信息 _** + +[Android 集成文档](./docs/v3/installation.android.md) + +[iOS 集成文档](./docs/v3/installation.ios.md) + +### 安装在 (React Native <= 0.58.x) + +**_ 重要信息 _** + +我们已经不再支持,你可以尝试老版本。 + +[安装 `react-native-agora`(^1.0.0)](./docs/v1/README.md) + +[安装 `react-native-agora`(^2.0.0)](./docs/v2/README.md) + +## 如何使用 + +```javascript +import RtcEngine from 'react-native-agora'; +RtcEngine.create('YOUR APP ID'); +``` +或者 +```javascript +const RtcEngine = require('react-native-agora'); +RtcEngine.create('YOUR APP ID'); +``` + +## 使用 TypeScript + +我们建议你使用 TypeScript 进行开发,或者使用 TypeScript eslint 来检查你的代码。 + +* [快速开始 TypeScript](https://reactnative.dev/docs/typescript#getting-started-with-typescript) +* [将 TypeScript 添加至现有项目](https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project) + +## 常见错误 + +### Pod install 失败 (React Native >= 0.62.0) + +错误日志: + +``` +[!] The 'xxx' target has libraries with conflicting names: libcrypto.a. +``` + +你应该禁用 Flipper, 你可以在 Podfile 中找到它, 并且注释掉 AppDelegate 中有关 Flipper 的代码。 + +``` + # Enables Flipper. + # + # Note that if you have use_frameworks! enabled, Flipper will not work and + # you should disable these next few lines. + add_flipper_pods! + post_install do |installer| + flipper_post_install(installer) + end +``` + +### RCT_EXTERN_MODULE Swift modules broken in Xcode 10.2 + +错误日志: + +``` +Swift class extensions and categories on Swift classes are not allowed to have +load methods +``` + +React Native 0.59.3 已修复。 + +参考:https://github.com/facebook/react-native/issues/24139 + +### XCode 11 Beta App Launch Crash + +错误日志: + +``` +Exception '*** -[__NSArrayM objectAtIndexedSubscript:]: index 1 beyond bounds [0 .. 0]' was thrown while invoking getCurrentAppState on target AppState with params ( +2, +3 +) +``` + +React Native 0.59.9 已修复。 + +参考:https://github.com/facebook/react-native/issues/25154 + +## API文档 + +* [React Native API](https://agoraio-community.github.io/react-native-agora/globals.html) +* [Android API](https://docs.agora.io/en/Video/API%20Reference/java/index.html) +* [iOS API](https://docs.agora.io/en/Video/API%20Reference/oc/docs/headers/Agora-Objective-C-API-Overview.html) + +## 资源 + +* 完整的 [API Doc](https://docs.agora.io/cn/) 在开发者中心 +* [反馈问题](https://github.com/AgoraIO-Community/react-native-agora/issues) +* [React Native 快速开始](https://facebook.github.io/react-native/docs/getting-started.html) + +开源许可 +-------- + + Copyright (c) 2020 syanbo luxuhui + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt b/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt index 891a0c7b2..d665d8143 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcSurfaceView.kt @@ -46,14 +46,17 @@ class RtcSurfaceView( } } - fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { - canvas.renderMode = renderMode - setupRenderMode(engine) - } + fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { + resetVideoCanvas(engine) - fun setChannel(engine: RtcEngine, channel: RtcChannel?) { this.channel = if (channel != null) WeakReference(channel) else null - canvas.channelId = channel?.channelId() + canvas.channelId = this.channel?.get()?.channelId() + canvas.uid = uid + setupVideoCanvas(engine) + } + + private fun resetVideoCanvas(engine: RtcEngine) { + val canvas = VideoCanvas(null, canvas.renderMode, canvas.channelId, canvas.uid, canvas.mirrorMode) if (canvas.uid == 0) { engine.setupLocalVideo(canvas) } else { @@ -61,13 +64,7 @@ class RtcSurfaceView( } } - fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { - canvas.mirrorMode = mirrorMode - setupRenderMode(engine) - } - - fun setUid(engine: RtcEngine, uid: Int) { - canvas.uid = uid + private fun setupVideoCanvas(engine: RtcEngine) { if (canvas.uid == 0) { engine.setupLocalVideo(canvas) } else { @@ -75,6 +72,16 @@ class RtcSurfaceView( } } + fun setRenderMode(engine: RtcEngine, @Annotations.AgoraVideoRenderMode renderMode: Int) { + canvas.renderMode = renderMode + setupRenderMode(engine) + } + + fun setMirrorMode(engine: RtcEngine, @Annotations.AgoraVideoMirrorMode mirrorMode: Int) { + canvas.mirrorMode = mirrorMode + setupRenderMode(engine) + } + private fun setupRenderMode(engine: RtcEngine) { if (canvas.uid == 0) { engine.setLocalRenderMode(canvas.renderMode, canvas.mirrorMode) diff --git a/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt b/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt index e028b55c4..be98e356a 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcTextureView.kt @@ -22,8 +22,11 @@ class RtcTextureView( addView(texture) } - fun setChannel(engine: RtcEngine, channel: RtcChannel?) { + fun setData(engine: RtcEngine, channel: RtcChannel?, uid: Int) { + resetVideoRender(engine) + this.channel = if (channel != null) WeakReference(channel) else null + this.uid = uid setupVideoRenderer(engine) } @@ -32,22 +35,26 @@ class RtcTextureView( setupVideoRenderer(engine) } - fun setUid(engine: RtcEngine, uid: Int) { - this.uid = uid - setupVideoRenderer(engine) + private fun resetVideoRender(engine: RtcEngine) { + if (uid == 0) { + engine.setLocalVideoRenderer(null) + } else { + channel?.get()?.let { + it.setRemoteVideoRenderer(uid, null) + return@resetVideoRender + } + engine.setRemoteVideoRenderer(uid, null) + } } private fun setupVideoRenderer(engine: RtcEngine) { if (uid == 0) { - engine.setLocalVideoRenderer(null) engine.setLocalVideoRenderer(texture) } else { channel?.get()?.let { - it.setRemoteVideoRenderer(uid, null) it.setRemoteVideoRenderer(uid, texture) return@setupVideoRenderer } - engine.setRemoteVideoRenderer(uid, null) engine.setRemoteVideoRenderer(uid, texture) } } diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt index 587ebcb1a..7a54a991f 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt @@ -1,5 +1,6 @@ package io.agora.rtc.react +import com.facebook.react.bridge.ReadableMap import com.facebook.react.uimanager.SimpleViewManager import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.annotations.ReactProp @@ -33,26 +34,22 @@ class RCTAgoraRtcSurfaceViewManager : SimpleViewManager() { view.setZOrderOnTop(onTop) } + @ReactProp(name = "data") + fun setData(view: RtcSurfaceView, data: ReadableMap) { + val channel = data.getString("channelId")?.let { getChannel(it) } + getEngine()?.let { view.setData(it, channel, data.getInt("uid")) } + } + @ReactProp(name = "renderMode") fun setRenderMode(view: RtcSurfaceView, renderMode: Int) { getEngine()?.let { view.setRenderMode(it, renderMode) } } - @ReactProp(name = "channelId") - fun setChannelId(view: RtcSurfaceView, channelId: String) { - getEngine()?.let { view.setChannel(it, getChannel(channelId)) } - } - @ReactProp(name = "mirrorMode") fun setMirrorMode(view: RtcSurfaceView, mirrorMode: Int) { getEngine()?.let { view.setMirrorMode(it, mirrorMode) } } - @ReactProp(name = "uid") - fun setUid(view: RtcSurfaceView, uid: Int) { - getEngine()?.let { view.setUid(it, uid) } - } - private fun getEngine(): RtcEngine? { return reactContext?.getNativeModule(RCTAgoraRtcEngineModule::class.java)?.engine() } diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt index 10290f7f8..60b0691e2 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt @@ -1,5 +1,6 @@ package io.agora.rtc.react +import com.facebook.react.bridge.ReadableMap import com.facebook.react.uimanager.SimpleViewManager import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.annotations.ReactProp @@ -23,10 +24,11 @@ class RCTAgoraRtcTextureViewManager : SimpleViewManager() { return REACT_CLASS } - @ReactProp(name = "channelId") - fun setChannelId(view: RtcTextureView, channelId: String) { + @ReactProp(name = "data") + fun setData(view: RtcTextureView, data: ReadableMap) { + val channel = data.getString("channelId")?.let { getChannel(it) } getEngine()?.let { - view.setChannel(it, getChannel(channelId)) + view.setData(it, channel, data.getInt("uid")) } } @@ -35,11 +37,6 @@ class RCTAgoraRtcTextureViewManager : SimpleViewManager() { getEngine()?.let { view.setMirror(it, mirror) } } - @ReactProp(name = "uid") - fun setUid(view: RtcTextureView, uid: Int) { - getEngine()?.let { view.setUid(it, uid) } - } - private fun getEngine(): RtcEngine? { return reactContext?.getNativeModule(RCTAgoraRtcEngineModule::class.java)?.engine() } diff --git a/ios/RCTAgora/Base/RtcSurfaceView.swift b/ios/RCTAgora/Base/RtcSurfaceView.swift index ab25b069c..ed70e403a 100644 --- a/ios/RCTAgora/Base/RtcSurfaceView.swift +++ b/ios/RCTAgora/Base/RtcSurfaceView.swift @@ -18,34 +18,47 @@ class RtcSurfaceView: UIView { }() private weak var channel: AgoraRtcChannel? - func setRenderMode(_ engine: AgoraRtcEngineKit, _ renderMode: Int) { - canvas.renderMode = AgoraVideoRenderMode(rawValue: UInt(renderMode))! - setupRenderMode(engine) - } - - func setChannel(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?) { + func setData(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?, _ uid: Int) { + resetVideoCanvas(engine) + self.channel = channel canvas.channelId = channel?.getId() + canvas.uid = UInt(uid) + setupVideoCanvas(engine) + } + + private func resetVideoCanvas(_ engine: AgoraRtcEngineKit) { + let canvas = AgoraRtcVideoCanvas() + canvas.view = nil + canvas.renderMode = self.canvas.renderMode + canvas.channelId = self.canvas.channelId + canvas.uid = self.canvas.uid + canvas.mirrorMode = self.canvas.mirrorMode + if canvas.uid == 0 { engine.setupLocalVideo(canvas) } else { engine.setupRemoteVideo(canvas) } } - - func setMirrorMode(_ engine: AgoraRtcEngineKit, _ mirrorMode: Int) { - canvas.mirrorMode = AgoraVideoMirrorMode(rawValue: UInt(mirrorMode))! - setupRenderMode(engine) - } - - func setUid(_ engine: AgoraRtcEngineKit, _ uid: Int) { - canvas.uid = UInt(uid) + + private func setupVideoCanvas(_ engine: AgoraRtcEngineKit) { if canvas.uid == 0 { engine.setupLocalVideo(canvas) } else { engine.setupRemoteVideo(canvas) } } + + func setRenderMode(_ engine: AgoraRtcEngineKit, _ renderMode: Int) { + canvas.renderMode = AgoraVideoRenderMode(rawValue: UInt(renderMode))! + setupRenderMode(engine) + } + + func setMirrorMode(_ engine: AgoraRtcEngineKit, _ mirrorMode: Int) { + canvas.mirrorMode = AgoraVideoMirrorMode(rawValue: UInt(mirrorMode))! + setupRenderMode(engine) + } private func setupRenderMode(_ engine: AgoraRtcEngineKit) { if canvas.uid == 0 { diff --git a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift index 0e5e57d44..660c8084a 100644 --- a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift +++ b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift @@ -54,21 +54,19 @@ class RtcView: RtcSurfaceView { } } - @objc func setChannelId(_ channelId: String) { - if let engine = getEngine?(), let channel = getChannel?(channelId) { - setChannel(engine, channel) + @objc func setData(_ data: NSDictionary) { + var channel: AgoraRtcChannel? = nil + if let channelId = data["channelId"] as? String { + channel = getChannel?(channelId) } - } - - @objc func setMirrorMode(_ mirrorMode: Int) { if let engine = getEngine?() { - setMirrorMode(engine, mirrorMode) + setData(engine, channel, data["uid"] as! Int) } } - @objc func setUid(_ uid: Int) { + @objc func setMirrorMode(_ mirrorMode: Int) { if let engine = getEngine?() { - setUid(engine, uid) + setMirrorMode(engine, mirrorMode) } } } diff --git a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManagerBridge.m b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManagerBridge.m index 4a792342d..814666eae 100644 --- a/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManagerBridge.m +++ b/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManagerBridge.m @@ -10,12 +10,10 @@ @interface RCT_EXTERN_MODULE(RCTAgoraRtcSurfaceViewManager, NSObject) -RCT_EXPORT_VIEW_PROPERTY(renderMode, NSInteger) +RCT_EXPORT_VIEW_PROPERTY(data, NSDictionary) -RCT_EXPORT_VIEW_PROPERTY(channelId, NSString) +RCT_EXPORT_VIEW_PROPERTY(renderMode, NSInteger) RCT_EXPORT_VIEW_PROPERTY(mirrorMode, NSInteger) -RCT_EXPORT_VIEW_PROPERTY(uid, NSInteger) - @end diff --git a/package.json b/package.json index fdcaa5f3a..4debe3cd1 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "react-native-agora", - "version": "3.0.1-rc.2", + "version": "3.0.1-rc.3", "description": "React Native around the Agora RTC SDKs for Android and iOS agora", "summary": "agora native sdk for react-native", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { "build": "rm -rf lib && tsc", - "doc": "typedoc --out docs/api ./src", + "doc": "typedoc ./src", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "prepublish": "npm run build" diff --git a/src/RtcLocalView.tsx b/src/RtcLocalView.tsx new file mode 100644 index 000000000..943dfdce1 --- /dev/null +++ b/src/RtcLocalView.tsx @@ -0,0 +1,42 @@ +import React, {Component} from "react"; +import {Platform} from "react-native"; + +import {RtcSurfaceView, RtcSurfaceViewProps, RtcTextureView, RtcTextureViewProps} from "./src/RtcRenderView.native"; + +/** + * Use SurfaceView in Android. + * Use UIView in iOS. + */ +class SurfaceView extends Component { + render() { + return ( + + ); + } +} + +/** + * Use TextureView in Android. + * Not support for iOS. + */ +class TextureView extends Component { + render() { + if (Platform.OS === 'ios') + throw new Error('TextureView not support for iOS') + return ( + + ); + } +} + +/** + * View for preview local video. + */ +export default { + SurfaceView, + TextureView +} diff --git a/src/RtcRemoteView.tsx b/src/RtcRemoteView.tsx new file mode 100644 index 000000000..90a941528 --- /dev/null +++ b/src/RtcRemoteView.tsx @@ -0,0 +1,44 @@ +import React, {Component} from "react"; +import {Platform} from "react-native"; + +import { + RtcSurfaceView, + RtcSurfaceViewProps, + RtcTextureView, + RtcTextureViewProps, + RtcUidProps +} from "./src/RtcRenderView.native"; + +/** + * Use SurfaceView in Android. + * Use UIView in iOS. + */ +class SurfaceView extends Component { + render() { + return ( + + ); + } +} + +/** + * Use TextureView in Android. + * Not support for iOS. + */ +class TextureView extends Component { + render() { + if (Platform.OS === 'ios') + throw new Error('TextureView not support for iOS') + return ( + + ); + } +} + +/** + * View for render remote video. + */ +export default { + SurfaceView, + TextureView +} diff --git a/src/Types.ts b/src/Types.ts index d017ecaad..a306920d9 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -1,2955 +1,2 @@ -/** - * IP areas - * @enum {number} - */ -export enum IPAreaCode { - /** - * Mainland China - */ - AREA_CN = 1 << 0, - /** - * North America - */ - AREA_NA = 1 << 1, - /** - * AREA_EUR - */ - AREA_EUR = 1 << 2, - /** - * Asia, excluding Mainland China - */ - AREA_AS = 1 << 3, - /** - * (Default) Global - */ - AREA_GLOBAL = -1, -} - -/** - * Audio codec profile. - * @enum {number} - */ -export enum AudioCodecProfileType { - /** - * (Default) LC-AAC, the low-complexity audio codec profile. - */ - LCAAC = 0, - /** - * HE-AAC, the high-efficiency audio codec profile. - */ - HEAAC = 1, -} - -/** - * Audio equalization band frequency. - * @enum {number} - */ -export enum AudioEqualizationBandFrequency { - /** - * 31 Hz. - */ - Band31 = 0, - /** - * 62 Hz. - */ - Band62 = 1, - /** - * 125 Hz. - */ - Band125 = 2, - /** - * 250 Hz. - */ - Band250 = 3, - /** - * 500 Hz. - */ - Band500 = 4, - /** - * 1 kHz. - */ - Band1K = 5, - /** - * 2 kHz. - */ - Band2K = 6, - /** - * 4 kHz. - */ - Band4K = 7, - /** - * 8 kHz. - */ - Band8K = 8, - /** - * 16 kHz. - */ - Band16K = 9, -} - -/** - * The error information of the local audio. - * @enum {number} - */ -export enum AudioLocalError { - /** - * The local audio is normal. - */ - Ok = 0, - /** - * No specified reason for the local audio failure. - */ - Failure = 1, - /** - * No permission to use the local audio device. - */ - DeviceNoPermission = 2, - /** - * The microphone is in use. - */ - DeviceBusy = 3, - /** - * The local audio recording fails. Check whether the recording device is working properly. - */ - RecordFailure = 4, - /** - * The local audio encoding fails. - */ - EncodeFailure = 5, -} - -/** - * The state of the local audio. - * @enum {number} - */ -export enum AudioLocalState { - /** - * The local audio is in the initial state. - */ - Stopped = 0, - /** - * The recording device starts successfully. - */ - Recording = 1, - /** - * The first audio frame encodes successfully. - */ - Encoding = 2, - /** - * The local audio fails to start. - */ - Failed = 3, -} - -/** - * The error code of the audio mixing file. - * @enum {number} - */ -export enum AudioMixingErrorCode { - /** - * The SDK cannot open the audio mixing file. - */ - CanNotOpen = 701, - /** - * The SDK opens the audio mixing file too frequently. - */ - TooFrequentCall = 702, - /** - * The opening of the audio mixing file is interrupted. - */ - InterruptedEOF = 703, - /** - * No error. - */ - OK = 0, -} - -/** - * The state of the audio mixing file. - * @enum {number} - */ -export enum AudioMixingStateCode { - /** - * The audio mixing file is playing. - */ - Playing = 710, - /** - * The audio mixing file pauses playing. - */ - Paused = 711, - /** - * The audio mixing file stops playing. - */ - Stopped = 713, - /** - * An exception occurs when playing the audio mixing file. - */ - Failed = 714, -} - -/** - * Audio output routing. - * @enum {number} - */ -export enum AudioOutputRouting { - /** - * Default. - */ - Default = -1, - /** - * Headset. - */ - Headset = 0, - /** - * Earpiece. - */ - Earpiece = 1, - /** - * Headset with no microphone. - */ - HeadsetNoMic = 2, - /** - * Speakerphone. - */ - Speakerphone = 3, - /** - * Loudspeaker. - */ - Loudspeaker = 4, - /** - * Bluetooth headset. - */ - HeadsetBluetooth = 5, -} - -/** - * Audio profile. - * @enum {number} - */ -export enum AudioProfile { - /** - * Default audio profile. - * - In the Communication profile: A sample rate of 32 KHz, audio encoding, mono, and a bitrate of up to 18 Kbps. - * - In the Live-broadcast profile: A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 52 Kbps. - */ - Default = 0, - /** - * A sample rate of 32 KHz, audio encoding, mono, and a bitrate of up to 18 Kbps. - */ - SpeechStandard = 1, - /** - * A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 48 Kbps. - */ - MusicStandard = 2, - /** - * A sample rate of 48 KHz, music encoding, stereo, and a bitrate of up to 56 Kbps. - */ - MusicStandardStereo = 3, - /** - * A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 128 Kbps. - */ - MusicHighQuality = 4, - /** - * A sample rate of 48 KHz, music encoding, stereo, and a bitrate of up to 192 Kbps. - */ - MusicHighQualityStereo = 5, -} - -/** - * Use mode of the onRecordAudioFrame callback. - * @enum {number} - * TODO setPlaybackAudioFrameParameters - */ -export enum AudioRawFrameOperationMode { - /** - * Users only read the AudioFrame data without modifying anything. For example, when users acquire data with the Agora SDK then push the RTMP streams. - */ - ReadOnly = 0, - /** - * Users replace the AudioFrame data with their own data and pass them to the SDK for encoding. For example, when users acquire data. - */ - WriteOnly = 1, - /** - * Users read the data from AudioFrame, modify it, and then play it. For example, when users have their own sound-effect processing module and perform some voice pre-processing such as a voice change. - */ - ReadWrite = 2, -} - -/** - * Audio recording quality. - */ -export enum AudioRecordingQuality { - /** - * The sample rate is 32 KHz, and the file size is around 1.2 MB after 10 minutes of recording. - */ - Low = 0, - /** - * The sample rate is 32 KHz, and the file size is around 2 MB after 10 minutes of recording. - */ - Medium = 1, - /** - * The sample rate is 32 KHz, and the file size is around 3.75 MB after 10 minutes of recording. - */ - High = 2, -} - -/** - * The state of the remote audio. - * @enum {number} - */ -export enum AudioRemoteState { - /** - * The remote audio is in the default state, probably due to: - * @see AudioRemoteStateReason.LocalMuted - * @see AudioRemoteStateReason.RemoteMuted - * @see AudioRemoteStateReason.RemoteOffline - */ - Stopped = 0, - /** - * The first remote audio packet is received. - */ - Starting = 1, - /** - * The remote audio stream is decoded and plays normally, probably due to: - * @see AudioRemoteStateReason.NetworkRecovery - * @see AudioRemoteStateReason.LocalUnmuted - * @see AudioRemoteStateReason.RemoteUnmuted - */ - Decoding = 2, - /** - * The remote audio is frozen, probably due to: - * @see AudioRemoteStateReason.NetworkCongestion - */ - Frozen = 3, - /** - * The remote audio fails to start, probably due to: - * @see AudioRemoteStateReason.Internal - */ - Failed = 4, -} - -/** - * The reason of the remote audio state change. - * @enum {number} - */ -export enum AudioRemoteStateReason { - /** - * Internal reasons. - */ - Internal = 0, - /** - * Network congestion. - */ - NetworkCongestion = 1, - /** - * Network recovery. - */ - NetworkRecovery = 2, - /** - * The local user stops receiving the remote audio stream or disables the audio module. - */ - LocalMuted = 3, - /** - * The local user resumes receiving the remote audio stream or enables the audio module. - */ - LocalUnmuted = 4, - /** - * The remote user stops sending the audio stream or disables the audio module. - */ - RemoteMuted = 5, - /** - * The remote user resumes sending the audio stream or enables the audio module. - */ - RemoteUnmuted = 6, - /** - * The remote user leaves the channel. - */ - RemoteOffline = 7, -} - -/** - * The preset local voice reverberation option. - * @enum {number} - */ -export enum AudioReverbPreset { - /** - * The original voice (no local voice reverberation). - */ - Off = 0x00000000, - /** - * Pop music - */ - Popular = 0x00000001, - /** - * R&B - */ - RnB = 0x00000002, - /** - * Rock music - */ - Rock = 0x00000003, - /** - * Hip-hop music - */ - HipHop = 0x00000004, - /** - * Pop concert - */ - VocalConcert = 0x00000005, - /** - * Karaoke - */ - KTV = 0x00000006, - /** - * Recording studio - */ - Studio = 0x00000007, - /** - * The reverberation style typical of a KTV venue (enhanced). - */ - FX_KTV = 0x00100001, - /** - * The reverberation style typical of a concert hall (enhanced). - */ - FX_VOCAL_CONCERT = 0x00100002, - /** - * The reverberation style typical of an uncle’s voice. - */ - FX_UNCLE = 0x00100003, - /** - * The reverberation style typical of a sister’s voice. - */ - FX_SISTER = 0x00100004, - /** - * The reverberation style typical of a recording studio (enhanced). - */ - FX_STUDIO = 0x00100005, - /** - * The reverberation style typical of popular music (enhanced). - */ - FX_POPULAR = 0x00100006, - /** - * The reverberation style typical of R&B music (enhanced). - */ - FX_RNB = 0x00100007, - /** - * The reverberation style typical of the vintage phonograph. - */ - FX_PHONOGRAPH = 0x00100008, - /** - * The reverberation of the virtual stereo. The virtual stereo is an effect that renders the monophonic audio as the stereo audio, so that all users in the channel can hear the stereo voice effect. To achieve better virtual stereo reverberation, Agora recommends setting the profile parameter in setAudioProfile as MusicHighQualityStereo(5). - * @see RtcEngine#setAudioProfile - * @see AudioProfile.MusicHighQualityStereo - */ - VIRTUAL_STEREO = 0x00200001, -} - -/** - * Audio reverberation type. - * @enum {number} - */ -export enum AudioReverbType { - /** - * The level of the dry signal (dB). The value ranges between -20 and 10. - */ - DryLevel = 0, - /** - * The level of the early reflection signal (wet signal) in dB. The value ranges between -20 and 10. - */ - WetLevel = 1, - /** - * The room size of the reverberation. A larger room size means a stronger reverberation. The value ranges between 0 and 100. - */ - RoomSize = 2, - /** - * The length of the initial delay of the wet signal (ms). The value ranges between 0 and 200. - */ - WetDelay = 3, - /** - * The reverberation strength. The value ranges between 0 and 100. - */ - Strength = 4, -} - -/** - * Audio sample rate. - * @enum {number} - */ -export enum AudioSampleRateType { - /** - * 32 kHz. - */ - Type32000 = 32000, - /** - * 44.1 kHz. - */ - Type44100 = 44100, - /** - * 48 kHz. - */ - Type48000 = 48000, -} - -/** - * Audio scenario. - * @enum {number} - */ -export enum AudioScenario { - /** - * Default. - */ - Default = 0, - /** - * Entertainment scenario, supporting voice during gameplay. - */ - ChatRoomEntertainment = 1, - /** - * Education scenario, prioritizing fluency and stability. - */ - Education = 2, - /** - * Live gaming scenario, enabling the gaming audio effects in the speaker mode in a live broadcast scenario. Choose this scenario for high-fidelity music playback. - */ - GameStreaming = 3, - /** - * Showroom scenario, optimizing the audio quality with external professional equipment. - */ - ShowRoom = 4, - /** - * Gaming scenario. - */ - ChatRoomGaming = 5, -} - -/** - * Audio session restriction. - * @enum {number} - * TODO iOS setAudioSessionOperationRestriction - */ -export enum AudioSessionOperationRestriction { - /** - * No restriction, the SDK has full control of the audio session operations. - */ - None = 0, - /** - * The SDK does not change the audio session category. - */ - SetCategory = 1, - /** - * The SDK does not change any setting of the audio session (category, mode, categoryOptions). - */ - ConfigureSession = 1 << 1, - /** - * The SDK keeps the audio session active when leaving a channel. - */ - DeactivateSession = 1 << 2, - /** - * The SDK does not configure the audio session anymore. - */ - All = 1 << 7, -} - -/** - * The preset audio voice configuration used to change the voice effect. - * @enum {number} - */ -export enum AudioVoiceChanger { - /** - * The original voice (no local voice change). - */ - Off = 0x00000000, - /** - * An old man’s voice. - */ - OldMan = 0x00000001, - /** - * A little boy’s voice. - */ - BabyBoy = 0x00000002, - /** - * A little girl’s voice. - */ - BabyGirl = 0x00000003, - /** - * TBD - */ - ZhuBaJie = 0x00000004, - /** - * Ethereal vocal effects. - */ - Ethereal = 0x00000005, - /** - * Hulk’s voice. - */ - Hulk = 0x00000006, - /** - * A more vigorous voice. - */ - BEAUTY_VIGOROUS = 0x00100001, - /** - * A deeper voice. - */ - BEAUTY_DEEP = 0x00100002, - /** - * A mellower voice. - */ - BEAUTY_MELLOW = 0x00100003, - /** - * Falsetto. - */ - BEAUTY_FALSETTO = 0x00100004, - /** - * A fuller voice. - */ - BEAUTY_FULL = 0x00100005, - /** - * A clearer voice. - */ - BEAUTY_CLEAR = 0x00100006, - /** - * A more resounding voice. - */ - BEAUTY_RESOUNDING = 0x00100007, - /** - * A more ringing voice. - */ - BEAUTY_RINGING = 0x00100008, - /** - * A more spatially resonant voice. - */ - BEAUTY_SPACIAL = 0x00100009, - /** - * (For male only) A more magnetic voice. Do not use it when the speaker is a female; otherwise, voice distortion occurs. - */ - GENERAL_BEAUTY_VOICE_MALE_MAGNETIC = 0x00200001, - /** - * (For female only) A fresher voice. Do not use it when the speaker is a male; otherwise, voice distortion occurs. - */ - GENERAL_BEAUTY_VOICE_FEMALE_FRESH = 0x00200002, - /** - * (For female only) A more vital voice. Do not use it when the speaker is a male; otherwise, voice distortion occurs. - */ - GENERAL_BEAUTY_VOICE_FEMALE_VITALITY = 0x00200003, -} - -/** - * The camera capturer configuration. - * @enum {number} - */ -export enum CameraCaptureOutputPreference { - /** - * (default) Self-adapts the camera output parameters to the system performance and network conditions to balance CPU consumption and video preview quality. - */ - Auto = 0, - /** - * Prioritizes the system performance. The SDK chooses the dimension and frame rate of the local camera capture closest to those set by setVideoEncoderConfiguration. - * @see RtcEngine.setVideoEncoderConfiguration - */ - Performance = 1, - /** - * Prioritizes the local preview quality. The SDK chooses higher camera output parameters to improve the local video preview quality. This option requires extra CPU and RAM usage for video pre-processing. - */ - Preview = 2, - /** - * Internal use only - */ - Unkown = 3, -} - -/** - * The camera direction. - * @enum {number} - */ -export enum CameraDirection { - /** - * The rear camera. - */ - Rear = 0, - /** - * The front camera. - */ - Front = 1, -} - -/** - * The error code in AgoraChannelMediaRelayError. - * @enum {number} - */ -export enum ChannelMediaRelayError { - /** - * The state is normal. - */ - None = 0, - /** - * An error occurs in the server response. - */ - ServerErrorResponse = 1, - /** - * No server response. You can call the leaveChannel method to leave the channel. - * @see RtcEngine.leaveChannel - */ - ServerNoResponse = 2, - /** - * The SDK fails to access the service, probably due to limited resources of the server. - */ - NoResourceAvailable = 3, - /** - * Fails to send the relay request. - */ - FailedJoinSourceChannel = 4, - /** - * Fails to accept the relay request. - */ - FailedJoinDestinationChannel = 5, - /** - * The server fails to receive the media stream. - */ - FailedPacketReceivedFromSource = 6, - /** - * The server fails to send the media stream. - */ - FailedPacketSentToDestination = 7, - /** - * The SDK disconnects from the server due to poor network connections. You can call the leaveChannel method to leave the channel. - * @see RtcEngine.leaveChannel - */ - ServerConnectionLost = 8, - /** - * An internal error occurs in the server. - */ - InternalError = 9, - /** - * The token of the source channel has expired. - */ - SourceTokenExpired = 10, - /** - * The token of the destination channel has expired. - */ - DestinationTokenExpired = 11, -} - -/** - * The event code in AgoraChannelMediaRelayEvent. - * @enum {number} - */ -export enum ChannelMediaRelayEvent { - /** - * The user disconnects from the server due to poor network connections. - */ - Disconnect = 0, - /** - * The network reconnects. - */ - Connected = 1, - /** - * The user joins the source channel. - */ - JoinedSourceChannel = 2, - /** - * The user joins the destination channel. - */ - JoinedDestinationChannel = 3, - /** - * The SDK starts relaying the media stream to the destination channel. - */ - SentToDestinationChannel = 4, - /** - * The server receives the video stream from the source channel. - */ - ReceivedVideoPacketFromSource = 5, - /** - * The server receives the audio stream from the source channel. - */ - ReceivedAudioPacketFromSource = 6, - /** - * The destination channel is updated. - */ - UpdateDestinationChannel = 7, - /** - * The destination channel update fails due to internal reasons. - */ - UpdateDestinationChannelRefused = 8, - /** - * The destination channel does not change, which means that the destination channel fails to be updated. - */ - UpdateDestinationChannelNotChange = 9, - /** - * The destination channel name is NULL. - */ - UpdateDestinationChannelIsNil = 10, - /** - * The video profile is sent to the server. - */ - VideoProfileUpdate = 11, -} - -/** - * The state code in AgoraChannelMediaRelayState. - * @enum {number} - */ -export enum ChannelMediaRelayState { - /** - * The SDK is initializing. - */ - Idle = 0, - /** - * The SDK tries to relay the media stream to the destination channel. - */ - Connecting = 1, - /** - * The SDK successfully relays the media stream to the destination channel. - */ - Running = 2, - /** - * A failure occurs. See the details in error. - */ - Failure = 3, -} - -/** - * Channel profile. - * @enum {number} - */ -export enum ChannelProfile { - /** - * (Default) The Communication profile. - * Use this profile in one-on-one calls or group calls, where all users can talk freely. - */ - Communication = 0, - /** - * The Live-Broadcast profile. - * Users in a live-broadcast channel have a role as either broadcaster or audience. A broadcaster can both send and receive streams; an audience can only receive streams. - */ - LiveBroadcasting = 1, - /** - * The Gaming profile. - * This profile uses a codec with a lower bitrate and consumes less power. Applies to the gaming scenario, where all game players can talk freely. - */ - Game = 2, -} - -/** - * Client role in a live broadcast. - * @enum {number} - */ -export enum ClientRole { - /** - * A broadcaster can both send and receive streams. - */ - Broadcaster = 1, - /** - * The default role. An audience can only receive streams. - */ - Audience = 2, -} - -/** - * Reasons for the connection state change. - * @enum {number} - */ -export enum ConnectionChangedReason { - /** - * The SDK is connecting to Agora’s edge server. - */ - Connecting = 0, - /** - * The SDK has joined the channel successfully. - */ - JoinSuccess = 1, - /** - * The connection between the SDK and Agora’s edge server is interrupted. - */ - Interrupted = 2, - /** - * The connection between the SDK and Agora’s edge server is banned by Agora’s edge server. - */ - BannedByServer = 3, - /** - * The SDK fails to join the channel for more than 20 minutes and stops reconnecting to the channel. - */ - JoinFailed = 4, - /** - * The SDK has left the channel. - */ - LeaveChannel = 5, - /** - * The specified App ID is invalid. Try to rejoin the channel with a valid App ID. - */ - InvalidAppId = 6, - /** - * The specified channel name is invalid. Try to rejoin the channel with a valid channel name. - */ - InvalidChannelName = 7, - /** - * The generated token is invalid probably due to the following reasons: - * - The App Certificate for the project is enabled in Console, but you do not use Token when joining the channel. If you enable the App Certificate, you must use a token to join the channel. - * - The uid that you specify in the joinChannel method is different from the uid that you pass for generating the token. - * @see RtcEngine.joinChannel - */ - InvalidToken = 8, - /** - * The token has expired. Generate a new token from your server. - */ - TokenExpired = 9, - /** - * The user is banned by the server. - */ - RejectedByServer = 10, - /** - * The SDK tries to reconnect after setting a proxy server. - */ - SettingProxyServer = 11, - /** - * The token renews. - */ - RenewToken = 12, - /** - * The client IP address has changed, probably due to a change of the network type, IP address, or network port. - */ - ClientIpAddressChanged = 13, - /** - * Timeout for the keep-alive of the connection between the SDK and Agora’s edge server. The connection state changes to: - * @see ConnectionStateType.Reconnecting - */ - KeepAliveTimeout = 14, -} - -/** - * Connection states. - * @enum {number} - */ -export enum ConnectionStateType { - /** - * The SDK is disconnected from Agora's edge server. - * - This is the initial state before joinChannel. - * @see RtcEngine.joinChannel - * - The SDK also enters this state when the app calls leaveChannel. - * @see RtcEngine.leaveChannel - */ - Disconnected = 1, - /** - * The SDK is connecting to Agora's edge server. - * - When the app calls joinChannel, the SDK starts to establish a connection to the specified channel, triggers the onConnectionStateChanged callback, and switches to the Connecting state. - * @see RtcEngine.joinChannel - * @see RtcEngineEvents.onConnectionStateChanged - * @see ConnectionStateType.Connecting - * - When the SDK successfully joins the channel, the SDK triggers the onConnectionStateChanged callback and switches to the Connected state. - * @see RtcEngineEvents.onConnectionStateChanged - * @see ConnectionStateType.Connected - * - After the SDK joins the channel and when it finishes initializing the media engine, the SDK triggers the onJoinChannelSuccess callback. - * @see RtcEngineEvents.onJoinChannelSuccess - */ - Connecting = 2, - /** - * The SDK is connected to Agora's edge server and joins a channel. You can now publish or subscribe to a media stream in the channel. - * If the connection to the channel is lost because, for example, the network is down or switched, the SDK automatically tries to reconnect and triggers: - * - The onConnectionStateChanged callback, and switches to the Reconnecting state. - * @see RtcEngineEvents.onConnectionStateChanged - * @see ConnectionStateType.Reconnecting - */ - Connected = 3, - /** - * The SDK keeps rejoining the channel after being disconnected from a joined channel because of network issues. - * - If the SDK cannot rejoin the channel within 10 seconds after being disconnected from Agora’s edge server, the SDK triggers the onConnectionLost callback, stays in the Reconnecting state, and keeps rejoining the channel. - * @see RtcEngineEvents.onConnectionLost - * - If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora’s edge server, the SDK triggers the onConnectionStateChanged callback, switches to the Failed state, and stops rejoining the channel. - * @see RtcEngineEvents.onConnectionStateChanged - * @see ConnectionStateType.Failed - */ - Reconnecting = 4, - /** - * The SDK fails to connect to Agora's edge server or join the channel. - * You must call leaveChannel to leave this state, and call joinChannel again to rejoin the channel. - * @see RtcEngine.leaveChannel - * @see RtcEngine.joinChannel - * If the SDK is banned from joining the channel by Agora’s edge server (through the RESTful API), the SDK triggers the onConnectionStateChanged callbacks. - * @see RtcEngineEvents.onConnectionStateChanged - */ - Failed = 5, -} - -/** - * The video encoding degradation preference under limited bandwidth. - * @enum {number} - */ -export enum DegradationPreference { - /** - * (Default) Degrades the frame rate to guarantee the video quality. - */ - MaintainQuality = 0, - /** - * Degrades the video quality to guarantee the frame rate. - */ - MaintainFramerate = 1, - /** - * Reserved for future use. - */ - Balanced = 2, -} - -/** - * Encryption mode - * @enum {string} - */ -export enum EncryptionMode { - /** - * (Default) 128-bit AES encryption, XTS mode. - */ - AES128XTS = 'aes-128-xts', - /** - * 256-bit AES encryption, XTS mode. - */ - AES256XTS = 'aes-256-xts', - /** - * 128-bit AES encryption, ECB mode. - */ - AES128ECB = 'aes-128-ecb', -} - -/** - * Error codes occur when the SDK encounters an error that cannot be recovered automatically without any app intervention. - * @enum {number} - */ -export enum ErrorCode { - /** - * No error occurs. - */ - NoError = 0, - /** - * A general error occurs (no specified reason). - */ - Failed = 1, - /** - * An invalid parameter is used. For example, the specific channel name includes illegal characters. - */ - InvalidArgument = 2, - /** - * The SDK module is not ready. - * Possible solutions: - * - Check the audio device. - * - Check the completeness of the app. - * - Re-initialize the SDK. - */ - NotReady = 3, - /** - * The current state of the SDK does not support this function. - */ - NotSupported = 4, - /** - * The request is rejected. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - Refused = 5, - /** - * The buffer size is not big enough to store the returned data. - */ - BufferTooSmall = 6, - /** - * The SDK is not initialized before calling this method. - */ - NotInitialized = 7, - /** - * No permission exists. Check if the user has granted access to the audio or video device. - */ - NoPermission = 9, - /** - * An API method timeout occurs. Some API methods require the SDK to return the execution result, and this error occurs if the request takes too long (over 10 seconds) for the SDK to process. - */ - TimedOut = 10, - /** - * The request is canceled. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - Canceled = 11, - /** - * The method is called too often. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - TooOften = 12, - /** - * The SDK fails to bind to the network socket. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - BindSocket = 13, - /** - * The network is unavailable. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - NetDown = 14, - /** - * No network buffers are available. This is for internal SDK use only, and is not returned to the app through any method or callback. - */ - NoBufs = 15, - /** - * The request to join the channel is rejected. - * Possible reasons are: - * - The user is already in the channel, and still calls the API method to join the channel, for example, joinChannel - * @see RtcEngine.joinChannel - * - The user tries joining the channel during the echo test. Please join the channel after the echo test ends. - */ - JoinChannelRejected = 17, - /** - * The request to leave the channel is rejected. - * Possible reasons are: - * - The user left the channel and still calls the API method to leave the channel, for example, leaveChannel. - * @see RtcEngine.leaveChannel - * - The user has not joined the channel and calls the API method to leave the channel. - */ - LeaveChannelRejected = 18, - /** - * The resources are occupied and cannot be used. - */ - AlreadyInUse = 19, - /** - * The SDK gave up the request due to too many requests. - */ - Abort = 20, - /** - * In Windows, specific firewall settings cause the SDK to fail to initialize and crash. - */ - InitNetEngine = 21, - /** - * The app uses too much of the system resources and the SDK fails to allocate the resources. - */ - ResourceLimited = 22, - /** - * The specified App ID is invalid. Please try to rejoin the channel with a valid App ID. - */ - InvalidAppId = 101, - /** - * The specified channel name is invalid. Please try to rejoin the channel with a valid channel name. - */ - InvalidChannelId = 102, - /** - * The token expired. DEPRECATED as of v2.4.1. Use TokenExpired(9) in the reason parameter of onConnectionStateChanged. - * @see ConnectionChangedReason.TokenExpired - * @see RtcEngineEvents.onConnectionStateChanged - * Possible reasons are: - * - Authorized Timestamp expired: The timestamp is represented by the number of seconds elapsed since 1/1/1970. The user can use the token to access the Agora service within five minutes after the token is generated. If the user does not access the Agora service after five minutes, this token is no longer valid. - * - Call Expiration Timestamp expired: The timestamp is the exact time when a user can no longer use the Agora service (for example, when a user is forced to leave an ongoing call). When a value is set for the Call Expiration Timestamp, it does not mean that the token will expire, but that the user will be banned from the channel. - * @deprecated - */ - TokenExpired = 109, - /** - * The token is invalid. DEPRECATED as of v2.4.1. Use InvalidToken(8) in the reason parameter of onConnectionStateChanged. - * @see ConnectionChangedReason.InvalidToken - * @see RtcEngineEvents.onConnectionStateChanged - * Possible reasons are: - * - The App Certificate for the project is enabled in Console, but the user is using the App ID. Once the App Certificate is enabled, the user must use a token. - * - The uid is mandatory, and users must set the same uid as the one set in the joinChannel method. - * @see RtcEngine.joinChannel - * @deprecated - */ - InvalidToken = 110, - /** - * The Internet connection is interrupted. This applies to the Agora Web SDK only. - */ - ConnectionInterrupted = 111, - /** - * The Internet connection is lost. This applies to the Agora Web SDK only. - */ - ConnectionLost = 112, - /** - * The user is not in the channel when calling the sendStreamMessage or getUserInfoByUserAccount method. - * @see RtcEngine.sendStreamMessage - * @see RtcEngine.getUserInfoByUserAccount - */ - NotInChannel = 113, - /** - * The size of the sent data is over 1024 bytes when the user calls the sendStreamMessage method. - * @see RtcEngine.sendStreamMessage - */ - SizeTooLarge = 114, - /** - * The bitrate of the sent data exceeds the limit of 6 Kbps when the user calls the sendStreamMessage method. - * @see RtcEngine.sendStreamMessage - */ - BitrateLimit = 115, - /** - * Too many data streams (over five streams) are created when the user calls the createDataStream method. - * @see RtcEngine.createDataStream - */ - TooManyDataStreams = 116, - /** - * Decryption fails. The user may have used a different encryption password to join the channel. Check your settings or try rejoining the channel. - */ - DecryptionFailed = 120, - /** - * The client is banned by the server. - */ - ClientIsBannedByServer = 123, - /** - * Incorrect watermark file parameter. - */ - WatermarkParam = 124, - /** - * Incorrect watermark file path. - */ - WatermarkPath = 125, - /** - * Incorrect watermark file format. - */ - WatermarkPng = 126, - /** - * Incorrect watermark file information. - */ - WatermarkInfo = 127, - /** - * Incorrect watermark file data format. - */ - WatermarkAGRB = 128, - /** - * An error occurs in reading the watermark file. - */ - WatermarkRead = 129, - /** - * The encrypted stream is not allowed to publish. - */ - EncryptedStreamNotAllowedPublish = 130, - /** - * The user account is invalid. - */ - InvalidUserAccount = 134, - /** - * CDN related errors. Remove the original URL address and add a new one by calling the removePublishStreamUrl and addPublishStreamUrl methods. - * @see RtcEngine.removePublishStreamUrl - * @see RtcEngine.addPublishStreamUrl - */ - PublishStreamCDNError = 151, - /** - * The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. - */ - PublishStreamNumReachLimit = 152, - /** - * The host manipulates other hosts' URLs. Check your app logic. - */ - PublishStreamNotAuthorized = 153, - /** - * An error occurs in Agora’s streaming server. Call the addPublishStreamUrl method to publish the stream again. - * @see RtcEngine.addPublishStreamUrl - */ - PublishStreamInternalServerError = 154, - /** - * The server fails to find the stream. - */ - PublishStreamNotFound = 155, - /** - * The format of the RTMP stream URL is not supported. Check whether the URL format is correct. - */ - PublishStreamFormatNotSuppported = 156, - /** - * Fails to load the media engine. - */ - LoadMediaEngine = 1001, - /** - * Fails to start the call after enabling the media engine. - */ - StartCall = 1002, - /** - * Fails to start the camera. DEPRECATED as of v2.4.1. Use CaptureFailure(4) in the error parameter of onLocalVideoStateChanged. - * @see LocalVideoStreamError.CaptureFailure - * @see RtcEngineEvents.onLocalVideoStateChanged - * @deprecated - */ - StartCamera = 1003, - /** - * Fails to start the video rendering module. - */ - StartVideoRender = 1004, - /** - * Audio Device Module: A general error occurs in the Audio Device Module (the reason is not classified specifically). Check if the audio device is used by another app, or try rejoining the channel. - */ - AdmGeneralError = 1005, - /** - * Audio Device Module: An error occurs in using the Java resources. - */ - AdmJavaResource = 1006, - /** - * Audio Device Module: An error occurs in setting the sampling frequency. - */ - AdmSampleRate = 1007, - /** - * Audio Device Module: An error occurs in initializing the playback device. - */ - AdmInitPlayout = 1008, - /** - * Audio Device Module: An error occurs in starting the playback device. - */ - AdmStartPlayout = 1009, - /** - * Audio Device Module: An error occurs in stopping the playback device. - */ - AdmStopPlayout = 1010, - /** - * Audio Device Module: An error occurs in initializing the recording device. - */ - AdmInitRecording = 1011, - /** - * Audio Device Module: An error occurs in starting the recording device. - */ - AdmStartRecording = 1012, - /** - * Audio Device Module: An error occurs in stopping the recording device. - */ - AdmStopRecording = 1013, - /** - * Audio Device Module: A playback error occurs. Check your playback device, or try rejoining the channel. - */ - AdmRuntimePlayoutError = 1015, - /** - * Audio Device Module: A recording error occurs. - */ - AdmRuntimeRecordingError = 1017, - /** - * Audio Device Module: Fails to record. - */ - AdmRecordAudioFailed = 1018, - /** - * Audio Device Module: Abnormal audio playback frequency. - */ - AdmPlayAbnormalFrequency = 1020, - /** - * Audio Device Module: Abnormal audio recording frequency. - */ - AdmRecordAbnormalFrequency = 1021, - /** - * Audio Device Module: An error occurs in initializing the loopback device. - */ - AdmInitLoopback = 1022, - /** - * Audio Device Module: An error occurs in starting the loopback device. - */ - AdmStartLoopback = 1023, - /** - * Audio Device Module: An error occurs in no recording Permission. - */ - AdmNoPermission = 1027, - /** - * Audio Routing: Fails to route the audio to the connected Bluetooth device. The default route is used. - */ - AudioBtScoFailed = 1030, - /** - * Audio Device Module: No recording device exists. - */ - AdmNoRecordingDevice = 1359, - /** - * No playback device exists. - */ - AdmNoPlayoutDevice = 1360, - /** - * Video Device Module: The camera is unauthorized. - */ - VdmCameraNotAuthorized = 1501, - /** - * Video Device Module: An unknown error occurs. - */ - VcmUnknownError = 1600, - /** - * Video Device Module: An error occurs in initializing the video encoder. - */ - VcmEncoderInitError = 1601, - /** - * Video Device Module: An error occurs in video encoding. - */ - VcmEncoderEncodeError = 1602, - /** - * Video Device Module: An error occurs in setting the video encoder. - * @deprecated - */ - VcmEncoderSetError = 1603, -} - -/** - * State of importing an external video stream in a live broadcast. - * @enum {number} - */ -export enum InjectStreamStatus { - /** - * The external video stream imported successfully. - */ - StartSuccess = 0, - /** - * The external video stream already exists. - */ - StartAlreadyExists = 1, - /** - * The external video stream import is unauthorized. - */ - StartUnauthorized = 2, - /** - * Import external video stream timeout. - */ - StartTimedout = 3, - /** - * The external video stream failed to import. - */ - StartFailed = 4, - /** - * The external video stream imports successfully. - */ - StopSuccess = 5, - /** - * No external video stream is found. - */ - StopNotFound = 6, - /** - * The external video stream is stopped from being unauthorized. - */ - StopUnauthorized = 7, - /** - * Importing the external video stream timeout. - */ - StopTimedout = 8, - /** - * Importing the external video stream failed. - */ - StopFailed = 9, - /** - * The external video stream import is interrupted. - */ - Broken = 10, -} - -/** - * The state of the probe test result. - * @enum {number} - */ -export enum LastmileProbeResultState { - /** - * the last-mile network probe test is complete. - */ - Complete = 1, - /** - * the last-mile network probe test is incomplete and the bandwidth estimation is not available, probably due to limited test resources. - */ - IncompleteNoBwe = 2, - /** - * the last-mile network probe test is not carried out, probably due to poor network conditions. - */ - Unavailable = 3, -} - -/** - * The lightening contrast level. - * @enum {number} - */ -export enum LighteningContrastLevel { - /** - * Low contrast level. - */ - Low = 0, - /** - * (Default) Normal contrast level. - */ - Normal = 1, - /** - * High contrast level. - */ - High = 2, -} - -/** - * The detailed error information of the local video. - * @enum {number} - */ -export enum LocalVideoStreamError { - /** - * The local video is normal. - */ - OK = 0, - /** - * No specified reason for the local video failure. - */ - Failure = 1, - /** - * No permission to use the local video device. - */ - DeviceNoPermission = 2, - /** - * The local video capturer is in use. - */ - DeviceBusy = 3, - /** - * The local video capture fails. Check whether the capturer is working properly. - */ - CaptureFailure = 4, - /** - * The local video encoding fails. - */ - EncodeFailure = 5, -} - -/** - * The state of the local video stream. - * @enum {number} - */ -export enum LocalVideoStreamState { - /** - * The local video is in the initial state. - */ - Stopped = 0, - /** - * The local video capturer starts successfully. - */ - Capturing = 1, - /** - * The first local video frame encodes successfully. - */ - Encoding = 2, - /** - * The local video fails to start. - */ - Failed = 3, -} - -/** - * Output log filter level. - * @enum {number} - */ -export enum LogFilter { - /** - * Do not output any log information. - */ - Off = 0, - /** - * Output all log information. Set your log filter as debug if you want to get the most complete log file. - */ - Debug = 0x080f, - /** - * Output CRITICAL, ERROR, WARNING, and INFO level log information. We recommend setting your log filter as this level. - */ - Info = 0x000f, - /** - * Outputs CRITICAL, ERROR, and WARNING level log information. - */ - Warning = 0x000e, - /** - * Outputs CRITICAL and ERROR level log information. - */ - Error = 0x000c, - /** - * Outputs CRITICAL level log information. - */ - Critical = 0x0008, -} - -/** - * Media device type. - * @enum {number} - * TODO MacOS AgoraMediaDeviceType - */ -export enum MediaDeviceType { - /** - * Unknown device. - */ - AudioUnknown = -1, - /** - * Audio playback device. - */ - AudioPlayout = 0, - /** - * Audio recording device. - */ - AudioRecording = 1, - /** - * Video render device. - */ - VideoRender = 2, - /** - * Video capture device. - */ - VideoCapture = 3, -} - -/** - * Media type. - * @enum {number} - * TODO LiveEngine - */ -export enum MediaType { - /** - * No audio and video. - */ - None = 0, - /** - * Audio only. - */ - AudioOnly = 1, - /** - * Video only. - */ - VideoOnly = 2, - /** - * Audio and video. - */ - AudioAndVideo = 3, -} - -/** - * The metadata type. - * @enum {number} - * TODO registerMediaMetadataObserver - */ -export enum MetadataType { - /** - * the metadata type is unknown. - */ - Unknown = -1, - /** - * the metadata type is video. - */ - Video = 0, -} - -/** - * Network quality. - * @enum {number} - */ -export enum NetworkQuality { - /** - * The network quality is unknown. - */ - Unknown = 0, - /** - * The network quality is excellent. - */ - Excellent = 1, - /** - * The network quality is quite good, but the bitrate may be slightly lower than excellent. - */ - Good = 2, - /** - * Users can feel the communication slightly impaired. - */ - Poor = 3, - /** - * Users can communicate only not very smoothly. - */ - Bad = 4, - /** - * The network quality is so bad that users can hardly communicate. - */ - VBad = 5, - /** - * The network is disconnected and users cannot communicate at all. - */ - Down = 6, - /** - * Users cannot detect the network quality. (Not in use.) - */ - Unsupported = 7, - /** - * Detecting the network quality. - */ - Detecting = 8, -} - -/** - * Network type. - * @enum {number} - */ -export enum NetworkType { - /** - * The network type is unknown. - */ - Unknown = -1, - /** - * The SDK disconnects from the network. - */ - Disconnected = 0, - /** - * The network type is LAN. - */ - LAN = 1, - /** - * The network type is Wi-Fi (including hotspots). - */ - WIFI = 2, - /** - * The network type is mobile 2G. - */ - Mobile2G = 3, - /** - * The network type is mobile 3G. - */ - Mobile3G = 4, - /** - * The network type is mobile 4G. - */ - Mobile4G = 5, -} - -/** - * Default camera position - * @enum {number} - * TODO AgoraRtcDefaultCamera - */ -export enum RtcDefaultCameraPosition { - /** - * Front camera - */ - Front = 0, - /** - * Rear camera - */ - Back = 1, -} - -/** - * Lifecycle of the CDN live video stream. - * @enum {number} - * TODO AgoraPublisherConfiguration - */ -export enum RtmpStreamLifeCycle { - /** - * Bound to the channel lifecycle. If all hosts leave the channel, the CDN live streaming stops after 30 seconds. - */ - BindToChannel = 1, - /** - * Bound to the owner of the RTMP stream. If the owner leaves the channel, the CDN live streaming stops immediately. - */ - BindToOwnner = 2, -} - -/** - * The detailed error information for streaming. - * @enum {number} - */ -export enum RtmpStreamingErrorCode { - /** - * The RTMP streaming publishes successfully. - */ - OK = 0, - /** - * Invalid argument used. If, for example, you do not call the setLiveTranscoding method to configure the LiveTranscoding parameters before calling the addPublishStreamUrl method, the SDK returns this error. Check whether you set the parameters in the setLiveTranscoding method properly. - * @see RtcEngine.setLiveTranscoding - * @see RtcEngine.addPublishStreamUrl - */ - InvalidParameters = 1, - /** - * The RTMP streaming is encrypted and cannot be published. - */ - EncryptedStreamNotAllowed = 2, - /** - * Timeout for the RTMP streaming. Call the addPublishStreamUrl method to publish the streaming again. - * @see RtcEngine.addPublishStreamUrl - */ - ConnectionTimeout = 3, - /** - * An error occurs in Agora’s streaming server. Call the addPublishStreamUrl method to publish the streaming again. - * @see RtcEngine.addPublishStreamUrl - */ - InternalServerError = 4, - /** - * An error occurs in the RTMP server. - */ - RtmpServerError = 5, - /** - * The RTMP streaming publishes too frequently. - */ - TooOften = 6, - /** - * The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. - */ - ReachLimit = 7, - /** - * The host manipulates other hosts' URLs. Check your app logic. - */ - NotAuthorized = 8, - /** - * Agora’s server fails to find the RTMP streaming. - */ - StreamNotFound = 9, - /** - * The format of the RTMP streaming URL is not supported. Check whether the URL format is correct. - */ - FormatNotSupported = 10, -} - -/** - * The RTMP streaming state. - * @enum {number} - */ -export enum RtmpStreamingState { - /** - * The RTMP streaming has not started or has ended. This state is also triggered after you remove an RTMP address from the CDN by calling removePublishStreamUrl. - * @see RtcEngine.removePublishStreamUrl - */ - Idle = 0, - /** - * The SDK is connecting to Agora’s streaming server and the RTMP server. This state is triggered after you call the addPublishStreamUrl method. - * @see RtcEngine.addPublishStreamUrl - */ - Connecting = 1, - /** - * The RTMP streaming is being published. The SDK successfully publishes the RTMP streaming and returns this state. - */ - Running = 2, - /** - * The RTMP streaming is recovering. When exceptions occur to the CDN, or the streaming is interrupted, the SDK attempts to resume RTMP streaming and returns this state. - * - If the SDK successfully resumes the streaming, Running(2) returns. - * @see RtmpStreamingState.Running - * - If the streaming does not resume within 60 seconds or server errors occur, Failure(4) returns. You can also reconnect to the server by calling the removePublishStreamUrl and addPublishStreamUrl methods. - * @see RtmpStreamingState.Failure - * @see RtcEngine.removePublishStreamUrl - * @see RtcEngine.addPublishStreamUrl - */ - Recovering = 3, - /** - * The RTMP streaming fails. See the errorCode parameter for the detailed error information. You can also call the addPublishStreamUrl method to publish the RTMP streaming again. - * @see RtcEngine.addPublishStreamUrl - */ - Failure = 4, -} - -/** - * Stream fallback option. - * @enum {number} - */ -export enum StreamFallbackOptions { - /** - * No fallback behavior for the local/remote video stream when the uplink/downlink network condition is unreliable. The quality of the stream is not guaranteed. - */ - Disabled = 0, - /** - * Under unreliable downlink network conditions, the remote video stream falls back to the low-stream (low resolution and low bitrate) video. You can only set this option in the setRemoteSubscribeFallbackOption method. Nothing happens when you set this in the setLocalPublishFallbackOption method. - * @see RtcEngine.setRemoteSubscribeFallbackOption - * @see RtcEngine.setLocalPublishFallbackOption - */ - VideoStreamLow = 1, - /** - * Under unreliable uplink network conditions, the published video stream falls back to audio only. Under unreliable downlink network conditions, the remote video stream first falls back to the low-stream (low resolution and low bitrate) video; and then to an audio-only stream if the network condition deteriorates. - */ - AudioOnly = 2, -} - -/** - * Reason for the user being offline. - * @enum {number} - */ -export enum UserOfflineReason { - /** - * The user left the current channel. - */ - Quit = 0, - /** - * The SDK timed out and the user dropped offline because no data packet is received within a certain period of time. If a user quits the call and the message is not passed to the SDK (due to an unreliable channel), the SDK assumes the user dropped offline. - */ - Dropped = 1, - /** - * (Live broadcast only.) The client role switched from the host to the audience. - */ - BecomeAudience = 2, -} - -/** - * The priority of the remote user. - * @enum {number} - */ -export enum UserPriority { - /** - * The user’s priority is high. - */ - High = 50, - /** - * (Default) The user’s priority is normal. - */ - Normal = 100, -} - -/** - * Video buffer type - * @enum {number} - * TODO iOS AgoraVideoSourceProtocol AgoraVideoSinkProtocol - */ -export enum VideoBufferType { - /** - * Use a pixel buffer to transmit the video data. - */ - PixelBuffer = 1, - /** - * Use raw data to transmit the video data. - */ - RawData = 2, -} - -/** - * Self-defined video codec profile. - * @enum {number} - */ -export enum VideoCodecProfileType { - /** - * Baseline video codec profile. Generally used in video calls on mobile phones. - */ - BaseLine = 66, - /** - * Main video codec profile. Generally used in mainstream electronics, such as MP4 players, portable video players, PSP, and iPads. - */ - Main = 77, - /** - * (Default) High video codec profile. Generally used in high-resolution broadcasts or television. - */ - High = 100, -} - -/** - * The content hint for screen sharing. - * @enum {number} - * TODO MacOS setScreenCaptureContentHint - */ -export enum VideoContentHint { - /** - * (Default) No content hint. - */ - None = 0, - /** - * Motion-intensive content. Choose this option if you prefer smoothness or when you are sharing a video clip, movie, or video game. - */ - Motion = 1, - /** - * Motionless content. Choose this option if you prefer sharpness or when you are sharing a picture, PowerPoint slide, or text. - */ - Details = 2, -} - -/** - * Video frame rate - * @enum {number} - */ -export enum VideoFrameRate { - Min = -1, - /** - * 1 fps. - */ - Fps1 = 1, - /** - * 7 fps. - */ - Fps7 = 7, - /** - * 10 fps. - */ - Fps10 = 10, - /** - * 15 fps. - */ - Fps15 = 15, - /** - * 24 fps. - */ - Fps24 = 24, - /** - * 30 fps. - */ - Fps30 = 30, - /** - * 60 fps (macOS only). - */ - Fps60 = 60, -} - -/** - * Sets the video bitrate (Kbps). Refer to the table below and set your bitrate. If you set a bitrate beyond the proper range, the SDK automatically adjusts it to a value within the range. You can also choose from the following options: - * @enum {number} - */ -export enum BitRate { - /** - * (recommended) the standard bitrate mode. In this mode, the bitrates differ between the Live-broadcast and Communication profiles: - * - Communication profile: the video bitrate is the same as the base bitrate. - * - Live-broadcast profile: the video bitrate is twice the base bitrate. - */ - Standard = 0, - /** - * the compatible bitrate mode. In this mode, the bitrate stays the same regardless of the profile. In the Live-broadcast profile, if you choose this mode, the video frame rate may be lower than the set value. - */ - Compatible = -1, -} - -/** - * Video mirror mode. - * @enum {number} - */ -export enum VideoMirrorMode { - /** - * (Default) The SDK determines the mirror mode. - */ - Auto = 0, - /** - * Enables mirror mode. - */ - Enabled = 1, - /** - * Disables mirror mode. - */ - Disabled = 2, -} - -/** - * Video output orientation mode. - * @enum {number} - */ -export enum VideoOutputOrientationMode { - /** - * Adaptive mode (Default). - * The video encoder adapts to the orientation mode of the video input device. When you use a custom video source, the output video from the encoder inherits the orientation of the original video. - * - If the width of the captured video from the SDK is greater than the height, the encoder sends the video in landscape mode. The encoder also sends the rotational information of the video, and the receiver uses the rotational information to rotate the received video. - * - If the original video is in portrait mode, the output video from the encoder is also in portrait mode. The encoder also sends the rotational information of the video to the receiver. - */ - Adaptative = 0, - /** - * Landscape mode. - * The video encoder always sends the video in landscape mode. The video encoder rotates the original video before sending it and the rotational information is 0. This mode applies to scenarios involving CDN live streaming. - */ - FixedLandscape = 1, - /** - * Portrait mode. - * The video encoder always sends the video in portrait mode. The video encoder rotates the original video before sending it and the rotational information is 0. This mode applies to scenarios involving CDN live streaming. - */ - FixedPortrait = 2, -} - -/** - * Video pixel format. - * @enum {number} - * TODO iOS AgoraVideoSinkProtocol - */ -export enum VideoPixelFormat { - /** - * I420 - */ - I420 = 1, - /** - * BGRA - */ - BGRA = 2, - /** - * NV12 - */ - NV12 = 8, -} - -/** - * Quality change of the local video in terms of target frame rate and target bit rate since last count. - * @enum {number} - */ -export enum VideoQualityAdaptIndication { - /** - * The quality of the local video stays the same. - */ - AdaptNone = 0, - /** - * The quality improves because the network bandwidth increases. - */ - AdaptUpBandwidth = 1, - /** - * The quality worsens because the network bandwidth decreases. - */ - AdaptDownBandwidth = 2, -} - -/** - * The state of the remote video. - * @enum {number} - */ -export enum VideoRemoteState { - /** - * The remote video is in the default state, probably due to: - * @see VideoRemoteStateReason.LocalMuted - * @see VideoRemoteStateReason.RemoteMuted - * @see VideoRemoteStateReason.RemoteOffline - */ - Stopped = 0, - /** - * The first remote video packet is received. - */ - Starting = 1, - /** - * The remote video stream is decoded and plays normally, probably due to: - * @see VideoRemoteStateReason.NetworkRecovery - * @see VideoRemoteStateReason.LocalUnmuted - * @see VideoRemoteStateReason.RemoteUnmuted - * @see VideoRemoteStateReason.AudioFallbackRecovery - */ - Decoding = 2, - /** - * The remote video is frozen, probably due to: - * @see VideoRemoteStateReason.NetworkCongestion - * @see VideoRemoteStateReason.AudioFallback - */ - Frozen = 3, - /** - * The remote video fails to start, probably due to: - * @see VideoRemoteStateReason.Internal - */ - Failed = 4, -} - -/** - * The reason of the remote video state change. - * @enum {number} - */ -export enum VideoRemoteStateReason { - /** - * Internal reasons. - */ - Internal = 0, - /** - * Network congestion. - */ - NetworkCongestion = 1, - /** - * Network recovery. - */ - NetworkRecovery = 2, - /** - * The local user stops receiving the remote video stream or disables the video module. - */ - LocalMuted = 3, - /** - * The local user stops receiving the remote video stream or disables the video module. - */ - LocalUnmuted = 4, - /** - * The remote user stops sending the video stream or disables the video module. - */ - RemoteMuted = 5, - /** - * The remote user resumes sending the video stream or enables the video module. - */ - RemoteUnmuted = 6, - /** - * The remote user leaves the channel. - */ - RemoteOffline = 7, - /** - * The remote media stream falls back to the audio-only stream due to poor network conditions. - */ - AudioFallback = 8, - /** - * The remote media stream switches back to the video stream after the network conditions improve. - */ - AudioFallbackRecovery = 9, -} - -/** - * Video display mode. - * @enum {number} - */ -export enum VideoRenderMode { - /** - * Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents. - */ - Hidden = 1, - /** - * Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black. - */ - Fit = 2, - /** - * This mode is deprecated. - * @deprecated - */ - Adaptive = 3, - /** - * The fill mode. In this mode, the SDK stretches or zooms the video to fill the display window. - */ - FILL = 4, -} - -/** - * Video rotation. - * @enum {number} - * TODO iOS AgoraVideoSourceProtocol AgoraVideoSinkProtocol - */ -export enum VideoRotation { - /** - * No rotation - */ - RotationNone = 0, - /** - * 90 degrees - */ - Rotation90 = 1, - /** - * 180 degrees - */ - Rotation180 = 2, - /** - * 270 degrees - */ - Rotation270 = 3, -} - -/** - * Video stream type. - * @enum {number} - */ -export enum VideoStreamType { - /** - * High-bitrate, high-resolution video stream. - */ - High = 0, - /** - * Low-bitrate, low-resolution video stream. - */ - Low = 1, -} - -/** - * Warning codes occur when the SDK encounters an error that may be recovered automatically. These are only notifications, and can generally be ignored. For example, when the SDK loses connection to the server, the SDK reports the OpenChannelTimeout(106) warning and tries to reconnect automatically. - * @see WarningCode.OpenChannelTimeout - * @enum {number} - */ -export enum WarningCode { - /** - * The specified view is invalid. Specify a view when using the video call function. - */ - InvalidView = 8, - /** - * Failed to initialize the video function, possibly caused by a lack of resources. The users cannot see the video while the voice communication is not affected. - */ - InitVideo = 16, - /** - * The request is pending, usually due to some module not being ready, and the SDK postpones processing the request. - */ - Pending = 20, - /** - * No channel resources are available. Maybe because the server cannot allocate any channel resource. - */ - NoAvailableChannel = 103, - /** - * A timeout occurs when looking up the channel. When joining a channel, the SDK looks up the specified channel. The warning usually occurs when the network condition is too poor for the SDK to connect to the server. - */ - LookupChannelTimeout = 104, - /** - * The server rejects the request to look up the channel. The server cannot process this request or the request is illegal. DEPRECATED as of v2.4.1. Use RejectedByServer(10) in the reason parameter of onConnectionStateChanged. - * @see ConnectionChangedReason.RejectedByServer - * @see RtcEngineEvents.onConnectionStateChanged - * @deprecated - */ - LookupChannelRejected = 105, - /** - * The server rejects the request to look up the channel. The server cannot process this request or the request is illegal. - */ - OpenChannelTimeout = 106, - /** - * The server rejects the request to open the channel. The server cannot process this request or the request is illegal. - */ - OpenChannelRejected = 107, - /** - * A timeout occurs when switching to the live video. - */ - SwitchLiveVideoTimeout = 111, - /** - * A timeout occurs when setting the client role in the live broadcast profile. - */ - SetClientRoleTimeout = 118, - /** - * The client role is unauthorized. - */ - SetClientRoleNotAuthorized = 119, - /** - * The ticket to open the channel is invalid. - */ - OpenChannelInvalidTicket = 121, - /** - * Try connecting to another server. - */ - OpenChannelTryNextVos = 122, - /** - * An error occurs in opening the audio mixing file. - */ - AudioMixingOpenError = 701, - /** - * Audio Device Module: a warning occurs in the playback device. - */ - AdmRuntimePlayoutWarning = 1014, - /** - * Audio Device Module: a warning occurs in the recording device. - */ - AdmRuntimeRecordingWarning = 1016, - /** - * Audio Device Module: no valid audio data is collected. - */ - AdmRecordAudioSilence = 1019, - /** - * Audio Device Module: a playback device fails. - */ - AdmPlaybackMalfunction = 1020, - /** - * Audio Device Module: a recording device fails. - */ - AdmRecordMalfunction = 1021, - /** - * Audio Device Module: call is interrupted by system events such as phone call or siri etc. - */ - AdmInterruption = 1025, - /** - * Audio Device Module: the recorded audio is too low. - */ - AdmRecordAudioLowlevel = 1031, - /** - * Audio Device Module: the playback audio is too low. - */ - AdmPlayoutAudioLowlevel = 1032, - /** - * Audio Device Module: The recording device is busy. - */ - AdmRecordIsOccupied = 1033, - /** - * Audio Device Module: howling is detected. - */ - ApmHowling = 1051, - /** - * Audio Device Module: the device is in the glitch state. - */ - AdmGlitchState = 1052, - /** - * Audio Device Module: the underlying audio settings have changed. - */ - AdmImproperSettings = 1053, -} - -/** - * The audio channel of the sound. - * @enum {number} - */ -export enum AudioChannel { - /** - * (Default) Supports dual channels. Depends on the upstream of the broadcaster. - */ - Channel0 = 0, - /** - * The audio stream of the broadcaster uses the FL audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. - */ - Channel1 = 1, - /** - * The audio stream of the broadcaster uses the FC audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. - */ - Channel2 = 2, - /** - * The audio stream of the broadcaster uses the FR audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. - */ - Channel3 = 3, - /** - * The audio stream of the broadcaster uses the BL audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. - */ - Channel4 = 4, - /** - * The audio stream of the broadcaster uses the BR audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. - */ - Channel5 = 5, -} - -/** - * Video codec types. - * @enum {number} - */ -export enum VideoCodecType { - /** - * Standard VP8. - */ - VP8 = 1, - /** - * Standard H264. - */ - H264 = 2, - /** - * Enhanced VP8. - */ - EVP = 3, - /** - * Enhanced H264. - */ - E264 = 4, -} - -export type String = string | undefined | null -export type Rate = 1 | 2 | 3 | 4 | 5 - -/** - * The user information, including the user ID and user account. - * @property uid: int | The user ID of a user. - * @property userAccount: string | The user account of a user. - */ -export interface UserInfo { - uid: number - userAccount: string -} - -/** - * The video resolution. - * @property width: int | The video resolution on the horizontal axis. - * @property height: int | The video resolution on the vertical axis. - */ -export class VideoDimensions { - width: number - height: number - - constructor(width: number, height: number) { - this.width = width; - this.height = height; - } -} - -/** - * Definition of VideoEncoderConfiguration. - * @property dimensions: object | The video frame dimensions (px), which is used to specify the video quality and measured by the total number of pixels along a frame's width and height. The default value is 640 × 360. - * @property frameRate: int | The video frame rate (fps). The default value is 15. Users can either set the frame rate manually or choose from the following options. We do not recommend setting this to a value greater than 30. - * @property minFrameRate: int | The minimum video encoder frame rate (fps). The default value is Min(-1) (the SDK uses the lowest encoder frame rate). - * @property bitrate: int | Bitrate of the video (Kbps). Refer to the table below and set your bitrate. If you set a bitrate beyond the proper range, the SDK automatically adjusts it to a value within the range. - * @property minBitrate: int | The minimum encoding bitrate (Kbps). The Agora SDK automatically adjusts the encoding bitrate to adapt to the network conditions. Using a value greater than the default value forces the video encoder to output high-quality images but may cause more packet loss and hence sacrifice the smoothness of the video transmission. That said, unless you have special requirements for image quality, Agora does not recommend changing this value. - * @property orientationMode: int | The orientation mode. - * @property degradationPrefer: int | The video encoding degradation preference under limited bandwidth. - * @property mirrorMode: int | Sets the mirror mode of the published local video stream. - */ -export class VideoEncoderConfiguration { - dimensions?: VideoDimensions - frameRate?: VideoFrameRate - minFrameRate?: VideoFrameRate - bitrate?: BitRate | number - minBitrate?: number - orientationMode?: VideoOutputOrientationMode - degradationPrefer?: DegradationPreference - mirrorMode?: VideoMirrorMode - - constructor({dimensions, frameRate, minFrameRate, bitrate, minBitrate, orientationMode, degradationPrefer, mirrorMode}: { dimensions?: VideoDimensions, frameRate?: VideoFrameRate, minFrameRate?: VideoFrameRate, bitrate?: BitRate | number, minBitrate?: number, orientationMode?: VideoOutputOrientationMode, degradationPrefer?: DegradationPreference, mirrorMode?: VideoMirrorMode }) { - this.dimensions = dimensions; - this.frameRate = frameRate; - this.minFrameRate = minFrameRate; - this.bitrate = bitrate; - this.minBitrate = minBitrate; - this.orientationMode = orientationMode; - this.degradationPrefer = degradationPrefer; - this.mirrorMode = mirrorMode; - } -} - -/** - * Sets the image enhancement options. - * @property lighteningContrastLevel: int | The lightening contrast level. - * @property lighteningLevel: float | The brightness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.7. - * @property smoothnessLevel: float | The sharpness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.5. This parameter is usually used to remove blemishes. - * @property rednessLevel: float | The redness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.1. This parameter adjusts the red saturation level. - */ -export class BeautyOptions { - lighteningContrastLevel?: LighteningContrastLevel - lighteningLevel?: number - smoothnessLevel?: number - rednessLevel?: number - - constructor({lighteningContrastLevel, lighteningLevel, smoothnessLevel, rednessLevel}: { lighteningContrastLevel?: LighteningContrastLevel, lighteningLevel?: number, smoothnessLevel?: number, rednessLevel?: number }) { - this.lighteningContrastLevel = lighteningContrastLevel; - this.lighteningLevel = lighteningLevel; - this.smoothnessLevel = smoothnessLevel; - this.rednessLevel = rednessLevel; - } -} - -/** - * Agora image properties. A class for setting the properties of the watermark and background images. - * @property url: string | HTTP/HTTPS URL address of the image on the broadcasting video. The maximum length of this parameter is 1024 bytes. - * @property x: int | Position of the image on the upper left of the broadcasting video on the horizontal axis. - * @property y: int | Position of the image on the upper left of the broadcasting video on the vertical axis. - * @property width: int | Width of the image on the broadcasting video. - * @property height: int | Height of the image on the broadcasting video. - */ -export class AgoraImage { - url: string - x: number - y: number - width: number - height: number - - constructor(url: string, x: number, y: number, width: number, height: number) { - this.url = url; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } -} - -/** - * The transcodingUser class, which defines the audio and video properties in the CDN live. Agora supports a maximum of 17 transcoding users in a CDN live streaming channel. - * @property uid: int | ID of the user in the CDN live streaming. - * @property x: int | Horizontal position of the video frame of the user from the top left corner of the CDN live streaming. - * @property y: int | Vertical position of the video frame of the user from the top left corner of the CDN live streaming. - * @property width: int | Width of the video frame of the user on the CDN live streaming. The default value is 360. - * @property height: int | Height of the video frame of the user on the CDN live streaming. The default value is 640. - * @property zOrder: int | Layer position of video frame of the user on the CDN live streaming. The value ranges between 0 and 100. From v2.3.0, Agora SDK supports setting zOrder as 0. The smallest value is 0 (default value), which means that the video frame is at the bottom layer. The biggest value is 100, which means that the video frame is at the top layer. - * @property alpha: float | The transparency of the video frame of the user in the CDN live stream that ranges between 0.0 and 1.0. 0.0 means that the video frame is completely transparent and 1.0 means opaque. The default value is 1.0. - * @property audioChannel: int | The audio channel ranging between 0 and 5. The default value is 0. - */ -export class TranscodingUser { - uid: number - x: number - y: number - width?: number - height?: number - zOrder?: number - alpha?: number - audioChannel?: AudioChannel - - constructor(uid: number, x: number, y: number, {width, height, zOrder, alpha, audioChannel}: { width?: number, height?: number, zOrder?: number, alpha?: number, audioChannel?: AudioChannel }) { - this.uid = uid; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.zOrder = zOrder; - this.alpha = alpha; - this.audioChannel = audioChannel; - } -} - -/** - * Color. - * @property red: int | Red. - * @property green: int | Green. - * @property blue: int | Blue. - */ -export class Color { - red: number - green: number - blue: number - - constructor(red: number, green: number, blue: number) { - this.red = red; - this.green = green; - this.blue = blue; - } -} - -/** - * A class for managing user-specific CDN live audio/video transcoding settings. - * @property width: int | Width (pixel) of the video. The default value is 360. If you push video streams to the CDN, set the value of width × height to at least 64 × 64, or the SDK adjusts it to 64 x 64. If you push audio streams to the CDN, set the value of width × height to 0 × 0. - * @property height: int | Height (pixel) of the video. The default value is 640. If you push video streams to the CDN, set the value of width × height to at least 64 × 64, or the SDK adjusts it to 64 x 64. If you push audio streams to the CDN, set the value of width × height to 0 × 0. - * @property videoBitrate: int | Bitrate (Kbps) of the CDN live output video stream. The default value is 400. Set this parameter according to the Video Bitrate Table. If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range. - * @property videoFramerate: int | Frame rate (fps) of the CDN live output video stream. The value range is [0, 30]. The default value is 15. Agora adjusts all values over 30 to 30. - * @property lowLatency: boolean | true: Low latency with unassured quality. false: (Default) High latency with assured quality. - * @property videoGop: int | Gop of the video frames in the CDN live stream. The default value is 30 fps. - * @property watermark: object | The watermark image added to the CDN live publishing stream. Ensure that the format of the image is PNG. Once a watermark image is added, the audience of the CDN live publishing stream can see it. - * @property backgroundImage: object | The background image added to the CDN live publishing stream. Once a background image is added, the audience of the CDN live publishing stream can see it. - * @property audioSampleRate: int | Self-defined audio-sample rate: AudioSampleRateType. - * @property audioBitrate: int | Bitrate (Kbps) of the CDN live audio output stream. The default value is 48 and the highest value is 128. - * @property audioChannels: int | Agora’s self-defined audio channel type. We recommend choosing 1 or 2. Special players are required if you choose 3, 4 or 5. - * @property audioCodecProfile: int | Audio codec profile type: AudioCodecProfileType. Set it as LC-AAC or HE-AAC. The default value is LC-AAC. - * @property videoCodecProfile: int | Video codec profile type: VideoCodecProfileType. Set it as BASELINE, MAIN, or HIGH (default). If you set this parameter to other values, Agora adjusts it to the default value HIGH. - * @property backgroundColor: int | Sets the background color. - * @property userConfigExtraInfo: string | Reserved property. Extra user-defined information to send the Supplemental Enhancement Information (SEI) for the H.264/H.265 video stream to the CDN live client. Maximum length: 4096 Bytes. - * @property transcodingUsers: array | An TranscodingUser object managing the user layout configuration in the CDN live stream. Agora supports a maximum of 17 transcoding users in a CDN live stream channel. - */ -export class LiveTranscoding { - width?: number - height?: number - videoBitrate?: number - videoFramerate?: VideoFrameRate - /** @deprecated */ - lowLatency?: boolean - videoGop?: number - watermark?: AgoraImage - backgroundImage?: AgoraImage - audioSampleRate?: AudioSampleRateType - audioBitrate?: number - audioChannels?: AudioChannel - audioCodecProfile?: AudioCodecProfileType - videoCodecProfile?: VideoCodecProfileType - backgroundColor?: Color - userConfigExtraInfo?: string - transcodingUsers: TranscodingUser[] - - constructor(transcodingUsers: TranscodingUser[], {width, height, videoBitrate, videoFramerate, lowLatency, videoGop, watermark, backgroundImage, audioSampleRate, audioBitrate, audioChannels, audioCodecProfile, videoCodecProfile, backgroundColor, userConfigExtraInfo}: { width?: number, height?: number, videoBitrate?: number, videoFramerate?: VideoFrameRate, lowLatency?: boolean, videoGop?: number, watermark?: AgoraImage, backgroundImage?: AgoraImage, audioSampleRate?: AudioSampleRateType, audioBitrate?: number, audioChannels?: AudioChannel, audioCodecProfile?: AudioCodecProfileType, videoCodecProfile?: VideoCodecProfileType, backgroundColor?: Color, userConfigExtraInfo?: string, }) { - this.width = width; - this.height = height; - this.videoBitrate = videoBitrate; - this.videoFramerate = videoFramerate; - this.lowLatency = lowLatency; - this.videoGop = videoGop; - this.watermark = watermark; - this.backgroundImage = backgroundImage; - this.audioSampleRate = audioSampleRate; - this.audioBitrate = audioBitrate; - this.audioChannels = audioChannels; - this.audioCodecProfile = audioCodecProfile; - this.videoCodecProfile = videoCodecProfile; - this.backgroundColor = backgroundColor; - this.userConfigExtraInfo = userConfigExtraInfo; - this.transcodingUsers = transcodingUsers; - } -} - -/** - * The ChannelMediaInfo class. - * @property channelName: string | The channel name. - * @property token: string | The token that enables the user to join the channel. - * @property uid: int | The user ID. - */ -export class ChannelMediaInfo { - channelName?: string - token?: string - uid: number - - constructor(uid: number, {channelName, token}: { channelName?: string, token?: string }) { - this.channelName = channelName; - this.token = token; - this.uid = uid; - } -} - -/** - * The ChannelMediaRelayConfiguration class. - * @property srcInfo: object | Sets the information of the source channel. - * @property destInfos: array | Sets the information of the destination channel. - */ -export class ChannelMediaRelayConfiguration { - srcInfo: ChannelMediaInfo - destInfos: ChannelMediaInfo[] - - constructor(srcInfo: ChannelMediaInfo, destInfos: ChannelMediaInfo[]) { - this.srcInfo = srcInfo; - this.destInfos = destInfos; - } -} - -/** - * Lastmile probe configuration. - * @property probeUplink: boolean | Whether to probe uplink of lastmile. i.e., audience don't need probe uplink bandwidth. - * @property probeDownlink: boolean | Whether to probe downlink of lastmile. - * @property expectedUplinkBitrate: int | The expected maximum sending bitrate in bps in range of [100000, 5000000]. It is recommended to set this value according to the required bitrate of selected video profile. - * @property expectedDownlinkBitrate: int | The expected maximum receive bitrate in bps in range of [100000, 5000000]. - */ -export class LastmileProbeConfig { - probeUplink: boolean - probeDownlink: boolean - expectedUplinkBitrate: number - expectedDownlinkBitrate: number - - constructor(probeUplink: boolean, probeDownlink: boolean, expectedUplinkBitrate: number, expectedDownlinkBitrate: number) { - this.probeUplink = probeUplink; - this.probeDownlink = probeDownlink; - this.expectedUplinkBitrate = expectedUplinkBitrate; - this.expectedDownlinkBitrate = expectedDownlinkBitrate; - } -} - -/** - * The position and size of the watermark image. - * @property x: int | The horizontal offset from the top-left corner. - * @property y: int | The vertical offset from the top-left corner. - * @property width: int | The width (pixels) of the watermark image. - * @property height: int | The height (pixels) of the watermark image. - */ -export class Rectangle { - x: number - y: number - width: number - height: number - - constructor(x: number, y: number, width: number, height: number) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } -} - -/** - * Agora watermark options. A class for setting the properties of watermark. - * @property visibleInPreview: boolean | Sets whether or not the watermark image is visible in the local video preview: true: (Default) The watermark image is visible in preview. false: The watermark image is not visible in preview. - * @property positionInLandscapeMode: object | The watermark position in the landscape mode. - * @property positionInPortraitMode: object | The watermark position in the portrait mode. - */ -export class WatermarkOptions { - visibleInPreview?: boolean - positionInLandscapeMode: Rectangle - positionInPortraitMode: Rectangle - - constructor(positionInLandscapeMode: Rectangle, positionInPortraitMode: Rectangle, visibleInPreview?: boolean) { - this.visibleInPreview = visibleInPreview; - this.positionInLandscapeMode = positionInLandscapeMode; - this.positionInPortraitMode = positionInPortraitMode; - } -} - -/** - * Configuration of the imported live broadcast voice or video stream. - * @property width: int | Width of the added stream to the broadcast. The default value is 0, which is the same width as the original stream. - * @property height: int | Height of the added stream to the broadcast. The default value is 0, which is the same height as the original stream. - * @property videoGop: int | Video GOP of the added stream to the broadcast. The default value is 30 frames. - * @property videoFramerate: int | Video frame rate of the added stream to the broadcast. The default value is 15 fps. - * @property videoBitrate: int | Video bitrate of the added stream to the broadcast. The default value is 400 Kbps. - * @property audioSampleRate: int | Audio sample rate of the added stream to the broadcast: AudioSampleRateType. The default value is 44100 Hz. - * @property audioBitrate: int | Audio bitrate of the added stream to the broadcast. The default value is 48. - * @property audioChannels: int | Audio channels to add into the broadcast. The value ranges between 1 and 2. The default value is 1. - */ -export class LiveInjectStreamConfig { - width?: number - height?: number - videoGop?: number - videoFramerate?: VideoFrameRate - videoBitrate?: number - audioSampleRate?: AudioSampleRateType - audioBitrate?: number - audioChannels?: AudioChannel - - constructor({width, height, videoGop, videoFramerate, videoBitrate, audioSampleRate, audioBitrate, audioChannels}: { width?: number, height?: number, videoGop?: number, videoFramerate?: VideoFrameRate, videoBitrate?: number, audioSampleRate?: AudioSampleRateType, audioBitrate?: number, audioChannels?: AudioChannel }) { - this.width = width; - this.height = height; - this.videoGop = videoGop; - this.videoFramerate = videoFramerate; - this.videoBitrate = videoBitrate; - this.audioSampleRate = audioSampleRate; - this.audioBitrate = audioBitrate; - this.audioChannels = audioChannels; - } -} - -/** - * The definition of CameraCapturerConfiguration. - * @property preference: int | The camera capturer configuration. - * @property cameraDirection: int | The camera direction. - */ -export class CameraCapturerConfiguration { - preference: CameraCaptureOutputPreference - cameraDirection: CameraDirection - - constructor(preference: CameraCaptureOutputPreference, cameraDirection: CameraDirection) { - this.preference = preference; - this.cameraDirection = cameraDirection; - } -} - -/** - * The channel media options. - * @property autoSubscribeAudio: boolean | Determines whether to subscribe to audio streams when the user joins the channel. - * @property autoSubscribeVideo: boolean | Determines whether to subscribe to video streams when the user joins the channel. - */ -export class ChannelMediaOptions { - autoSubscribeAudio: boolean - autoSubscribeVideo: boolean - - constructor(autoSubscribeAudio: boolean, autoSubscribeVideo: boolean) { - this.autoSubscribeAudio = autoSubscribeAudio; - this.autoSubscribeVideo = autoSubscribeVideo; - } -} - -/** - * Statistics of RTCEngine. - * @property totalDuration: int | Call duration in seconds, represented by an aggregate value. - * @property txBytes: int | Total number of bytes transmitted, represented by an aggregate value. - * @property rxBytes: int | Total number of bytes received, represented by an aggregate value. - * @property txAudioBytes: int | Total number of audio bytes sent (bytes), represented by an aggregate value. - * @property txVideoBytes: int | Total number of video bytes sent (bytes), represented by an aggregate value. - * @property rxAudioBytes: int | Total number of audio bytes received (bytes), represented by an aggregate value. - * @property rxVideoBytes: int | Total number of video bytes received (bytes), represented by an aggregate value. - * @property txKBitRate: int | Transmission bitrate in Kbps, represented by an instantaneous value. - * @property rxKBitRate: int | Receive bitrate (Kbps), represented by an instantaneous value. - * @property txAudioKBitRate: int | The transmission bitrate of the audio packet (Kbps), represented by an instantaneous value. - * @property rxAudioKBitRate: int | Audio receive bitrate (Kbps), represented by an instantaneous value. - * @property txVideoKBitRate: int | Video transmission bitrate (Kbps), represented by an instantaneous value. - * @property rxVideoKBitRate: int | Video receive bitrate (Kbps), represented by an instantaneous value. - * @property users: int | The number of users in the channel. - * @property lastmileDelay: int | Client-server latency. - * @property txPacketLossRate: int | The packet loss rate (%) from the local client to Agora's edge server, before network countermeasures. - * @property rxPacketLossRate: int | The packet loss rate (%) from Agora's edge server to the local client, before network countermeasures. - * @property cpuTotalUsage: float | System CPU usage (%). - * @property cpuAppUsage: float | Application CPU usage (%). - * @property gatewayRtt: int | The round-trip time delay from the client to the local router. - * @property memoryAppUsageRatio: float | The memory usage ratio of the app (%). - * @property memoryTotalUsageRatio: float | The memory usage ratio of the system (%). - * @property memoryAppUsageInKbytes: int | The memory usage of the app (KB). - */ -export interface RtcStats { - totalDuration: number - txBytes: number - rxBytes: number - txAudioBytes: number - txVideoBytes: number - rxAudioBytes: number - rxVideoBytes: number - txKBitRate: number - rxKBitRate: number - txAudioKBitRate: number - rxAudioKBitRate: number - txVideoKBitRate: number - rxVideoKBitRate: number - users: number - lastmileDelay: number - txPacketLossRate: number - rxPacketLossRate: number - cpuTotalUsage: number - cpuAppUsage: number - gatewayRtt: number - memoryAppUsageRatio: number - memoryTotalUsageRatio: number - memoryAppUsageInKbytes: number -} - -/** - * Properties of the audio volume information. An array containing the user ID and volume information for each speaker. - * @property uid: int | The user ID of the speaker. The uid of the local user is 0. - * @property volume: int | The sum of the voice volume and audio-mixing volume of the speaker. The value ranges between 0 (lowest volume) and 255 (highest volume). - * @property vad: int | Voice activity status of the local user. - * @property channelId: string | The channel ID, which indicates which channel the speaker is in. - */ -export interface AudioVolumeInfo { - uid: number - volume: number - vad: number - channelId: string -} - -/** - * Rect. - * @property left: int | Left. - * @property top: int | Top. - * @property right: int | Right. - * @property bottom: int | Bottom. - */ -export interface Rect { - left: number - top: number - right: number - bottom: number -} - -/** - * The one-way last-mile probe result. - * @property packetLossRate: int | The packet loss rate (%). - * @property jitter: int | The network jitter (ms). - * @property availableBandwidth: int | The estimated available bandwidth (bps). - */ -export interface LastmileProbeOneWayResult { - packetLossRate: number - jitter: number - availableBandwidth: number -} - -/** - * Statistics of the lastmile probe. - * @property state: int | The state of the probe test. - * @property rtt: int | The round-trip delay time (ms). - * @property uplinkReport: object | The uplink last-mile network report. - * @property downlinkReport: object | The downlink last-mile network report. - */ -export interface LastmileProbeResult { - state: LastmileProbeResultState - rtt: number - uplinkReport: LastmileProbeOneWayResult - downlinkReport: LastmileProbeOneWayResult -} - -/** - * Statistics of the local audio stream. - * @property numChannels: int | The number of channels. - * @property sentSampleRate: int | The sample rate (Hz). - * @property sentBitrate: int | The average sending bitrate (Kbps). - */ -export interface LocalAudioStats { - numChannels: number - sentSampleRate: number - sentBitrate: number -} - -/** - * Statistics of the local video. - * @property sentBitrate: int | Bitrate (Kbps) sent in the reported interval, which does not include the bitrate of the re-transmission video after the packet loss. - * @property sentFrameRate: int | Frame rate (fps) sent in the reported interval, which does not include the frame rate of the re-transmission video after the packet loss. - * @property encoderOutputFrameRate: int | The encoder output frame rate (fps) of the local video. - * @property rendererOutputFrameRate: int | The renderer output frame rate (fps) of the local video. - * @property targetBitrate: int | The target bitrate (Kbps) of the current encoder. This value is estimated by the SDK based on the current network conditions. - * @property targetFrameRate: int | The target frame rate (fps) of the current encoder. - * @property qualityAdaptIndication: int | Quality change of the local video in terms of target frame rate and target bit rate since last count. - * @property encodedBitrate: int | The encoding bitrate (Kbps), which does not include the bitrate of the re-transmission video after packet loss. - * @property encodedFrameWidth: int | The width of the encoding frame (px). - * @property encodedFrameHeight: int | The height of the encoding frame (px). - * @property encodedFrameCount: int | The value of the sent frame rate, represented by an aggregate value. - * @property codecType: int | The codec type of the local video. - */ -export interface LocalVideoStats { - sentBitrate: number - sentFrameRate: number - encoderOutputFrameRate: number - rendererOutputFrameRate: number - targetBitrate: number - targetFrameRate: number - qualityAdaptIndication: VideoQualityAdaptIndication - encodedBitrate: number - encodedFrameWidth: number - encodedFrameHeight: number - encodedFrameCount: number - codecType: VideoCodecType -} - -/** - * Statistics of the remote audio. - * @property uid: int | User ID of the user sending the audio streams. - * @property quality: int | Audio quality received by the user. - * @property networkTransportDelay: int | Network delay (ms) from the sender to the receiver. - * @property jitterBufferDelay: int | Network delay (ms) from the receiver to the jitter buffer. - * @property audioLossRate: int | Packet loss rate in the reported interval. - * @property numChannels: int | The number of channels. - * @property receivedSampleRate: int | The sample rate (Hz) of the received audio stream in the reported interval. - * @property receivedBitrate: int | The average bitrate (Kbps) of the received audio stream in the reported interval. - * @property totalFrozenTime: int | The total freeze time (ms) of the remote audio stream after the remote user joins the channel. In the reported interval, audio freeze occurs when the audio frame loss rate reaches 4%. totalFrozenTime = The audio freeze time × 2 × 1000 (ms). - * @property frozenRate: int | The total audio freeze time as a percentage (%) of the total time when the audio is available. - * @property totalActiveTime: int | The total time (ms) when the remote user in the Communication profile or the remote broadcaster in the Live-broadcast profile neither stops sending the audio stream nor disables the audio module after joining the channel. - */ -export interface RemoteAudioStats { - uid: number - quality: NetworkQuality - networkTransportDelay: number - jitterBufferDelay: number - audioLossRate: number - numChannels: number - receivedSampleRate: number - receivedBitrate: number - totalFrozenTime: number - frozenRate: number - totalActiveTime: number -} - -/** - * Statistics of the remote video. - * @property uid: int | User ID of the user sending the video streams. - * @property delay: int | Time delay (ms). In scenarios where audio and video is synchronized, you can use the value of networkTransportDelay and jitterBufferDelay in RemoteAudioStats to know the delay statistics of the remote video. - * @property width: int | Width (pixels) of the remote video. - * @property height: int | Height (pixels) of the remote video. - * @property receivedBitrate: int | Bitrate (Kbps) received in the reported interval. - * @property decoderOutputFrameRate: int | The decoder output frame rate (fps) of the remote video. - * @property rendererOutputFrameRate: int | The renderer output frame rate (fps) of the remote video. - * @property packetLossRate: int | Packet loss rate (%) of the remote video stream after network countermeasures. - * @property rxStreamType: int | Video stream type (high-stream or low-stream). - * @property totalFrozenTime: int | The total freeze time (ms) of the remote video stream after the remote user joins the channel. - * @property frozenRate: int | The total video freeze time as a percentage (%) of the total time when the video is available. - * @property totalActiveTime: int | The total time (ms) when the remote user in the Communication profile or the remote broadcaster in the Live-broadcast profile neither stops sending the video stream nor disables the video module after joining the channel. - */ -export interface RemoteVideoStats { - uid: number - /** - * @deprecated - */ - delay: number - width: number - height: number - receivedBitrate: number - decoderOutputFrameRate: number - rendererOutputFrameRate: number - packetLossRate: number - rxStreamType: VideoStreamType - totalFrozenTime: number - frozenRate: number - totalActiveTime: number -} - -/** - * The information of the detected human face. - * @property x: int | The x coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, the x coordinate represents the relative lateral displacement of the top left corner of the human face to the origin. - * @property y: int | The y coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, the y coordinate represents the relative longitudinal displacement of the top left corner of the human face to the origin. - * @property width: int | The width (px) of the human face in the captured video. - * @property height: int | The height (px) of the human face in the captured video. - * @property distance: int | The distance (cm) between the human face and the screen. - */ -export interface FacePositionInfo { - x: number - y: number - width: number - height: number - distance: number -} +export * from './src/Classes' +export * from './src/Enums' diff --git a/src/index.ts b/src/index.ts index 5c0c95ba4..55ff6a171 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,12 +1,13 @@ -import RtcEngine from './RtcEngine.native' -import RtcChannel from './RtcChannel.native' -import {RtcLocalView, RtcRemoteView} from './RtcRenderView.native' -import * as Types from './Types' +import RtcEngine from './src/RtcEngine.native' +import RtcChannel from './src/RtcChannel.native' +import RtcLocalView from './RtcLocalView' +import RtcRemoteView from './RtcRemoteView' + +export * from './Types' export default RtcEngine export { RtcChannel, RtcLocalView, - RtcRemoteView, - Types + RtcRemoteView } diff --git a/src/src/Classes.ts b/src/src/Classes.ts new file mode 100644 index 000000000..d5f8a7c3f --- /dev/null +++ b/src/src/Classes.ts @@ -0,0 +1,611 @@ +import { + AudioChannel, + AudioCodecProfileType, + AudioSampleRateType, + CameraCaptureOutputPreference, + CameraDirection, + DegradationPreference, + LastmileProbeResultState, + LighteningContrastLevel, + NetworkQuality, + VideoCodecProfileType, + VideoCodecType, + VideoFrameRate, + VideoMirrorMode, + VideoOutputOrientationMode, + VideoQualityAdaptIndication, + VideoStreamType +} from "./Enums"; + +/** + * The user information, including the user ID and user account. + * @property uid: int | The user ID of a user. + * @property userAccount: string | The user account of a user. + */ +export interface UserInfo { + uid: number + userAccount: string +} + +/** + * The video resolution. + * @property width: int | The video resolution on the horizontal axis. + * @property height: int | The video resolution on the vertical axis. + */ +export class VideoDimensions { + width: number + height: number + + constructor(width: number, height: number) { + this.width = width; + this.height = height; + } +} + +/** + * Definition of VideoEncoderConfiguration. + * @property dimensions: object | The video frame dimensions (px), which is used to specify the video quality and measured by the total number of pixels along a frame's width and height. The default value is 640 × 360. + * @property frameRate: int | The video frame rate (fps). The default value is 15. Users can either set the frame rate manually or choose from the following options. We do not recommend setting this to a value greater than 30. + * @property minFrameRate: int | The minimum video encoder frame rate (fps). The default value is Min(-1) (the SDK uses the lowest encoder frame rate). + * @property bitrate: int | Bitrate of the video (Kbps). Refer to the table below and set your bitrate. If you set a bitrate beyond the proper range, the SDK automatically adjusts it to a value within the range. + * @property minBitrate: int | The minimum encoding bitrate (Kbps). The Agora SDK automatically adjusts the encoding bitrate to adapt to the network conditions. Using a value greater than the default value forces the video encoder to output high-quality images but may cause more packet loss and hence sacrifice the smoothness of the video transmission. That said, unless you have special requirements for image quality, Agora does not recommend changing this value. + * @property orientationMode: int | The orientation mode. + * @property degradationPrefer: int | The video encoding degradation preference under limited bandwidth. + * @property mirrorMode: int | Sets the mirror mode of the published local video stream. + */ +export class VideoEncoderConfiguration { + dimensions?: VideoDimensions + frameRate?: VideoFrameRate + minFrameRate?: VideoFrameRate + bitrate?: number + minBitrate?: number + orientationMode?: VideoOutputOrientationMode + degradationPrefer?: DegradationPreference + mirrorMode?: VideoMirrorMode + + constructor({dimensions, frameRate, minFrameRate, bitrate, minBitrate, orientationMode, degradationPrefer, mirrorMode}: { dimensions?: VideoDimensions, frameRate?: VideoFrameRate, minFrameRate?: VideoFrameRate, bitrate?: number, minBitrate?: number, orientationMode?: VideoOutputOrientationMode, degradationPrefer?: DegradationPreference, mirrorMode?: VideoMirrorMode }) { + this.dimensions = dimensions; + this.frameRate = frameRate; + this.minFrameRate = minFrameRate; + this.bitrate = bitrate; + this.minBitrate = minBitrate; + this.orientationMode = orientationMode; + this.degradationPrefer = degradationPrefer; + this.mirrorMode = mirrorMode; + } +} + +/** + * Sets the image enhancement options. + * @property lighteningContrastLevel: int | The lightening contrast level. + * @property lighteningLevel: float | The brightness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.7. + * @property smoothnessLevel: float | The sharpness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.5. This parameter is usually used to remove blemishes. + * @property rednessLevel: float | The redness level. The value ranges between 0.0 (original) and 1.0. The default value is 0.1. This parameter adjusts the red saturation level. + */ +export class BeautyOptions { + lighteningContrastLevel?: LighteningContrastLevel + lighteningLevel?: number + smoothnessLevel?: number + rednessLevel?: number + + constructor({lighteningContrastLevel, lighteningLevel, smoothnessLevel, rednessLevel}: { lighteningContrastLevel?: LighteningContrastLevel, lighteningLevel?: number, smoothnessLevel?: number, rednessLevel?: number }) { + this.lighteningContrastLevel = lighteningContrastLevel; + this.lighteningLevel = lighteningLevel; + this.smoothnessLevel = smoothnessLevel; + this.rednessLevel = rednessLevel; + } +} + +/** + * Agora image properties. A class for setting the properties of the watermark and background images. + * @property url: string | HTTP/HTTPS URL address of the image on the broadcasting video. The maximum length of this parameter is 1024 bytes. + * @property x: int | Position of the image on the upper left of the broadcasting video on the horizontal axis. + * @property y: int | Position of the image on the upper left of the broadcasting video on the vertical axis. + * @property width: int | Width of the image on the broadcasting video. + * @property height: int | Height of the image on the broadcasting video. + */ +export class AgoraImage { + url: string + x: number + y: number + width: number + height: number + + constructor(url: string, x: number, y: number, width: number, height: number) { + this.url = url; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } +} + +/** + * The transcodingUser class, which defines the audio and video properties in the CDN live. Agora supports a maximum of 17 transcoding users in a CDN live streaming channel. + * @property uid: int | ID of the user in the CDN live streaming. + * @property x: int | Horizontal position of the video frame of the user from the top left corner of the CDN live streaming. + * @property y: int | Vertical position of the video frame of the user from the top left corner of the CDN live streaming. + * @property width: int | Width of the video frame of the user on the CDN live streaming. The default value is 360. + * @property height: int | Height of the video frame of the user on the CDN live streaming. The default value is 640. + * @property zOrder: int | Layer position of video frame of the user on the CDN live streaming. The value ranges between 0 and 100. From v2.3.0, Agora SDK supports setting zOrder as 0. The smallest value is 0 (default value), which means that the video frame is at the bottom layer. The biggest value is 100, which means that the video frame is at the top layer. + * @property alpha: float | The transparency of the video frame of the user in the CDN live stream that ranges between 0.0 and 1.0. 0.0 means that the video frame is completely transparent and 1.0 means opaque. The default value is 1.0. + * @property audioChannel: int | The audio channel ranging between 0 and 5. The default value is 0. + */ +export class TranscodingUser { + uid: number + x: number + y: number + width?: number + height?: number + zOrder?: number + alpha?: number + audioChannel?: AudioChannel + + constructor(uid: number, x: number, y: number, {width, height, zOrder, alpha, audioChannel}: { width?: number, height?: number, zOrder?: number, alpha?: number, audioChannel?: AudioChannel }) { + this.uid = uid; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.zOrder = zOrder; + this.alpha = alpha; + this.audioChannel = audioChannel; + } +} + +/** + * Color. + * @property red: int | Red. + * @property green: int | Green. + * @property blue: int | Blue. + */ +export class Color { + red: number + green: number + blue: number + + constructor(red: number, green: number, blue: number) { + this.red = red; + this.green = green; + this.blue = blue; + } +} + +/** + * A class for managing user-specific CDN live audio/video transcoding settings. + * @property width: int | Width (pixel) of the video. The default value is 360. If you push video streams to the CDN, set the value of width × height to at least 64 × 64, or the SDK adjusts it to 64 x 64. If you push audio streams to the CDN, set the value of width × height to 0 × 0. + * @property height: int | Height (pixel) of the video. The default value is 640. If you push video streams to the CDN, set the value of width × height to at least 64 × 64, or the SDK adjusts it to 64 x 64. If you push audio streams to the CDN, set the value of width × height to 0 × 0. + * @property videoBitrate: int | Bitrate (Kbps) of the CDN live output video stream. The default value is 400. Set this parameter according to the Video Bitrate Table. If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range. + * @property videoFramerate: int | Frame rate (fps) of the CDN live output video stream. The value range is [0, 30]. The default value is 15. Agora adjusts all values over 30 to 30. + * @property lowLatency: boolean | true: Low latency with unassured quality. false: (Default) High latency with assured quality. + * @property videoGop: int | Gop of the video frames in the CDN live stream. The default value is 30 fps. + * @property watermark: object | The watermark image added to the CDN live publishing stream. Ensure that the format of the image is PNG. Once a watermark image is added, the audience of the CDN live publishing stream can see it. + * @property backgroundImage: object | The background image added to the CDN live publishing stream. Once a background image is added, the audience of the CDN live publishing stream can see it. + * @property audioSampleRate: int | Self-defined audio-sample rate: AudioSampleRateType. + * @property audioBitrate: int | Bitrate (Kbps) of the CDN live audio output stream. The default value is 48 and the highest value is 128. + * @property audioChannels: int | Agora’s self-defined audio channel type. We recommend choosing 1 or 2. Special players are required if you choose 3, 4 or 5. + * @property audioCodecProfile: int | Audio codec profile type: AudioCodecProfileType. Set it as LC-AAC or HE-AAC. The default value is LC-AAC. + * @property videoCodecProfile: int | Video codec profile type: VideoCodecProfileType. Set it as BASELINE, MAIN, or HIGH (default). If you set this parameter to other values, Agora adjusts it to the default value HIGH. + * @property backgroundColor: int | Sets the background color. + * @property userConfigExtraInfo: string | Reserved property. Extra user-defined information to send the Supplemental Enhancement Information (SEI) for the H.264/H.265 video stream to the CDN live client. Maximum length: 4096 Bytes. + * @property transcodingUsers: array | An TranscodingUser object managing the user layout configuration in the CDN live stream. Agora supports a maximum of 17 transcoding users in a CDN live stream channel. + */ +export class LiveTranscoding { + width?: number + height?: number + videoBitrate?: number + videoFramerate?: VideoFrameRate + /** @deprecated */ + lowLatency?: boolean + videoGop?: number + watermark?: AgoraImage + backgroundImage?: AgoraImage + audioSampleRate?: AudioSampleRateType + audioBitrate?: number + audioChannels?: AudioChannel + audioCodecProfile?: AudioCodecProfileType + videoCodecProfile?: VideoCodecProfileType + backgroundColor?: Color + userConfigExtraInfo?: string + transcodingUsers: TranscodingUser[] + + constructor(transcodingUsers: TranscodingUser[], {width, height, videoBitrate, videoFramerate, lowLatency, videoGop, watermark, backgroundImage, audioSampleRate, audioBitrate, audioChannels, audioCodecProfile, videoCodecProfile, backgroundColor, userConfigExtraInfo}: { width?: number, height?: number, videoBitrate?: number, videoFramerate?: VideoFrameRate, lowLatency?: boolean, videoGop?: number, watermark?: AgoraImage, backgroundImage?: AgoraImage, audioSampleRate?: AudioSampleRateType, audioBitrate?: number, audioChannels?: AudioChannel, audioCodecProfile?: AudioCodecProfileType, videoCodecProfile?: VideoCodecProfileType, backgroundColor?: Color, userConfigExtraInfo?: string, }) { + this.width = width; + this.height = height; + this.videoBitrate = videoBitrate; + this.videoFramerate = videoFramerate; + this.lowLatency = lowLatency; + this.videoGop = videoGop; + this.watermark = watermark; + this.backgroundImage = backgroundImage; + this.audioSampleRate = audioSampleRate; + this.audioBitrate = audioBitrate; + this.audioChannels = audioChannels; + this.audioCodecProfile = audioCodecProfile; + this.videoCodecProfile = videoCodecProfile; + this.backgroundColor = backgroundColor; + this.userConfigExtraInfo = userConfigExtraInfo; + this.transcodingUsers = transcodingUsers; + } +} + +/** + * The ChannelMediaInfo class. + * @property channelName: string | The channel name. + * @property token: string | The token that enables the user to join the channel. + * @property uid: int | The user ID. + */ +export class ChannelMediaInfo { + channelName?: string + token?: string + uid: number + + constructor(uid: number, {channelName, token}: { channelName?: string, token?: string }) { + this.channelName = channelName; + this.token = token; + this.uid = uid; + } +} + +/** + * The ChannelMediaRelayConfiguration class. + * @property srcInfo: object | Sets the information of the source channel. + * @property destInfos: array | Sets the information of the destination channel. + */ +export class ChannelMediaRelayConfiguration { + srcInfo: ChannelMediaInfo + destInfos: ChannelMediaInfo[] + + constructor(srcInfo: ChannelMediaInfo, destInfos: ChannelMediaInfo[]) { + this.srcInfo = srcInfo; + this.destInfos = destInfos; + } +} + +/** + * Lastmile probe configuration. + * @property probeUplink: boolean | Whether to probe uplink of lastmile. i.e., audience don't need probe uplink bandwidth. + * @property probeDownlink: boolean | Whether to probe downlink of lastmile. + * @property expectedUplinkBitrate: int | The expected maximum sending bitrate in bps in range of [100000, 5000000]. It is recommended to set this value according to the required bitrate of selected video profile. + * @property expectedDownlinkBitrate: int | The expected maximum receive bitrate in bps in range of [100000, 5000000]. + */ +export class LastmileProbeConfig { + probeUplink: boolean + probeDownlink: boolean + expectedUplinkBitrate: number + expectedDownlinkBitrate: number + + constructor(probeUplink: boolean, probeDownlink: boolean, expectedUplinkBitrate: number, expectedDownlinkBitrate: number) { + this.probeUplink = probeUplink; + this.probeDownlink = probeDownlink; + this.expectedUplinkBitrate = expectedUplinkBitrate; + this.expectedDownlinkBitrate = expectedDownlinkBitrate; + } +} + +/** + * The position and size of the watermark image. + * @property x: int | The horizontal offset from the top-left corner. + * @property y: int | The vertical offset from the top-left corner. + * @property width: int | The width (pixels) of the watermark image. + * @property height: int | The height (pixels) of the watermark image. + */ +export class Rectangle { + x: number + y: number + width: number + height: number + + constructor(x: number, y: number, width: number, height: number) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } +} + +/** + * Agora watermark options. A class for setting the properties of watermark. + * @property visibleInPreview: boolean | Sets whether or not the watermark image is visible in the local video preview: true: (Default) The watermark image is visible in preview. false: The watermark image is not visible in preview. + * @property positionInLandscapeMode: object | The watermark position in the landscape mode. + * @property positionInPortraitMode: object | The watermark position in the portrait mode. + */ +export class WatermarkOptions { + visibleInPreview?: boolean + positionInLandscapeMode: Rectangle + positionInPortraitMode: Rectangle + + constructor(positionInLandscapeMode: Rectangle, positionInPortraitMode: Rectangle, visibleInPreview?: boolean) { + this.visibleInPreview = visibleInPreview; + this.positionInLandscapeMode = positionInLandscapeMode; + this.positionInPortraitMode = positionInPortraitMode; + } +} + +/** + * Configuration of the imported live broadcast voice or video stream. + * @property width: int | Width of the added stream to the broadcast. The default value is 0, which is the same width as the original stream. + * @property height: int | Height of the added stream to the broadcast. The default value is 0, which is the same height as the original stream. + * @property videoGop: int | Video GOP of the added stream to the broadcast. The default value is 30 frames. + * @property videoFramerate: int | Video frame rate of the added stream to the broadcast. The default value is 15 fps. + * @property videoBitrate: int | Video bitrate of the added stream to the broadcast. The default value is 400 Kbps. + * @property audioSampleRate: int | Audio sample rate of the added stream to the broadcast: AudioSampleRateType. The default value is 44100 Hz. + * @property audioBitrate: int | Audio bitrate of the added stream to the broadcast. The default value is 48. + * @property audioChannels: int | Audio channels to add into the broadcast. The value ranges between 1 and 2. The default value is 1. + */ +export class LiveInjectStreamConfig { + width?: number + height?: number + videoGop?: number + videoFramerate?: VideoFrameRate + videoBitrate?: number + audioSampleRate?: AudioSampleRateType + audioBitrate?: number + audioChannels?: AudioChannel + + constructor({width, height, videoGop, videoFramerate, videoBitrate, audioSampleRate, audioBitrate, audioChannels}: { width?: number, height?: number, videoGop?: number, videoFramerate?: VideoFrameRate, videoBitrate?: number, audioSampleRate?: AudioSampleRateType, audioBitrate?: number, audioChannels?: AudioChannel }) { + this.width = width; + this.height = height; + this.videoGop = videoGop; + this.videoFramerate = videoFramerate; + this.videoBitrate = videoBitrate; + this.audioSampleRate = audioSampleRate; + this.audioBitrate = audioBitrate; + this.audioChannels = audioChannels; + } +} + +/** + * The definition of CameraCapturerConfiguration. + * @property preference: int | The camera capturer configuration. + * @property cameraDirection: int | The camera direction. + */ +export class CameraCapturerConfiguration { + preference: CameraCaptureOutputPreference + cameraDirection: CameraDirection + + constructor(preference: CameraCaptureOutputPreference, cameraDirection: CameraDirection) { + this.preference = preference; + this.cameraDirection = cameraDirection; + } +} + +/** + * The channel media options. + * @property autoSubscribeAudio: boolean | Determines whether to subscribe to audio streams when the user joins the channel. + * @property autoSubscribeVideo: boolean | Determines whether to subscribe to video streams when the user joins the channel. + */ +export class ChannelMediaOptions { + autoSubscribeAudio: boolean + autoSubscribeVideo: boolean + + constructor(autoSubscribeAudio: boolean, autoSubscribeVideo: boolean) { + this.autoSubscribeAudio = autoSubscribeAudio; + this.autoSubscribeVideo = autoSubscribeVideo; + } +} + +/** + * Statistics of RTCEngine. + * @property totalDuration: int | Call duration in seconds, represented by an aggregate value. + * @property txBytes: int | Total number of bytes transmitted, represented by an aggregate value. + * @property rxBytes: int | Total number of bytes received, represented by an aggregate value. + * @property txAudioBytes: int | Total number of audio bytes sent (bytes), represented by an aggregate value. + * @property txVideoBytes: int | Total number of video bytes sent (bytes), represented by an aggregate value. + * @property rxAudioBytes: int | Total number of audio bytes received (bytes), represented by an aggregate value. + * @property rxVideoBytes: int | Total number of video bytes received (bytes), represented by an aggregate value. + * @property txKBitRate: int | Transmission bitrate in Kbps, represented by an instantaneous value. + * @property rxKBitRate: int | Receive bitrate (Kbps), represented by an instantaneous value. + * @property txAudioKBitRate: int | The transmission bitrate of the audio packet (Kbps), represented by an instantaneous value. + * @property rxAudioKBitRate: int | Audio receive bitrate (Kbps), represented by an instantaneous value. + * @property txVideoKBitRate: int | Video transmission bitrate (Kbps), represented by an instantaneous value. + * @property rxVideoKBitRate: int | Video receive bitrate (Kbps), represented by an instantaneous value. + * @property users: int | The number of users in the channel. + * @property lastmileDelay: int | Client-server latency. + * @property txPacketLossRate: int | The packet loss rate (%) from the local client to Agora's edge server, before network countermeasures. + * @property rxPacketLossRate: int | The packet loss rate (%) from Agora's edge server to the local client, before network countermeasures. + * @property cpuTotalUsage: float | System CPU usage (%). + * @property cpuAppUsage: float | Application CPU usage (%). + * @property gatewayRtt: int | The round-trip time delay from the client to the local router. + * @property memoryAppUsageRatio: float | The memory usage ratio of the app (%). + * @property memoryTotalUsageRatio: float | The memory usage ratio of the system (%). + * @property memoryAppUsageInKbytes: int | The memory usage of the app (KB). + */ +export interface RtcStats { + totalDuration: number + txBytes: number + rxBytes: number + txAudioBytes: number + txVideoBytes: number + rxAudioBytes: number + rxVideoBytes: number + txKBitRate: number + rxKBitRate: number + txAudioKBitRate: number + rxAudioKBitRate: number + txVideoKBitRate: number + rxVideoKBitRate: number + users: number + lastmileDelay: number + txPacketLossRate: number + rxPacketLossRate: number + cpuTotalUsage: number + cpuAppUsage: number + gatewayRtt: number + memoryAppUsageRatio: number + memoryTotalUsageRatio: number + memoryAppUsageInKbytes: number +} + +/** + * Properties of the audio volume information. An array containing the user ID and volume information for each speaker. + * @property uid: int | The user ID of the speaker. The uid of the local user is 0. + * @property volume: int | The sum of the voice volume and audio-mixing volume of the speaker. The value ranges between 0 (lowest volume) and 255 (highest volume). + * @property vad: int | Voice activity status of the local user. + * @property channelId: string | The channel ID, which indicates which channel the speaker is in. + */ +export interface AudioVolumeInfo { + uid: number + volume: number + vad: number + channelId: string +} + +/** + * Rect. + * @property left: int | Left. + * @property top: int | Top. + * @property right: int | Right. + * @property bottom: int | Bottom. + */ +export interface Rect { + left: number + top: number + right: number + bottom: number +} + +/** + * The one-way last-mile probe result. + * @property packetLossRate: int | The packet loss rate (%). + * @property jitter: int | The network jitter (ms). + * @property availableBandwidth: int | The estimated available bandwidth (bps). + */ +export interface LastmileProbeOneWayResult { + packetLossRate: number + jitter: number + availableBandwidth: number +} + +/** + * Statistics of the lastmile probe. + * @property state: int | The state of the probe test. + * @property rtt: int | The round-trip delay time (ms). + * @property uplinkReport: object | The uplink last-mile network report. + * @property downlinkReport: object | The downlink last-mile network report. + */ +export interface LastmileProbeResult { + state: LastmileProbeResultState + rtt: number + uplinkReport: LastmileProbeOneWayResult + downlinkReport: LastmileProbeOneWayResult +} + +/** + * Statistics of the local audio stream. + * @property numChannels: int | The number of channels. + * @property sentSampleRate: int | The sample rate (Hz). + * @property sentBitrate: int | The average sending bitrate (Kbps). + */ +export interface LocalAudioStats { + numChannels: number + sentSampleRate: number + sentBitrate: number +} + +/** + * Statistics of the local video. + * @property sentBitrate: int | Bitrate (Kbps) sent in the reported interval, which does not include the bitrate of the re-transmission video after the packet loss. + * @property sentFrameRate: int | Frame rate (fps) sent in the reported interval, which does not include the frame rate of the re-transmission video after the packet loss. + * @property encoderOutputFrameRate: int | The encoder output frame rate (fps) of the local video. + * @property rendererOutputFrameRate: int | The renderer output frame rate (fps) of the local video. + * @property targetBitrate: int | The target bitrate (Kbps) of the current encoder. This value is estimated by the SDK based on the current network conditions. + * @property targetFrameRate: int | The target frame rate (fps) of the current encoder. + * @property qualityAdaptIndication: int | Quality change of the local video in terms of target frame rate and target bit rate since last count. + * @property encodedBitrate: int | The encoding bitrate (Kbps), which does not include the bitrate of the re-transmission video after packet loss. + * @property encodedFrameWidth: int | The width of the encoding frame (px). + * @property encodedFrameHeight: int | The height of the encoding frame (px). + * @property encodedFrameCount: int | The value of the sent frame rate, represented by an aggregate value. + * @property codecType: int | The codec type of the local video. + */ +export interface LocalVideoStats { + sentBitrate: number + sentFrameRate: number + encoderOutputFrameRate: number + rendererOutputFrameRate: number + targetBitrate: number + targetFrameRate: number + qualityAdaptIndication: VideoQualityAdaptIndication + encodedBitrate: number + encodedFrameWidth: number + encodedFrameHeight: number + encodedFrameCount: number + codecType: VideoCodecType +} + +/** + * Statistics of the remote audio. + * @property uid: int | User ID of the user sending the audio streams. + * @property quality: int | Audio quality received by the user. + * @property networkTransportDelay: int | Network delay (ms) from the sender to the receiver. + * @property jitterBufferDelay: int | Network delay (ms) from the receiver to the jitter buffer. + * @property audioLossRate: int | Packet loss rate in the reported interval. + * @property numChannels: int | The number of channels. + * @property receivedSampleRate: int | The sample rate (Hz) of the received audio stream in the reported interval. + * @property receivedBitrate: int | The average bitrate (Kbps) of the received audio stream in the reported interval. + * @property totalFrozenTime: int | The total freeze time (ms) of the remote audio stream after the remote user joins the channel. In the reported interval, audio freeze occurs when the audio frame loss rate reaches 4%. totalFrozenTime = The audio freeze time × 2 × 1000 (ms). + * @property frozenRate: int | The total audio freeze time as a percentage (%) of the total time when the audio is available. + * @property totalActiveTime: int | The total time (ms) when the remote user in the Communication profile or the remote broadcaster in the Live-broadcast profile neither stops sending the audio stream nor disables the audio module after joining the channel. + */ +export interface RemoteAudioStats { + uid: number + quality: NetworkQuality + networkTransportDelay: number + jitterBufferDelay: number + audioLossRate: number + numChannels: number + receivedSampleRate: number + receivedBitrate: number + totalFrozenTime: number + frozenRate: number + totalActiveTime: number +} + +/** + * Statistics of the remote video. + * @property uid: int | User ID of the user sending the video streams. + * @property delay: int | Time delay (ms). In scenarios where audio and video is synchronized, you can use the value of networkTransportDelay and jitterBufferDelay in RemoteAudioStats to know the delay statistics of the remote video. + * @property width: int | Width (pixels) of the remote video. + * @property height: int | Height (pixels) of the remote video. + * @property receivedBitrate: int | Bitrate (Kbps) received in the reported interval. + * @property decoderOutputFrameRate: int | The decoder output frame rate (fps) of the remote video. + * @property rendererOutputFrameRate: int | The renderer output frame rate (fps) of the remote video. + * @property packetLossRate: int | Packet loss rate (%) of the remote video stream after network countermeasures. + * @property rxStreamType: int | Video stream type (high-stream or low-stream). + * @property totalFrozenTime: int | The total freeze time (ms) of the remote video stream after the remote user joins the channel. + * @property frozenRate: int | The total video freeze time as a percentage (%) of the total time when the video is available. + * @property totalActiveTime: int | The total time (ms) when the remote user in the Communication profile or the remote broadcaster in the Live-broadcast profile neither stops sending the video stream nor disables the video module after joining the channel. + */ +export interface RemoteVideoStats { + uid: number + /** + * @deprecated + */ + delay: number + width: number + height: number + receivedBitrate: number + decoderOutputFrameRate: number + rendererOutputFrameRate: number + packetLossRate: number + rxStreamType: VideoStreamType + totalFrozenTime: number + frozenRate: number + totalActiveTime: number +} + +/** + * The information of the detected human face. + * @property x: int | The x coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, the x coordinate represents the relative lateral displacement of the top left corner of the human face to the origin. + * @property y: int | The y coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin, the y coordinate represents the relative longitudinal displacement of the top left corner of the human face to the origin. + * @property width: int | The width (px) of the human face in the captured video. + * @property height: int | The height (px) of the human face in the captured video. + * @property distance: int | The distance (cm) between the human face and the screen. + */ +export interface FacePositionInfo { + x: number + y: number + width: number + height: number + distance: number +} diff --git a/src/src/Enums.ts b/src/src/Enums.ts new file mode 100644 index 000000000..8ce401738 --- /dev/null +++ b/src/src/Enums.ts @@ -0,0 +1,2359 @@ +/** + * IP areas + * @enum {number} + */ +export enum IPAreaCode { + /** + * Mainland China + */ + AREA_CN = 1 << 0, + /** + * North America + */ + AREA_NA = 1 << 1, + /** + * AREA_EUR + */ + AREA_EUR = 1 << 2, + /** + * Asia, excluding Mainland China + */ + AREA_AS = 1 << 3, + /** + * (Default) Global + */ + AREA_GLOBAL = -1, +} + +/** + * Audio codec profile. + * @enum {number} + */ +export enum AudioCodecProfileType { + /** + * (Default) LC-AAC, the low-complexity audio codec profile. + */ + LCAAC = 0, + /** + * HE-AAC, the high-efficiency audio codec profile. + */ + HEAAC = 1, +} + +/** + * Audio equalization band frequency. + * @enum {number} + */ +export enum AudioEqualizationBandFrequency { + /** + * 31 Hz. + */ + Band31 = 0, + /** + * 62 Hz. + */ + Band62 = 1, + /** + * 125 Hz. + */ + Band125 = 2, + /** + * 250 Hz. + */ + Band250 = 3, + /** + * 500 Hz. + */ + Band500 = 4, + /** + * 1 kHz. + */ + Band1K = 5, + /** + * 2 kHz. + */ + Band2K = 6, + /** + * 4 kHz. + */ + Band4K = 7, + /** + * 8 kHz. + */ + Band8K = 8, + /** + * 16 kHz. + */ + Band16K = 9, +} + +/** + * The error information of the local audio. + * @enum {number} + */ +export enum AudioLocalError { + /** + * The local audio is normal. + */ + Ok = 0, + /** + * No specified reason for the local audio failure. + */ + Failure = 1, + /** + * No permission to use the local audio device. + */ + DeviceNoPermission = 2, + /** + * The microphone is in use. + */ + DeviceBusy = 3, + /** + * The local audio recording fails. Check whether the recording device is working properly. + */ + RecordFailure = 4, + /** + * The local audio encoding fails. + */ + EncodeFailure = 5, +} + +/** + * The state of the local audio. + * @enum {number} + */ +export enum AudioLocalState { + /** + * The local audio is in the initial state. + */ + Stopped = 0, + /** + * The recording device starts successfully. + */ + Recording = 1, + /** + * The first audio frame encodes successfully. + */ + Encoding = 2, + /** + * The local audio fails to start. + */ + Failed = 3, +} + +/** + * The error code of the audio mixing file. + * @enum {number} + */ +export enum AudioMixingErrorCode { + /** + * The SDK cannot open the audio mixing file. + */ + CanNotOpen = 701, + /** + * The SDK opens the audio mixing file too frequently. + */ + TooFrequentCall = 702, + /** + * The opening of the audio mixing file is interrupted. + */ + InterruptedEOF = 703, + /** + * No error. + */ + OK = 0, +} + +/** + * The state of the audio mixing file. + * @enum {number} + */ +export enum AudioMixingStateCode { + /** + * The audio mixing file is playing. + */ + Playing = 710, + /** + * The audio mixing file pauses playing. + */ + Paused = 711, + /** + * The audio mixing file stops playing. + */ + Stopped = 713, + /** + * An exception occurs when playing the audio mixing file. + */ + Failed = 714, +} + +/** + * Audio output routing. + * @enum {number} + */ +export enum AudioOutputRouting { + /** + * Default. + */ + Default = -1, + /** + * Headset. + */ + Headset = 0, + /** + * Earpiece. + */ + Earpiece = 1, + /** + * Headset with no microphone. + */ + HeadsetNoMic = 2, + /** + * Speakerphone. + */ + Speakerphone = 3, + /** + * Loudspeaker. + */ + Loudspeaker = 4, + /** + * Bluetooth headset. + */ + HeadsetBluetooth = 5, +} + +/** + * Audio profile. + * @enum {number} + */ +export enum AudioProfile { + /** + * Default audio profile. + * - In the Communication profile: A sample rate of 32 KHz, audio encoding, mono, and a bitrate of up to 18 Kbps. + * - In the Live-broadcast profile: A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 52 Kbps. + */ + Default = 0, + /** + * A sample rate of 32 KHz, audio encoding, mono, and a bitrate of up to 18 Kbps. + */ + SpeechStandard = 1, + /** + * A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 48 Kbps. + */ + MusicStandard = 2, + /** + * A sample rate of 48 KHz, music encoding, stereo, and a bitrate of up to 56 Kbps. + */ + MusicStandardStereo = 3, + /** + * A sample rate of 48 KHz, music encoding, mono, and a bitrate of up to 128 Kbps. + */ + MusicHighQuality = 4, + /** + * A sample rate of 48 KHz, music encoding, stereo, and a bitrate of up to 192 Kbps. + */ + MusicHighQualityStereo = 5, +} + +/** + * Use mode of the onRecordAudioFrame callback. + * @enum {number} + * TODO setPlaybackAudioFrameParameters + */ +export enum AudioRawFrameOperationMode { + /** + * Users only read the AudioFrame data without modifying anything. For example, when users acquire data with the Agora SDK then push the RTMP streams. + */ + ReadOnly = 0, + /** + * Users replace the AudioFrame data with their own data and pass them to the SDK for encoding. For example, when users acquire data. + */ + WriteOnly = 1, + /** + * Users read the data from AudioFrame, modify it, and then play it. For example, when users have their own sound-effect processing module and perform some voice pre-processing such as a voice change. + */ + ReadWrite = 2, +} + +/** + * Audio recording quality. + */ +export enum AudioRecordingQuality { + /** + * The sample rate is 32 KHz, and the file size is around 1.2 MB after 10 minutes of recording. + */ + Low = 0, + /** + * The sample rate is 32 KHz, and the file size is around 2 MB after 10 minutes of recording. + */ + Medium = 1, + /** + * The sample rate is 32 KHz, and the file size is around 3.75 MB after 10 minutes of recording. + */ + High = 2, +} + +/** + * The state of the remote audio. + * @enum {number} + */ +export enum AudioRemoteState { + /** + * The remote audio is in the default state, probably due to: + * @see AudioRemoteStateReason.LocalMuted + * @see AudioRemoteStateReason.RemoteMuted + * @see AudioRemoteStateReason.RemoteOffline + */ + Stopped = 0, + /** + * The first remote audio packet is received. + */ + Starting = 1, + /** + * The remote audio stream is decoded and plays normally, probably due to: + * @see AudioRemoteStateReason.NetworkRecovery + * @see AudioRemoteStateReason.LocalUnmuted + * @see AudioRemoteStateReason.RemoteUnmuted + */ + Decoding = 2, + /** + * The remote audio is frozen, probably due to: + * @see AudioRemoteStateReason.NetworkCongestion + */ + Frozen = 3, + /** + * The remote audio fails to start, probably due to: + * @see AudioRemoteStateReason.Internal + */ + Failed = 4, +} + +/** + * The reason of the remote audio state change. + * @enum {number} + */ +export enum AudioRemoteStateReason { + /** + * Internal reasons. + */ + Internal = 0, + /** + * Network congestion. + */ + NetworkCongestion = 1, + /** + * Network recovery. + */ + NetworkRecovery = 2, + /** + * The local user stops receiving the remote audio stream or disables the audio module. + */ + LocalMuted = 3, + /** + * The local user resumes receiving the remote audio stream or enables the audio module. + */ + LocalUnmuted = 4, + /** + * The remote user stops sending the audio stream or disables the audio module. + */ + RemoteMuted = 5, + /** + * The remote user resumes sending the audio stream or enables the audio module. + */ + RemoteUnmuted = 6, + /** + * The remote user leaves the channel. + */ + RemoteOffline = 7, +} + +/** + * The preset local voice reverberation option. + * @enum {number} + */ +export enum AudioReverbPreset { + /** + * The original voice (no local voice reverberation). + */ + Off = 0x00000000, + /** + * Pop music + */ + Popular = 0x00000001, + /** + * R&B + */ + RnB = 0x00000002, + /** + * Rock music + */ + Rock = 0x00000003, + /** + * Hip-hop music + */ + HipHop = 0x00000004, + /** + * Pop concert + */ + VocalConcert = 0x00000005, + /** + * Karaoke + */ + KTV = 0x00000006, + /** + * Recording studio + */ + Studio = 0x00000007, + /** + * The reverberation style typical of a KTV venue (enhanced). + */ + FX_KTV = 0x00100001, + /** + * The reverberation style typical of a concert hall (enhanced). + */ + FX_VOCAL_CONCERT = 0x00100002, + /** + * The reverberation style typical of an uncle’s voice. + */ + FX_UNCLE = 0x00100003, + /** + * The reverberation style typical of a sister’s voice. + */ + FX_SISTER = 0x00100004, + /** + * The reverberation style typical of a recording studio (enhanced). + */ + FX_STUDIO = 0x00100005, + /** + * The reverberation style typical of popular music (enhanced). + */ + FX_POPULAR = 0x00100006, + /** + * The reverberation style typical of R&B music (enhanced). + */ + FX_RNB = 0x00100007, + /** + * The reverberation style typical of the vintage phonograph. + */ + FX_PHONOGRAPH = 0x00100008, + /** + * The reverberation of the virtual stereo. The virtual stereo is an effect that renders the monophonic audio as the stereo audio, so that all users in the channel can hear the stereo voice effect. To achieve better virtual stereo reverberation, Agora recommends setting the profile parameter in setAudioProfile as MusicHighQualityStereo(5). + * @see RtcEngine#setAudioProfile + * @see AudioProfile.MusicHighQualityStereo + */ + VIRTUAL_STEREO = 0x00200001, +} + +/** + * Audio reverberation type. + * @enum {number} + */ +export enum AudioReverbType { + /** + * The level of the dry signal (dB). The value ranges between -20 and 10. + */ + DryLevel = 0, + /** + * The level of the early reflection signal (wet signal) in dB. The value ranges between -20 and 10. + */ + WetLevel = 1, + /** + * The room size of the reverberation. A larger room size means a stronger reverberation. The value ranges between 0 and 100. + */ + RoomSize = 2, + /** + * The length of the initial delay of the wet signal (ms). The value ranges between 0 and 200. + */ + WetDelay = 3, + /** + * The reverberation strength. The value ranges between 0 and 100. + */ + Strength = 4, +} + +/** + * Audio sample rate. + * @enum {number} + */ +export enum AudioSampleRateType { + /** + * 32 kHz. + */ + Type32000 = 32000, + /** + * 44.1 kHz. + */ + Type44100 = 44100, + /** + * 48 kHz. + */ + Type48000 = 48000, +} + +/** + * Audio scenario. + * @enum {number} + */ +export enum AudioScenario { + /** + * Default. + */ + Default = 0, + /** + * Entertainment scenario, supporting voice during gameplay. + */ + ChatRoomEntertainment = 1, + /** + * Education scenario, prioritizing fluency and stability. + */ + Education = 2, + /** + * Live gaming scenario, enabling the gaming audio effects in the speaker mode in a live broadcast scenario. Choose this scenario for high-fidelity music playback. + */ + GameStreaming = 3, + /** + * Showroom scenario, optimizing the audio quality with external professional equipment. + */ + ShowRoom = 4, + /** + * Gaming scenario. + */ + ChatRoomGaming = 5, +} + +/** + * Audio session restriction. + * @enum {number} + * TODO iOS setAudioSessionOperationRestriction + */ +export enum AudioSessionOperationRestriction { + /** + * No restriction, the SDK has full control of the audio session operations. + */ + None = 0, + /** + * The SDK does not change the audio session category. + */ + SetCategory = 1, + /** + * The SDK does not change any setting of the audio session (category, mode, categoryOptions). + */ + ConfigureSession = 1 << 1, + /** + * The SDK keeps the audio session active when leaving a channel. + */ + DeactivateSession = 1 << 2, + /** + * The SDK does not configure the audio session anymore. + */ + All = 1 << 7, +} + +/** + * The preset audio voice configuration used to change the voice effect. + * @enum {number} + */ +export enum AudioVoiceChanger { + /** + * The original voice (no local voice change). + */ + Off = 0x00000000, + /** + * An old man’s voice. + */ + OldMan = 0x00000001, + /** + * A little boy’s voice. + */ + BabyBoy = 0x00000002, + /** + * A little girl’s voice. + */ + BabyGirl = 0x00000003, + /** + * TBD + */ + ZhuBaJie = 0x00000004, + /** + * Ethereal vocal effects. + */ + Ethereal = 0x00000005, + /** + * Hulk’s voice. + */ + Hulk = 0x00000006, + /** + * A more vigorous voice. + */ + BEAUTY_VIGOROUS = 0x00100001, + /** + * A deeper voice. + */ + BEAUTY_DEEP = 0x00100002, + /** + * A mellower voice. + */ + BEAUTY_MELLOW = 0x00100003, + /** + * Falsetto. + */ + BEAUTY_FALSETTO = 0x00100004, + /** + * A fuller voice. + */ + BEAUTY_FULL = 0x00100005, + /** + * A clearer voice. + */ + BEAUTY_CLEAR = 0x00100006, + /** + * A more resounding voice. + */ + BEAUTY_RESOUNDING = 0x00100007, + /** + * A more ringing voice. + */ + BEAUTY_RINGING = 0x00100008, + /** + * A more spatially resonant voice. + */ + BEAUTY_SPACIAL = 0x00100009, + /** + * (For male only) A more magnetic voice. Do not use it when the speaker is a female; otherwise, voice distortion occurs. + */ + GENERAL_BEAUTY_VOICE_MALE_MAGNETIC = 0x00200001, + /** + * (For female only) A fresher voice. Do not use it when the speaker is a male; otherwise, voice distortion occurs. + */ + GENERAL_BEAUTY_VOICE_FEMALE_FRESH = 0x00200002, + /** + * (For female only) A more vital voice. Do not use it when the speaker is a male; otherwise, voice distortion occurs. + */ + GENERAL_BEAUTY_VOICE_FEMALE_VITALITY = 0x00200003, +} + +/** + * The camera capturer configuration. + * @enum {number} + */ +export enum CameraCaptureOutputPreference { + /** + * (default) Self-adapts the camera output parameters to the system performance and network conditions to balance CPU consumption and video preview quality. + */ + Auto = 0, + /** + * Prioritizes the system performance. The SDK chooses the dimension and frame rate of the local camera capture closest to those set by setVideoEncoderConfiguration. + * @see RtcEngine.setVideoEncoderConfiguration + */ + Performance = 1, + /** + * Prioritizes the local preview quality. The SDK chooses higher camera output parameters to improve the local video preview quality. This option requires extra CPU and RAM usage for video pre-processing. + */ + Preview = 2, + /** + * Internal use only + */ + Unkown = 3, +} + +/** + * The camera direction. + * @enum {number} + */ +export enum CameraDirection { + /** + * The rear camera. + */ + Rear = 0, + /** + * The front camera. + */ + Front = 1, +} + +/** + * The error code in AgoraChannelMediaRelayError. + * @enum {number} + */ +export enum ChannelMediaRelayError { + /** + * The state is normal. + */ + None = 0, + /** + * An error occurs in the server response. + */ + ServerErrorResponse = 1, + /** + * No server response. You can call the leaveChannel method to leave the channel. + * @see RtcEngine.leaveChannel + */ + ServerNoResponse = 2, + /** + * The SDK fails to access the service, probably due to limited resources of the server. + */ + NoResourceAvailable = 3, + /** + * Fails to send the relay request. + */ + FailedJoinSourceChannel = 4, + /** + * Fails to accept the relay request. + */ + FailedJoinDestinationChannel = 5, + /** + * The server fails to receive the media stream. + */ + FailedPacketReceivedFromSource = 6, + /** + * The server fails to send the media stream. + */ + FailedPacketSentToDestination = 7, + /** + * The SDK disconnects from the server due to poor network connections. You can call the leaveChannel method to leave the channel. + * @see RtcEngine.leaveChannel + */ + ServerConnectionLost = 8, + /** + * An internal error occurs in the server. + */ + InternalError = 9, + /** + * The token of the source channel has expired. + */ + SourceTokenExpired = 10, + /** + * The token of the destination channel has expired. + */ + DestinationTokenExpired = 11, +} + +/** + * The event code in AgoraChannelMediaRelayEvent. + * @enum {number} + */ +export enum ChannelMediaRelayEvent { + /** + * The user disconnects from the server due to poor network connections. + */ + Disconnect = 0, + /** + * The network reconnects. + */ + Connected = 1, + /** + * The user joins the source channel. + */ + JoinedSourceChannel = 2, + /** + * The user joins the destination channel. + */ + JoinedDestinationChannel = 3, + /** + * The SDK starts relaying the media stream to the destination channel. + */ + SentToDestinationChannel = 4, + /** + * The server receives the video stream from the source channel. + */ + ReceivedVideoPacketFromSource = 5, + /** + * The server receives the audio stream from the source channel. + */ + ReceivedAudioPacketFromSource = 6, + /** + * The destination channel is updated. + */ + UpdateDestinationChannel = 7, + /** + * The destination channel update fails due to internal reasons. + */ + UpdateDestinationChannelRefused = 8, + /** + * The destination channel does not change, which means that the destination channel fails to be updated. + */ + UpdateDestinationChannelNotChange = 9, + /** + * The destination channel name is NULL. + */ + UpdateDestinationChannelIsNil = 10, + /** + * The video profile is sent to the server. + */ + VideoProfileUpdate = 11, +} + +/** + * The state code in AgoraChannelMediaRelayState. + * @enum {number} + */ +export enum ChannelMediaRelayState { + /** + * The SDK is initializing. + */ + Idle = 0, + /** + * The SDK tries to relay the media stream to the destination channel. + */ + Connecting = 1, + /** + * The SDK successfully relays the media stream to the destination channel. + */ + Running = 2, + /** + * A failure occurs. See the details in error. + */ + Failure = 3, +} + +/** + * Channel profile. + * @enum {number} + */ +export enum ChannelProfile { + /** + * (Default) The Communication profile. + * Use this profile in one-on-one calls or group calls, where all users can talk freely. + */ + Communication = 0, + /** + * The Live-Broadcast profile. + * Users in a live-broadcast channel have a role as either broadcaster or audience. A broadcaster can both send and receive streams; an audience can only receive streams. + */ + LiveBroadcasting = 1, + /** + * The Gaming profile. + * This profile uses a codec with a lower bitrate and consumes less power. Applies to the gaming scenario, where all game players can talk freely. + */ + Game = 2, +} + +/** + * Client role in a live broadcast. + * @enum {number} + */ +export enum ClientRole { + /** + * A broadcaster can both send and receive streams. + */ + Broadcaster = 1, + /** + * The default role. An audience can only receive streams. + */ + Audience = 2, +} + +/** + * Reasons for the connection state change. + * @enum {number} + */ +export enum ConnectionChangedReason { + /** + * The SDK is connecting to Agora’s edge server. + */ + Connecting = 0, + /** + * The SDK has joined the channel successfully. + */ + JoinSuccess = 1, + /** + * The connection between the SDK and Agora’s edge server is interrupted. + */ + Interrupted = 2, + /** + * The connection between the SDK and Agora’s edge server is banned by Agora’s edge server. + */ + BannedByServer = 3, + /** + * The SDK fails to join the channel for more than 20 minutes and stops reconnecting to the channel. + */ + JoinFailed = 4, + /** + * The SDK has left the channel. + */ + LeaveChannel = 5, + /** + * The specified App ID is invalid. Try to rejoin the channel with a valid App ID. + */ + InvalidAppId = 6, + /** + * The specified channel name is invalid. Try to rejoin the channel with a valid channel name. + */ + InvalidChannelName = 7, + /** + * The generated token is invalid probably due to the following reasons: + * - The App Certificate for the project is enabled in Console, but you do not use Token when joining the channel. If you enable the App Certificate, you must use a token to join the channel. + * - The uid that you specify in the joinChannel method is different from the uid that you pass for generating the token. + * @see RtcEngine.joinChannel + */ + InvalidToken = 8, + /** + * The token has expired. Generate a new token from your server. + */ + TokenExpired = 9, + /** + * The user is banned by the server. + */ + RejectedByServer = 10, + /** + * The SDK tries to reconnect after setting a proxy server. + */ + SettingProxyServer = 11, + /** + * The token renews. + */ + RenewToken = 12, + /** + * The client IP address has changed, probably due to a change of the network type, IP address, or network port. + */ + ClientIpAddressChanged = 13, + /** + * Timeout for the keep-alive of the connection between the SDK and Agora’s edge server. The connection state changes to: + * @see ConnectionStateType.Reconnecting + */ + KeepAliveTimeout = 14, +} + +/** + * Connection states. + * @enum {number} + */ +export enum ConnectionStateType { + /** + * The SDK is disconnected from Agora's edge server. + * - This is the initial state before joinChannel. + * @see RtcEngine.joinChannel + * - The SDK also enters this state when the app calls leaveChannel. + * @see RtcEngine.leaveChannel + */ + Disconnected = 1, + /** + * The SDK is connecting to Agora's edge server. + * - When the app calls joinChannel, the SDK starts to establish a connection to the specified channel, triggers the onConnectionStateChanged callback, and switches to the Connecting state. + * @see RtcEngine.joinChannel + * @see RtcEngineEvents.onConnectionStateChanged + * @see ConnectionStateType.Connecting + * - When the SDK successfully joins the channel, the SDK triggers the onConnectionStateChanged callback and switches to the Connected state. + * @see RtcEngineEvents.onConnectionStateChanged + * @see ConnectionStateType.Connected + * - After the SDK joins the channel and when it finishes initializing the media engine, the SDK triggers the onJoinChannelSuccess callback. + * @see RtcEngineEvents.onJoinChannelSuccess + */ + Connecting = 2, + /** + * The SDK is connected to Agora's edge server and joins a channel. You can now publish or subscribe to a media stream in the channel. + * If the connection to the channel is lost because, for example, the network is down or switched, the SDK automatically tries to reconnect and triggers: + * - The onConnectionStateChanged callback, and switches to the Reconnecting state. + * @see RtcEngineEvents.onConnectionStateChanged + * @see ConnectionStateType.Reconnecting + */ + Connected = 3, + /** + * The SDK keeps rejoining the channel after being disconnected from a joined channel because of network issues. + * - If the SDK cannot rejoin the channel within 10 seconds after being disconnected from Agora’s edge server, the SDK triggers the onConnectionLost callback, stays in the Reconnecting state, and keeps rejoining the channel. + * @see RtcEngineEvents.onConnectionLost + * - If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora’s edge server, the SDK triggers the onConnectionStateChanged callback, switches to the Failed state, and stops rejoining the channel. + * @see RtcEngineEvents.onConnectionStateChanged + * @see ConnectionStateType.Failed + */ + Reconnecting = 4, + /** + * The SDK fails to connect to Agora's edge server or join the channel. + * You must call leaveChannel to leave this state, and call joinChannel again to rejoin the channel. + * @see RtcEngine.leaveChannel + * @see RtcEngine.joinChannel + * If the SDK is banned from joining the channel by Agora’s edge server (through the RESTful API), the SDK triggers the onConnectionStateChanged callbacks. + * @see RtcEngineEvents.onConnectionStateChanged + */ + Failed = 5, +} + +/** + * The video encoding degradation preference under limited bandwidth. + * @enum {number} + */ +export enum DegradationPreference { + /** + * (Default) Degrades the frame rate to guarantee the video quality. + */ + MaintainQuality = 0, + /** + * Degrades the video quality to guarantee the frame rate. + */ + MaintainFramerate = 1, + /** + * Reserved for future use. + */ + Balanced = 2, +} + +/** + * Encryption mode + * @enum {string} + */ +export enum EncryptionMode { + /** + * (Default) 128-bit AES encryption, XTS mode. + */ + AES128XTS = 'aes-128-xts', + /** + * 256-bit AES encryption, XTS mode. + */ + AES256XTS = 'aes-256-xts', + /** + * 128-bit AES encryption, ECB mode. + */ + AES128ECB = 'aes-128-ecb', +} + +/** + * Error codes occur when the SDK encounters an error that cannot be recovered automatically without any app intervention. + * @enum {number} + */ +export enum ErrorCode { + /** + * No error occurs. + */ + NoError = 0, + /** + * A general error occurs (no specified reason). + */ + Failed = 1, + /** + * An invalid parameter is used. For example, the specific channel name includes illegal characters. + */ + InvalidArgument = 2, + /** + * The SDK module is not ready. + * Possible solutions: + * - Check the audio device. + * - Check the completeness of the app. + * - Re-initialize the SDK. + */ + NotReady = 3, + /** + * The current state of the SDK does not support this function. + */ + NotSupported = 4, + /** + * The request is rejected. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + Refused = 5, + /** + * The buffer size is not big enough to store the returned data. + */ + BufferTooSmall = 6, + /** + * The SDK is not initialized before calling this method. + */ + NotInitialized = 7, + /** + * No permission exists. Check if the user has granted access to the audio or video device. + */ + NoPermission = 9, + /** + * An API method timeout occurs. Some API methods require the SDK to return the execution result, and this error occurs if the request takes too long (over 10 seconds) for the SDK to process. + */ + TimedOut = 10, + /** + * The request is canceled. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + Canceled = 11, + /** + * The method is called too often. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + TooOften = 12, + /** + * The SDK fails to bind to the network socket. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + BindSocket = 13, + /** + * The network is unavailable. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + NetDown = 14, + /** + * No network buffers are available. This is for internal SDK use only, and is not returned to the app through any method or callback. + */ + NoBufs = 15, + /** + * The request to join the channel is rejected. + * Possible reasons are: + * - The user is already in the channel, and still calls the API method to join the channel, for example, joinChannel + * @see RtcEngine.joinChannel + * - The user tries joining the channel during the echo test. Please join the channel after the echo test ends. + */ + JoinChannelRejected = 17, + /** + * The request to leave the channel is rejected. + * Possible reasons are: + * - The user left the channel and still calls the API method to leave the channel, for example, leaveChannel. + * @see RtcEngine.leaveChannel + * - The user has not joined the channel and calls the API method to leave the channel. + */ + LeaveChannelRejected = 18, + /** + * The resources are occupied and cannot be used. + */ + AlreadyInUse = 19, + /** + * The SDK gave up the request due to too many requests. + */ + Abort = 20, + /** + * In Windows, specific firewall settings cause the SDK to fail to initialize and crash. + */ + InitNetEngine = 21, + /** + * The app uses too much of the system resources and the SDK fails to allocate the resources. + */ + ResourceLimited = 22, + /** + * The specified App ID is invalid. Please try to rejoin the channel with a valid App ID. + */ + InvalidAppId = 101, + /** + * The specified channel name is invalid. Please try to rejoin the channel with a valid channel name. + */ + InvalidChannelId = 102, + /** + * The token expired. DEPRECATED as of v2.4.1. Use TokenExpired(9) in the reason parameter of onConnectionStateChanged. + * @see ConnectionChangedReason.TokenExpired + * @see RtcEngineEvents.onConnectionStateChanged + * Possible reasons are: + * - Authorized Timestamp expired: The timestamp is represented by the number of seconds elapsed since 1/1/1970. The user can use the token to access the Agora service within five minutes after the token is generated. If the user does not access the Agora service after five minutes, this token is no longer valid. + * - Call Expiration Timestamp expired: The timestamp is the exact time when a user can no longer use the Agora service (for example, when a user is forced to leave an ongoing call). When a value is set for the Call Expiration Timestamp, it does not mean that the token will expire, but that the user will be banned from the channel. + * @deprecated + */ + TokenExpired = 109, + /** + * The token is invalid. DEPRECATED as of v2.4.1. Use InvalidToken(8) in the reason parameter of onConnectionStateChanged. + * @see ConnectionChangedReason.InvalidToken + * @see RtcEngineEvents.onConnectionStateChanged + * Possible reasons are: + * - The App Certificate for the project is enabled in Console, but the user is using the App ID. Once the App Certificate is enabled, the user must use a token. + * - The uid is mandatory, and users must set the same uid as the one set in the joinChannel method. + * @see RtcEngine.joinChannel + * @deprecated + */ + InvalidToken = 110, + /** + * The Internet connection is interrupted. This applies to the Agora Web SDK only. + */ + ConnectionInterrupted = 111, + /** + * The Internet connection is lost. This applies to the Agora Web SDK only. + */ + ConnectionLost = 112, + /** + * The user is not in the channel when calling the sendStreamMessage or getUserInfoByUserAccount method. + * @see RtcEngine.sendStreamMessage + * @see RtcEngine.getUserInfoByUserAccount + */ + NotInChannel = 113, + /** + * The size of the sent data is over 1024 bytes when the user calls the sendStreamMessage method. + * @see RtcEngine.sendStreamMessage + */ + SizeTooLarge = 114, + /** + * The bitrate of the sent data exceeds the limit of 6 Kbps when the user calls the sendStreamMessage method. + * @see RtcEngine.sendStreamMessage + */ + BitrateLimit = 115, + /** + * Too many data streams (over five streams) are created when the user calls the createDataStream method. + * @see RtcEngine.createDataStream + */ + TooManyDataStreams = 116, + /** + * Decryption fails. The user may have used a different encryption password to join the channel. Check your settings or try rejoining the channel. + */ + DecryptionFailed = 120, + /** + * The client is banned by the server. + */ + ClientIsBannedByServer = 123, + /** + * Incorrect watermark file parameter. + */ + WatermarkParam = 124, + /** + * Incorrect watermark file path. + */ + WatermarkPath = 125, + /** + * Incorrect watermark file format. + */ + WatermarkPng = 126, + /** + * Incorrect watermark file information. + */ + WatermarkInfo = 127, + /** + * Incorrect watermark file data format. + */ + WatermarkAGRB = 128, + /** + * An error occurs in reading the watermark file. + */ + WatermarkRead = 129, + /** + * The encrypted stream is not allowed to publish. + */ + EncryptedStreamNotAllowedPublish = 130, + /** + * The user account is invalid. + */ + InvalidUserAccount = 134, + /** + * CDN related errors. Remove the original URL address and add a new one by calling the removePublishStreamUrl and addPublishStreamUrl methods. + * @see RtcEngine.removePublishStreamUrl + * @see RtcEngine.addPublishStreamUrl + */ + PublishStreamCDNError = 151, + /** + * The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. + */ + PublishStreamNumReachLimit = 152, + /** + * The host manipulates other hosts' URLs. Check your app logic. + */ + PublishStreamNotAuthorized = 153, + /** + * An error occurs in Agora’s streaming server. Call the addPublishStreamUrl method to publish the stream again. + * @see RtcEngine.addPublishStreamUrl + */ + PublishStreamInternalServerError = 154, + /** + * The server fails to find the stream. + */ + PublishStreamNotFound = 155, + /** + * The format of the RTMP stream URL is not supported. Check whether the URL format is correct. + */ + PublishStreamFormatNotSuppported = 156, + /** + * Fails to load the media engine. + */ + LoadMediaEngine = 1001, + /** + * Fails to start the call after enabling the media engine. + */ + StartCall = 1002, + /** + * Fails to start the camera. DEPRECATED as of v2.4.1. Use CaptureFailure(4) in the error parameter of onLocalVideoStateChanged. + * @see LocalVideoStreamError.CaptureFailure + * @see RtcEngineEvents.onLocalVideoStateChanged + * @deprecated + */ + StartCamera = 1003, + /** + * Fails to start the video rendering module. + */ + StartVideoRender = 1004, + /** + * Audio Device Module: A general error occurs in the Audio Device Module (the reason is not classified specifically). Check if the audio device is used by another app, or try rejoining the channel. + */ + AdmGeneralError = 1005, + /** + * Audio Device Module: An error occurs in using the Java resources. + */ + AdmJavaResource = 1006, + /** + * Audio Device Module: An error occurs in setting the sampling frequency. + */ + AdmSampleRate = 1007, + /** + * Audio Device Module: An error occurs in initializing the playback device. + */ + AdmInitPlayout = 1008, + /** + * Audio Device Module: An error occurs in starting the playback device. + */ + AdmStartPlayout = 1009, + /** + * Audio Device Module: An error occurs in stopping the playback device. + */ + AdmStopPlayout = 1010, + /** + * Audio Device Module: An error occurs in initializing the recording device. + */ + AdmInitRecording = 1011, + /** + * Audio Device Module: An error occurs in starting the recording device. + */ + AdmStartRecording = 1012, + /** + * Audio Device Module: An error occurs in stopping the recording device. + */ + AdmStopRecording = 1013, + /** + * Audio Device Module: A playback error occurs. Check your playback device, or try rejoining the channel. + */ + AdmRuntimePlayoutError = 1015, + /** + * Audio Device Module: A recording error occurs. + */ + AdmRuntimeRecordingError = 1017, + /** + * Audio Device Module: Fails to record. + */ + AdmRecordAudioFailed = 1018, + /** + * Audio Device Module: Abnormal audio playback frequency. + */ + AdmPlayAbnormalFrequency = 1020, + /** + * Audio Device Module: Abnormal audio recording frequency. + */ + AdmRecordAbnormalFrequency = 1021, + /** + * Audio Device Module: An error occurs in initializing the loopback device. + */ + AdmInitLoopback = 1022, + /** + * Audio Device Module: An error occurs in starting the loopback device. + */ + AdmStartLoopback = 1023, + /** + * Audio Device Module: An error occurs in no recording Permission. + */ + AdmNoPermission = 1027, + /** + * Audio Routing: Fails to route the audio to the connected Bluetooth device. The default route is used. + */ + AudioBtScoFailed = 1030, + /** + * Audio Device Module: No recording device exists. + */ + AdmNoRecordingDevice = 1359, + /** + * No playback device exists. + */ + AdmNoPlayoutDevice = 1360, + /** + * Video Device Module: The camera is unauthorized. + */ + VdmCameraNotAuthorized = 1501, + /** + * Video Device Module: An unknown error occurs. + */ + VcmUnknownError = 1600, + /** + * Video Device Module: An error occurs in initializing the video encoder. + */ + VcmEncoderInitError = 1601, + /** + * Video Device Module: An error occurs in video encoding. + */ + VcmEncoderEncodeError = 1602, + /** + * Video Device Module: An error occurs in setting the video encoder. + * @deprecated + */ + VcmEncoderSetError = 1603, +} + +/** + * State of importing an external video stream in a live broadcast. + * @enum {number} + */ +export enum InjectStreamStatus { + /** + * The external video stream imported successfully. + */ + StartSuccess = 0, + /** + * The external video stream already exists. + */ + StartAlreadyExists = 1, + /** + * The external video stream import is unauthorized. + */ + StartUnauthorized = 2, + /** + * Import external video stream timeout. + */ + StartTimedout = 3, + /** + * The external video stream failed to import. + */ + StartFailed = 4, + /** + * The external video stream imports successfully. + */ + StopSuccess = 5, + /** + * No external video stream is found. + */ + StopNotFound = 6, + /** + * The external video stream is stopped from being unauthorized. + */ + StopUnauthorized = 7, + /** + * Importing the external video stream timeout. + */ + StopTimedout = 8, + /** + * Importing the external video stream failed. + */ + StopFailed = 9, + /** + * The external video stream import is interrupted. + */ + Broken = 10, +} + +/** + * The state of the probe test result. + * @enum {number} + */ +export enum LastmileProbeResultState { + /** + * the last-mile network probe test is complete. + */ + Complete = 1, + /** + * the last-mile network probe test is incomplete and the bandwidth estimation is not available, probably due to limited test resources. + */ + IncompleteNoBwe = 2, + /** + * the last-mile network probe test is not carried out, probably due to poor network conditions. + */ + Unavailable = 3, +} + +/** + * The lightening contrast level. + * @enum {number} + */ +export enum LighteningContrastLevel { + /** + * Low contrast level. + */ + Low = 0, + /** + * (Default) Normal contrast level. + */ + Normal = 1, + /** + * High contrast level. + */ + High = 2, +} + +/** + * The detailed error information of the local video. + * @enum {number} + */ +export enum LocalVideoStreamError { + /** + * The local video is normal. + */ + OK = 0, + /** + * No specified reason for the local video failure. + */ + Failure = 1, + /** + * No permission to use the local video device. + */ + DeviceNoPermission = 2, + /** + * The local video capturer is in use. + */ + DeviceBusy = 3, + /** + * The local video capture fails. Check whether the capturer is working properly. + */ + CaptureFailure = 4, + /** + * The local video encoding fails. + */ + EncodeFailure = 5, +} + +/** + * The state of the local video stream. + * @enum {number} + */ +export enum LocalVideoStreamState { + /** + * The local video is in the initial state. + */ + Stopped = 0, + /** + * The local video capturer starts successfully. + */ + Capturing = 1, + /** + * The first local video frame encodes successfully. + */ + Encoding = 2, + /** + * The local video fails to start. + */ + Failed = 3, +} + +/** + * Output log filter level. + * @enum {number} + */ +export enum LogFilter { + /** + * Do not output any log information. + */ + Off = 0, + /** + * Output all log information. Set your log filter as debug if you want to get the most complete log file. + */ + Debug = 0x080f, + /** + * Output CRITICAL, ERROR, WARNING, and INFO level log information. We recommend setting your log filter as this level. + */ + Info = 0x000f, + /** + * Outputs CRITICAL, ERROR, and WARNING level log information. + */ + Warning = 0x000e, + /** + * Outputs CRITICAL and ERROR level log information. + */ + Error = 0x000c, + /** + * Outputs CRITICAL level log information. + */ + Critical = 0x0008, +} + +/** + * Media device type. + * @enum {number} + * TODO MacOS AgoraMediaDeviceType + */ +export enum MediaDeviceType { + /** + * Unknown device. + */ + AudioUnknown = -1, + /** + * Audio playback device. + */ + AudioPlayout = 0, + /** + * Audio recording device. + */ + AudioRecording = 1, + /** + * Video render device. + */ + VideoRender = 2, + /** + * Video capture device. + */ + VideoCapture = 3, +} + +/** + * Media type. + * @enum {number} + * TODO LiveEngine + */ +export enum MediaType { + /** + * No audio and video. + */ + None = 0, + /** + * Audio only. + */ + AudioOnly = 1, + /** + * Video only. + */ + VideoOnly = 2, + /** + * Audio and video. + */ + AudioAndVideo = 3, +} + +/** + * The metadata type. + * @enum {number} + * TODO registerMediaMetadataObserver + */ +export enum MetadataType { + /** + * the metadata type is unknown. + */ + Unknown = -1, + /** + * the metadata type is video. + */ + Video = 0, +} + +/** + * Network quality. + * @enum {number} + */ +export enum NetworkQuality { + /** + * The network quality is unknown. + */ + Unknown = 0, + /** + * The network quality is excellent. + */ + Excellent = 1, + /** + * The network quality is quite good, but the bitrate may be slightly lower than excellent. + */ + Good = 2, + /** + * Users can feel the communication slightly impaired. + */ + Poor = 3, + /** + * Users can communicate only not very smoothly. + */ + Bad = 4, + /** + * The network quality is so bad that users can hardly communicate. + */ + VBad = 5, + /** + * The network is disconnected and users cannot communicate at all. + */ + Down = 6, + /** + * Users cannot detect the network quality. (Not in use.) + */ + Unsupported = 7, + /** + * Detecting the network quality. + */ + Detecting = 8, +} + +/** + * Network type. + * @enum {number} + */ +export enum NetworkType { + /** + * The network type is unknown. + */ + Unknown = -1, + /** + * The SDK disconnects from the network. + */ + Disconnected = 0, + /** + * The network type is LAN. + */ + LAN = 1, + /** + * The network type is Wi-Fi (including hotspots). + */ + WIFI = 2, + /** + * The network type is mobile 2G. + */ + Mobile2G = 3, + /** + * The network type is mobile 3G. + */ + Mobile3G = 4, + /** + * The network type is mobile 4G. + */ + Mobile4G = 5, +} + +/** + * Default camera position + * @enum {number} + * TODO AgoraRtcDefaultCamera + */ +export enum RtcDefaultCameraPosition { + /** + * Front camera + */ + Front = 0, + /** + * Rear camera + */ + Back = 1, +} + +/** + * Lifecycle of the CDN live video stream. + * @enum {number} + * TODO AgoraPublisherConfiguration + */ +export enum RtmpStreamLifeCycle { + /** + * Bound to the channel lifecycle. If all hosts leave the channel, the CDN live streaming stops after 30 seconds. + */ + BindToChannel = 1, + /** + * Bound to the owner of the RTMP stream. If the owner leaves the channel, the CDN live streaming stops immediately. + */ + BindToOwnner = 2, +} + +/** + * The detailed error information for streaming. + * @enum {number} + */ +export enum RtmpStreamingErrorCode { + /** + * The RTMP streaming publishes successfully. + */ + OK = 0, + /** + * Invalid argument used. If, for example, you do not call the setLiveTranscoding method to configure the LiveTranscoding parameters before calling the addPublishStreamUrl method, the SDK returns this error. Check whether you set the parameters in the setLiveTranscoding method properly. + * @see RtcEngine.setLiveTranscoding + * @see RtcEngine.addPublishStreamUrl + */ + InvalidParameters = 1, + /** + * The RTMP streaming is encrypted and cannot be published. + */ + EncryptedStreamNotAllowed = 2, + /** + * Timeout for the RTMP streaming. Call the addPublishStreamUrl method to publish the streaming again. + * @see RtcEngine.addPublishStreamUrl + */ + ConnectionTimeout = 3, + /** + * An error occurs in Agora’s streaming server. Call the addPublishStreamUrl method to publish the streaming again. + * @see RtcEngine.addPublishStreamUrl + */ + InternalServerError = 4, + /** + * An error occurs in the RTMP server. + */ + RtmpServerError = 5, + /** + * The RTMP streaming publishes too frequently. + */ + TooOften = 6, + /** + * The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. + */ + ReachLimit = 7, + /** + * The host manipulates other hosts' URLs. Check your app logic. + */ + NotAuthorized = 8, + /** + * Agora’s server fails to find the RTMP streaming. + */ + StreamNotFound = 9, + /** + * The format of the RTMP streaming URL is not supported. Check whether the URL format is correct. + */ + FormatNotSupported = 10, +} + +/** + * The RTMP streaming state. + * @enum {number} + */ +export enum RtmpStreamingState { + /** + * The RTMP streaming has not started or has ended. This state is also triggered after you remove an RTMP address from the CDN by calling removePublishStreamUrl. + * @see RtcEngine.removePublishStreamUrl + */ + Idle = 0, + /** + * The SDK is connecting to Agora’s streaming server and the RTMP server. This state is triggered after you call the addPublishStreamUrl method. + * @see RtcEngine.addPublishStreamUrl + */ + Connecting = 1, + /** + * The RTMP streaming is being published. The SDK successfully publishes the RTMP streaming and returns this state. + */ + Running = 2, + /** + * The RTMP streaming is recovering. When exceptions occur to the CDN, or the streaming is interrupted, the SDK attempts to resume RTMP streaming and returns this state. + * - If the SDK successfully resumes the streaming, Running(2) returns. + * @see RtmpStreamingState.Running + * - If the streaming does not resume within 60 seconds or server errors occur, Failure(4) returns. You can also reconnect to the server by calling the removePublishStreamUrl and addPublishStreamUrl methods. + * @see RtmpStreamingState.Failure + * @see RtcEngine.removePublishStreamUrl + * @see RtcEngine.addPublishStreamUrl + */ + Recovering = 3, + /** + * The RTMP streaming fails. See the errorCode parameter for the detailed error information. You can also call the addPublishStreamUrl method to publish the RTMP streaming again. + * @see RtcEngine.addPublishStreamUrl + */ + Failure = 4, +} + +/** + * Stream fallback option. + * @enum {number} + */ +export enum StreamFallbackOptions { + /** + * No fallback behavior for the local/remote video stream when the uplink/downlink network condition is unreliable. The quality of the stream is not guaranteed. + */ + Disabled = 0, + /** + * Under unreliable downlink network conditions, the remote video stream falls back to the low-stream (low resolution and low bitrate) video. You can only set this option in the setRemoteSubscribeFallbackOption method. Nothing happens when you set this in the setLocalPublishFallbackOption method. + * @see RtcEngine.setRemoteSubscribeFallbackOption + * @see RtcEngine.setLocalPublishFallbackOption + */ + VideoStreamLow = 1, + /** + * Under unreliable uplink network conditions, the published video stream falls back to audio only. Under unreliable downlink network conditions, the remote video stream first falls back to the low-stream (low resolution and low bitrate) video; and then to an audio-only stream if the network condition deteriorates. + */ + AudioOnly = 2, +} + +/** + * Reason for the user being offline. + * @enum {number} + */ +export enum UserOfflineReason { + /** + * The user left the current channel. + */ + Quit = 0, + /** + * The SDK timed out and the user dropped offline because no data packet is received within a certain period of time. If a user quits the call and the message is not passed to the SDK (due to an unreliable channel), the SDK assumes the user dropped offline. + */ + Dropped = 1, + /** + * (Live broadcast only.) The client role switched from the host to the audience. + */ + BecomeAudience = 2, +} + +/** + * The priority of the remote user. + * @enum {number} + */ +export enum UserPriority { + /** + * The user’s priority is high. + */ + High = 50, + /** + * (Default) The user’s priority is normal. + */ + Normal = 100, +} + +/** + * Video buffer type + * @enum {number} + * TODO iOS AgoraVideoSourceProtocol AgoraVideoSinkProtocol + */ +export enum VideoBufferType { + /** + * Use a pixel buffer to transmit the video data. + */ + PixelBuffer = 1, + /** + * Use raw data to transmit the video data. + */ + RawData = 2, +} + +/** + * Self-defined video codec profile. + * @enum {number} + */ +export enum VideoCodecProfileType { + /** + * Baseline video codec profile. Generally used in video calls on mobile phones. + */ + BaseLine = 66, + /** + * Main video codec profile. Generally used in mainstream electronics, such as MP4 players, portable video players, PSP, and iPads. + */ + Main = 77, + /** + * (Default) High video codec profile. Generally used in high-resolution broadcasts or television. + */ + High = 100, +} + +/** + * The content hint for screen sharing. + * @enum {number} + * TODO MacOS setScreenCaptureContentHint + */ +export enum VideoContentHint { + /** + * (Default) No content hint. + */ + None = 0, + /** + * Motion-intensive content. Choose this option if you prefer smoothness or when you are sharing a video clip, movie, or video game. + */ + Motion = 1, + /** + * Motionless content. Choose this option if you prefer sharpness or when you are sharing a picture, PowerPoint slide, or text. + */ + Details = 2, +} + +/** + * Video frame rate + * @enum {number} + */ +export enum VideoFrameRate { + Min = -1, + /** + * 1 fps. + */ + Fps1 = 1, + /** + * 7 fps. + */ + Fps7 = 7, + /** + * 10 fps. + */ + Fps10 = 10, + /** + * 15 fps. + */ + Fps15 = 15, + /** + * 24 fps. + */ + Fps24 = 24, + /** + * 30 fps. + */ + Fps30 = 30, + /** + * 60 fps (macOS only). + */ + Fps60 = 60, +} + +/** + * Sets the video bitrate (Kbps). Refer to the table below and set your bitrate. If you set a bitrate beyond the proper range, the SDK automatically adjusts it to a value within the range. You can also choose from the following options: + * @enum {number} + */ +export enum BitRate { + /** + * (recommended) the standard bitrate mode. In this mode, the bitrates differ between the Live-broadcast and Communication profiles: + * - Communication profile: the video bitrate is the same as the base bitrate. + * - Live-broadcast profile: the video bitrate is twice the base bitrate. + */ + Standard = 0, + /** + * the compatible bitrate mode. In this mode, the bitrate stays the same regardless of the profile. In the Live-broadcast profile, if you choose this mode, the video frame rate may be lower than the set value. + */ + Compatible = -1, +} + +/** + * Video mirror mode. + * @enum {number} + */ +export enum VideoMirrorMode { + /** + * (Default) The SDK determines the mirror mode. + */ + Auto = 0, + /** + * Enables mirror mode. + */ + Enabled = 1, + /** + * Disables mirror mode. + */ + Disabled = 2, +} + +/** + * Video output orientation mode. + * @enum {number} + */ +export enum VideoOutputOrientationMode { + /** + * Adaptive mode (Default). + * The video encoder adapts to the orientation mode of the video input device. When you use a custom video source, the output video from the encoder inherits the orientation of the original video. + * - If the width of the captured video from the SDK is greater than the height, the encoder sends the video in landscape mode. The encoder also sends the rotational information of the video, and the receiver uses the rotational information to rotate the received video. + * - If the original video is in portrait mode, the output video from the encoder is also in portrait mode. The encoder also sends the rotational information of the video to the receiver. + */ + Adaptative = 0, + /** + * Landscape mode. + * The video encoder always sends the video in landscape mode. The video encoder rotates the original video before sending it and the rotational information is 0. This mode applies to scenarios involving CDN live streaming. + */ + FixedLandscape = 1, + /** + * Portrait mode. + * The video encoder always sends the video in portrait mode. The video encoder rotates the original video before sending it and the rotational information is 0. This mode applies to scenarios involving CDN live streaming. + */ + FixedPortrait = 2, +} + +/** + * Video pixel format. + * @enum {number} + * TODO iOS AgoraVideoSinkProtocol + */ +export enum VideoPixelFormat { + /** + * I420 + */ + I420 = 1, + /** + * BGRA + */ + BGRA = 2, + /** + * NV12 + */ + NV12 = 8, +} + +/** + * Quality change of the local video in terms of target frame rate and target bit rate since last count. + * @enum {number} + */ +export enum VideoQualityAdaptIndication { + /** + * The quality of the local video stays the same. + */ + AdaptNone = 0, + /** + * The quality improves because the network bandwidth increases. + */ + AdaptUpBandwidth = 1, + /** + * The quality worsens because the network bandwidth decreases. + */ + AdaptDownBandwidth = 2, +} + +/** + * The state of the remote video. + * @enum {number} + */ +export enum VideoRemoteState { + /** + * The remote video is in the default state, probably due to: + * @see VideoRemoteStateReason.LocalMuted + * @see VideoRemoteStateReason.RemoteMuted + * @see VideoRemoteStateReason.RemoteOffline + */ + Stopped = 0, + /** + * The first remote video packet is received. + */ + Starting = 1, + /** + * The remote video stream is decoded and plays normally, probably due to: + * @see VideoRemoteStateReason.NetworkRecovery + * @see VideoRemoteStateReason.LocalUnmuted + * @see VideoRemoteStateReason.RemoteUnmuted + * @see VideoRemoteStateReason.AudioFallbackRecovery + */ + Decoding = 2, + /** + * The remote video is frozen, probably due to: + * @see VideoRemoteStateReason.NetworkCongestion + * @see VideoRemoteStateReason.AudioFallback + */ + Frozen = 3, + /** + * The remote video fails to start, probably due to: + * @see VideoRemoteStateReason.Internal + */ + Failed = 4, +} + +/** + * The reason of the remote video state change. + * @enum {number} + */ +export enum VideoRemoteStateReason { + /** + * Internal reasons. + */ + Internal = 0, + /** + * Network congestion. + */ + NetworkCongestion = 1, + /** + * Network recovery. + */ + NetworkRecovery = 2, + /** + * The local user stops receiving the remote video stream or disables the video module. + */ + LocalMuted = 3, + /** + * The local user stops receiving the remote video stream or disables the video module. + */ + LocalUnmuted = 4, + /** + * The remote user stops sending the video stream or disables the video module. + */ + RemoteMuted = 5, + /** + * The remote user resumes sending the video stream or enables the video module. + */ + RemoteUnmuted = 6, + /** + * The remote user leaves the channel. + */ + RemoteOffline = 7, + /** + * The remote media stream falls back to the audio-only stream due to poor network conditions. + */ + AudioFallback = 8, + /** + * The remote media stream switches back to the video stream after the network conditions improve. + */ + AudioFallbackRecovery = 9, +} + +/** + * Video display mode. + * @enum {number} + */ +export enum VideoRenderMode { + /** + * Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents. + */ + Hidden = 1, + /** + * Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black. + */ + Fit = 2, + /** + * This mode is deprecated. + * @deprecated + */ + Adaptive = 3, + /** + * The fill mode. In this mode, the SDK stretches or zooms the video to fill the display window. + */ + FILL = 4, +} + +/** + * Video rotation. + * @enum {number} + * TODO iOS AgoraVideoSourceProtocol AgoraVideoSinkProtocol + */ +export enum VideoRotation { + /** + * No rotation + */ + RotationNone = 0, + /** + * 90 degrees + */ + Rotation90 = 1, + /** + * 180 degrees + */ + Rotation180 = 2, + /** + * 270 degrees + */ + Rotation270 = 3, +} + +/** + * Video stream type. + * @enum {number} + */ +export enum VideoStreamType { + /** + * High-bitrate, high-resolution video stream. + */ + High = 0, + /** + * Low-bitrate, low-resolution video stream. + */ + Low = 1, +} + +/** + * Warning codes occur when the SDK encounters an error that may be recovered automatically. These are only notifications, and can generally be ignored. For example, when the SDK loses connection to the server, the SDK reports the OpenChannelTimeout(106) warning and tries to reconnect automatically. + * @see WarningCode.OpenChannelTimeout + * @enum {number} + */ +export enum WarningCode { + /** + * The specified view is invalid. Specify a view when using the video call function. + */ + InvalidView = 8, + /** + * Failed to initialize the video function, possibly caused by a lack of resources. The users cannot see the video while the voice communication is not affected. + */ + InitVideo = 16, + /** + * The request is pending, usually due to some module not being ready, and the SDK postpones processing the request. + */ + Pending = 20, + /** + * No channel resources are available. Maybe because the server cannot allocate any channel resource. + */ + NoAvailableChannel = 103, + /** + * A timeout occurs when looking up the channel. When joining a channel, the SDK looks up the specified channel. The warning usually occurs when the network condition is too poor for the SDK to connect to the server. + */ + LookupChannelTimeout = 104, + /** + * The server rejects the request to look up the channel. The server cannot process this request or the request is illegal. DEPRECATED as of v2.4.1. Use RejectedByServer(10) in the reason parameter of onConnectionStateChanged. + * @see ConnectionChangedReason.RejectedByServer + * @see RtcEngineEvents.onConnectionStateChanged + * @deprecated + */ + LookupChannelRejected = 105, + /** + * The server rejects the request to look up the channel. The server cannot process this request or the request is illegal. + */ + OpenChannelTimeout = 106, + /** + * The server rejects the request to open the channel. The server cannot process this request or the request is illegal. + */ + OpenChannelRejected = 107, + /** + * A timeout occurs when switching to the live video. + */ + SwitchLiveVideoTimeout = 111, + /** + * A timeout occurs when setting the client role in the live broadcast profile. + */ + SetClientRoleTimeout = 118, + /** + * The client role is unauthorized. + */ + SetClientRoleNotAuthorized = 119, + /** + * The ticket to open the channel is invalid. + */ + OpenChannelInvalidTicket = 121, + /** + * Try connecting to another server. + */ + OpenChannelTryNextVos = 122, + /** + * An error occurs in opening the audio mixing file. + */ + AudioMixingOpenError = 701, + /** + * Audio Device Module: a warning occurs in the playback device. + */ + AdmRuntimePlayoutWarning = 1014, + /** + * Audio Device Module: a warning occurs in the recording device. + */ + AdmRuntimeRecordingWarning = 1016, + /** + * Audio Device Module: no valid audio data is collected. + */ + AdmRecordAudioSilence = 1019, + /** + * Audio Device Module: a playback device fails. + */ + AdmPlaybackMalfunction = 1020, + /** + * Audio Device Module: a recording device fails. + */ + AdmRecordMalfunction = 1021, + /** + * Audio Device Module: call is interrupted by system events such as phone call or siri etc. + */ + AdmInterruption = 1025, + /** + * Audio Device Module: the recorded audio is too low. + */ + AdmRecordAudioLowlevel = 1031, + /** + * Audio Device Module: the playback audio is too low. + */ + AdmPlayoutAudioLowlevel = 1032, + /** + * Audio Device Module: The recording device is busy. + */ + AdmRecordIsOccupied = 1033, + /** + * Audio Device Module: howling is detected. + */ + ApmHowling = 1051, + /** + * Audio Device Module: the device is in the glitch state. + */ + AdmGlitchState = 1052, + /** + * Audio Device Module: the underlying audio settings have changed. + */ + AdmImproperSettings = 1053, +} + +/** + * The audio channel of the sound. + * @enum {number} + */ +export enum AudioChannel { + /** + * (Default) Supports dual channels. Depends on the upstream of the broadcaster. + */ + Channel0 = 0, + /** + * The audio stream of the broadcaster uses the FL audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. + */ + Channel1 = 1, + /** + * The audio stream of the broadcaster uses the FC audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. + */ + Channel2 = 2, + /** + * The audio stream of the broadcaster uses the FR audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. + */ + Channel3 = 3, + /** + * The audio stream of the broadcaster uses the BL audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. + */ + Channel4 = 4, + /** + * The audio stream of the broadcaster uses the BR audio channel. If the upstream of the broadcaster uses multiple audio channels, these channels will be mixed into mono first. + */ + Channel5 = 5, +} + +/** + * Video codec types. + * @enum {number} + */ +export enum VideoCodecType { + /** + * Standard VP8. + */ + VP8 = 1, + /** + * Standard H264. + */ + H264 = 2, + /** + * Enhanced VP8. + */ + EVP = 3, + /** + * Enhanced H264. + */ + E264 = 4, +} diff --git a/src/RtcChannel.native.ts b/src/src/RtcChannel.native.ts similarity index 98% rename from src/RtcChannel.native.ts rename to src/src/RtcChannel.native.ts index a9c1e8d14..73fa1c7e1 100644 --- a/src/RtcChannel.native.ts +++ b/src/src/RtcChannel.native.ts @@ -1,4 +1,5 @@ import {NativeEventEmitter, NativeModules} from "react-native"; + import { ChannelMediaOptions, ChannelMediaRelayConfiguration, @@ -7,16 +8,29 @@ import { EncryptionMode, LiveInjectStreamConfig, LiveTranscoding, - String, UserPriority, VideoStreamType -} from "./Types"; +} from "../Types"; import {Listener, RtcChannelEvents, Subscription} from "./RtcEvents"; -const {AgoraRtcChannelModule} = NativeModules; -const Prefix = AgoraRtcChannelModule.prefix +const { + /** + * @ignore + */ + AgoraRtcChannelModule +} = NativeModules; +/** + * @ignore + */ +const Prefix = AgoraRtcChannelModule.prefix; +/** + * @ignore + */ const RtcChannelEvent = new NativeEventEmitter(AgoraRtcChannelModule); +/** + * @ignore + */ const channels = new Map(); /** @@ -25,10 +39,18 @@ const channels = new Map(); export default class RtcChannel implements RtcAudioInterface, RtcVideoInterface, RtcVoicePositionInterface, RtcPublishStreamInterface, RtcMediaRelayInterface, RtcDualStreamInterface, RtcFallbackInterface, RtcMediaMetadataInterface, RtcEncryptionInterface, RtcInjectStreamInterface, RtcStreamMessageInterface { - + /** + * @ignore + */ private readonly _channelId: string; + /** + * @ignore + */ private _listeners = new Map>(); + /** + * @ignore + */ private constructor(channelId: string) { this._channelId = channelId; } @@ -166,7 +188,7 @@ export default class RtcChannel implements RtcAudioInterface, RtcVideoInterface, * @param options The channel media options. * @see ChannelMediaOptions */ - joinChannel(token: String, optionalInfo: String, optionalUid: number, options: ChannelMediaOptions): Promise { + joinChannel(token: string | null, optionalInfo: string | null, optionalUid: number, options: ChannelMediaOptions): Promise { return AgoraRtcChannelModule.joinChannel(this._channelId, token, optionalInfo, optionalUid, options) } @@ -190,7 +212,7 @@ export default class RtcChannel implements RtcAudioInterface, RtcVideoInterface, * @param options The channel media options. * @see ChannelMediaOptions */ - joinChannelWithUserAccount(token: String, userAccount: string, options: ChannelMediaOptions): Promise { + joinChannelWithUserAccount(token: string | null, userAccount: string, options: ChannelMediaOptions): Promise { return AgoraRtcChannelModule.joinChannelWithUserAccount(this._channelId, token, userAccount, options) } @@ -257,116 +279,6 @@ export default class RtcChannel implements RtcAudioInterface, RtcVideoInterface, return AgoraRtcChannelModule.getCallId(this._channelId) } - adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise { - return AgoraRtcChannelModule.adjustUserPlaybackSignalVolume(this._channelId, uid, volume) - } - - muteRemoteAudioStream(uid: number, muted: boolean): Promise { - return AgoraRtcChannelModule.muteRemoteAudioStream(this._channelId, uid, muted) - } - - muteAllRemoteAudioStreams(muted: boolean): Promise { - return AgoraRtcChannelModule.muteAllRemoteAudioStreams(this._channelId, muted) - } - - setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise { - return AgoraRtcChannelModule.setDefaultMuteAllRemoteAudioStreams(this._channelId, muted) - } - - muteAllRemoteVideoStreams(muted: boolean): Promise { - return AgoraRtcChannelModule.muteAllRemoteVideoStreams(this._channelId, muted) - } - - muteRemoteVideoStream(uid: number, muted: boolean): Promise { - return AgoraRtcChannelModule.muteRemoteVideoStream(this._channelId, uid, muted) - } - - setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise { - return AgoraRtcChannelModule.setDefaultMuteAllRemoteVideoStreams(this._channelId, muted) - } - - setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise { - return AgoraRtcChannelModule.setRemoteVoicePosition(this._channelId, uid, pan, gain); - } - - addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise { - return AgoraRtcChannelModule.addPublishStreamUrl(this._channelId, url, transcodingEnabled); - } - - removePublishStreamUrl(url: string): Promise { - return AgoraRtcChannelModule.removePublishStreamUrl(this._channelId, url); - } - - setLiveTranscoding(transcoding: LiveTranscoding): Promise { - return AgoraRtcChannelModule.setLiveTranscoding(this._channelId, transcoding); - } - - startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { - return AgoraRtcChannelModule.startChannelMediaRelay(this._channelId, channelMediaRelayConfiguration); - } - - stopChannelMediaRelay(): Promise { - return AgoraRtcChannelModule.stopChannelMediaRelay(this._channelId); - } - - updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { - return AgoraRtcChannelModule.updateChannelMediaRelay(this._channelId, channelMediaRelayConfiguration); - } - - setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise { - return AgoraRtcChannelModule.setRemoteDefaultVideoStreamType(this._channelId, streamType); - } - - setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise { - return AgoraRtcChannelModule.setRemoteVideoStreamType(this._channelId, uid, streamType); - } - - setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise { - return AgoraRtcChannelModule.setRemoteUserPriority(this._channelId, uid, userPriority); - } - - registerMediaMetadataObserver(): Promise { - return AgoraRtcChannelModule.registerMediaMetadataObserver(this._channelId); - } - - sendMetadata(metadata: string): Promise { - return AgoraRtcChannelModule.sendMetadata(this._channelId, metadata); - } - - setMaxMetadataSize(size: number): Promise { - return AgoraRtcChannelModule.setMaxMetadataSize(this._channelId, size); - } - - unregisterMediaMetadataObserver(): Promise { - return AgoraRtcChannelModule.unregisterMediaMetadataObserver(this._channelId); - } - - setEncryptionMode(encryptionMode: EncryptionMode): Promise { - return AgoraRtcChannelModule.setEncryptionMode(this._channelId, encryptionMode); - } - - setEncryptionSecret(secret: string): Promise { - return AgoraRtcChannelModule.setEncryptionSecret(this._channelId, secret); - } - - addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise { - return AgoraRtcChannelModule.addInjectStreamUrl(this._channelId, url, config); - } - - removeInjectStreamUrl(url: string): Promise { - return AgoraRtcChannelModule.removeInjectStreamUrl(this._channelId, url); - } - - createDataStream(reliable: boolean, ordered: boolean): Promise { - return AgoraRtcChannelModule.createDataStream(this._channelId, reliable, ordered); - } - - sendStreamMessage(streamId: number, message: string): Promise { - return AgoraRtcChannelModule.sendStreamMessage(this._channelId, streamId, message); - } -} - -interface RtcAudioInterface { /** * Adjusts the playback volume of a specified remote user. * You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user. @@ -379,7 +291,9 @@ interface RtcAudioInterface { * - 0: Mute. * - 100: The original volume. */ - adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise; + adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise { + return AgoraRtcChannelModule.adjustUserPlaybackSignalVolume(this._channelId, uid, volume) + } /** * Stops/Resumes receiving the audio stream of the specified user. @@ -388,7 +302,9 @@ interface RtcAudioInterface { * - true: Stop receiving the audio stream of the user. * - false: (Default) Receive the audio stream of the user. */ - muteRemoteAudioStream(uid: number, muted: boolean): Promise; + muteRemoteAudioStream(uid: number, muted: boolean): Promise { + return AgoraRtcChannelModule.muteRemoteAudioStream(this._channelId, uid, muted) + } /** * Stops/Resumes receiving all remote audio streams. @@ -396,7 +312,9 @@ interface RtcAudioInterface { * - true: Stop receiving all remote audio streams. * - false: (Default) Receive all remote audio streams. */ - muteAllRemoteAudioStreams(muted: boolean): Promise; + muteAllRemoteAudioStreams(muted: boolean): Promise { + return AgoraRtcChannelModule.muteAllRemoteAudioStreams(this._channelId, muted) + } /** * Sets whether to receive all remote audio streams by default. @@ -404,10 +322,20 @@ interface RtcAudioInterface { * - true: Stop receiving all remote audio streams by default. * - false: (Default) Receive all remote audio streams by default. */ - setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise; -} + setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise { + return AgoraRtcChannelModule.setDefaultMuteAllRemoteAudioStreams(this._channelId, muted) + } + + /** + * Stops/Resumes receiving all remote video streams. + * @param muted Determines whether to receive/stop receiving all remote video streams: + * - true: Stop receiving all remote video streams. + * - false: (Default) Receive all remote video streams. + */ + muteAllRemoteVideoStreams(muted: boolean): Promise { + return AgoraRtcChannelModule.muteAllRemoteVideoStreams(this._channelId, muted) + } -interface RtcVideoInterface { /** * Stops/Resumes receiving the video stream of the specified user. * @param uid ID of the remote user whose video stream you want to mute. @@ -415,15 +343,9 @@ interface RtcVideoInterface { * - true: Stop receiving the video stream of the user. * - false: (Default) Receive the video stream of the user. */ - muteRemoteVideoStream(uid: number, muted: boolean): Promise; - - /** - * Stops/Resumes receiving all remote video streams. - * @param muted Determines whether to receive/stop receiving all remote video streams: - * - true: Stop receiving all remote video streams. - * - false: (Default) Receive all remote video streams. - */ - muteAllRemoteVideoStreams(muted: boolean): Promise; + muteRemoteVideoStream(uid: number, muted: boolean): Promise { + return AgoraRtcChannelModule.muteRemoteVideoStream(this._channelId, uid, muted) + } /** * Sets whether to receive all remote video streams by default. @@ -431,10 +353,10 @@ interface RtcVideoInterface { * - true: Stop receiving all remote video streams by default. * - false: (Default) Receive all remote video streams by default. */ - setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise; -} + setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise { + return AgoraRtcChannelModule.setDefaultMuteAllRemoteVideoStreams(this._channelId, muted) + } -interface RtcVoicePositionInterface { /** * Sets the sound position of a remote user. * When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. @@ -449,24 +371,9 @@ interface RtcVoicePositionInterface { * - 1.0: The remote sound comes from the right. * @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. */ - setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise; -} - -interface RtcPublishStreamInterface { - /** - * Sets the video layout and audio settings for CDN live. - * The SDK triggers the onTranscodingUpdated callback when you call this method to update the LiveTranscodingclass. If you call this method to set the LiveTranscoding class for the first time, the SDK does not trigger the onTranscodingUpdated callback. - * @see RtcChannelEvents.TranscodingUpdated - * Note - * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. - * - Ensure that the user joins a channel before calling this method. - * - This method can only be called by a broadcaster in a Live-Broadcast channel. - * - Ensure that you call this method before calling the addPublishStreamUrl method. - * @see RtcChannel.addPublishStreamUrl - * @param transcoding Sets the CDN live audio/video transcoding settings. - * @see LiveTranscoding - */ - setLiveTranscoding(transcoding: LiveTranscoding): Promise; + setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise { + return AgoraRtcChannelModule.setRemoteVoicePosition(this._channelId, uid, pan, gain); + } /** * Publishes the local stream to the CDN. @@ -483,7 +390,9 @@ interface RtcPublishStreamInterface { * - true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple broadcasters in CDN live. * - false: Disable transcoding. */ - addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise; + addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise { + return AgoraRtcChannelModule.addPublishStreamUrl(this._channelId, url, transcodingEnabled); + } /** * Removes an RTMP stream from the CDN. @@ -496,10 +405,27 @@ interface RtcPublishStreamInterface { * - This method removes only one stream HTTP/HTTPS URL address each time it is called. * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. */ - removePublishStreamUrl(url: string): Promise; -} + removePublishStreamUrl(url: string): Promise { + return AgoraRtcChannelModule.removePublishStreamUrl(this._channelId, url); + } + + /** + * Sets the video layout and audio settings for CDN live. + * The SDK triggers the onTranscodingUpdated callback when you call this method to update the LiveTranscodingclass. If you call this method to set the LiveTranscoding class for the first time, the SDK does not trigger the onTranscodingUpdated callback. + * @see RtcChannelEvents.TranscodingUpdated + * Note + * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. + * - Ensure that the user joins a channel before calling this method. + * - This method can only be called by a broadcaster in a Live-Broadcast channel. + * - Ensure that you call this method before calling the addPublishStreamUrl method. + * @see RtcChannel.addPublishStreamUrl + * @param transcoding Sets the CDN live audio/video transcoding settings. + * @see LiveTranscoding + */ + setLiveTranscoding(transcoding: LiveTranscoding): Promise { + return AgoraRtcChannelModule.setLiveTranscoding(this._channelId, transcoding); + } -interface RtcMediaRelayInterface { /** * Starts to relay media streams across channels. * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks report the state and events of the media stream relay. @@ -519,7 +445,27 @@ interface RtcMediaRelayInterface { * @param channelMediaRelayConfiguration The configuration of the media stream relay. * @see ChannelMediaRelayConfiguration */ - startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; + startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { + return AgoraRtcChannelModule.startChannelMediaRelay(this._channelId, channelMediaRelayConfiguration); + } + + /** + * Stops the media stream relay. + * Once the relay stops, the broadcaster quits all the destination channels. + * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback reports Idle(0) and None(0), the broadcaster successfully stops the relay. + * @see RtcChannelEvents.ChannelMediaRelayStateChanged + * @see ChannelMediaRelayState.Idle + * @see ChannelMediaRelayError.None + * Note + * - If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged callback with the ServerNoResponse(2) or ServerConnectionLost(8) state code. You can leave the channel using leaveChannel, and the media stream relay automatically stops. + * @see RtcChannelEvents.ChannelMediaRelayStateChanged + * @see ChannelMediaRelayError.ServerNoResponse + * @see ChannelMediaRelayError.ServerConnectionLost + * @see RtcChannel.leaveChannel + */ + stopChannelMediaRelay(): Promise { + return AgoraRtcChannelModule.stopChannelMediaRelay(this._channelId); + } /** * Updates the channels for media relay. @@ -534,26 +480,19 @@ interface RtcMediaRelayInterface { * @param channelMediaRelayConfiguration The media stream relay configuration. * @see ChannelMediaRelayConfiguration */ - updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; + updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { + return AgoraRtcChannelModule.updateChannelMediaRelay(this._channelId, channelMediaRelayConfiguration); + } /** - * Stops the media stream relay. - * Once the relay stops, the broadcaster quits all the destination channels. - * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback reports Idle(0) and None(0), the broadcaster successfully stops the relay. - * @see RtcChannelEvents.ChannelMediaRelayStateChanged - * @see ChannelMediaRelayState.Idle - * @see ChannelMediaRelayError.None - * Note - * - If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged callback with the ServerNoResponse(2) or ServerConnectionLost(8) state code. You can leave the channel using leaveChannel, and the media stream relay automatically stops. - * @see RtcChannelEvents.ChannelMediaRelayStateChanged - * @see ChannelMediaRelayError.ServerNoResponse - * @see ChannelMediaRelayError.ServerConnectionLost - * @see RtcChannel.leaveChannel + * Sets the default video-stream type of the remote video stream when the remote user sends dual streams. + * @param streamType Sets the default video-stream type. + * @see VideoStreamType */ - stopChannelMediaRelay(): Promise; -} + setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise { + return AgoraRtcChannelModule.setRemoteDefaultVideoStreamType(this._channelId, streamType); + } -interface RtcDualStreamInterface { /** * Sets the video stream type of the remote video stream when the remote user sends dual streams. * This method allows the app to adjust the corresponding video-stream type based on the size of the video window to reduce the bandwidth and resources. @@ -565,17 +504,10 @@ interface RtcDualStreamInterface { * @param streamType Sets the video-stream type. * @see VideoStreamType */ - setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise; - - /** - * Sets the default video-stream type of the remote video stream when the remote user sends dual streams. - * @param streamType Sets the default video-stream type. - * @see VideoStreamType - */ - setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise; -} + setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise { + return AgoraRtcChannelModule.setRemoteVideoStreamType(this._channelId, uid, streamType); + } -interface RtcFallbackInterface { /** * Sets the priority of a remote user's media stream. * Use this method with the setRemoteSubscribeFallbackOption method. If a remote video stream experiences the fallback, the SDK ensures the high-priority user gets the best possible stream quality. @@ -586,10 +518,10 @@ interface RtcFallbackInterface { * @param userPriority The priority of the remote user. * @see UserPriority */ - setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise; -} + setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise { + return AgoraRtcChannelModule.setRemoteUserPriority(this._channelId, uid, userPriority); + } -interface RtcMediaMetadataInterface { /** * Registers the metadata observer. * A successful call of this method triggers the getMaxMetadataSize callback. @@ -601,36 +533,21 @@ interface RtcMediaMetadataInterface { * - This method applies to the Live-Broadcast profile only. * @see ChannelProfile.LiveBroadcasting */ - registerMediaMetadataObserver(): Promise; - - /** - * TODO - */ - unregisterMediaMetadataObserver(): Promise; + registerMediaMetadataObserver(): Promise { + return AgoraRtcChannelModule.registerMediaMetadataObserver(this._channelId); + } - /** - * TODO - * @param size - */ - setMaxMetadataSize(size: number): Promise; + sendMetadata(metadata: string): Promise { + return AgoraRtcChannelModule.sendMetadata(this._channelId, metadata); + } - /** - * TODO - * @param metadata - */ - sendMetadata(metadata: string): Promise; -} + setMaxMetadataSize(size: number): Promise { + return AgoraRtcChannelModule.setMaxMetadataSize(this._channelId, size); + } -interface RtcEncryptionInterface { - /** - * Enables built-in encryption with an encryption password before joining a channel. - * All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled. - * Note - * - For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption. - * - Do not use this method for CDN live streaming. - * @param secret The encryption password. - */ - setEncryptionSecret(secret: string): Promise; + unregisterMediaMetadataObserver(): Promise { + return AgoraRtcChannelModule.unregisterMediaMetadataObserver(this._channelId); + } /** * Sets the built-in encryption mode. @@ -643,10 +560,22 @@ interface RtcEncryptionInterface { * @param encryptionMode Sets the encryption mode. * @see EncryptionMode */ - setEncryptionMode(encryptionMode: EncryptionMode): Promise; -} + setEncryptionMode(encryptionMode: EncryptionMode): Promise { + return AgoraRtcChannelModule.setEncryptionMode(this._channelId, encryptionMode); + } + + /** + * Enables built-in encryption with an encryption password before joining a channel. + * All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled. + * Note + * - For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption. + * - Do not use this method for CDN live streaming. + * @param secret The encryption password. + */ + setEncryptionSecret(secret: string): Promise { + return AgoraRtcChannelModule.setEncryptionSecret(this._channelId, secret); + } -interface RtcInjectStreamInterface { /** * Injects an online media stream to a Live-Broadcast channel. * If this method call succeeds, the server pulls the voice or video stream and injects it into a live channel. This applies to scenarios where all audience members in the channel can watch a live show and interact with each other. @@ -668,7 +597,9 @@ interface RtcInjectStreamInterface { * @param config The LiveInjectStreamConfig object, which contains the configuration information for the added voice or video stream. * @see LiveInjectStreamConfig */ - addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise; + addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise { + return AgoraRtcChannelModule.addInjectStreamUrl(this._channelId, url, config); + } /** * Removes the injected online media stream from a Live-Broadcast channel. @@ -678,10 +609,10 @@ interface RtcInjectStreamInterface { * @see RtcChannelEvents.UserJoined * @param url The URL address to be removed. */ - removeInjectStreamUrl(url: string): Promise; -} + removeInjectStreamUrl(url: string): Promise { + return AgoraRtcChannelModule.removeInjectStreamUrl(this._channelId, url); + } -interface RtcStreamMessageInterface { /** * Creates a data stream. * Each user can create up to five data streams during the life cycle of the RtcChannel instance. @@ -696,7 +627,9 @@ interface RtcStreamMessageInterface { * - true: The recipients receive the data in the sent order. * - false: The recipients do not receive the data in the sent order. */ - createDataStream(reliable: boolean, ordered: boolean): Promise; + createDataStream(reliable: boolean, ordered: boolean): Promise { + return AgoraRtcChannelModule.createDataStream(this._channelId, reliable, ordered); + } /** * Sends the data stream message. @@ -712,5 +645,116 @@ interface RtcStreamMessageInterface { * @see RtcChannel.createDataStream * @param message The message data. */ + sendStreamMessage(streamId: number, message: string): Promise { + return AgoraRtcChannelModule.sendStreamMessage(this._channelId, streamId, message); + } +} + +/** + * @ignore + */ +interface RtcAudioInterface { + adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise; + + muteRemoteAudioStream(uid: number, muted: boolean): Promise; + + muteAllRemoteAudioStreams(muted: boolean): Promise; + + setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise; +} + +/** + * @ignore + */ +interface RtcVideoInterface { + muteRemoteVideoStream(uid: number, muted: boolean): Promise; + + muteAllRemoteVideoStreams(muted: boolean): Promise; + + setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise; +} + +/** + * @ignore + */ +interface RtcVoicePositionInterface { + setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise; +} + +/** + * @ignore + */ +interface RtcPublishStreamInterface { + setLiveTranscoding(transcoding: LiveTranscoding): Promise; + + addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise; + + removePublishStreamUrl(url: string): Promise; +} + +/** + * @ignore + */ +interface RtcMediaRelayInterface { + startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; + + updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; + + stopChannelMediaRelay(): Promise; +} + +/** + * @ignore + */ +interface RtcDualStreamInterface { + setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise; + + setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise; +} + +/** + * @ignore + */ +interface RtcFallbackInterface { + setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise; +} + +/** + * @ignore + */ +interface RtcMediaMetadataInterface { + registerMediaMetadataObserver(): Promise; + + unregisterMediaMetadataObserver(): Promise; + + setMaxMetadataSize(size: number): Promise; + + sendMetadata(metadata: string): Promise; +} + +/** + * @ignore + */ +interface RtcEncryptionInterface { + setEncryptionSecret(secret: string): Promise; + + setEncryptionMode(encryptionMode: EncryptionMode): Promise; +} + +/** + * @ignore + */ +interface RtcInjectStreamInterface { + addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise; + + removeInjectStreamUrl(url: string): Promise; +} + +/** + * @ignore + */ +interface RtcStreamMessageInterface { + createDataStream(reliable: boolean, ordered: boolean): Promise; + sendStreamMessage(streamId: number, message: string): Promise; } diff --git a/src/RtcEngine.native.ts b/src/src/RtcEngine.native.ts similarity index 98% rename from src/RtcEngine.native.ts rename to src/src/RtcEngine.native.ts index 4bb84fcf1..cf9166095 100644 --- a/src/RtcEngine.native.ts +++ b/src/src/RtcEngine.native.ts @@ -1,4 +1,5 @@ -import { NativeEventEmitter, NativeModules } from "react-native"; +import {NativeEventEmitter, NativeModules} from "react-native"; + import { AudioEqualizationBandFrequency, AudioProfile, @@ -20,22 +21,39 @@ import { LiveInjectStreamConfig, LiveTranscoding, LogFilter, - Rate, StreamFallbackOptions, - String, UserInfo, UserPriority, VideoEncoderConfiguration, VideoStreamType, WatermarkOptions -} from "./Types"; -import { Listener, RtcEngineEvents, Subscription } from "./RtcEvents"; +} from "../Types"; +import {Listener, RtcEngineEvents, Subscription} from "./RtcEvents"; import RtcChannel from "./RtcChannel.native"; -const { AgoraRtcEngineModule } = NativeModules; -const Prefix = AgoraRtcEngineModule.prefix +/** + * @ignore + */ +type Rate = 1 | 2 | 3 | 4 | 5 + +const { + /** + * @ignore + */ + AgoraRtcEngineModule +} = NativeModules; +/** + * @ignore + */ +const Prefix = AgoraRtcEngineModule.prefix; +/** + * @ignore + */ const RtcEngineEvent = new NativeEventEmitter(AgoraRtcEngineModule); +/** + * @ignore + */ let engine: RtcEngine | undefined; /** @@ -46,7 +64,9 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac RtcMediaRelayInterface, RtcAudioRouteInterface, RtcEarMonitoringInterface, RtcDualStreamInterface, RtcFallbackInterface, RtcTestInterface, RtcMediaMetadataInterface, RtcWatermarkInterface, RtcEncryptionInterface, RtcAudioRecorderInterface, RtcInjectStreamInterface, RtcCameraInterface, RtcStreamMessageInterface { - + /** + * @ignore + */ private _listeners = new Map>(); static instance(): RtcEngine { @@ -119,7 +139,7 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac */ addListener(event: EventType, listener: RtcEngineEvents[EventType]): Subscription { const callback = (res: any) => { - const { channelId, data } = res; + const {channelId, data} = res; if (channelId === undefined) { // @ts-ignore listener(...data) @@ -228,7 +248,7 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac * @param optionalUid (Optional) User ID. A 32-bit unsigned integer with a value ranging from 1 to (2^32-1). optionalUid must be unique. If optionalUid is not assigned (or set to 0), the SDK assigns and returns uid in the onJoinChannelSuccess callback. Your app must record and maintain the returned uid since the SDK does not do so. * @see RtcEngineEvents.JoinChannelSuccess */ - joinChannel(token: String, channelName: string, optionalInfo: String, optionalUid: number): Promise { + joinChannel(token: string | null, channelName: string, optionalInfo: string | null, optionalUid: number): Promise { return AgoraRtcEngineModule.joinChannel(token, channelName, optionalInfo, optionalUid) } @@ -252,7 +272,7 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac * - The space character. * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". */ - switchChannel(token: String, channelName: string): Promise { + switchChannel(token: string | null, channelName: string): Promise { return AgoraRtcEngineModule.switchChannel(token, channelName) } @@ -350,7 +370,7 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac * The log file records all log data for the SDK’s operation. Ensure that the directory for the log file exists and is writable. * Note * - Ensure that you call this method immediately after calling the create method, otherwise the output log may not be complete. - * @see RtcEngine.create + * @see RtcEngine#create * @param filePath File path of the log file. The string of the log file is in UTF-8. The default file path is /storage/emulated/0/Android/data/="">/files/agorasdk.log. */ setLogFile(filePath: string): Promise { @@ -385,333 +405,1151 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac return AgoraRtcEngineModule.setParameters(parameters) } + /** + * Gets the user information by passing in the user ID. + * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the onUserInfoUpdated callback on the local client. + * @see UserInfo + * @see RtcEngineEvents.UserInfoUpdated + * After receiving the onUserInfoUpdated callback, you can call this method to get the user ID of the remote user from the userInfo object by passing in the user account. + * @param uid The user ID of the user. Ensure that you set this parameter. + */ getUserInfoByUid(uid: number): Promise { return AgoraRtcEngineModule.getUserInfoByUid(uid) } + /** + * Gets the user information by passing in the user account. + * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the onUserInfoUpdated callback on the local client. + * @see UserInfo + * @see RtcEngineEvents.UserInfoUpdated + * After receiving the onUserInfoUpdated callback, you can call this method to get the user ID of the remote user from the userInfo object by passing in the user account. + * @param userAccount The user account of the user. Ensure that you set this parameter. + */ getUserInfoByUserAccount(userAccount: string): Promise { return AgoraRtcEngineModule.getUserInfoByUserAccount(userAccount) } - joinChannelWithUserAccount(token: String, channelName: string, userAccount: string): Promise { + /** + * Joins the channel with a user account. + * After the user successfully joins the channel, the SDK triggers the following callbacks: + * - The local client: onLocalUserRegistered and onJoinChannelSuccess. + * @see RtcEngineEvents.LocalUserRegistered + * @see RtcEngineEvents.JoinChannelSuccess + * - The remote client: onUserJoined and onUserInfoUpdated, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile. + * @see RtcEngineEvents.UserJoined + * @see RtcEngineEvents.UserInfoUpdated + * Note + * - To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. + * @param token The token generated at your server: + * - In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token. + * - In situations requiring high security: Set it as the token generated at your server. For details, see Generate a token. + * @param channelName The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are: + * - All lowercase English letters: a to z. + * - All uppercase English letters: A to Z. + * - All numeric characters: 0 to 9. + * - The space character. + * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". + * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. + * - All lowercase English letters: a to z. + * - All uppercase English letters: A to Z. + * - All numeric characters: 0 to 9. + * - The space character. + * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". + */ + joinChannelWithUserAccount(token: string | null, channelName: string, userAccount: string): Promise { return AgoraRtcEngineModule.joinChannelWithUserAccount(token, channelName, userAccount); } + /** + * Registers a user account. + * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the onLocalUserRegistered callback on the local client, reporting the user ID and user account of the local user. + * @see RtcEngineEvents.LocalUserRegistered + * To join a channel with a user account, you can choose either of the following: + * - Call the registerLocalUserAccount method to create a user account, and then the joinChannelWithUserAccount method to join the channel. + * @see RtcEngine.registerLocalUserAccount + * - Call the joinChannelWithUserAccount method to join the channel. + * @see RtcEngine.joinChannelWithUserAccount + * The difference between the two is that for the former, the time elapsed between calling the joinChannelWithUserAccount method and joining the channel is shorter than the latter. + * Note + * - Ensure that you set the userAccount parameter. Otherwise, this method does not take effect. + * - Ensure that the value of the userAccount parameter is unique in the channel. + * - To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. + * @param appId The App ID of your project. + * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: + * - All lowercase English letters: a to z. + * - All uppercase English letters: A to Z. + * - All numeric characters: 0 to 9. + * - The space character. + * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". + */ registerLocalUserAccount(appId: string, userAccount: string): Promise { return AgoraRtcEngineModule.registerLocalUserAccount(appId, userAccount); } + /** + * Adjusts the playback volume of all remote users. + * Note + * - This method adjusts the playback volume which is mixed volume of all remote users. + * - To mute the local audio playback, call both adjustPlaybackSignalVolume and adjustAudioMixingVolume, and set volume as 0. + * @see RtcEngine.adjustPlaybackSignalVolume + * @see RtcEngine.adjustAudioMixingVolume + * - To avoid echoes and improve call quality, Agora recommends setting the value of volume between 0 and 100. If you need to set the value higher than 100, contact support@agora.io first. + * @param volume The playback volume of all remote users. The value ranges from 0 to 400: + * - 0: Mute. + * - 100: The original volume. + * - 400: (Maximum) Four times the original volume with signal clipping protection. + */ adjustPlaybackSignalVolume(volume: number): Promise { return AgoraRtcEngineModule.adjustPlaybackSignalVolume(volume); } + /** + * Adjusts the recording volume. + * Note + * - To avoid echoes and improve call quality, Agora recommends setting the value of volume between 0 and 100. If you need to set the value higher than 100, contact support@agora.io first. + * @param volume Recording volume. The value ranges between 0 and 400: + * - 0: Mute. + * - 100: Original volume. + * - 400: (Maximum) Four times the original volume with signal-clipping protection. + */ adjustRecordingSignalVolume(volume: number): Promise { return AgoraRtcEngineModule.adjustRecordingSignalVolume(volume); } + /** + * Adjusts the playback volume of a specified remote user. + * You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user. + * Note + * - Call this method after joining a channel. + * - The playback volume here refers to the mixed volume of a specified remote user. + * - This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user. + * @param uid ID of the remote user. + * @param volume The playback volume of the specified remote user. The value ranges from 0 to 100: + * - 0: Mute. + * - 100: The original volume. + */ adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise { return AgoraRtcEngineModule.adjustUserPlaybackSignalVolume(uid, volume); } + /** + * Disables the audio module. + * Note + * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. + * @see RtcEngine.leaveChannel + * - This method resets the engine and takes some time to take effect. We recommend using the following API methods to control the audio engine modules separately: + * -- enableLocalAudio: Whether to enable the microphone to create the local audio stream. + * @see RtcEngine.enableLocalAudio + * -- muteLocalAudioStream: Whether to publish the local audio stream. + * @see RtcEngine.muteLocalAudioStream + * -- muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream. + * @see RtcEngine.muteRemoteAudioStream + * -- muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams. + * @see RtcEngine.muteAllRemoteAudioStreams + */ disableAudio(): Promise { return AgoraRtcEngineModule.disableAudio(); } + /** + * Enables the audio module. + * The audio module is enabled by default. + * Note + * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. + * @see RtcEngine.leaveChannel + * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the audio engine modules separately: + * -- enableLocalAudio: Whether to enable the microphone to create the local audio stream. + * @see RtcEngine.enableLocalAudio + * -- muteLocalAudioStream: Whether to publish the local audio stream. + * @see RtcEngine.muteLocalAudioStream + * -- muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream. + * @see RtcEngine.muteRemoteAudioStream + * -- muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams. + * @see RtcEngine.muteAllRemoteAudioStreams + */ enableAudio(): Promise { return AgoraRtcEngineModule.enableAudio(); } + /** + * Enables the onAudioVolumeIndication callback at a set time interval to report on which users are speaking and the speakers' volume. + * @see RtcEngineEvents.AudioVolumeIndication + * Once this method is enabled, the SDK returns the volume indication in the onAudioVolumeIndication callback at the set time interval, regardless of whether any user is speaking in the channel. + * @param interval Sets the time interval between two consecutive volume indications: + * - ≤ 0: Disables the volume indication. + * - > 0: Time interval (ms) between two consecutive volume indications. We recommend setting interval ≥ 200 ms. + * @param smooth The smoothing factor sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The greater the value, the more sensitive the indicator. The recommended value is 3. + * @param report_vad + * - true: Enable the voice activity detection of the local user. Once it is enabled, the vad parameter of the onAudioVolumeIndication callback reports the voice activity status of the local user. + * - false: (Default) Disable the voice activity detection of the local user. Once it is enabled, the vad parameter of the onAudioVolumeIndication callback does not report the voice activity status of the local user, except for scenarios where the engine automatically detects the voice activity of the local user. + */ enableAudioVolumeIndication(interval: number, smooth: number, report_vad: boolean): Promise { return AgoraRtcEngineModule.enableAudioVolumeIndication(interval, smooth, report_vad); } + /** + * Enables/Disables the local audio capture. + * The audio function is enabled by default. This method disables/re-enables the local audio function, that is, to stop or restart local audio capture and processing. + * This method does not affect receiving or playing the remote audio streams, and enableLocalAudio(false) is applicable to scenarios where the user wants to receive remote audio streams without sending any audio stream to other users in the channel. + * The SDK triggers the onMicrophoneEnabled callback once the local audio function is disabled or re-enabled. + * @see RtcEngineEvents.MicrophoneEnabled + * Note + * - This method is different from the muteLocalAudioStream method: + * -- enableLocalAudio: Disables/Re-enables the local audio capture and processing. If you disable or re-enable local audio recording using the enableLocalAudio method, the local user may hear a pause in the remote audio playback. + * @see RtcEngine.enableLocalAudio + * -- muteLocalAudioStream: Stops/Continues sending the local audio streams. + * @see RtcEngine.muteLocalAudioStream + * @param enabled Sets whether to disable/re-enable the local audio function: + * - true: (Default) Re-enable the local audio function, that is, to start local audio capture and processing. + * - false: Disable the local audio function, that is, to stop local audio capture and processing. + */ enableLocalAudio(enabled: boolean): Promise { return AgoraRtcEngineModule.enableLocalAudio(enabled); } + /** + * Stops/Resumes receiving all remote audio streams. + * @param muted Sets whether to receive/stop receiving all remote audio streams: + * - true: Stop receiving all remote audio streams. + * - false: (Default) Receive all remote audio streams. + */ muteAllRemoteAudioStreams(muted: boolean): Promise { return AgoraRtcEngineModule.muteAllRemoteAudioStreams(muted); } + /** + * Stops/Resumes sending the local audio stream. + * A successful muteLocalAudioStream method call triggers the onUserMuteAudio callback on the remote client. + * @see RtcEngineEvents.UserMuteAudio + * Note + * - When muted is set as true, this method does not disable the microphone and thus does not affect any ongoing recording. + * - If you call setChannelProfile after this method, the SDK resets whether or not to mute the local audio according to the channel profile and user role. Therefore, we recommend calling this method after the setChannelProfile method. + * @see RtcEngine.setChannelProfile + * @param muted Sets whether to send/stop sending the local audio stream: + * - true: Stop sending the local audio stream. + * - false: (Default) Send the local audio stream. + */ muteLocalAudioStream(muted: boolean): Promise { return AgoraRtcEngineModule.muteLocalAudioStream(muted); } + /** + * Stops/Resumes receiving a specified audio stream. + * Note + * - If you called the muteAllRemoteAudioStreams method and set muted as true to stop receiving all remote video streams, ensure that the muteAllRemoteAudioStreams method is called and set muted as false before calling this method. The muteAllRemoteAudioStreams method sets all remote audio streams, while the muteRemoteAudioStream method sets a specified remote user's audio stream. + * @see RtcEngine.muteAllRemoteAudioStreams + * @param uid ID of the specified remote user. + * @param muted Sets whether to receive/stop receiving the specified remote user's audio stream: + * - true: Stop receiving the specified remote user’s audio stream. + * - false: (Default) Receive the specified remote user’s audio stream. + */ muteRemoteAudioStream(uid: number, muted: boolean): Promise { return AgoraRtcEngineModule.muteRemoteAudioStream(uid, muted); } + /** + * Sets the audio parameters and application scenarios. + * Note + * - You must call this method before calling the joinChannel method. + * @see RtcEngine.joinChannel + * - In the Communication and Live Broadcast profiles, the bitrates may be different from your settings due to network self-adaptation. + * - In scenarios requiring high-quality audio, we recommend setting profile as ShowRoom(4) and scenario as GameStreaming(3). For example, for music education scenarios. + * @see AudioScenario.ShowRoom + * @see AudioScenario.GameStreaming + * @param profile Sets the sample rate, bitrate, encoding mode, and the number of channels. + * @see AudioProfile + * @param scenario Sets the audio application scenarios. Under different audio scenarios, the device uses different volume tracks, i.e. either the in-call volume or the media volume. + * @see AudioScenario + */ setAudioProfile(profile: AudioProfile, scenario: AudioScenario): Promise { return AgoraRtcEngineModule.setAudioProfile(profile, scenario); } + /** + * Sets whether to receive all remote audio streams by default. + * You can call this method either before or after joining a channel. If you call setDefaultMuteAllRemoteAudioStreams(true) after joining a channel, you will not receive the audio streams of any subsequent user. + * Note + * - If you want to resume receiving audio streams, call muteRemoteAudioStream(false), and specify the ID of the remote user that you want to subscribe to. To resume audio streams of multiple users, call muteRemoteAudioStream as many times. Calling setDefaultMuteAllRemoteAudioStreams(false) resumes receiving audio streams of the subsequent users only. + * @see RtcEngine.muteRemoteAudioStream + * @param muted Sets whether or not to receive/stop receiving the remote audio streams by default: + * - true: Stop receiving any audio stream by default. + * - false: (Default) Receive all remote audio streams by default. + */ setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise { return AgoraRtcEngineModule.setDefaultMuteAllRemoteAudioStreams(muted); } + /** + * Disables the video module. + * You can call this method before joining a channel or during a call. If you call this method before joining a channel, the service starts in audio mode. If you call this method during a video call, the video mode switches to the audio mode. + * - A successful disableVideo method call triggers the onUserEnableVideo(false) callback on the remote client. + * @see RtcEngineEvents.UserEnableVideo + * - To enable the video mode, call the enableVideo method. + * @see RtcEngine.enableVideo + * Note + * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. + * @see RtcEngine.leaveChannel + * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately: + * -- enableLocalVideo: Whether to enable the camera to create the local video stream. + * @see RtcEngine.enableLocalVideo + * -- muteLocalVideoStream: Whether to publish the local video stream. + * @see RtcEngine.muteLocalVideoStream + * -- muteRemoteVideoStream: Whether to subscribe to and play the remote video stream. + * @see RtcEngine.muteRemoteVideoStream + * -- muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams. + * @see RtcEngine.muteAllRemoteVideoStreams + */ disableVideo(): Promise { return AgoraRtcEngineModule.disableVideo(); } - enableLocalVideo(enabled: boolean): Promise { - return AgoraRtcEngineModule.enableLocalVideo(enabled); - } - - enableVideo(): Promise { - return AgoraRtcEngineModule.enableVideo(); - } - - muteAllRemoteVideoStreams(muted: boolean): Promise { - return AgoraRtcEngineModule.muteAllRemoteVideoStreams(muted); + /** + * Disables/Re-enables the local video capture. + * This method disables or re-enables the local video capturer, and does not affect receiving the remote video stream. + * After you call the enableVideo method, the local video capturer is enabled by default. You can call enableLocalVideo(false) to disable the local video capturer. If you want to re-enable it, call enableLocalVideo(true). + * @see RtcEngine.enableVideo + * After the local video capturer is successfully disabled or re-enabled, the SDK triggers the onUserEnableLocalVideo callback on the remote client. + * @see RtcEngineEvents.UserEnableLocalVideo + * Note + * - This method affects the internal engine and can be called after calling the leaveChannel method. + * @param enabled Sets whether to disable/re-enable the local video, including the capturer, renderer, and sender: + * - true: (Default) Re-enable the local video. + * - false: Disable the local video. Once the local video is disabled, the remote users can no longer receive the video stream of this user, while this user can still receive the video streams of other remote users. When you set enabled as false, this method does not require a local camera. + */ + enableLocalVideo(enabled: boolean): Promise { + return AgoraRtcEngineModule.enableLocalVideo(enabled); + } + + /** + * Enables the video module. + * You can call this method either before joining a channel or during a call. If you call this method before joining a channel, the service starts in the video mode. If you call this method during an audio call, the audio mode switches to the video mode. + * A successful enableVideo method call triggers the onUserEnableVideo(true) callback on the remote client. + * @see RtcEngineEvents.UserEnableVideo + * To disable the video, call the disableVideo method. + * @see RtcEngine.disableVideo + * Note + * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. + * @see RtcEngine.leaveChannel + * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately: + * -- enableLocalVideo: Whether to enable the camera to create the local video stream. + * @see RtcEngine.enableLocalVideo + * -- muteLocalVideoStream: Whether to publish the local video stream. + * @see RtcEngine.muteLocalVideoStream + * -- muteRemoteVideoStream: Whether to subscribe to and play the remote video stream. + * @see RtcEngine.muteRemoteVideoStream + * -- muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams. + * @see RtcEngine.muteAllRemoteVideoStreams + */ + enableVideo(): Promise { + return AgoraRtcEngineModule.enableVideo(); + } + + /** + * Stops/Resumes receiving all remote video streams. + * @param muted Sets whether to receive/stop receiving all remote video streams: + * - true: Stop receiving all remote video streams. + * - false: (Default) Receive all remote video streams. + */ + muteAllRemoteVideoStreams(muted: boolean): Promise { + return AgoraRtcEngineModule.muteAllRemoteVideoStreams(muted); } + /** + * Stops/Resumes sending the local video stream. + * A successful muteLocalVideoStream method call triggers the onUserMuteVideo callback on the remote client. + * @see RtcEngineEvents.UserMuteVideo + * Note + * - When you set muted as true, this method does not disable the camera and thus does not affect the retrieval of the local video streams. This method responds faster than calling the enableLocalVideo method and set muted as false, which controls sending the local video stream. + * @see RtcEngine.enableLocalVideo + * - If you call setChannelProfile after this method, the SDK resets whether or not to mute the local video according to the channel profile and user role. Therefore, we recommend calling this method after the setChannelProfile method. + * @see RtcEngine.setChannelProfile + * @param muted Sets whether to send/stop sending the local video stream: + * - true: Stop sending the local video stream. + * - false: (Default) Send the local video stream. + */ muteLocalVideoStream(muted: boolean): Promise { return AgoraRtcEngineModule.muteLocalVideoStream(muted); } + /** + * Stops/Resumes receiving a specified remote user's video stream. + * Note + * - If you call the muteAllRemoteVideoStreams method and set set muted as true to stop receiving all remote video streams, ensure that the muteAllRemoteVideoStreams method is called and set muted as false before calling this method. The muteAllRemoteVideoStreams method sets all remote streams, while this method sets a specified remote user's stream. + * @see RtcEngine.muteAllRemoteVideoStreams + * @param uid User ID of the specified remote user. + * @param muted Sets whether to receive/stop receiving a specified remote user's video stream: + * - true: Stop receiving a specified remote user’s video stream. + * - false: (Default) Receive a specified remote user’s video stream. + */ muteRemoteVideoStream(uid: number, muted: boolean): Promise { return AgoraRtcEngineModule.muteRemoteVideoStream(uid, muted); } + /** + * Enables/Disables image enhancement and sets the options. + * Note + * - Call this method after calling enableVideo. + * - This method applies to Android 4.4 or later. + * @param enabled Sets whether or not to enable image enhancement: + * - enables image enhancement. + * - disables image enhancement. + * @param options The image enhancement options. + * @see BeautyOptions + */ setBeautyEffectOptions(enabled: boolean, options: BeautyOptions): Promise { return AgoraRtcEngineModule.setBeautyEffectOptions(enabled, options); } + /** + * Sets whether to receive all remote video streams by default. + * You can call this method either before or after joining a channel. If you call setDefaultMuteAllRemoteVideoStreams(true) after joining a channel, you will not receive the video stream of any subsequent user. + * Note + * - If you want to resume receiving video streams, call muteRemoteVideoStream(false), and specify the ID of the remote user that you want to subscribe to. To resume receiving video streams of multiple users, call muteRemoteVideoStream as many times. Calling setDefaultMuteAllRemoteVideoStreams(false) resumes receiving video streams of the subsequent users only. + * @see RtcEngine.muteRemoteVideoStream + * @param muted Sets whether to receive/stop receiving all remote video streams by default: + * - true: Stop receiving any remote video stream by default. + * - false: (Default) Receive all remote video streams by default. + */ setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise { return AgoraRtcEngineModule.setDefaultMuteAllRemoteVideoStreams(muted); } + /** + * Sets the video encoder configuration. + * Each video encoder configuration corresponds to a set of video parameters, including the resolution, frame rate, bitrate, and video orientation. The parameters specified in this method are the maximum values under ideal network conditions. If the video engine cannot render the video using the specified parameters due to poor network conditions, the parameters further down the list are considered until a successful configuration is found. + * If you do not set the video encoder configuration after joining the channel, you can call this method before calling the enableVideo method to reduce the render time of the first video frame. + * @see RtcEngine.enableVideo + * @param config The local video encoder configuration. + * @see VideoEncoderConfiguration + */ setVideoEncoderConfiguration(config: VideoEncoderConfiguration): Promise { return AgoraRtcEngineModule.setVideoEncoderConfiguration(config); } + /** + * Starts the local video preview before joining a channel. + * Before calling this method, you must: + * - Create the RtcLocalView. + * @see RtcLocalView + * - Call the enableVideo method to enable the video. + * @see RtcEngine.enableVideo + * Note + * - By default, the local preview enables the mirror mode. + * - Once you call this method to start the local video preview, if you leave the channel by calling the leaveChannel method, the local video preview remains until you call the stopPreview method to disable it. + * @see RtcEngine.leaveChannel + * @see RtcEngine.stopPreview + */ startPreview(): Promise { return AgoraRtcEngineModule.startPreview(); } + + /** + * Stops the local video preview and the video. + */ stopPreview(): Promise { return AgoraRtcEngineModule.stopPreview(); } + /** + * Adjusts the volume of audio mixing for local playback. + * Call this method when you are in a channel. + * @param volume Audio mixing volume for local playback. The value ranges between 0 and 100 (default). + */ adjustAudioMixingPlayoutVolume(volume: number): Promise { return AgoraRtcEngineModule.adjustAudioMixingPlayoutVolume(volume); } + /** + * Adjusts the volume of audio mixing for publishing (sending to other users). + * Call this method when you are in a channel. + * @param volume Audio mixing volume for publishing. The value ranges between 0 and 100 (default). + */ adjustAudioMixingPublishVolume(volume: number): Promise { return AgoraRtcEngineModule.adjustAudioMixingPublishVolume(volume); } + /** + * Adjusts the volume of audio mixing. + * Call this method when you are in a channel. + * Note + * - Calling this method does not affect the volume of the audio effect file playback invoked by the playEffect method. + * @see RtcEngine.playEffect + * @param volume Audio mixing volume. The value ranges between 0 and 100 (default). + */ adjustAudioMixingVolume(volume: number): Promise { return AgoraRtcEngineModule.adjustAudioMixingVolume(volume); } + /** + * Gets the playback position (ms) of the music file. + * Call this method when you are in a channel. + */ getAudioMixingCurrentPosition(): Promise { return AgoraRtcEngineModule.getAudioMixingCurrentPosition(); } + /** + * Gets the duration (ms) of the music file. + * Call this method when you are in a channel. + */ getAudioMixingDuration(): Promise { return AgoraRtcEngineModule.getAudioMixingDuration(); } + /** + * Gets the audio mixing volume for local playback. + * This method helps troubleshoot audio volume related issues. + */ getAudioMixingPlayoutVolume(): Promise { return AgoraRtcEngineModule.getAudioMixingPlayoutVolume(); } + /** + * Gets the audio mixing volume for publishing. + * This method helps troubleshoot audio volume related issues. + */ getAudioMixingPublishVolume(): Promise { return AgoraRtcEngineModule.getAudioMixingPublishVolume(); } + /** + * Pauses playing and mixing the music file. + * Call this method when you are in a channel. + */ pauseAudioMixing(): Promise { return AgoraRtcEngineModule.pauseAudioMixing(); } + /** + * Resumes playing and mixing the music file. + * Call this method when you are in a channel. + */ resumeAudioMixing(): Promise { return AgoraRtcEngineModule.resumeAudioMixing(); } + /** + * Sets the pitch of the local music file. + * When a local music file is mixed with a local human voice, call this method to set the pitch of the local music file only. + * Note + * - Call this method after calling startAudioMixing. + * @see RtcEngine#startAudioMixing + * @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0, which means keep the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file. + */ setAudioMixingPitch(pitch: number): Promise { return AgoraRtcEngineModule.setAudioMixingPitch(pitch); } + /** + * Sets the playback position (ms) of the music file to a different starting position (the default plays from the beginning). + * @param pos The playback starting position (ms) of the audio mixing file. + */ setAudioMixingPosition(pos: number): Promise { return AgoraRtcEngineModule.setAudioMixingPosition(pos); } + /** + * Starts playing and mixing the music file. + * This method mixes the specified local or online audio file with the audio stream from the microphone, or replaces the microphone’s audio stream with the specified local or remote audio file. You can choose whether the other user can hear the local audio playback and specify the number of playback loops. When the audio mixing file playback finishes after calling this method, the SDK triggers the onAudioMixingFinished callback. + * @see RtcEngineEvents.AudioMixingFinished + * A successful startAudioMixing method call triggers the onAudioMixingStateChanged(Playing) callback on the local client. + * @see RtcEngineEvents.AudioMixingStateChanged + * @see AudioMixingStateCode.Playing + * When the audio mixing file playback finishes, the SDK triggers the onAudioMixingStateChanged(Stopped) callback on the local client. + * @see RtcEngineEvents.AudioMixingStateChanged + * @see AudioMixingStateCode.Stopped + * Note + * - To use this method, ensure that the Android device is v4.2 or later, and the API version is v16 or later. + * - Call this method when you are in the channel, otherwise it may cause issues. + * - If you want to play an online music file, ensure that the time interval between calling this method is more than 100 ms, or the TooFrequentCall = 702 error occurs. + * @see AudioMixingErrorCode.TooFrequentCall + * - If you want to play an online music file, Agora does not recommend using the redirected URL address. Some Android devices may fail to open a redirected URL address. + * - If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns CanNotOpen = 701. + * @see AudioMixingErrorCode.CanNotOpen + * - If you call this method on an emulator, only the MP3 file format is supported. + * @param filePath Specifies the absolute path (including the suffixes of the filename) of the local or online audio file to be mixed. For example, /sdcard/emulated/0/audio.mp4. Supported audio formats: mp3, mp4, m4a, aac, 3gp, mkv, and wav. + * - If the path begins with /assets/, the audio file is in the /assets/ directory. + * - Otherwise, the audio file is in the absolute path. + * @param loopback Sets which user can hear the audio mixing: + * - true: Only the local user can hear the audio mixing. + * - false: Both users can hear the audio mixing. + * @param replace Sets the audio mixing content: + * - true: Only publish the specified audio file; the audio stream from the microphone is not published. + * - false: The local audio file is mixed with the audio stream from the microphone. + * @param cycle Sets the number of playback loops: + * - Positive integer: Number of playback loops + * - -1: Infinite playback loops + */ startAudioMixing(filePath: string, loopback: boolean, replace: boolean, cycle: number): Promise { return AgoraRtcEngineModule.startAudioMixing(filePath, loopback, replace, cycle); } + /** + * Stops playing or mixing the music file. + * Call this method when you are in a channel. + */ stopAudioMixing(): Promise { return AgoraRtcEngineModule.stopAudioMixing(); } + /** + * Gets the volume of the audio effects. + * The value ranges between 0.0 and 100.0. + */ getEffectsVolume(): Promise { return AgoraRtcEngineModule.getEffectsVolume(); } + /** + * Pauses all audio effects. + */ pauseAllEffects(): Promise { return AgoraRtcEngineModule.pauseAllEffects(); } + /** + * Pauses a specified audio effect. + * @param soundId ID of the audio effect. Each audio effect has a unique ID. + */ pauseEffect(soundId: number): Promise { return AgoraRtcEngineModule.pauseEffect(soundId); } - playEffect(soundId: number, filePath: String, loopCount: number, pitch: number, pan: number, gain: number, publish: Boolean): Promise { + /** + * Plays a specified local or online audio effect file. + * With this method, you can set the loop count, pitch, pan, and gain of the audio effect file and whether the remote user can hear the audio effect. + * To play multiple audio effect files simultaneously, call this method multiple times with different soundIds and filePaths. We recommend playing no more than three audio effect files at the same time. + * When the audio effect file playback is finished, the SDK triggers the onAudioEffectFinished callback. + * @see RtcEngineEvents.AudioEffectFinished + * @param soundId ID of the specified audio effect. Each audio effect has a unique ID. If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method. + * @see RtcEngine.preloadEffect + * @param filePath The absolute file path (including the suffixes of the filename) of the audio effect file or the URL of the online audio effect file. For example, /sdcard/emulated/0/audio.mp4. Supported audio formats: mp3, mp4, m4a, aac. 3gp, mkv, and wav. + * @param loopCount Sets the number of times the audio effect loops: + * - 0: Plays the audio effect once. + * - 1: Plays the audio effect twice. + * - -1: Plays the audio effect in a loop indefinitely, until you call the stopEffect or stopAllEffects method. + * @see RtcEngine.stopEffect + * @see RtcEngine.stopAllEffects + * @param pitch Sets the pitch of the audio effect. The value ranges between 0.5 and 2. The default value is 1 (no change to the pitch). The lower the value, the lower the pitch. + * @param pan Sets the spatial position of the audio effect. The value ranges between -1.0 and 1.0. + * - 0.0: The audio effect shows ahead. + * - 1.0: The audio effect shows on the right. + * - -1.0: The audio effect shows on the left. + * @param gain Sets the volume of the audio effect. The value ranges between 0.0 and 100,0. The default value is 100.0. The lower the value, the lower the volume of the audio effect. + * @param publish Set whether or not to publish the specified audio effect to the remote stream: + * - true: The locally played audio effect is published to the Agora Cloud and the remote users can hear it. + * - false: The locally played audio effect is not published to the Agora Cloud and the remote users cannot hear it. + */ + playEffect(soundId: number, filePath: string, loopCount: number, pitch: number, pan: number, gain: number, publish: Boolean): Promise { return AgoraRtcEngineModule.playEffect(soundId, filePath, loopCount, pitch, pan, gain, publish); } - preloadEffect(soundId: number, filePath: String): Promise { + /** + * Preloads a specified audio effect file into the memory. + * Supported audio formats: mp3, aac, m4a, 3gp, wav. + * Note + * - This method does not support online audio effect files. + * Note + * - To ensure smooth communication, limit the size of the audio effect file. We recommend using this method to preload the audio effect before calling the joinChannel method. + * @see RtcEngine.joinChannel + * @param soundId ID of the audio effect. Each audio effect has a unique ID. + * @param filePath Absolute path of the audio effect file. + */ + preloadEffect(soundId: number, filePath: string): Promise { return AgoraRtcEngineModule.preloadEffect(soundId, filePath); } - resumeAllEffects(): Promise { + /** + * Resumes playing all audio effects. + */ + resumeAllEffects(): Promise { return AgoraRtcEngineModule.resumeAllEffects(); } + /** + * Resumes playing a specified audio effect. + * @param soundId ID of the audio effect. Each audio effect has a unique ID. + */ resumeEffect(soundId: number): Promise { return AgoraRtcEngineModule.resumeEffect(soundId); } + /** + * Sets the volume of the audio effects. + * @param volume Volume of the audio effects. The value ranges between 0.0 and 100.0 (default). + */ setEffectsVolume(volume: number): Promise { return AgoraRtcEngineModule.setEffectsVolume(volume); } + /** + * Sets the volume of a specified audio effect. + * @param soundId ID of the audio effect. Each audio effect has a unique ID. + * @param volume Volume of the audio effect. The value ranges between 0.0 and 100.0 (default). + */ setVolumeOfEffect(soundId: number, volume: number): Promise { return AgoraRtcEngineModule.setVolumeOfEffect(soundId, volume); } + /** + * Stops playing all audio effects. + */ stopAllEffects(): Promise { return AgoraRtcEngineModule.stopAllEffects(); } + /** + * Stops playing a specified audio effect. + * Note + * - If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method. + * @see RtcEngine.preloadEffect + * @param soundId ID of the specified audio effect. Each audio effect has a unique ID. + */ stopEffect(soundId: number): Promise { return AgoraRtcEngineModule.stopEffect(soundId); } + /** + * Releases a specified preloaded audio effect from the memory. + * @param soundId ID of the audio effect. Each audio effect has a unique ID. + */ unloadEffect(soundId: number): Promise { return AgoraRtcEngineModule.unloadEffect(soundId); } + /** + * Sets the local voice changer option. + * Note + * - Do not use this method together with setLocalVoiceReverbPreset, or the method called earlier does not take effect. + * @see RtcEngine.setLocalVoiceReverbPreset + * @param voiceChanger The local voice changer option. + * @see AudioVoiceChanger + */ setLocalVoiceChanger(voiceChanger: AudioVoiceChanger): Promise { return AgoraRtcEngineModule.setLocalVoiceChanger(voiceChanger); } + /** + * Sets the local voice equalization effect. + * @param bandFrequency Sets the band frequency. The value ranges between 0 and 9; representing the respective 10-band center frequencies of the voice effects, including 31, 62, 125, 500, 1k, 2k, 4k, 8k, and 16k Hz. + * @see AudioEqualizationBandFrequency + * @param bandGain Sets the gain of each band (dB). The value ranges between -15 and 15. The default value is 0. + */ setLocalVoiceEqualization(bandFrequency: AudioEqualizationBandFrequency, bandGain: number): Promise { return AgoraRtcEngineModule.setLocalVoiceEqualization(bandFrequency, bandGain); } + /** + * Changes the voice pitch of the local speaker. + * @param pitch Sets the voice pitch. The value ranges between 0.5 and 2.0. The lower the value, the lower the voice pitch. The default value is 1.0 (no change to the local voice pitch). + */ setLocalVoicePitch(pitch: number): Promise { return AgoraRtcEngineModule.setLocalVoicePitch(pitch); } + /** + * Sets the local voice reverberation. + * Note + * - Adds the setLocalVoiceReverbPreset method, a more user-friendly method for setting the local voice reverberation. You can use this method to set the local reverberation effect, such as Popular, R&B, Rock, Hip-hop, and more. + * @see RtcEngine.setLocalVoiceReverbPreset + * @param reverbKey Sets the reverberation key. This method contains five reverberation keys. For details, see the description of each @ value. + * @see AudioReverbType + * @param value Sets the local voice reverberation value. + */ setLocalVoiceReverb(reverbKey: AudioReverbType, value: number): Promise { return AgoraRtcEngineModule.setLocalVoiceReverb(reverbKey, value); } + /** + * Sets the preset local voice reverberation effect + * Note + * - Do not use this method together with setLocalVoiceReverb. + * @see RtcEngine.setLocalVoiceReverb + * - Do not use this method together with setLocalVoiceChanger, or the method called eariler does not take effect. + * @see RtcEngine.setLocalVoiceChanger + * @param preset The local voice reverberation preset + * @see AudioReverbPreset + */ setLocalVoiceReverbPreset(preset: AudioReverbPreset): Promise { return AgoraRtcEngineModule.setLocalVoiceReverbPreset(preset); } + /** + * Enables/Disables stereo panning for remote users. + * Ensure that you call this method before joinChannel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling setRemoteVoicePosition. + * @see RtcEngine.joinChannel + * @see RtcEngine.setRemoteVoicePosition + * @param enabled Sets whether or not to enable stereo panning for remote users: + * - true: enables stereo panning. + * - false: disables stereo panning. + */ enableSoundPositionIndication(enabled: boolean): Promise { return AgoraRtcEngineModule.enableSoundPositionIndication(enabled); } + /** + * Sets the sound position of a remote user. + * When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. + * Note + * - For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel. + * @see RtcEngine.enableSoundPositionIndication + * - This method requires hardware support. For the best sound positioning, we recommend using a stereo headset. + * @param uid The ID of the remote user. + * @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: + * - 0.0: The remote sound comes from the front. + * - -1.0: The remote sound comes from the left. + * - 1.0: The remote sound comes from the right. + * @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. + */ setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise { return AgoraRtcEngineModule.setRemoteVoicePosition(uid, pan, gain); } + /** + * Publishes the local stream to the CDN. + * The addPublishStreamUrl method call triggers the onRtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN. + * @see RtcEngineEvents.RtmpStreamingStateChanged + * Note + * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. + * - This method applies to Live Broadcast only. + * - Ensure that the user joins a channel before calling this method. + * - This method adds only one stream HTTP/HTTPS URL address each time it is called. + * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. + * @param transcodingEnabled Sets whether transcoding is enabled/disabled. If you set this parameter as true, ensure that you call the setLiveTranscoding method before this method. + * @see RtcEngine.setLiveTranscoding + * - true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple hosts in CDN live. + * - false: Disable transcoding. + */ addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise { return AgoraRtcEngineModule.addPublishStreamUrl(url, transcodingEnabled); } + /** + * Removes an RTMP stream from the CDN. + * This method removes the RTMP URL address (added by addPublishStreamUrl) from a CDN live stream. The SDK reports the result of this method call in the onRtmpStreamingStateChanged callback. + * @see RtcEngine.addPublishStreamUrl + * @see RtcEngineEvents.RtmpStreamingStateChanged + * Note + * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. + * - Ensure that the user joins a channel before calling this method. + * - This method applies to Live Broadcast only. + * - This method removes only one stream RTMP URL address each time it is called. + * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. + */ removePublishStreamUrl(url: string): Promise { return AgoraRtcEngineModule.removePublishStreamUrl(url); } + /** + * Sets the video layout and audio settings for CDN live. + * The SDK triggers the onTranscodingUpdated callback when you call this method to update the LiveTranscodingclass. If you call this method to set the LiveTranscoding class for the first time, the SDK does not trigger the onTranscodingUpdated callback. + * @see RtcEngineEvents.TranscodingUpdated + * Note + * - Before calling the methods listed in this section: + * -- This method applies to Live Broadcast only. + * -- Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. + * -- Ensure that you call the setClientRole method and set the user role as the host. + * @see RtcEngine.setClientRole + * -- Ensure that you call the setLiveTranscoding method before calling the addPublishStreamUrl method. + * @see RtcEngine.addPublishStreamUrl + * @param transcoding Sets the CDN live audio/video transcoding settings. + * @see LiveTranscoding + */ setLiveTranscoding(transcoding: LiveTranscoding): Promise { return AgoraRtcEngineModule.setLiveTranscoding(transcoding); } + /** + * Starts to relay media streams across channels. + * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks return the state and events of the media stream relay. + * @see RtcEngineEvents.ChannelMediaRelayStateChanged + * @see RtcEngineEvents.ChannelMediaRelayEvent + * - If the onChannelMediaRelayStateChanged callback returns Running(2) and None(0), and the onChannelMediaRelayEvent callback returns SentToDestinationChannel(4), the SDK starts relaying media streams between the original and the destination channel. + * @see ChannelMediaRelayState.Running + * @see ChannelMediaRelayError.None + * @see ChannelMediaRelayEvent.SentToDestinationChannel + * - If the onChannelMediaRelayStateChanged callback returns Failure(3), an exception occurs during the media stream relay. + * @see ChannelMediaRelayState.Failure + * Note + * - Contact sales-us@agora.io before implementing this function. + * - We do not support string user accounts in this API. + * - Call this method after the joinChannel method. + * @see RtcEngine.joinChannel + * - This method takes effect only when you are a broadcaster in a Live-broadcast channel. + * - After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay method to quit the current relay. + * @see RtcEngine.stopChannelMediaRelay + * @param channelMediaRelayConfiguration The configuration of the media stream relay. + * @see ChannelMediaRelayConfiguration + */ startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { return AgoraRtcEngineModule.startChannelMediaRelay(channelMediaRelayConfiguration); } + /** + * Stops the media stream relay. + * Once the relay stops, the broadcaster quits all the destination channels. + * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback returns Idle(0) and None(0), the broadcaster successfully stops the relay. + * @see RtcEngineEvents.ChannelMediaRelayStateChanged + * @see ChannelMediaRelayState.Idle + * @see ChannelMediaRelayError.None + * Note + * - If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged callback with the ServerNoResponse(2) or ServerConnectionLost(8) state code. You can leave the channel by calling the leaveChannel method, and the media stream relay automatically stops. + * @see RtcEngineEvents.ChannelMediaRelayStateChanged + * @see ChannelMediaRelayError.ServerNoResponse + * @see ChannelMediaRelayError.ServerConnectionLost + * @see RtcEngine.leaveChannel + */ stopChannelMediaRelay(): Promise { return AgoraRtcEngineModule.stopChannelMediaRelay(); } + /** + * Updates the channels for media relay. + * After the channel media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the updateChannelMediaRelay method. + * After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback with the UpdateDestinationChannel(7) state code. + * @see RtcEngineEvents.ChannelMediaRelayEvent + * @see ChannelMediaRelayEvent.UpdateDestinationChannel + * Note + * - Call this method after the startChannelMediaRelay method to update the destination channel. + * @see RtcEngine.startChannelMediaRelay + * - This method supports adding at most four destination channels in the relay. If there are already four destination channels in the relay. + * @param channelMediaRelayConfiguration The media stream relay configuration + * @see ChannelMediaRelayConfiguration + */ updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise { return AgoraRtcEngineModule.updateChannelMediaRelay(channelMediaRelayConfiguration); } + /** + * Checks whether the speakerphone is enabled. + */ isSpeakerphoneEnabled(): Promise { return AgoraRtcEngineModule.isSpeakerphoneEnabled(); } + /** + * Sets the default audio playback route. + * This method sets whether the received audio is routed to the earpiece or speakerphone by default before joining a channel. If a user does not call this method, the audio is routed to the earpiece by default. If you need to change the default audio route after joining a channel, call the setEnableSpeakerphone method. + * @see RtcEngine.setEnableSpeakerphone + * The default audio route for each scenario: + * - In the Communication profile: + * @see ChannelProfile.Communication + * -- For a voice call, the default audio route is the earpiece. + * -- For a video call, the default audio route is the speaker. If the user disables the video using disableVideo, or muteLocalVideoStream and muteAllRemoteVideoStreams, the default audio route automatically switches back to the earpiece. + * @see RtcEngine.disableVideo + * @see RtcEngine.muteLocalVideoStream + * @see RtcEngine.muteAllRemoteVideoStreams + * - In the Live Broadcast profile: The default audio route is the speaker. + * @see ChannelProfile.LiveBroadcasting + * Note + * - This method applies to the Communication profile only. + * - Call this method before the user joins a channel. + * @param defaultToSpeaker Sets the default audio route: + * - true: Route the audio to the speaker. If the playback device connects to the earpiece or Bluetooth, the audio cannot be routed to the earpiece. + * - false: (Default) Route the audio to the earpiece. If a headset is plugged in, the audio is routed to the headset. + */ setDefaultAudioRoutetoSpeakerphone(defaultToSpeaker: boolean): Promise { return AgoraRtcEngineModule.setDefaultAudioRoutetoSpeakerphone(defaultToSpeaker); } + /** + * Enables/Disables the audio playback route to the speakerphone. + * This method sets whether the audio is routed to the speakerphone or earpiece. After calling this method, the SDK returns the onAudioRouteChanged callback to indicate the changes. + * @see RtcEngineEvents.AudioRouteChanged + * Note + * - Ensure that you have successfully called the joinChannel method before calling this method. + * @see RtcEngine.joinChannel + * - This method is invalid for audience users in the Live Broadcast profile. + * @see ChannelProfile.LiveBroadcasting + * @param enabled Sets whether to route the audio to the speakerphone or earpiece: + * - true: Route the audio to the speakerphone. + * - false: Route the audio to the earpiece. If the headset is plugged in, the audio is routed to the headset. + */ setEnableSpeakerphone(enabled: boolean): Promise { return AgoraRtcEngineModule.setEnableSpeakerphone(enabled); } + /** + * Enables in-ear monitoring. + * @param enabled Sets whether to enable/disable in-ear monitoring: + * - true: Enable. + * - false: (Default) Disable. + */ enableInEarMonitoring(enabled: boolean): Promise { return AgoraRtcEngineModule.enableInEarMonitoring(enabled); } + /** + * Sets the volume of the in-ear monitor. + * @param volume Sets the volume of the in-ear monitor. The value ranges between 0 and 100 (default). + */ setInEarMonitoringVolume(volume: number): Promise { return AgoraRtcEngineModule.setInEarMonitoringVolume(volume); } + /** + * Enables/Disables the dual video stream mode. + * If dual-stream mode is enabled, the receiver can choose to receive the high stream (high-resolution high-bitrate video stream) or low stream (low-resolution low-bitrate video stream) video. + * @param enabled Sets the stream mode: + * - true: Dual-stream mode. + * - false: (Default) Single-stream mode. + */ enableDualStreamMode(enabled: boolean): Promise { return AgoraRtcEngineModule.enableDualStreamMode(enabled); } + /** + * Sets the default video-stream type of the remotely subscribed video stream when the remote user sends dual streams. + * @param streamType Sets the default video-stream type. + * @see VideoStreamType + */ setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise { return AgoraRtcEngineModule.setRemoteDefaultVideoStreamType(streamType); } + /** + * Sets the stream type of the remote video. + * Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode(false), the receiver can choose to receive either the high-video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream). + * @see RtcEngine.enableDualStreamMode + * By default, users receive the high-video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources. + * The aspect ratio of the low-video stream is the same as the high-video stream. Once the resolution of the high-video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream. + * The SDK reports the result of calling this method in the onApiCallExecuted callback. + * @see RtcEngineEvents.ApiCallExecuted + * @param uid ID of the remote user sending the video stream. + * @param streamType Sets the video-stream type. + * @see VideoStreamType + */ setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise { return AgoraRtcEngineModule.setRemoteVideoStreamType(uid, streamType); } - setLocalPublishFallbackOption(option: StreamFallbackOptions): Promise { - return AgoraRtcEngineModule.setLocalPublishFallbackOption(option); - } + /** + * Sets the fallback option for the locally published video stream based on the network conditions. + * If option is set as AudioOnly(2), the SDK will: + * @see StreamFallbackOptions.AudioOnly + * - Disable the upstream video but enable audio only when the network conditions deteriorate and cannot support both video and audio. + * - Re-enable the video when the network conditions improve. + * When the locally published video stream falls back to audio only or when the audio-only stream switches back to the video, the SDK triggers the onLocalPublishFallbackToAudioOnly. + * @see RtcEngineEvents.LocalPublishFallbackToAudioOnly + * Note + * - Agora does not recommend using this method for CDN live streaming, because the remote CDN live user will have a noticeable lag when the locally published video stream falls back to audio only. + * @param option Sets the fallback option for the locally published video stream. + * @see StreamFallbackOptions + */ + setLocalPublishFallbackOption(option: StreamFallbackOptions): Promise { + return AgoraRtcEngineModule.setLocalPublishFallbackOption(option); + } + /** + * Sets the fallback option for the remotely subscribed video stream based on the network conditions. + * If option is set as AudioOnly(2), the SDK automatically switches the video from a high-stream to a low-stream, or disables the video when the downlink network condition cannot support both audio and video to guarantee the quality of the audio. The SDK monitors the network quality and restores the video stream when the network conditions improve. When the remotely subscribed video stream falls back to audio only, or the audio-only stream switches back to the video, the SDK triggers the onRemoteSubscribeFallbackToAudioOnly callback. + * @see StreamFallbackOptions.AudioOnly + * @see RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly + * @param option Sets the fallback option for the remotely subscribed video stream. + * @see StreamFallbackOptions + */ setRemoteSubscribeFallbackOption(option: StreamFallbackOptions): Promise { return AgoraRtcEngineModule.setRemoteSubscribeFallbackOption(option); } + /** + * Sets the priority of a remote user's media stream. + * Use this method with the setRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality. + * @see RtcEngine.setRemoteSubscribeFallbackOption + * Note + * - The Agora SDK supports setting userPriority as high for one user only. + * @param uid The ID of the remote user. + * @param userPriority The priority of the remote user. + * @see UserPriority + */ setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise { return AgoraRtcEngineModule.setRemoteUserPriority(uid, userPriority); } + /** + * Disables the network connection quality test. + */ disableLastmileTest(): Promise { return AgoraRtcEngineModule.disableLastmileTest(); } + /** + * Enables the network connection quality test. + * This method tests the quality of the users' network connections and is disabled by default. + * Before users join a channel or before an audience switches to a host, call this method to check the uplink network quality. This method consumes additional network traffic, which may affect the communication quality. Call the disableLastmileTest method to disable this test after receiving the onLastmileQuality callback, and before the user joins a channel or switches the user role. + * @see RtcEngine.disableLastmileTest + * @see RtcEngineEvents.LastmileQuality + * Note + * - Do not use this method with the startLastmileProbeTest method. + * @see RtcEngine.startLastmileProbeTest + * - Do not call any other methods before receiving the onLastmileQuality callback. Otherwise, the callback may be interrupted by other methods and may not execute. + * @see RtcEngineEvents.LastmileQuality + * - In the Live Broadcast profile, a host should not call this method after joining a channel. + * - If you call this method to test the last-mile quality, the SDK consumes the bandwidth of a video stream, whose bitrate corresponds to the bitrate you set in the setVideoEncoderConfiguration method. After you join the channel, whether you have called the disableLastmileTest method or not, the SDK automatically stops consuming the bandwidth. + * @see RtcEngine.setVideoEncoderConfiguration + * @see RtcEngine.disableLastmileTest + */ enableLastmileTest(): Promise { return AgoraRtcEngineModule.enableLastmileTest(); } + /** + * Starts an audio call test. + * In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly. + * Note + * - Call this method before joining a channel. + * - After calling this method, call the stopEchoTest method to end the test. Otherwise, the app cannot run the next echo test, or call the joinChannel method. + * @see RtcEngine.stopEchoTest + * @see RtcEngine.joinChannel + * - In the Live Broadcast profile, only a host can call this method. + * @param intervalInSeconds The time interval (s) between when you speak and when the recording plays back. + */ startEchoTest(intervalInSeconds: number): Promise { return AgoraRtcEngineModule.startEchoTest(intervalInSeconds); } + /** + * Starts the last-mile network probe test before joining a channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT). + * Once this method is enabled, the SDK returns the following callbacks: + * - onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience. + * @see RtcEngineEvents.LastmileQuality + * - onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective. + * @see RtcEngineEvents.LastmileProbeResult + * Call this method to check the uplink network quality before users join a channel or before an audience switches to a host. + * Note + * - This method consumes extra network traffic and may affect communication quality. We do not recommend calling this method together with enableLastmileTest. + * @see RtcEngine.enableLastmileTest + * - Do not call other methods before receiving the onLastmileQuality and onLastmileProbeResult callbacks. Otherwise, the callbacks may be interrupted by other methods. + * - In the Live Broadcast profile, a host should not call this method after joining a channel. + * @see ChannelProfile.LiveBroadcasting + * @param config The configurations of the last-mile network probe test. + * @see LastmileProbeConfig + */ startLastmileProbeTest(config: LastmileProbeConfig): Promise { return AgoraRtcEngineModule.startLastmileProbeTest(config); } + /** + * Stops the audio call test. + */ stopEchoTest(): Promise { return AgoraRtcEngineModule.stopEchoTest(); } + /** + * Stops the last-mile network probe test. + */ stopLastmileProbeTest(): Promise { return AgoraRtcEngineModule.stopLastmileProbeTest(); } + /** + * Registers the metadata observer. + * This method enables you to add synchronized metadata in the video stream for more diversified live broadcast interactions, such as sending shopping links, digital coupons, and online quizzes. + * Note + * - Call this method before the joinChannel method. + * @see RtcEngine.joinChannel + */ registerMediaMetadataObserver(): Promise { return AgoraRtcEngineModule.registerMediaMetadataObserver(); } @@ -728,1405 +1566,640 @@ export default class RtcEngine implements RtcUserInfoInterface, RtcAudioInterfac return AgoraRtcEngineModule.unregisterMediaMetadataObserver(); } + /** + * Adds a watermark image to the local video. + * This method adds a PNG watermark image to the local video stream in a live broadcast. Once the watermark image is added, all the audience in the channel (CDN audience included), and the recording device can see and capture it. + * Agora supports adding only one watermark image onto the local video, and the newly watermark image replaces the previous one. + * The watermark position depends on the settings in the setVideoEncoderConfiguration method: + * @see RtcEngine.setVideoEncoderConfiguration + * - If the orientation mode of the encoding video is FixedLandscape, or the landscape mode in Adaptative, the watermark uses the landscape orientation. + * @see VideoOutputOrientationMode.FixedLandscape + * @see VideoOutputOrientationMode.Adaptative + * - If the orientation mode of the encoding video is FixedPortrait, or the portrait mode in Adaptative, the watermark uses the portrait orientation. + * @see VideoOutputOrientationMode.FixedPortrait + * @see VideoOutputOrientationMode.Adaptative + * - When setting the watermark position, the region must be less than the dimensions set in the setVideoEncoderConfiguration method. Otherwise, the watermark image will be cropped. + * Note + * - Ensure that you have called the enableVideo method to enable the video module before calling this method. + * @see RtcEngine.enableVideo + * - If you only want to add a watermark image to the local video for the audience in the CDN live broadcast channel to see and capture, you can call this method or the setLiveTranscoding method. + * @see RtcEngine.setLiveTranscoding + * - This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray. + * - If the dimensions the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings. + * - If you have enabled the local video preview by calling the startPreview method, you can use the visibleInPreview member in the WatermarkOptions class to set whether or not the watermark is visible in preview. + * - If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer. + * @param watermarkUrl The local file path of the watermark image to be added. This method supports adding a watermark image from either the local file path or the assets file path. If you use the assets file path, you need to start with /assets/ when filling in this parameter. + * @param options The options of the watermark image to be added. + * @see WatermarkOptions + */ addVideoWatermark(watermarkUrl: string, options: WatermarkOptions): Promise { return AgoraRtcEngineModule.addVideoWatermark(watermarkUrl, options); } + /** + * Removes the watermark image from the video stream added by addVideoWatermark. + * @see RtcEngine.addVideoWatermark + */ clearVideoWatermarks(): Promise { return AgoraRtcEngineModule.clearVideoWatermarks(); } + /** + * Sets the built-in encryption mode. + * The Agora SDK supports built-in encryption, which is set to aes-128-xts mode by default. Call this method to set the encryption mode to use other encryption modes. All users in the same channel must use the same encryption mode and password. + * Refer to the information related to the AES encryption algorithm on the differences between the encryption modes. + * Note + * - Call the setEncryptionSecret method before calling this method. + * @see RtcEngine.setEncryptionSecret + * @param encryptionMode Sets the encryption mode. + * @see EncryptionMode + */ setEncryptionMode(encryptionMode: EncryptionMode): Promise { return AgoraRtcEngineModule.setEncryptionMode(encryptionMode); } + /** + * Enables built-in encryption with an encryption password before joining a channel. + * All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled. + * Note + * - For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption. + * - Do not use this method for CDN live streaming. + * @param secret The encryption password. + */ setEncryptionSecret(secret: string): Promise { return AgoraRtcEngineModule.setEncryptionSecret(secret); } + /** + * Starts an audio recording on the client. + * The SDK allows recording during a call. After successfully calling this method, you can record the audio of all the users in the channel and get an audio recording file. + * Supported formats of the recording file are as follows: + * - .wav: Large file size with high fidelity. + * - .aac: Small file size with low fidelity. + * Note + * - Ensure that the directory to save the recording file exists and is writable. + * - This method is usually called after calling the joinChannel method. The recording automatically stops when you call the leaveChannel method. + * @see RtcEngine.joinChannel + * @see RtcEngine.leaveChannel + * - For better recording effects, set quality as AUDIO_RECORDING_QUALITY_MEDIUM or AUDIO_RECORDING_QUALITY_HIGH when sampleRate is 44.1 kHz or 48 kHz. + * @see AudioRecordingQuality.Medium + * @see AudioRecordingQuality.High + * @param filePath Absolute file path (including the suffixes of the filename) of the recording file. The string of the file name is in UTF-8. For example, /sdcard/emulated/0/audio/aac. + * @param sampleRate Sample rate (Hz) of the recording file. Supported values are as follows. + * @see AudioSampleRateType + * @param quality The audio recording quality. + * @see AudioRecordingQuality + */ startAudioRecording(filePath: string, sampleRate: AudioSampleRateType, quality: AudioRecordingQuality): Promise { return AgoraRtcEngineModule.startAudioRecording(filePath, sampleRate, quality); } + /** + * Stops the audio recording on the client. + * Note + * - You can call this method before calling the leaveChannel method; else, the recording automatically stops when you call the leaveChannel method. + * @see RtcEngine.leaveChannel + */ stopAudioRecording(): Promise { return AgoraRtcEngineModule.stopAudioRecording(); } + /** + * Injects an online media stream to a live broadcast. + * If this method call is successful, the server pulls the voice or video stream and injects it into a live channel. This is applicable to scenarios where all audience members in the channel can watch a live show and interact with each other. + * Note + * - This method applies to the Live-Broadcast profile only. + * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. + * - You can inject only one media stream into the channel at the same time. + * The addInjectStreamUrl method call triggers the following callbacks: + * - The local client: + * -- onStreamInjectedStatus, with the state of the injecting the online stream. + * @see RtcEngineEvents.StreamInjectedStatus + * -- onUserJoined(uid: 666), if the method call is successful and the online media stream is injected into the channel. + * @see RtcEngineEvents.UserJoined + * - The remote client: + * -- onUserJoined(uid: 666), if the method call is successful and the online media stream is injected into the channel. + * @see RtcEngineEvents.UserJoined + * @param url The URL address to be added to the ongoing live broadcast. Valid protocols are RTMP, HLS, and HTTP-FLV. + * - Supported audio codec type: AAC. + * - Supported video codec type: H264(AVC). + * @param config The LiveInjectStreamConfig object which contains the configuration information for the added voice or video stream. + * @see LiveInjectStreamConfig + */ addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise { return AgoraRtcEngineModule.addInjectStreamUrl(url, config); } + /** + * Removes the injected online media stream from a live broadcast. + * This method removes the URL address (added by addInjectStreamUrl) from a live broadcast. + * @see RtcEngine.addInjectStreamUrl + * If this method call is successful, the SDK triggers the onUserOffline callback and returns a stream uid of 666. + * @see RtcEngineEvents.UserOffline + * @param url HTTP/HTTPS URL address of the added stream to be removed. + */ removeInjectStreamUrl(url: string): Promise { return AgoraRtcEngineModule.removeInjectStreamUrl(url); } + /** + * Enables/Disables face detection for the local user. + * Once face detection is enabled, the SDK triggers the onFacePositionChanged callback to report the face information of the local user, which includes the following aspects: + * @see RtcEngineEvents.FacePositionChanged + * - The width and height of the local video. + * - The position of the human face in the local video. + * - The distance between the human face and the device screen. + * @param enable Determines whether to enable the face detection function for the local user: + * - true: Enable face detection. + * - false: (Default) Disable face detection. + */ enableFaceDetection(enable: boolean): Promise { return AgoraRtcEngineModule.enableFaceDetection(enable) } + /** + * Gets the maximum zoom ratio supported by the camera. + */ getCameraMaxZoomFactor(): Promise { return AgoraRtcEngineModule.getCameraMaxZoomFactor(); } + /** + * Checks whether the camera auto-face focus function is supported. + */ isCameraAutoFocusFaceModeSupported(): Promise { return AgoraRtcEngineModule.isCameraAutoFocusFaceModeSupported(); } + /** + * Checks whether the camera exposure function is supported. + */ isCameraExposurePositionSupported(): Promise { return AgoraRtcEngineModule.isCameraExposurePositionSupported(); } + /** + * Checks whether the camera manual focus function is supported. + */ isCameraFocusSupported(): Promise { return AgoraRtcEngineModule.isCameraFocusSupported(); } + /** + * Checks whether the camera flash function is supported. + */ isCameraTorchSupported(): Promise { return AgoraRtcEngineModule.isCameraTorchSupported(); } + /** + * Checks whether the camera zoom function is supported. + */ isCameraZoomSupported(): Promise { return AgoraRtcEngineModule.isCameraZoomSupported(); } + /** + * Enables the camera auto-face focus function. + * @param enabled Sets whether to enable/disable the camera auto-face focus function: + * - true: Enable the camera auto-face focus function. + * - false: (Default) Disable the camera auto-face focus function. + */ setCameraAutoFocusFaceModeEnabled(enabled: boolean): Promise { return AgoraRtcEngineModule.setCameraAutoFocusFaceModeEnabled(enabled); } + /** + * Sets the camera capturer configuration. + * For a video call or live broadcast, generally the SDK controls the camera output parameters. When the default camera capture settings do not meet special requirements or cause performance problems, we recommend using this method to set the camera capturer configuration: + * - If the resolution or frame rate of the captured raw video data are higher than those set by setVideoEncoderConfiguration, processing video frames requires extra CPU and RAM usage and degrades performance. We recommend setting config as Performance(1) to avoid such problems. + * @see RtcEngine.setVideoEncoderConfiguration + * @see CameraCaptureOutputPreference.Performance + * - If you do not need local video preview or are willing to sacrifice preview quality, we recommend setting config as Performance(1) to optimize CPU and RAM usage. + * @see CameraCaptureOutputPreference.Performance + * - If you want better quality for the local video preview, we recommend setting config as Preview(2). + * @see CameraCaptureOutputPreference.Preview + * Note + * - Call this method before enabling the local camera. That said, you can call this method before calling joinChannel, enableVideo, or enableLocalVideo, depending on which method you use to turn on your local camera. + * @see RtcEngine.joinChannel + * @see RtcEngine.enableVideo + * @see RtcEngine.enableLocalVideo + * @param config The camera capturer configuration. + * @see CameraCapturerConfiguration + */ setCameraCapturerConfiguration(config: CameraCapturerConfiguration): Promise { return AgoraRtcEngineModule.setCameraCapturerConfiguration(config); } - setCameraExposurePosition(positionXinView: number, positionYinView: number): Promise { - return AgoraRtcEngineModule.setCameraExposurePosition(positionXinView, positionYinView); - } - - setCameraFocusPositionInPreview(positionX: number, positionY: number): Promise { + /** + * Sets the camera exposure position. + * A successful setCameraExposurePosition method call triggers the onCameraExposureAreaChanged callback on the local client. + * @see RtcEngineEvents.CameraExposureAreaChanged + * @param positionXinView The horizontal coordinate of the touch point in the view. + * @param positionYinView The vertical coordinate of the touch point in the view. + */ + setCameraExposurePosition(positionXinView: number, positionYinView: number): Promise { + return AgoraRtcEngineModule.setCameraExposurePosition(positionXinView, positionYinView); + } + + /** + * Sets the camera manual focus position. + * A successful setCameraFocusPositionInPreview method call triggers the onCameraFocusAreaChanged callback on the local client. + * @see RtcEngineEvents.CameraFocusAreaChanged + * @param positionX The horizontal coordinate of the touch point in the view. + * @param positionY The vertical coordinate of the touch point in the view. + */ + setCameraFocusPositionInPreview(positionX: number, positionY: number): Promise { return AgoraRtcEngineModule.setCameraFocusPositionInPreview(positionX, positionY); } + /** + * Enables the camera flash function. + * @param isOn Sets whether to enable/disable the camera flash function: + * - true: Enable the camera flash function. + * - false: Disable the camera flash function. + */ setCameraTorchOn(isOn: boolean): Promise { return AgoraRtcEngineModule.setCameraTorchOn(isOn); } + /** + * Sets the camera zoom ratio. + * @param factor Sets the camera zoom factor. The value ranges between 1.0 and the maximum zoom supported by the device. + */ setCameraZoomFactor(factor: number): Promise { return AgoraRtcEngineModule.setCameraZoomFactor(factor); } + /** + * Switches between front and rear cameras. + */ switchCamera(): Promise { return AgoraRtcEngineModule.switchCamera(); } + /** + * Creates a data stream. + * Each user can create up to five data streams during the lifecycle of the RtcEngine. + * @see RtcEngine + * Note + * - Set both the reliable and ordered parameters to true or false. Do not set one as true and the other as false. + * @param reliable Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds: + * - true: The recipients receive the data from the sender within five seconds. If the recipient does not receive the data within five seconds, the SDK triggers the onStreamMessageError callback and returns an error code. + * @see RtcEngineEvents.StreamMessageError + * - false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream. + * @param ordered Sets whether or not the recipients receive the data stream in the sent order: + * - true: The recipients receive the data in the sent order. + * - false: The recipients do not receive the data in the sent order. + */ createDataStream(reliable: boolean, ordered: boolean): Promise { return AgoraRtcEngineModule.createDataStream(reliable, ordered); } + /** + * Sends data stream messages. + * The SDK has the following restrictions on this method: + * - Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 kB. + * - Each client can send up to 6 kB of data per second. + * - Each user can have up to five data channels simultaneously. + * A successful sendStreamMessage method call triggers the onStreamMessage callback on the remote client, from which the remote user gets the stream message. + * @see RtcEngineEvents.StreamMessage + * A failed sendStreamMessage method call triggers the onStreamMessageError callback on the remote client. + * @see RtcEngineEvents.StreamMessageError + * Note + * - Ensure that you have created the data stream using createDataStream before calling this method. + * @see RtcEngine.createDataStream + * - This method applies only to the Communication profile or to hosts in the Live Broadcast profile. + * @param streamId ID of the sent data stream returned by the createDataStream method. + * @see RtcEngine.createDataStream + * @param message Sent data. + */ sendStreamMessage(streamId: number, message: string): Promise { return AgoraRtcEngineModule.sendStreamMessage(streamId, message); } } +/** + * @ignore + */ interface RtcUserInfoInterface { - /** - * Registers a user account. - * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the onLocalUserRegistered callback on the local client, reporting the user ID and user account of the local user. - * @see RtcEngineEvents.LocalUserRegistered - * To join a channel with a user account, you can choose either of the following: - * - Call the registerLocalUserAccount method to create a user account, and then the joinChannelWithUserAccount method to join the channel. - * @see RtcEngine.registerLocalUserAccount - * - Call the joinChannelWithUserAccount method to join the channel. - * @see RtcEngine.joinChannelWithUserAccount - * The difference between the two is that for the former, the time elapsed between calling the joinChannelWithUserAccount method and joining the channel is shorter than the latter. - * Note - * - Ensure that you set the userAccount parameter. Otherwise, this method does not take effect. - * - Ensure that the value of the userAccount parameter is unique in the channel. - * - To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * @param appId The App ID of your project. - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - */ registerLocalUserAccount(appId: string, userAccount: string): Promise; - /** - * Joins the channel with a user account. - * After the user successfully joins the channel, the SDK triggers the following callbacks: - * - The local client: onLocalUserRegistered and onJoinChannelSuccess. - * @see RtcEngineEvents.LocalUserRegistered - * @see RtcEngineEvents.JoinChannelSuccess - * - The remote client: onUserJoined and onUserInfoUpdated, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile. - * @see RtcEngineEvents.UserJoined - * @see RtcEngineEvents.UserInfoUpdated - * Note - * - To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type. - * @param token The token generated at your server: - * - In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token. - * - In situations requiring high security: Set it as the token generated at your server. For details, see Generate a token. - * @param channelName The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - * @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",". - */ - joinChannelWithUserAccount(token: String, channelName: string, userAccount: string): Promise; + joinChannelWithUserAccount(token: string, channelName: string, userAccount: string): Promise; - /** - * Gets the user information by passing in the user account. - * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the onUserInfoUpdated callback on the local client. - * @see UserInfo - * @see RtcEngineEvents.UserInfoUpdated - * After receiving the onUserInfoUpdated callback, you can call this method to get the user ID of the remote user from the userInfo object by passing in the user account. - * @param userAccount The user account of the user. Ensure that you set this parameter. - */ getUserInfoByUserAccount(userAccount: string): Promise; - /** - * Gets the user information by passing in the user ID. - * After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers the onUserInfoUpdated callback on the local client. - * @see UserInfo - * @see RtcEngineEvents.UserInfoUpdated - * After receiving the onUserInfoUpdated callback, you can call this method to get the user ID of the remote user from the userInfo object by passing in the user account. - * @param uid The user ID of the user. Ensure that you set this parameter. - */ getUserInfoByUid(uid: number): Promise; } +/** + * @ignore + */ interface RtcAudioInterface { - /** - * Enables the audio module. - * The audio module is enabled by default. - * Note - * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. - * @see RtcEngine.leaveChannel - * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the audio engine modules separately: - * -- enableLocalAudio: Whether to enable the microphone to create the local audio stream. - * @see RtcEngine.enableLocalAudio - * -- muteLocalAudioStream: Whether to publish the local audio stream. - * @see RtcEngine.muteLocalAudioStream - * -- muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream. - * @see RtcEngine.muteRemoteAudioStream - * -- muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams. - * @see RtcEngine.muteAllRemoteAudioStreams - */ enableAudio(): Promise; - /** - * Disables the audio module. - * Note - * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. - * @see RtcEngine.leaveChannel - * - This method resets the engine and takes some time to take effect. We recommend using the following API methods to control the audio engine modules separately: - * -- enableLocalAudio: Whether to enable the microphone to create the local audio stream. - * @see RtcEngine.enableLocalAudio - * -- muteLocalAudioStream: Whether to publish the local audio stream. - * @see RtcEngine.muteLocalAudioStream - * -- muteRemoteAudioStream: Whether to subscribe to and play the remote audio stream. - * @see RtcEngine.muteRemoteAudioStream - * -- muteAllRemoteAudioStreams: Whether to subscribe to and play all remote audio streams. - * @see RtcEngine.muteAllRemoteAudioStreams - */ disableAudio(): Promise; - /** - * Sets the audio parameters and application scenarios. - * Note - * - You must call this method before calling the joinChannel method. - * @see RtcEngine.joinChannel - * - In the Communication and Live Broadcast profiles, the bitrates may be different from your settings due to network self-adaptation. - * - In scenarios requiring high-quality audio, we recommend setting profile as ShowRoom(4) and scenario as GameStreaming(3). For example, for music education scenarios. - * @see AudioScenario.ShowRoom - * @see AudioScenario.GameStreaming - * @param profile Sets the sample rate, bitrate, encoding mode, and the number of channels. - * @see AudioProfile - * @param scenario Sets the audio application scenarios. Under different audio scenarios, the device uses different volume tracks, i.e. either the in-call volume or the media volume. - * @see AudioScenario - */ setAudioProfile(profile: AudioProfile, scenario: AudioScenario): Promise; - /** - * Adjusts the recording volume. - * Note - * - To avoid echoes and improve call quality, Agora recommends setting the value of volume between 0 and 100. If you need to set the value higher than 100, contact support@agora.io first. - * @param volume Recording volume. The value ranges between 0 and 400: - * - 0: Mute. - * - 100: Original volume. - * - 400: (Maximum) Four times the original volume with signal-clipping protection. - */ adjustRecordingSignalVolume(volume: number): Promise; - /** - * Adjusts the playback volume of a specified remote user. - * You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user. - * Note - * - Call this method after joining a channel. - * - The playback volume here refers to the mixed volume of a specified remote user. - * - This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user. - * @param uid ID of the remote user. - * @param volume The playback volume of the specified remote user. The value ranges from 0 to 100: - * - 0: Mute. - * - 100: The original volume. - */ adjustUserPlaybackSignalVolume(uid: number, volume: number): Promise; - /** - * Adjusts the playback volume of all remote users. - * Note - * - This method adjusts the playback volume which is mixed volume of all remote users. - * - To mute the local audio playback, call both adjustPlaybackSignalVolume and adjustAudioMixingVolume, and set volume as 0. - * @see RtcEngine.adjustPlaybackSignalVolume - * @see RtcEngine.adjustAudioMixingVolume - * - To avoid echoes and improve call quality, Agora recommends setting the value of volume between 0 and 100. If you need to set the value higher than 100, contact support@agora.io first. - * @param volume The playback volume of all remote users. The value ranges from 0 to 400: - * - 0: Mute. - * - 100: The original volume. - * - 400: (Maximum) Four times the original volume with signal clipping protection. - */ adjustPlaybackSignalVolume(volume: number): Promise; - /** - * Enables/Disables the local audio capture. - * The audio function is enabled by default. This method disables/re-enables the local audio function, that is, to stop or restart local audio capture and processing. - * This method does not affect receiving or playing the remote audio streams, and enableLocalAudio(false) is applicable to scenarios where the user wants to receive remote audio streams without sending any audio stream to other users in the channel. - * The SDK triggers the onMicrophoneEnabled callback once the local audio function is disabled or re-enabled. - * @see RtcEngineEvents.MicrophoneEnabled - * Note - * - This method is different from the muteLocalAudioStream method: - * -- enableLocalAudio: Disables/Re-enables the local audio capture and processing. If you disable or re-enable local audio recording using the enableLocalAudio method, the local user may hear a pause in the remote audio playback. - * @see RtcEngine.enableLocalAudio - * -- muteLocalAudioStream: Stops/Continues sending the local audio streams. - * @see RtcEngine.muteLocalAudioStream - * @param enabled Sets whether to disable/re-enable the local audio function: - * - true: (Default) Re-enable the local audio function, that is, to start local audio capture and processing. - * - false: Disable the local audio function, that is, to stop local audio capture and processing. - */ enableLocalAudio(enabled: boolean): Promise; - /** - * Stops/Resumes sending the local audio stream. - * A successful muteLocalAudioStream method call triggers the onUserMuteAudio callback on the remote client. - * @see RtcEngineEvents.UserMuteAudio - * Note - * - When muted is set as true, this method does not disable the microphone and thus does not affect any ongoing recording. - * - If you call setChannelProfile after this method, the SDK resets whether or not to mute the local audio according to the channel profile and user role. Therefore, we recommend calling this method after the setChannelProfile method. - * @see RtcEngine.setChannelProfile - * @param muted Sets whether to send/stop sending the local audio stream: - * - true: Stop sending the local audio stream. - * - false: (Default) Send the local audio stream. - */ muteLocalAudioStream(muted: boolean): Promise; - /** - * Stops/Resumes receiving a specified audio stream. - * Note - * - If you called the muteAllRemoteAudioStreams method and set muted as true to stop receiving all remote video streams, ensure that the muteAllRemoteAudioStreams method is called and set muted as false before calling this method. The muteAllRemoteAudioStreams method sets all remote audio streams, while the muteRemoteAudioStream method sets a specified remote user's audio stream. - * @see RtcEngine.muteAllRemoteAudioStreams - * @param uid ID of the specified remote user. - * @param muted Sets whether to receive/stop receiving the specified remote user's audio stream: - * - true: Stop receiving the specified remote user’s audio stream. - * - false: (Default) Receive the specified remote user’s audio stream. - */ muteRemoteAudioStream(uid: number, muted: boolean): Promise; - /** - * Stops/Resumes receiving all remote audio streams. - * @param muted Sets whether to receive/stop receiving all remote audio streams: - * - true: Stop receiving all remote audio streams. - * - false: (Default) Receive all remote audio streams. - */ muteAllRemoteAudioStreams(muted: boolean): Promise; - /** - * Sets whether to receive all remote audio streams by default. - * You can call this method either before or after joining a channel. If you call setDefaultMuteAllRemoteAudioStreams(true) after joining a channel, you will not receive the audio streams of any subsequent user. - * Note - * - If you want to resume receiving audio streams, call muteRemoteAudioStream(false), and specify the ID of the remote user that you want to subscribe to. To resume audio streams of multiple users, call muteRemoteAudioStream as many times. Calling setDefaultMuteAllRemoteAudioStreams(false) resumes receiving audio streams of the subsequent users only. - * @see RtcEngine.muteRemoteAudioStream - * @param muted Sets whether or not to receive/stop receiving the remote audio streams by default: - * - true: Stop receiving any audio stream by default. - * - false: (Default) Receive all remote audio streams by default. - */ setDefaultMuteAllRemoteAudioStreams(muted: boolean): Promise; - /** - * Enables the onAudioVolumeIndication callback at a set time interval to report on which users are speaking and the speakers' volume. - * @see RtcEngineEvents.AudioVolumeIndication - * Once this method is enabled, the SDK returns the volume indication in the onAudioVolumeIndication callback at the set time interval, regardless of whether any user is speaking in the channel. - * @param interval Sets the time interval between two consecutive volume indications: - * - ≤ 0: Disables the volume indication. - * - > 0: Time interval (ms) between two consecutive volume indications. We recommend setting interval ≥ 200 ms. - * @param smooth The smoothing factor sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The greater the value, the more sensitive the indicator. The recommended value is 3. - * @param report_vad - * - true: Enable the voice activity detection of the local user. Once it is enabled, the vad parameter of the onAudioVolumeIndication callback reports the voice activity status of the local user. - * - false: (Default) Disable the voice activity detection of the local user. Once it is enabled, the vad parameter of the onAudioVolumeIndication callback does not report the voice activity status of the local user, except for scenarios where the engine automatically detects the voice activity of the local user. - */ enableAudioVolumeIndication(interval: number, smooth: number, report_vad: boolean): Promise; } +/** + * @ignore + */ interface RtcVideoInterface { - /** - * Enables the video module. - * You can call this method either before joining a channel or during a call. If you call this method before joining a channel, the service starts in the video mode. If you call this method during an audio call, the audio mode switches to the video mode. - * A successful enableVideo method call triggers the onUserEnableVideo(true) callback on the remote client. - * @see RtcEngineEvents.UserEnableVideo - * To disable the video, call the disableVideo method. - * @see RtcEngine.disableVideo - * Note - * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. - * @see RtcEngine.leaveChannel - * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately: - * -- enableLocalVideo: Whether to enable the camera to create the local video stream. - * @see RtcEngine.enableLocalVideo - * -- muteLocalVideoStream: Whether to publish the local video stream. - * @see RtcEngine.muteLocalVideoStream - * -- muteRemoteVideoStream: Whether to subscribe to and play the remote video stream. - * @see RtcEngine.muteRemoteVideoStream - * -- muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams. - * @see RtcEngine.muteAllRemoteVideoStreams - */ enableVideo(): Promise; - /** - * Disables the video module. - * You can call this method before joining a channel or during a call. If you call this method before joining a channel, the service starts in audio mode. If you call this method during a video call, the video mode switches to the audio mode. - * - A successful disableVideo method call triggers the onUserEnableVideo(false) callback on the remote client. - * @see RtcEngineEvents.UserEnableVideo - * - To enable the video mode, call the enableVideo method. - * @see RtcEngine.enableVideo - * Note - * - This method affects the internal engine and can be called after calling the leaveChannel method. You can call this method either before or after joining a channel. - * @see RtcEngine.leaveChannel - * - This method resets the internal engine and takes some time to take effect. We recommend using the following API methods to control the video engine modules separately: - * -- enableLocalVideo: Whether to enable the camera to create the local video stream. - * @see RtcEngine.enableLocalVideo - * -- muteLocalVideoStream: Whether to publish the local video stream. - * @see RtcEngine.muteLocalVideoStream - * -- muteRemoteVideoStream: Whether to subscribe to and play the remote video stream. - * @see RtcEngine.muteRemoteVideoStream - * -- muteAllRemoteVideoStreams: Whether to subscribe to and play all remote video streams. - * @see RtcEngine.muteAllRemoteVideoStreams - */ disableVideo(): Promise; - /** - * Sets the video encoder configuration. - * Each video encoder configuration corresponds to a set of video parameters, including the resolution, frame rate, bitrate, and video orientation. The parameters specified in this method are the maximum values under ideal network conditions. If the video engine cannot render the video using the specified parameters due to poor network conditions, the parameters further down the list are considered until a successful configuration is found. - * If you do not set the video encoder configuration after joining the channel, you can call this method before calling the enableVideo method to reduce the render time of the first video frame. - * @see RtcEngine.enableVideo - * @param config The local video encoder configuration. - * @see VideoEncoderConfiguration - */ setVideoEncoderConfiguration(config: VideoEncoderConfiguration): Promise; - /** - * Starts the local video preview before joining a channel. - * Before calling this method, you must: - * - Create the RtcLocalView. - * @see RtcLocalView - * - Call the enableVideo method to enable the video. - * @see RtcEngine.enableVideo - * Note - * - By default, the local preview enables the mirror mode. - * - Once you call this method to start the local video preview, if you leave the channel by calling the leaveChannel method, the local video preview remains until you call the stopPreview method to disable it. - * @see RtcEngine.leaveChannel - * @see RtcEngine.stopPreview - */ startPreview(): Promise; - /** - * Stops the local video preview and the video. - */ stopPreview(): Promise; - /** - * Disables/Re-enables the local video capture. - * This method disables or re-enables the local video capturer, and does not affect receiving the remote video stream. - * After you call the enableVideo method, the local video capturer is enabled by default. You can call enableLocalVideo(false) to disable the local video capturer. If you want to re-enable it, call enableLocalVideo(true). - * @see RtcEngine.enableVideo - * After the local video capturer is successfully disabled or re-enabled, the SDK triggers the onUserEnableLocalVideo callback on the remote client. - * @see RtcEngineEvents.UserEnableLocalVideo - * Note - * - This method affects the internal engine and can be called after calling the leaveChannel method. - * @param enabled Sets whether to disable/re-enable the local video, including the capturer, renderer, and sender: - * - true: (Default) Re-enable the local video. - * - false: Disable the local video. Once the local video is disabled, the remote users can no longer receive the video stream of this user, while this user can still receive the video streams of other remote users. When you set enabled as false, this method does not require a local camera. - */ enableLocalVideo(enabled: boolean): Promise; - /** - * Stops/Resumes sending the local video stream. - * A successful muteLocalVideoStream method call triggers the onUserMuteVideo callback on the remote client. - * @see RtcEngineEvents.UserMuteVideo - * Note - * - When you set muted as true, this method does not disable the camera and thus does not affect the retrieval of the local video streams. This method responds faster than calling the enableLocalVideo method and set muted as false, which controls sending the local video stream. - * @see RtcEngine.enableLocalVideo - * - If you call setChannelProfile after this method, the SDK resets whether or not to mute the local video according to the channel profile and user role. Therefore, we recommend calling this method after the setChannelProfile method. - * @see RtcEngine.setChannelProfile - * @param muted Sets whether to send/stop sending the local video stream: - * - true: Stop sending the local video stream. - * - false: (Default) Send the local video stream. - */ muteLocalVideoStream(muted: boolean): Promise; - /** - * Stops/Resumes receiving a specified remote user's video stream. - * Note - * - If you call the muteAllRemoteVideoStreams method and set set muted as true to stop receiving all remote video streams, ensure that the muteAllRemoteVideoStreams method is called and set muted as false before calling this method. The muteAllRemoteVideoStreams method sets all remote streams, while this method sets a specified remote user's stream. - * @see RtcEngine.muteAllRemoteVideoStreams - * @param uid User ID of the specified remote user. - * @param muted Sets whether to receive/stop receiving a specified remote user's video stream: - * - true: Stop receiving a specified remote user’s video stream. - * - false: (Default) Receive a specified remote user’s video stream. - */ muteRemoteVideoStream(uid: number, muted: boolean): Promise; - /** - * Stops/Resumes receiving all remote video streams. - * @param muted Sets whether to receive/stop receiving all remote video streams: - * - true: Stop receiving all remote video streams. - * - false: (Default) Receive all remote video streams. - */ muteAllRemoteVideoStreams(muted: boolean): Promise; - /** - * Sets whether to receive all remote video streams by default. - * You can call this method either before or after joining a channel. If you call setDefaultMuteAllRemoteVideoStreams(true) after joining a channel, you will not receive the video stream of any subsequent user. - * Note - * - If you want to resume receiving video streams, call muteRemoteVideoStream(false), and specify the ID of the remote user that you want to subscribe to. To resume receiving video streams of multiple users, call muteRemoteVideoStream as many times. Calling setDefaultMuteAllRemoteVideoStreams(false) resumes receiving video streams of the subsequent users only. - * @see RtcEngine.muteRemoteVideoStream - * @param muted Sets whether to receive/stop receiving all remote video streams by default: - * - true: Stop receiving any remote video stream by default. - * - false: (Default) Receive all remote video streams by default. - */ setDefaultMuteAllRemoteVideoStreams(muted: boolean): Promise; - /** - * Enables/Disables image enhancement and sets the options. - * Note - * - Call this method after calling enableVideo. - * - This method applies to Android 4.4 or later. - * @param enabled Sets whether or not to enable image enhancement: - * - enables image enhancement. - * - disables image enhancement. - * @param options The image enhancement options. - * @see BeautyOptions - */ setBeautyEffectOptions(enabled: boolean, options: BeautyOptions): Promise; } +/** + * @ignore + */ interface RtcAudioMixingInterface { - /** - * Starts playing and mixing the music file. - * This method mixes the specified local or online audio file with the audio stream from the microphone, or replaces the microphone’s audio stream with the specified local or remote audio file. You can choose whether the other user can hear the local audio playback and specify the number of playback loops. When the audio mixing file playback finishes after calling this method, the SDK triggers the onAudioMixingFinished callback. - * @see RtcEngineEvents.AudioMixingFinished - * A successful startAudioMixing method call triggers the onAudioMixingStateChanged(Playing) callback on the local client. - * @see RtcEngineEvents.AudioMixingStateChanged - * @see AudioMixingStateCode.Playing - * When the audio mixing file playback finishes, the SDK triggers the onAudioMixingStateChanged(Stopped) callback on the local client. - * @see RtcEngineEvents.AudioMixingStateChanged - * @see AudioMixingStateCode.Stopped - * Note - * - To use this method, ensure that the Android device is v4.2 or later, and the API version is v16 or later. - * - Call this method when you are in the channel, otherwise it may cause issues. - * - If you want to play an online music file, ensure that the time interval between calling this method is more than 100 ms, or the TooFrequentCall = 702 error occurs. - * @see AudioMixingErrorCode.TooFrequentCall - * - If you want to play an online music file, Agora does not recommend using the redirected URL address. Some Android devices may fail to open a redirected URL address. - * - If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns CanNotOpen = 701. - * @see AudioMixingErrorCode.CanNotOpen - * - If you call this method on an emulator, only the MP3 file format is supported. - * @param filePath Specifies the absolute path (including the suffixes of the filename) of the local or online audio file to be mixed. For example, /sdcard/emulated/0/audio.mp4. Supported audio formats: mp3, mp4, m4a, aac, 3gp, mkv, and wav. - * - If the path begins with /assets/, the audio file is in the /assets/ directory. - * - Otherwise, the audio file is in the absolute path. - * @param loopback Sets which user can hear the audio mixing: - * - true: Only the local user can hear the audio mixing. - * - false: Both users can hear the audio mixing. - * @param replace Sets the audio mixing content: - * - true: Only publish the specified audio file; the audio stream from the microphone is not published. - * - false: The local audio file is mixed with the audio stream from the microphone. - * @param cycle Sets the number of playback loops: - * - Positive integer: Number of playback loops - * - -1: Infinite playback loops - */ startAudioMixing(filePath: string, loopback: boolean, replace: boolean, cycle: number): Promise; - /** - * Stops playing or mixing the music file. - * Call this method when you are in a channel. - */ stopAudioMixing(): Promise; - /** - * Pauses playing and mixing the music file. - * Call this method when you are in a channel. - */ pauseAudioMixing(): Promise; - /** - * Resumes playing and mixing the music file. - * Call this method when you are in a channel. - */ resumeAudioMixing(): Promise; - /** - * Adjusts the volume of audio mixing. - * Call this method when you are in a channel. - * Note - * - Calling this method does not affect the volume of the audio effect file playback invoked by the playEffect method. - * @see RtcEngine.playEffect - * @param volume Audio mixing volume. The value ranges between 0 and 100 (default). - */ adjustAudioMixingVolume(volume: number): Promise; - /** - * Adjusts the volume of audio mixing for local playback. - * Call this method when you are in a channel. - * @param volume Audio mixing volume for local playback. The value ranges between 0 and 100 (default). - */ adjustAudioMixingPlayoutVolume(volume: number): Promise; - /** - * Adjusts the volume of audio mixing for publishing (sending to other users). - * Call this method when you are in a channel. - * @param volume Audio mixing volume for publishing. The value ranges between 0 and 100 (default). - */ adjustAudioMixingPublishVolume(volume: number): Promise; - /** - * Gets the audio mixing volume for local playback. - * This method helps troubleshoot audio volume related issues. - */ getAudioMixingPlayoutVolume(): Promise; - /** - * Gets the audio mixing volume for publishing. - * This method helps troubleshoot audio volume related issues. - */ getAudioMixingPublishVolume(): Promise; - /** - * Gets the duration (ms) of the music file. - * Call this method when you are in a channel. - */ getAudioMixingDuration(): Promise; - /** - * Gets the playback position (ms) of the music file. - * Call this method when you are in a channel. - */ getAudioMixingCurrentPosition(): Promise; - /** - * Sets the playback position (ms) of the music file to a different starting position (the default plays from the beginning). - * @param pos The playback starting position (ms) of the audio mixing file. - */ setAudioMixingPosition(pos: number): Promise; - /** - * Sets the pitch of the local music file. - * When a local music file is mixed with a local human voice, call this method to set the pitch of the local music file only. - * Note - * - Call this method after calling startAudioMixing. - * @see RtcEngine#startAudioMixing - * @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0, which means keep the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file. - */ setAudioMixingPitch(pitch: number): Promise; } +/** + * @ignore + */ interface RtcAudioEffectInterface { - /** - * Gets the volume of the audio effects. - * The value ranges between 0.0 and 100.0. - */ getEffectsVolume(): Promise; - /** - * Sets the volume of the audio effects. - * @param volume Volume of the audio effects. The value ranges between 0.0 and 100.0 (default). - */ setEffectsVolume(volume: number): Promise; - /** - * Sets the volume of a specified audio effect. - * @param soundId ID of the audio effect. Each audio effect has a unique ID. - * @param volume Volume of the audio effect. The value ranges between 0.0 and 100.0 (default). - */ setVolumeOfEffect(soundId: number, volume: number): Promise; - /** - * Plays a specified local or online audio effect file. - * With this method, you can set the loop count, pitch, pan, and gain of the audio effect file and whether the remote user can hear the audio effect. - * To play multiple audio effect files simultaneously, call this method multiple times with different soundIds and filePaths. We recommend playing no more than three audio effect files at the same time. - * When the audio effect file playback is finished, the SDK triggers the onAudioEffectFinished callback. - * @see RtcEngineEvents.AudioEffectFinished - * @param soundId ID of the specified audio effect. Each audio effect has a unique ID. If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method. - * @see RtcEngine.preloadEffect - * @param filePath The absolute file path (including the suffixes of the filename) of the audio effect file or the URL of the online audio effect file. For example, /sdcard/emulated/0/audio.mp4. Supported audio formats: mp3, mp4, m4a, aac. 3gp, mkv, and wav. - * @param loopCount Sets the number of times the audio effect loops: - * - 0: Plays the audio effect once. - * - 1: Plays the audio effect twice. - * - -1: Plays the audio effect in a loop indefinitely, until you call the stopEffect or stopAllEffects method. - * @see RtcEngine.stopEffect - * @see RtcEngine.stopAllEffects - * @param pitch Sets the pitch of the audio effect. The value ranges between 0.5 and 2. The default value is 1 (no change to the pitch). The lower the value, the lower the pitch. - * @param pan Sets the spatial position of the audio effect. The value ranges between -1.0 and 1.0. - * - 0.0: The audio effect shows ahead. - * - 1.0: The audio effect shows on the right. - * - -1.0: The audio effect shows on the left. - * @param gain Sets the volume of the audio effect. The value ranges between 0.0 and 100,0. The default value is 100.0. The lower the value, the lower the volume of the audio effect. - * @param publish Set whether or not to publish the specified audio effect to the remote stream: - * - true: The locally played audio effect is published to the Agora Cloud and the remote users can hear it. - * - false: The locally played audio effect is not published to the Agora Cloud and the remote users cannot hear it. - */ - playEffect(soundId: number, filePath: String, loopCount: number, pitch: number, pan: number, gain: number, publish: Boolean): Promise; + playEffect(soundId: number, filePath: string, loopCount: number, pitch: number, pan: number, gain: number, publish: Boolean): Promise; - /** - * Stops playing a specified audio effect. - * Note - * - If you preloaded the audio effect into the memory through the preloadEffect method, ensure that the soundID value is set to the same value as in the preloadEffect method. - * @see RtcEngine.preloadEffect - * @param soundId ID of the specified audio effect. Each audio effect has a unique ID. - */ stopEffect(soundId: number): Promise; - /** - * Stops playing all audio effects. - */ stopAllEffects(): Promise; - /** - * Preloads a specified audio effect file into the memory. - * Supported audio formats: mp3, aac, m4a, 3gp, wav. - * Note - * - This method does not support online audio effect files. - * Note - * - To ensure smooth communication, limit the size of the audio effect file. We recommend using this method to preload the audio effect before calling the joinChannel method. - * @see RtcEngine.joinChannel - * @param soundId ID of the audio effect. Each audio effect has a unique ID. - * @param filePath Absolute path of the audio effect file. - */ - preloadEffect(soundId: number, filePath: String): Promise; + preloadEffect(soundId: number, filePath: string): Promise; - /** - * Releases a specified preloaded audio effect from the memory. - * @param soundId ID of the audio effect. Each audio effect has a unique ID. - */ unloadEffect(soundId: number): Promise; - /** - * Pauses a specified audio effect. - * @param soundId ID of the audio effect. Each audio effect has a unique ID. - */ pauseEffect(soundId: number): Promise; - /** - * Pauses all audio effects. - */ pauseAllEffects(): Promise; - /** - * Resumes playing a specified audio effect. - * @param soundId ID of the audio effect. Each audio effect has a unique ID. - */ resumeEffect(soundId: number): Promise; - /** - * Resumes playing all audio effects. - */ resumeAllEffects(): Promise; } +/** + * @ignore + */ interface RtcVoiceChangerInterface { - /** - * Sets the local voice changer option. - * Note - * - Do not use this method together with setLocalVoiceReverbPreset, or the method called earlier does not take effect. - * @see RtcEngine.setLocalVoiceReverbPreset - * @param voiceChanger The local voice changer option. - * @see AudioVoiceChanger - */ setLocalVoiceChanger(voiceChanger: AudioVoiceChanger): Promise; - /** - * Sets the preset local voice reverberation effect - * Note - * - Do not use this method together with setLocalVoiceReverb. - * @see RtcEngine.setLocalVoiceReverb - * - Do not use this method together with setLocalVoiceChanger, or the method called eariler does not take effect. - * @see RtcEngine.setLocalVoiceChanger - * @param preset The local voice reverberation preset - * @see AudioReverbPreset - */ setLocalVoiceReverbPreset(preset: AudioReverbPreset): Promise; - /** - * Changes the voice pitch of the local speaker. - * @param pitch Sets the voice pitch. The value ranges between 0.5 and 2.0. The lower the value, the lower the voice pitch. The default value is 1.0 (no change to the local voice pitch). - */ setLocalVoicePitch(pitch: number): Promise; - /** - * Sets the local voice equalization effect. - * @param bandFrequency Sets the band frequency. The value ranges between 0 and 9; representing the respective 10-band center frequencies of the voice effects, including 31, 62, 125, 500, 1k, 2k, 4k, 8k, and 16k Hz. - * @see AudioEqualizationBandFrequency - * @param bandGain Sets the gain of each band (dB). The value ranges between -15 and 15. The default value is 0. - */ setLocalVoiceEqualization(bandFrequency: AudioEqualizationBandFrequency, bandGain: number): Promise; - /** - * Sets the local voice reverberation. - * Note - * - Adds the setLocalVoiceReverbPreset method, a more user-friendly method for setting the local voice reverberation. You can use this method to set the local reverberation effect, such as Popular, R&B, Rock, Hip-hop, and more. - * @see RtcEngine.setLocalVoiceReverbPreset - * @param reverbKey Sets the reverberation key. This method contains five reverberation keys. For details, see the description of each @ value. - * @see AudioReverbType - * @param value Sets the local voice reverberation value. - */ setLocalVoiceReverb(reverbKey: AudioReverbType, value: number): Promise; } +/** + * @ignore + */ interface RtcVoicePositionInterface { - /** - * Enables/Disables stereo panning for remote users. - * Ensure that you call this method before joinChannel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling setRemoteVoicePosition. - * @see RtcEngine.joinChannel - * @see RtcEngine.setRemoteVoicePosition - * @param enabled Sets whether or not to enable stereo panning for remote users: - * - true: enables stereo panning. - * - false: disables stereo panning. - */ enableSoundPositionIndication(enabled: boolean): Promise; - /** - * Sets the sound position of a remote user. - * When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. - * Note - * - For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel. - * @see RtcEngine.enableSoundPositionIndication - * - This method requires hardware support. For the best sound positioning, we recommend using a stereo headset. - * @param uid The ID of the remote user. - * @param pan The sound position of the remote user. The value ranges from -1.0 to 1.0: - * - 0.0: The remote sound comes from the front. - * - -1.0: The remote sound comes from the left. - * - 1.0: The remote sound comes from the right. - * @param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain. - */ setRemoteVoicePosition(uid: number, pan: number, gain: number): Promise; } +/** + * @ignore + */ interface RtcPublishStreamInterface { - /** - * Sets the video layout and audio settings for CDN live. - * The SDK triggers the onTranscodingUpdated callback when you call this method to update the LiveTranscodingclass. If you call this method to set the LiveTranscoding class for the first time, the SDK does not trigger the onTranscodingUpdated callback. - * @see RtcEngineEvents.TranscodingUpdated - * Note - * - Before calling the methods listed in this section: - * -- This method applies to Live Broadcast only. - * -- Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. - * -- Ensure that you call the setClientRole method and set the user role as the host. - * @see RtcEngine.setClientRole - * -- Ensure that you call the setLiveTranscoding method before calling the addPublishStreamUrl method. - * @see RtcEngine.addPublishStreamUrl - * @param transcoding Sets the CDN live audio/video transcoding settings. - * @see LiveTranscoding - */ setLiveTranscoding(transcoding: LiveTranscoding): Promise; - /** - * Publishes the local stream to the CDN. - * The addPublishStreamUrl method call triggers the onRtmpStreamingStateChanged callback on the local client to report the state of adding a local stream to the CDN. - * @see RtcEngineEvents.RtmpStreamingStateChanged - * Note - * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. - * - This method applies to Live Broadcast only. - * - Ensure that the user joins a channel before calling this method. - * - This method adds only one stream HTTP/HTTPS URL address each time it is called. - * @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. - * @param transcodingEnabled Sets whether transcoding is enabled/disabled. If you set this parameter as true, ensure that you call the setLiveTranscoding method before this method. - * @see RtcEngine.setLiveTranscoding - * - true: Enable transcoding. To transcode the audio or video streams when publishing them to CDN live, often used for combining the audio and video streams of multiple hosts in CDN live. - * - false: Disable transcoding. - */ addPublishStreamUrl(url: string, transcodingEnabled: boolean): Promise; - /** - * Removes an RTMP stream from the CDN. - * This method removes the RTMP URL address (added by addPublishStreamUrl) from a CDN live stream. The SDK reports the result of this method call in the onRtmpStreamingStateChanged callback. - * @see RtcEngine.addPublishStreamUrl - * @see RtcEngineEvents.RtmpStreamingStateChanged - * Note - * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. - * - Ensure that the user joins a channel before calling this method. - * - This method applies to Live Broadcast only. - * - This method removes only one stream RTMP URL address each time it is called. - * @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes. The URL address must not contain special characters, such as Chinese language characters. - */ removePublishStreamUrl(url: string): Promise; } +/** + * @ignore + */ interface RtcMediaRelayInterface { - /** - * Starts to relay media streams across channels. - * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks return the state and events of the media stream relay. - * @see RtcEngineEvents.ChannelMediaRelayStateChanged - * @see RtcEngineEvents.ChannelMediaRelayEvent - * - If the onChannelMediaRelayStateChanged callback returns Running(2) and None(0), and the onChannelMediaRelayEvent callback returns SentToDestinationChannel(4), the SDK starts relaying media streams between the original and the destination channel. - * @see ChannelMediaRelayState.Running - * @see ChannelMediaRelayError.None - * @see ChannelMediaRelayEvent.SentToDestinationChannel - * - If the onChannelMediaRelayStateChanged callback returns Failure(3), an exception occurs during the media stream relay. - * @see ChannelMediaRelayState.Failure - * Note - * - Contact sales-us@agora.io before implementing this function. - * - We do not support string user accounts in this API. - * - Call this method after the joinChannel method. - * @see RtcEngine.joinChannel - * - This method takes effect only when you are a broadcaster in a Live-broadcast channel. - * - After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay method to quit the current relay. - * @see RtcEngine.stopChannelMediaRelay - * @param channelMediaRelayConfiguration The configuration of the media stream relay. - * @see ChannelMediaRelayConfiguration - */ startChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; - /** - * Updates the channels for media relay. - * After the channel media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the updateChannelMediaRelay method. - * After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback with the UpdateDestinationChannel(7) state code. - * @see RtcEngineEvents.ChannelMediaRelayEvent - * @see ChannelMediaRelayEvent.UpdateDestinationChannel - * Note - * - Call this method after the startChannelMediaRelay method to update the destination channel. - * @see RtcEngine.startChannelMediaRelay - * - This method supports adding at most four destination channels in the relay. If there are already four destination channels in the relay. - * @param channelMediaRelayConfiguration The media stream relay configuration - * @see ChannelMediaRelayConfiguration - */ updateChannelMediaRelay(channelMediaRelayConfiguration: ChannelMediaRelayConfiguration): Promise; - /** - * Stops the media stream relay. - * Once the relay stops, the broadcaster quits all the destination channels. - * After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback returns Idle(0) and None(0), the broadcaster successfully stops the relay. - * @see RtcEngineEvents.ChannelMediaRelayStateChanged - * @see ChannelMediaRelayState.Idle - * @see ChannelMediaRelayError.None - * Note - * - If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged callback with the ServerNoResponse(2) or ServerConnectionLost(8) state code. You can leave the channel by calling the leaveChannel method, and the media stream relay automatically stops. - * @see RtcEngineEvents.ChannelMediaRelayStateChanged - * @see ChannelMediaRelayError.ServerNoResponse - * @see ChannelMediaRelayError.ServerConnectionLost - * @see RtcEngine.leaveChannel - */ stopChannelMediaRelay(): Promise; } +/** + * @ignore + */ interface RtcAudioRouteInterface { - /** - * Sets the default audio playback route. - * This method sets whether the received audio is routed to the earpiece or speakerphone by default before joining a channel. If a user does not call this method, the audio is routed to the earpiece by default. If you need to change the default audio route after joining a channel, call the setEnableSpeakerphone method. - * @see RtcEngine.setEnableSpeakerphone - * The default audio route for each scenario: - * - In the Communication profile: - * @see ChannelProfile.Communication - * -- For a voice call, the default audio route is the earpiece. - * -- For a video call, the default audio route is the speaker. If the user disables the video using disableVideo, or muteLocalVideoStream and muteAllRemoteVideoStreams, the default audio route automatically switches back to the earpiece. - * @see RtcEngine.disableVideo - * @see RtcEngine.muteLocalVideoStream - * @see RtcEngine.muteAllRemoteVideoStreams - * - In the Live Broadcast profile: The default audio route is the speaker. - * @see ChannelProfile.LiveBroadcasting - * Note - * - This method applies to the Communication profile only. - * - Call this method before the user joins a channel. - * @param defaultToSpeaker Sets the default audio route: - * - true: Route the audio to the speaker. If the playback device connects to the earpiece or Bluetooth, the audio cannot be routed to the earpiece. - * - false: (Default) Route the audio to the earpiece. If a headset is plugged in, the audio is routed to the headset. - */ setDefaultAudioRoutetoSpeakerphone(defaultToSpeaker: boolean): Promise; - /** - * Enables/Disables the audio playback route to the speakerphone. - * This method sets whether the audio is routed to the speakerphone or earpiece. After calling this method, the SDK returns the onAudioRouteChanged callback to indicate the changes. - * @see RtcEngineEvents.AudioRouteChanged - * Note - * - Ensure that you have successfully called the joinChannel method before calling this method. - * @see RtcEngine.joinChannel - * - This method is invalid for audience users in the Live Broadcast profile. - * @see ChannelProfile.LiveBroadcasting - * @param enabled Sets whether to route the audio to the speakerphone or earpiece: - * - true: Route the audio to the speakerphone. - * - false: Route the audio to the earpiece. If the headset is plugged in, the audio is routed to the headset. - */ setEnableSpeakerphone(enabled: boolean): Promise; - /** - * Checks whether the speakerphone is enabled. - */ isSpeakerphoneEnabled(): Promise; } +/** + * @ignore + */ interface RtcEarMonitoringInterface { - /** - * Enables in-ear monitoring. - * @param enabled Sets whether to enable/disable in-ear monitoring: - * - true: Enable. - * - false: (Default) Disable. - */ enableInEarMonitoring(enabled: boolean): Promise; - /** - * Sets the volume of the in-ear monitor. - * @param volume Sets the volume of the in-ear monitor. The value ranges between 0 and 100 (default). - */ setInEarMonitoringVolume(volume: number): Promise; } +/** + * @ignore + */ interface RtcDualStreamInterface { - /** - * Enables/Disables the dual video stream mode. - * If dual-stream mode is enabled, the receiver can choose to receive the high stream (high-resolution high-bitrate video stream) or low stream (low-resolution low-bitrate video stream) video. - * @param enabled Sets the stream mode: - * - true: Dual-stream mode. - * - false: (Default) Single-stream mode. - */ enableDualStreamMode(enabled: boolean): Promise; - /** - * Sets the stream type of the remote video. - * Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode(false), the receiver can choose to receive either the high-video stream (the high resolution, and high bitrate video stream) or the low-video stream (the low resolution, and low bitrate video stream). - * @see RtcEngine.enableDualStreamMode - * By default, users receive the high-video stream. Call this method if you want to switch to the low-video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources. - * The aspect ratio of the low-video stream is the same as the high-video stream. Once the resolution of the high-video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-video stream. - * The SDK reports the result of calling this method in the onApiCallExecuted callback. - * @see RtcEngineEvents.ApiCallExecuted - * @param uid ID of the remote user sending the video stream. - * @param streamType Sets the video-stream type. - * @see VideoStreamType - */ setRemoteVideoStreamType(uid: number, streamType: VideoStreamType): Promise; - /** - * Sets the default video-stream type of the remotely subscribed video stream when the remote user sends dual streams. - * @param streamType Sets the default video-stream type. - * @see VideoStreamType - */ setRemoteDefaultVideoStreamType(streamType: VideoStreamType): Promise; } +/** + * @ignore + */ interface RtcFallbackInterface { - /** - * Sets the fallback option for the locally published video stream based on the network conditions. - * If option is set as AudioOnly(2), the SDK will: - * @see StreamFallbackOptions.AudioOnly - * - Disable the upstream video but enable audio only when the network conditions deteriorate and cannot support both video and audio. - * - Re-enable the video when the network conditions improve. - * When the locally published video stream falls back to audio only or when the audio-only stream switches back to the video, the SDK triggers the onLocalPublishFallbackToAudioOnly. - * @see RtcEngineEvents.LocalPublishFallbackToAudioOnly - * Note - * - Agora does not recommend using this method for CDN live streaming, because the remote CDN live user will have a noticeable lag when the locally published video stream falls back to audio only. - * @param option Sets the fallback option for the locally published video stream. - * @see StreamFallbackOptions - */ setLocalPublishFallbackOption(option: StreamFallbackOptions): Promise; - /** - * Sets the fallback option for the remotely subscribed video stream based on the network conditions. - * If option is set as AudioOnly(2), the SDK automatically switches the video from a high-stream to a low-stream, or disables the video when the downlink network condition cannot support both audio and video to guarantee the quality of the audio. The SDK monitors the network quality and restores the video stream when the network conditions improve. When the remotely subscribed video stream falls back to audio only, or the audio-only stream switches back to the video, the SDK triggers the onRemoteSubscribeFallbackToAudioOnly callback. - * @see StreamFallbackOptions.AudioOnly - * @see RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly - * @param option Sets the fallback option for the remotely subscribed video stream. - * @see StreamFallbackOptions - */ setRemoteSubscribeFallbackOption(option: StreamFallbackOptions): Promise; - /** - * Sets the priority of a remote user's media stream. - * Use this method with the setRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality. - * @see RtcEngine.setRemoteSubscribeFallbackOption - * Note - * - The Agora SDK supports setting userPriority as high for one user only. - * @param uid The ID of the remote user. - * @param userPriority The priority of the remote user. - * @see UserPriority - */ setRemoteUserPriority(uid: number, userPriority: UserPriority): Promise; } -interface RtcTestInterface { - /** - * Starts an audio call test. - * In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly. - * Note - * - Call this method before joining a channel. - * - After calling this method, call the stopEchoTest method to end the test. Otherwise, the app cannot run the next echo test, or call the joinChannel method. - * @see RtcEngine.stopEchoTest - * @see RtcEngine.joinChannel - * - In the Live Broadcast profile, only a host can call this method. - * @param intervalInSeconds The time interval (s) between when you speak and when the recording plays back. - */ - startEchoTest(intervalInSeconds: number): Promise; - - /** - * Stops the audio call test. - */ - stopEchoTest(): Promise; - - /** - * Enables the network connection quality test. - * This method tests the quality of the users' network connections and is disabled by default. - * Before users join a channel or before an audience switches to a host, call this method to check the uplink network quality. This method consumes additional network traffic, which may affect the communication quality. Call the disableLastmileTest method to disable this test after receiving the onLastmileQuality callback, and before the user joins a channel or switches the user role. - * @see RtcEngine.disableLastmileTest - * @see RtcEngineEvents.LastmileQuality - * Note - * - Do not use this method with the startLastmileProbeTest method. - * @see RtcEngine.startLastmileProbeTest - * - Do not call any other methods before receiving the onLastmileQuality callback. Otherwise, the callback may be interrupted by other methods and may not execute. - * @see RtcEngineEvents.LastmileQuality - * - In the Live Broadcast profile, a host should not call this method after joining a channel. - * - If you call this method to test the last-mile quality, the SDK consumes the bandwidth of a video stream, whose bitrate corresponds to the bitrate you set in the setVideoEncoderConfiguration method. After you join the channel, whether you have called the disableLastmileTest method or not, the SDK automatically stops consuming the bandwidth. - * @see RtcEngine.setVideoEncoderConfiguration - * @see RtcEngine.disableLastmileTest - */ - enableLastmileTest(): Promise; - - /** - * Disables the network connection quality test. - */ - disableLastmileTest(): Promise; - - /** - * Starts the last-mile network probe test before joining a channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT). - * Once this method is enabled, the SDK returns the following callbacks: - * - onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience. - * @see RtcEngineEvents.LastmileQuality - * - onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective. - * @see RtcEngineEvents.LastmileProbeResult - * Call this method to check the uplink network quality before users join a channel or before an audience switches to a host. - * Note - * - This method consumes extra network traffic and may affect communication quality. We do not recommend calling this method together with enableLastmileTest. - * @see RtcEngine.enableLastmileTest - * - Do not call other methods before receiving the onLastmileQuality and onLastmileProbeResult callbacks. Otherwise, the callbacks may be interrupted by other methods. - * - In the Live Broadcast profile, a host should not call this method after joining a channel. - * @see ChannelProfile.LiveBroadcasting - * @param config The configurations of the last-mile network probe test. - * @see LastmileProbeConfig - */ +/** + * @ignore + */ +interface RtcTestInterface { + startEchoTest(intervalInSeconds: number): Promise; + + stopEchoTest(): Promise; + + enableLastmileTest(): Promise; + + disableLastmileTest(): Promise; + startLastmileProbeTest(config: LastmileProbeConfig): Promise; - /** - * Stops the last-mile network probe test. - */ stopLastmileProbeTest(): Promise; } +/** + * @ignore + */ interface RtcMediaMetadataInterface { - /** - * Registers the metadata observer. - * This method enables you to add synchronized metadata in the video stream for more diversified live broadcast interactions, such as sending shopping links, digital coupons, and online quizzes. - * Note - * - Call this method before the joinChannel method. - * @see RtcEngine.joinChannel - */ registerMediaMetadataObserver(): Promise; - /** - * TODO - */ unregisterMediaMetadataObserver(): Promise; - /** - * TODO - * @param size - */ setMaxMetadataSize(size: number): Promise; - /** - * TODO - * @param metadata - */ sendMetadata(metadata: string): Promise; } +/** + * @ignore + */ interface RtcWatermarkInterface { - /** - * Adds a watermark image to the local video. - * This method adds a PNG watermark image to the local video stream in a live broadcast. Once the watermark image is added, all the audience in the channel (CDN audience included), and the recording device can see and capture it. - * Agora supports adding only one watermark image onto the local video, and the newly watermark image replaces the previous one. - * The watermark position depends on the settings in the setVideoEncoderConfiguration method: - * @see RtcEngine.setVideoEncoderConfiguration - * - If the orientation mode of the encoding video is FixedLandscape, or the landscape mode in Adaptative, the watermark uses the landscape orientation. - * @see VideoOutputOrientationMode.FixedLandscape - * @see VideoOutputOrientationMode.Adaptative - * - If the orientation mode of the encoding video is FixedPortrait, or the portrait mode in Adaptative, the watermark uses the portrait orientation. - * @see VideoOutputOrientationMode.FixedPortrait - * @see VideoOutputOrientationMode.Adaptative - * - When setting the watermark position, the region must be less than the dimensions set in the setVideoEncoderConfiguration method. Otherwise, the watermark image will be cropped. - * Note - * - Ensure that you have called the enableVideo method to enable the video module before calling this method. - * @see RtcEngine.enableVideo - * - If you only want to add a watermark image to the local video for the audience in the CDN live broadcast channel to see and capture, you can call this method or the setLiveTranscoding method. - * @see RtcEngine.setLiveTranscoding - * - This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray. - * - If the dimensions the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings. - * - If you have enabled the local video preview by calling the startPreview method, you can use the visibleInPreview member in the WatermarkOptions class to set whether or not the watermark is visible in preview. - * - If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer. - * @param watermarkUrl The local file path of the watermark image to be added. This method supports adding a watermark image from either the local file path or the assets file path. If you use the assets file path, you need to start with /assets/ when filling in this parameter. - * @param options The options of the watermark image to be added. - * @see WatermarkOptions - */ addVideoWatermark(watermarkUrl: string, options: WatermarkOptions): Promise; - /** - * Removes the watermark image from the video stream added by addVideoWatermark. - * @see RtcEngine.addVideoWatermark - */ clearVideoWatermarks(): Promise; } +/** + * @ignore + */ interface RtcEncryptionInterface { - /** - * Enables built-in encryption with an encryption password before joining a channel. - * All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user leaves the channel. If the encryption password is not specified or set to empty, the encryption functionality is disabled. - * Note - * - For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption. - * - Do not use this method for CDN live streaming. - * @param secret The encryption password. - */ setEncryptionSecret(secret: string): Promise; - /** - * Sets the built-in encryption mode. - * The Agora SDK supports built-in encryption, which is set to aes-128-xts mode by default. Call this method to set the encryption mode to use other encryption modes. All users in the same channel must use the same encryption mode and password. - * Refer to the information related to the AES encryption algorithm on the differences between the encryption modes. - * Note - * - Call the setEncryptionSecret method before calling this method. - * @see RtcEngine.setEncryptionSecret - * @param encryptionMode Sets the encryption mode. - * @see EncryptionMode - */ setEncryptionMode(encryptionMode: EncryptionMode): Promise; } +/** + * @ignore + */ interface RtcAudioRecorderInterface { - /** - * Starts an audio recording on the client. - * The SDK allows recording during a call. After successfully calling this method, you can record the audio of all the users in the channel and get an audio recording file. - * Supported formats of the recording file are as follows: - * - .wav: Large file size with high fidelity. - * - .aac: Small file size with low fidelity. - * Note - * - Ensure that the directory to save the recording file exists and is writable. - * - This method is usually called after calling the joinChannel method. The recording automatically stops when you call the leaveChannel method. - * @see RtcEngine.joinChannel - * @see RtcEngine.leaveChannel - * - For better recording effects, set quality as AUDIO_RECORDING_QUALITY_MEDIUM or AUDIO_RECORDING_QUALITY_HIGH when sampleRate is 44.1 kHz or 48 kHz. - * @see AudioRecordingQuality.Medium - * @see AudioRecordingQuality.High - * @param filePath Absolute file path (including the suffixes of the filename) of the recording file. The string of the file name is in UTF-8. For example, /sdcard/emulated/0/audio/aac. - * @param sampleRate Sample rate (Hz) of the recording file. Supported values are as follows. - * @see AudioSampleRateType - * @param quality The audio recording quality. - * @see AudioRecordingQuality - */ startAudioRecording(filePath: string, sampleRate: AudioSampleRateType, quality: AudioRecordingQuality): Promise; - /** - * Stops the audio recording on the client. - * Note - * - You can call this method before calling the leaveChannel method; else, the recording automatically stops when you call the leaveChannel method. - * @see RtcEngine.leaveChannel - */ stopAudioRecording(): Promise; } +/** + * @ignore + */ interface RtcInjectStreamInterface { - /** - * Injects an online media stream to a live broadcast. - * If this method call is successful, the server pulls the voice or video stream and injects it into a live channel. This is applicable to scenarios where all audience members in the channel can watch a live show and interact with each other. - * Note - * - This method applies to the Live-Broadcast profile only. - * - Ensure that you enable the RTMP Converter service before using this function. See Prerequisites. - * - You can inject only one media stream into the channel at the same time. - * The addInjectStreamUrl method call triggers the following callbacks: - * - The local client: - * -- onStreamInjectedStatus, with the state of the injecting the online stream. - * @see RtcEngineEvents.StreamInjectedStatus - * -- onUserJoined(uid: 666), if the method call is successful and the online media stream is injected into the channel. - * @see RtcEngineEvents.UserJoined - * - The remote client: - * -- onUserJoined(uid: 666), if the method call is successful and the online media stream is injected into the channel. - * @see RtcEngineEvents.UserJoined - * @param url The URL address to be added to the ongoing live broadcast. Valid protocols are RTMP, HLS, and HTTP-FLV. - * - Supported audio codec type: AAC. - * - Supported video codec type: H264(AVC). - * @param config The LiveInjectStreamConfig object which contains the configuration information for the added voice or video stream. - * @see LiveInjectStreamConfig - */ addInjectStreamUrl(url: string, config: LiveInjectStreamConfig): Promise; - /** - * Removes the injected online media stream from a live broadcast. - * This method removes the URL address (added by addInjectStreamUrl) from a live broadcast. - * @see RtcEngine.addInjectStreamUrl - * If this method call is successful, the SDK triggers the onUserOffline callback and returns a stream uid of 666. - * @see RtcEngineEvents.UserOffline - * @param url HTTP/HTTPS URL address of the added stream to be removed. - */ removeInjectStreamUrl(url: string): Promise; } +/** + * @ignore + */ interface RtcCameraInterface { - /** - * Switches between front and rear cameras. - */ switchCamera(): Promise; - /** - * Checks whether the camera zoom function is supported. - */ isCameraZoomSupported(): Promise; - /** - * Checks whether the camera flash function is supported. - */ isCameraTorchSupported(): Promise; - /** - * Checks whether the camera manual focus function is supported. - */ isCameraFocusSupported(): Promise; - /** - * Checks whether the camera exposure function is supported. - */ isCameraExposurePositionSupported(): Promise; - /** - * Checks whether the camera auto-face focus function is supported. - */ isCameraAutoFocusFaceModeSupported(): Promise; - /** - * Sets the camera zoom ratio. - * @param factor Sets the camera zoom factor. The value ranges between 1.0 and the maximum zoom supported by the device. - */ setCameraZoomFactor(factor: number): Promise; - /** - * Gets the maximum zoom ratio supported by the camera. - */ getCameraMaxZoomFactor(): Promise; - /** - * Sets the camera manual focus position. - * A successful setCameraFocusPositionInPreview method call triggers the onCameraFocusAreaChanged callback on the local client. - * @see RtcEngineEvents.CameraFocusAreaChanged - * @param positionX The horizontal coordinate of the touch point in the view. - * @param positionY The vertical coordinate of the touch point in the view. - */ setCameraFocusPositionInPreview(positionX: number, positionY: number): Promise; - /** - * Sets the camera exposure position. - * A successful setCameraExposurePosition method call triggers the onCameraExposureAreaChanged callback on the local client. - * @see RtcEngineEvents.CameraExposureAreaChanged - * @param positionXinView The horizontal coordinate of the touch point in the view. - * @param positionYinView The vertical coordinate of the touch point in the view. - */ setCameraExposurePosition(positionXinView: number, positionYinView: number): Promise; - /** - * Enables/Disables face detection for the local user. - * Once face detection is enabled, the SDK triggers the onFacePositionChanged callback to report the face information of the local user, which includes the following aspects: - * @see RtcEngineEvents.FacePositionChanged - * - The width and height of the local video. - * - The position of the human face in the local video. - * - The distance between the human face and the device screen. - * @param enable Determines whether to enable the face detection function for the local user: - * - true: Enable face detection. - * - false: (Default) Disable face detection. - */ enableFaceDetection(enable: boolean): Promise; - /** - * Enables the camera flash function. - * @param isOn Sets whether to enable/disable the camera flash function: - * - true: Enable the camera flash function. - * - false: Disable the camera flash function. - */ setCameraTorchOn(isOn: boolean): Promise; - /** - * Enables the camera auto-face focus function. - * @param enabled Sets whether to enable/disable the camera auto-face focus function: - * - true: Enable the camera auto-face focus function. - * - false: (Default) Disable the camera auto-face focus function. - */ setCameraAutoFocusFaceModeEnabled(enabled: boolean): Promise; - /** - * Sets the camera capturer configuration. - * For a video call or live broadcast, generally the SDK controls the camera output parameters. When the default camera capture settings do not meet special requirements or cause performance problems, we recommend using this method to set the camera capturer configuration: - * - If the resolution or frame rate of the captured raw video data are higher than those set by setVideoEncoderConfiguration, processing video frames requires extra CPU and RAM usage and degrades performance. We recommend setting config as Performance(1) to avoid such problems. - * @see RtcEngine.setVideoEncoderConfiguration - * @see CameraCaptureOutputPreference.Performance - * - If you do not need local video preview or are willing to sacrifice preview quality, we recommend setting config as Performance(1) to optimize CPU and RAM usage. - * @see CameraCaptureOutputPreference.Performance - * - If you want better quality for the local video preview, we recommend setting config as Preview(2). - * @see CameraCaptureOutputPreference.Preview - * Note - * - Call this method before enabling the local camera. That said, you can call this method before calling joinChannel, enableVideo, or enableLocalVideo, depending on which method you use to turn on your local camera. - * @see RtcEngine.joinChannel - * @see RtcEngine.enableVideo - * @see RtcEngine.enableLocalVideo - * @param config The camera capturer configuration. - * @see CameraCapturerConfiguration - */ setCameraCapturerConfiguration(config: CameraCapturerConfiguration): Promise; } +/** + * @ignore + */ interface RtcStreamMessageInterface { - /** - * Creates a data stream. - * Each user can create up to five data streams during the lifecycle of the RtcEngine. - * @see RtcEngine - * Note - * - Set both the reliable and ordered parameters to true or false. Do not set one as true and the other as false. - * @param reliable Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds: - * - true: The recipients receive the data from the sender within five seconds. If the recipient does not receive the data within five seconds, the SDK triggers the onStreamMessageError callback and returns an error code. - * @see RtcEngineEvents.StreamMessageError - * - false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream. - * @param ordered Sets whether or not the recipients receive the data stream in the sent order: - * - true: The recipients receive the data in the sent order. - * - false: The recipients do not receive the data in the sent order. - */ createDataStream(reliable: boolean, ordered: boolean): Promise; - /** - * Sends data stream messages. - * The SDK has the following restrictions on this method: - * - Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 kB. - * - Each client can send up to 6 kB of data per second. - * - Each user can have up to five data channels simultaneously. - * A successful sendStreamMessage method call triggers the onStreamMessage callback on the remote client, from which the remote user gets the stream message. - * @see RtcEngineEvents.StreamMessage - * A failed sendStreamMessage method call triggers the onStreamMessageError callback on the remote client. - * @see RtcEngineEvents.StreamMessageError - * Note - * - Ensure that you have created the data stream using createDataStream before calling this method. - * @see RtcEngine.createDataStream - * - This method applies only to the Communication profile or to hosts in the Live Broadcast profile. - * @param streamId ID of the sent data stream returned by the createDataStream method. - * @see RtcEngine.createDataStream - * @param message Sent data. - */ sendStreamMessage(streamId: number, message: string): Promise; } diff --git a/src/RtcEvents.ts b/src/src/RtcEvents.ts similarity index 57% rename from src/RtcEvents.ts rename to src/src/RtcEvents.ts index 116f6af59..611a4e3d8 100644 --- a/src/RtcEvents.ts +++ b/src/src/RtcEvents.ts @@ -34,137 +34,165 @@ import { VideoRemoteState, VideoRemoteStateReason, WarningCode -} from "./Types" +} from "../Types" +/** + * @internal + */ export type Listener = (...args: any[]) => any +/** + * @internal + */ export interface Subscription { remove(): void } -type EmptyCallback = () => void -type WarningCallback = (warn: WarningCode) => void -type ErrorCallback = (err: ErrorCode) => void -type ApiCallCallback = (error: ErrorCode, api: string, result: string) => void -type UidWithElapsedAndChannelCallback = (channel: string, uid: number, elapsed: number) => void -type RtcStatsCallback = (stats: RtcStats) => void -type UserAccountCallback = (uid: number, userAccount: string) => void -type UserInfoCallback = (uid: number, userInfo: UserInfo) => void -type ClientRoleCallback = (oldRole: ClientRole, newRole: ClientRole) => void -type UidWithElapsedCallback = (uid: number, elapsed: number) => void -type UserOfflineCallback = (uid: number, reason: UserOfflineReason) => void -type ConnectionStateCallback = (state: ConnectionStateType, reason: ConnectionChangedReason) => void -type NetworkTypeCallback = (type: NetworkType) => void -type TokenCallback = (token: string) => void -type AudioVolumeCallback = (speakers: AudioVolumeInfo[], totalVolume: number) => void -type UidCallback = (uid: number) => void -type ElapsedCallback = (elapsed: number) => void -type VideoFrameCallback = (width: number, height: number, elapsed: number) => void -type UidWithMutedCallback = (uid: number, muted: boolean) => void -type VideoSizeCallback = (uid: number, width: number, height: number, rotation: number) => void -type RemoteVideoStateCallback = (uid: number, state: VideoRemoteState, reason: VideoRemoteStateReason, elapsed: number) => void -type LocalVideoStateCallback = (localVideoState: LocalVideoStreamState, error: LocalVideoStreamError) => void -type RemoteAudioStateCallback = (uid: number, state: AudioRemoteState, reason: AudioRemoteStateReason, elapsed: number) => void -type LocalAudioStateCallback = (state: AudioLocalState, error: AudioLocalError) => void -type FallbackCallback = (isFallbackOrRecover: boolean) => void -type FallbackWithUidCallback = (uid: number, isFallbackOrRecover: boolean) => void -type AudioRouteCallback = (routing: AudioOutputRouting) => void -type RectCallback = (rect: Rect) => void -type NetworkQualityCallback = (quality: NetworkQuality) => void -type NetworkQualityWithUidCallback = (uid: number, txQuality: NetworkQuality, rxQuality: NetworkQuality) => void -type LastmileProbeCallback = (result: LastmileProbeResult) => void -type LocalVideoStatsCallback = (stats: LocalVideoStats) => void -type LocalAudioStatsCallback = (stats: LocalAudioStats) => void -type RemoteVideoStatsCallback = (stats: RemoteVideoStats) => void -type RemoteAudioStatsCallback = (stats: RemoteAudioStats) => void -type AudioMixingStateCallback = (state: AudioMixingStateCode, errorCode: AudioMixingErrorCode) => void -type SoundIdCallback = (soundId: number) => void -type RtmpStreamingStateCallback = (url: string, state: RtmpStreamingState, errCode: RtmpStreamingErrorCode) => void -type StreamInjectedStatusCallback = (url: string, uid: number, status: InjectStreamStatus) => void -type StreamMessageCallback = (uid: number, streamId: number, data: string) => void -type StreamMessageErrorCallback = (uid: number, streamId: number, error: ErrorCode, missed: number, cached: number) => void -type MediaRelayStateCallback = (state: ChannelMediaRelayState, code: ChannelMediaRelayError) => void -type MediaRelayEventCallback = (code: ChannelMediaRelayEvent) => void -type VideoFrameWithUidCallback = (uid: number, width: number, height: number, elapsed: number) => void -type UrlWithErrorCallback = (url: string, error: ErrorCode) => void -type UrlCallback = (url: string) => void -type TransportStatsCallback = (uid: number, delay: number, lost: number, rxKBitRate: number) => void -type UidWithEnabledCallback = (uid: number, enabled: boolean) => void -type EnabledCallback = (enabled: boolean) => void -type AudioQualityCallback = (uid: number, quality: number, delay: number, lost: number) => void -type MetadataCallback = (buffer: string, uid: number, timeStampMs: number) => void -type FacePositionCallback = (imageWidth: number, imageHeight: number, faces: FacePositionInfo[]) => void +export type EmptyCallback = () => void +export type WarningCallback = (warn: WarningCode) => void +export type ErrorCallback = (err: ErrorCode) => void +export type ApiCallCallback = (error: ErrorCode, api: string, result: string) => void +export type UidWithElapsedAndChannelCallback = (channel: string, uid: number, elapsed: number) => void +export type RtcStatsCallback = (stats: RtcStats) => void +export type UserAccountCallback = (uid: number, userAccount: string) => void +export type UserInfoCallback = (uid: number, userInfo: UserInfo) => void +export type ClientRoleCallback = (oldRole: ClientRole, newRole: ClientRole) => void +export type UidWithElapsedCallback = (uid: number, elapsed: number) => void +export type UserOfflineCallback = (uid: number, reason: UserOfflineReason) => void +export type ConnectionStateCallback = (state: ConnectionStateType, reason: ConnectionChangedReason) => void +export type NetworkTypeCallback = (type: NetworkType) => void +export type TokenCallback = (token: string) => void +export type AudioVolumeCallback = (speakers: AudioVolumeInfo[], totalVolume: number) => void +export type UidCallback = (uid: number) => void +export type ElapsedCallback = (elapsed: number) => void +export type VideoFrameCallback = (width: number, height: number, elapsed: number) => void +export type UidWithMutedCallback = (uid: number, muted: boolean) => void +export type VideoSizeCallback = (uid: number, width: number, height: number, rotation: number) => void +export type RemoteVideoStateCallback = (uid: number, state: VideoRemoteState, reason: VideoRemoteStateReason, elapsed: number) => void +export type LocalVideoStateCallback = (localVideoState: LocalVideoStreamState, error: LocalVideoStreamError) => void +export type RemoteAudioStateCallback = (uid: number, state: AudioRemoteState, reason: AudioRemoteStateReason, elapsed: number) => void +export type LocalAudioStateCallback = (state: AudioLocalState, error: AudioLocalError) => void +export type FallbackCallback = (isFallbackOrRecover: boolean) => void +export type FallbackWithUidCallback = (uid: number, isFallbackOrRecover: boolean) => void +export type AudioRouteCallback = (routing: AudioOutputRouting) => void +export type RectCallback = (rect: Rect) => void +export type NetworkQualityCallback = (quality: NetworkQuality) => void +export type NetworkQualityWithUidCallback = (uid: number, txQuality: NetworkQuality, rxQuality: NetworkQuality) => void +export type LastmileProbeCallback = (result: LastmileProbeResult) => void +export type LocalVideoStatsCallback = (stats: LocalVideoStats) => void +export type LocalAudioStatsCallback = (stats: LocalAudioStats) => void +export type RemoteVideoStatsCallback = (stats: RemoteVideoStats) => void +export type RemoteAudioStatsCallback = (stats: RemoteAudioStats) => void +export type AudioMixingStateCallback = (state: AudioMixingStateCode, errorCode: AudioMixingErrorCode) => void +export type SoundIdCallback = (soundId: number) => void +export type RtmpStreamingStateCallback = (url: string, state: RtmpStreamingState, errCode: RtmpStreamingErrorCode) => void +export type StreamInjectedStatusCallback = (url: string, uid: number, status: InjectStreamStatus) => void +export type StreamMessageCallback = (uid: number, streamId: number, data: string) => void +export type StreamMessageErrorCallback = (uid: number, streamId: number, error: ErrorCode, missed: number, cached: number) => void +export type MediaRelayStateCallback = (state: ChannelMediaRelayState, code: ChannelMediaRelayError) => void +export type MediaRelayEventCallback = (code: ChannelMediaRelayEvent) => void +export type VideoFrameWithUidCallback = (uid: number, width: number, height: number, elapsed: number) => void +export type UrlWithErrorCallback = (url: string, error: ErrorCode) => void +export type UrlCallback = (url: string) => void +export type TransportStatsCallback = (uid: number, delay: number, lost: number, rxKBitRate: number) => void +export type UidWithEnabledCallback = (uid: number, enabled: boolean) => void +export type EnabledCallback = (enabled: boolean) => void +export type AudioQualityCallback = (uid: number, quality: number, delay: number, lost: number) => void +export type MetadataCallback = (buffer: string, uid: number, timeStampMs: number) => void +export type FacePositionCallback = (imageWidth: number, imageHeight: number, faces: FacePositionInfo[]) => void /** * The SDK uses the RtcEngineEvents interface class to send callbacks to the application, and the application inherits the methods of this interface class to retrieve these callbacks. + * * All methods in this interface class have their (empty) default implementations, and the application can inherit only some of the required events instead of all of them. + * * In the callbacks, the application should avoid time-consuming tasks or call blocking APIs (such as SendMessage), otherwise, the SDK may not work properly. */ export interface RtcEngineEvents { /** * Reports a warning during SDK runtime. + * * In most cases, the app can ignore the warning reported by the SDK because the SDK can usually fix the issue and resume running. - * For instance, the SDK may report a LookupChannelTimeout warning upon disconnection with the server and tries to reconnect. For detailed warning codes, see Warning Codes. - * @see WarningCode.LookupChannelTimeout - * @see WarningCode + * + * For instance, the SDK may report a {@link WarningCode.LookupChannelTimeout} warning upon disconnection with the server and tries to reconnect. For detailed warning codes, see {@link WarningCode}. + * + * @event Warning */ Warning: WarningCallback /** * Reports an error during SDK runtime. + * * In most cases, the SDK cannot fix the issue and resume running. The SDK requires the app to take action or informs the user about the issue. - * For example, the SDK reports an StartCall error when failing to initialize a call. The app informs the user that the call initialization failed and invokes the leaveChannel method to leave the channel. For detailed error codes, see Error Codes. - * @see ErrorCode.StartCall - * @see RtcEngine.leaveChannel - * @see ErrorCode + * + * For example, the SDK reports an {@link ErrorCode.StartCall} error when failing to initialize a call. The app informs the user that the call initialization failed and invokes the {@link RtcEngine.leaveChannel} method to leave the channel. For detailed error codes, see {@link ErrorCode}. + * + * @event Error */ Error: ErrorCallback /** * Occurs when an API method is executed. + * + * @event ApiCallExecuted */ ApiCallExecuted: ApiCallCallback /** * Occurs when the local user joins a specified channel. + * * The channel name assignment is based on channelName specified in the joinChannel method. - * If the uid is not specified when joinChannel is called, the server automatically assigns a uid. - * @see RtcEngine.joinChannel + * + * If the uid is not specified when {@link RtcEngine.joinChannel} is called, the server automatically assigns a uid. + * + * @event JoinChannelSuccess */ JoinChannelSuccess: UidWithElapsedAndChannelCallback /** * Occurs when a user rejoins the channel after being disconnected due to network problems. + * * When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection. + * + * @event RejoinChannelSuccess */ RejoinChannelSuccess: UidWithElapsedAndChannelCallback /** * Occurs when a user leaves the channel. - * When the app calls the leaveChannel method, the SDK uses this callback to notify the app when the user leaves the channel. + * + * When the app calls the {@link RtcEngine.leaveChannel} method, the SDK uses this callback to notify the app when the user leaves the channel. + * * With this callback, the application retrieves the channel information, such as the call duration and statistics. - * @see RtcEngine.leaveChannel + * + * @event LeaveChannel */ LeaveChannel: RtcStatsCallback /** * Occurs when the local user registers a user account. - * This callback is triggered when the local user successfully registers a user account by calling the registerLocalUserAccount method, or joins a channel by calling the joinChannelWithUserAccount method. This callback reports the user ID and user account of the local user. - * @see RtcEngine.joinChannelWithUserAccount + * + * This callback is triggered when the local user successfully registers a user account by calling the {@link RtcEngine.registerLocalUserAccount} method, or joins a channel by calling the {@link RtcEngine.joinChannelWithUserAccount} method. This callback reports the user ID and user account of the local user. + * + * @event LocalUserRegistered */ LocalUserRegistered: UserAccountCallback /** * Occurs when the SDK gets the user ID and user account of the remote user. - * After a remote user joins the channel, the SDK gets the UID and user account of the remote user, caches them in a mapping table object (UserInfo), and triggers this callback on the local client. - * @see UserInfo + * + * After a remote user joins the channel, the SDK gets the UID and user account of the remote user, caches them in a mapping table object ({@link UserInfo}), and triggers this callback on the local client. + * + * @event UserInfoUpdated */ UserInfoUpdated: UserInfoCallback /** * Occurs when the user role switches in a live broadcast. For example, from a host to an audience or vice versa. - * The SDK triggers this callback when the local user switches the user role by calling the setClientRole method after joining the channel. - * @see RtcEngine.setClientRole + * + * The SDK triggers this callback when the local user switches the user role by calling the {@link RtcEngine.setClientRole} method after joining the channel. + * + * @event ClientRoleChanged */ ClientRoleChanged: ClientRoleCallback @@ -172,547 +200,650 @@ export interface RtcEngineEvents { * Occurs when a remote user (Communication)/host (Live Broadcast) joins the channel. * - Communication profile: This callback notifies the app when another user joins the channel. If other users are already in the channel, the SDK also reports to the app on the existing users. * - Live Broadcast profile: This callback notifies the app when the host joins the channel. If other hosts are already in the channel, the SDK also reports to the app on the existing hosts. We recommend having at most 17 hosts in a channel + * * The SDK triggers this callback under one of the following circumstances: - * - A remote user/host joins the channel by calling the joinChannel method. - * @see RtcEngine.joinChannel - * - A remote user switches the user role to the host by calling the setClientRole method after joining the channel. - * @see RtcEngine.setClientRole + * - A remote user/host joins the channel by calling the {@link RtcEngine.joinChannel} method. + * - A remote user switches the user role to the host by calling the {@link RtcEngine.setClientRole} method after joining the channel. * - A remote user/host rejoins the channel after a network interruption. - * - The host injects an online media stream into the channel by calling the addInjectStreamUrl method. - * @see RtcEngine.addInjectStreamUrl - * Note + * - The host injects an online media stream into the channel by calling the {@link RtcEngine.addInjectStreamUrl} method. + * + * **Note** * - In the Live Broadcast profile: - * -- The host receives the onUserJoined callback when another host joins the channel. - * -- The audience in the channel receives the onUserJoined callback when a new host joins the channel. - * -- When a web application joins the channel, the onUserJoined callback is triggered as long as the web application publishes streams. + * - The host receives the onUserJoined callback when another host joins the channel. + * - The audience in the channel receives the onUserJoined callback when a new host joins the channel. + * - When a web application joins the channel, the onUserJoined callback is triggered as long as the web application publishes streams. + * + * @event UserJoined */ UserJoined: UidWithElapsedCallback /** * Occurs when a remote user (Communication)/host (Live Broadcast) leaves the channel. + * * There are two reasons for users to become offline: * - Leave the channel: When the user/host leaves the channel, the user/host sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel. * - Drop offline: When no data packet of the user or host is received for a certain period of time (20 seconds for the communication profile, and more for the live broadcast profile), the SDK assumes that the user/host drops offline. A poor network connection may lead to false detections, so we recommend using the Agora RTM SDK for reliable offline detection. + * + * @event UserOffline */ UserOffline: UserOfflineCallback /** * Occurs when the network connection state changes. + * * The Agora SDK returns this callback to report on the current network connection state when it changes, and the reason to such change. + * + * @event ConnectionStateChanged */ ConnectionStateChanged: ConnectionStateCallback /** * Occurs when the network type changes. + * * The SDK returns the current network type in this callback. When the network connection is interrupted, this callback indicates whether the interruption is caused by a network type change or poor network conditions. + * + * @event NetworkTypeChanged */ NetworkTypeChanged: NetworkTypeCallback /** * Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted. - * The SDK triggers this callback when it cannot connect to the server 10 seconds after calling joinChannel(), regardless of whether it is in the channel or not. - * @see RtcEngine.joinChannel + * + * The SDK triggers this callback when it cannot connect to the server 10 seconds after calling {@link RtcEngine.joinChannel}, regardless of whether it is in the channel or not. + * * If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel. + * + * @event ConnectionLost */ ConnectionLost: EmptyCallback /** * Occurs when the token expires in 30 seconds. - * The user becomes offline if the token used when joining the channel expires. This callback is triggered 30 seconds before the token expires to remind the app to get a new token. Upon receiving this callback, you need to generate a new token on the server and call renewToken to pass the new token to the SDK. - * @see RtcEngine.renewToken + * + * The user becomes offline if the token used when joining the channel expires. This callback is triggered 30 seconds before the token expires to remind the app to get a new token. Upon receiving this callback, you need to generate a new token on the server and call {@link RtcEngine.renewToken} to pass the new token to the SDK. + * + * @event TokenPrivilegeWillExpire */ TokenPrivilegeWillExpire: TokenCallback /** * Occurs when the token has expired. - * After a token is specified when joining the channel, the token expires after a certain period of time, and a new token is required to reconnect to the server. This callback notifies the app to generate a new token and call joinChannel to rejoin the channel with the new token. - * @see RtcEngine.joinChannel + * + * After a token is specified when joining the channel, the token expires after a certain period of time, and a new token is required to reconnect to the server. This callback notifies the app to generate a new token and call {@link RtcEngine.joinChannel} to rejoin the channel with the new token. + * + * @event RequestToken */ RequestToken: EmptyCallback /** * Reports which users are speaking and the speakers' volume, and whether the local user is speaking. + * * This callback reports the IDs and volumes of the loudest speakers (at most 3) at the moment in the channel, and whether the local user is speaking. - * By default, this callback is disabled. You can enable it by calling the enableAudioVolumeIndication method. Once enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not. - * @see RtcEngine.enableAudioVolumeIndication + * + * By default, this callback is disabled. You can enable it by calling the {@link RtcEngine.enableAudioVolumeIndication} method. Once enabled, this callback is triggered at the set interval, regardless of whether a user speaks or not. + * * The SDK triggers two independent onAudioVolumeIndication callbacks at one time, which separately report the volume information of the local user and all the remote speakers. For more information, see the detailed parameter descriptions. - * Note - * - To enable the voice activity detection of the local user, ensure that you set report_vad(true) in the enableAudioVolumeIndication method. - * @see RtcEngine.enableAudioVolumeIndication - * - Calling the muteLocalAudioStream method affects the SDK's behavior. - * @see RtcEngine.muteLocalAudioStream - * -- If the local user calls the muteLocalAudioStream method, the SDK stops triggering the local user's callback. - * @see RtcEngine.muteLocalAudioStream - * -- 20 seconds after a remote speaker calls the muteLocalAudioStream method, the remote speakers' callback does not include information of this remote user; 20 seconds after all remote users call the the muteLocalAudioStream method, the SDK stops triggering the remote speakers' callback. - * @see RtcEngine.muteLocalAudioStream + * + * **Note** + * - To enable the voice activity detection of the local user, ensure that you set report_vad(true) in the {@link RtcEngine.enableAudioVolumeIndication} method. + * - Calling the {@link RtcEngine.muteLocalAudioStream} method affects the SDK's behavior. + * - If the local user calls the {@link RtcEngine.muteLocalAudioStream} method, the SDK stops triggering the local user's callback. + * - 20 seconds after a remote speaker calls the {@link RtcEngine.muteLocalAudioStream} method, the remote speakers' callback does not include information of this remote user; 20 seconds after all remote users call the the muteLocalAudioStream method, the SDK stops triggering the remote speakers' callback. + * + * @event AudioVolumeIndication */ AudioVolumeIndication: AudioVolumeCallback /** * Reports which user is the loudest speaker. - * This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling enableAudioVolumeIndication, this callback returns the uid of the active speaker whose voice is detected by the audio volume detection module of the SDK. - * @see RtcEngine.enableAudioVolumeIndication - * Note - * - To receive this callback, you need to call enableAudioVolumeIndication. - * @see RtcEngine.enableAudioVolumeIndication + * + * This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling {@link RtcEngine.enableAudioVolumeIndication}, this callback returns the uid of the active speaker whose voice is detected by the audio volume detection module of the SDK. + * + * **Note** + * - To receive this callback, you need to call {@link RtcEngine.enableAudioVolumeIndication}. * - This callback returns the user ID of the user with the highest voice volume during a period of time, instead of at the moment. + * + * @event ActiveSpeaker */ ActiveSpeaker: UidCallback /** * Occurs when the first local audio frame is sent. + * + * @event FirstLocalAudioFrame */ FirstLocalAudioFrame: ElapsedCallback /** * Occurs when the first local video frame is rendered. + * * This callback is triggered after the first local video frame is rendered on the local video window. + * + * @event FirstLocalVideoFrame */ FirstLocalVideoFrame: VideoFrameCallback /** * Occurs when a remote user stops/resumes sending the video stream. - * @deprecated This callback is deprecated. Use the onRemoteVideoStateChanged callback with the following parameters for the same function: - * @see RemoteVideoStateChanged - * - Stopped(0) and RemoteMuted(5). - * @see VideoRemoteState.Stopped - * @see VideoRemoteStateReason.RemoteMuted - * - Decoding(2) and RemoteUnmuted(6). - * @see VideoRemoteState.Decoding - * @see VideoRemoteStateReason.RemoteUnmuted - * The SDK triggers this callback when the remote user stops or resumes sending the video stream by calling the muteLocalVideoStream method. - * @see RtcEngine.muteLocalVideoStream - * Note + * + * @deprecated This callback is deprecated. Use the {@link RemoteVideoStateChanged} callback with the following parameters for the same function: + * - {@link VideoRemoteState.Stopped} and {@link VideoRemoteStateReason.RemoteMuted}. + * - {@link VideoRemoteState.Decoding} and {@link VideoRemoteStateReason.RemoteUnmuted}. + * + * The SDK triggers this callback when the remote user stops or resumes sending the video stream by calling the {@link RtcEngine.muteLocalVideoStream} method. + * + * **Note** * - This callback is invalid when the number of users or broadcasters in the channel exceeds 20. + * + * @event UserMuteVideo */ UserMuteVideo: UidWithMutedCallback /** * Occurs when the video size or rotation information of a remote user changes. + * + * @event VideoSizeChanged */ VideoSizeChanged: VideoSizeCallback /** * Occurs when the remote video state changes. + * + * @event RemoteVideoStateChanged */ RemoteVideoStateChanged: RemoteVideoStateCallback /** * Occurs when the local video state changes. - * The SDK returns the current video state in this callback. When the state is Failed(3), see the error parameter for details. - * @see LocalVideoStreamState.Failed - * @see LocalVideoStreamError - * Note - * - This callback reports the current state of the local video, which keeps changing throughout the RtcEngine life cycle. We recommend maintaining the states reported in this callback, and check the local video state before starting the local camera. If the SDK reports CaptureFailure(4), the local camera is occupied by either the system or a third-party app. To access the camera, call enableLocalVideo (false) first, and then enableLocalVideo (video). - * @see LocalVideoStreamError.CaptureFailure - * @see RtcEngine.enableLocalVideo + * + * The SDK returns the current video state in this callback. When the state is {@link LocalVideoStreamState.Failed}, see the error parameter for details. + * + * **Note** + * - This callback reports the current state of the local video, which keeps changing throughout the RtcEngine life cycle. We recommend maintaining the states reported in this callback, and check the local video state before starting the local camera. If the SDK reports {@link LocalVideoStreamError.CaptureFailure}, the local camera is occupied by either the system or a third-party app. To access the camera, call {@link RtcEngine.enableLocalVideo} (false) first, and then {@link RtcEngine.enableLocalVideo} (video). + * + * @event LocalVideoStateChanged */ LocalVideoStateChanged: LocalVideoStateCallback /** * Occurs when the remote audio state changes. + * * This callback indicates the state change of the remote audio stream. + * + * @event RemoteAudioStateChanged */ RemoteAudioStateChanged: RemoteAudioStateCallback /** * Occurs when the local audio stream state changes. + * * This callback indicates the state change of the local audio stream, including the state of the audio recording and encoding, and allows you to troubleshoot issues when exceptions occur. - * Note - * - When the state is Failed(3), see the error parameter for details. - * @see AudioLocalState.Failed - * @see AudioLocalError + * + * **Note** + * - When the state is {@link AudioLocalState.Failed}, see the error parameter for details. + * + * @event LocalAudioStateChanged */ LocalAudioStateChanged: LocalAudioStateCallback /** * Occurs when the published media stream falls back to an audio-only stream due to poor network conditions or switches back to video stream after the network conditions improve. - * If you call setLocalPublishFallbackOption and set option as AudioOnly(2), this callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink conditions, or when the audio stream switches back to the video after the uplink network condition improves. - * @see RtcEngine.setLocalPublishFallbackOption - * @see StreamFallbackOptions.AudioOnly + * + * If you call {@link RtcEngine.setLocalPublishFallbackOption} and set option as {@link StreamFallbackOptions.AudioOnly}, this callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink conditions, or when the audio stream switches back to the video after the uplink network condition improves. + * + * @event LocalPublishFallbackToAudioOnly */ LocalPublishFallbackToAudioOnly: FallbackCallback /** * Occurs when the remote media stream falls back to audio-only stream due to poor network conditions or switches back to video stream after the network conditions improve. - * If you call setRemoteSubscribeFallbackOption and set option as AudioOnly(2), this callback is triggered when the remotely subscribed media stream falls back to audio-only mode due to poor uplink conditions, or when the remotely subscribed media stream switches back to the video after the uplink network condition improves. - * @see RtcEngine.setRemoteSubscribeFallbackOption - * @see StreamFallbackOptions.AudioOnly + * + * If you call {@link RtcEngine.setRemoteSubscribeFallbackOption} and set option as {@link StreamFallbackOptions.AudioOnly}, this callback is triggered when the remotely subscribed media stream falls back to audio-only mode due to poor uplink conditions, or when the remotely subscribed media stream switches back to the video after the uplink network condition improves. + * + * @event RemoteSubscribeFallbackToAudioOnly */ RemoteSubscribeFallbackToAudioOnly: FallbackWithUidCallback /** * Occurs when the local audio playback route changes. + * * This callback returns that the audio route switched to an earpiece, speakerphone, headset, or Bluetooth device. + * * The definition of the routing is listed as follows: - * @see AudioOutputRouting + * - {@link AudioOutputRouting} + * + * @event AudioRouteChanged */ AudioRouteChanged: AudioRouteCallback /** * Occurs when the camera focus area is changed. - * The SDK triggers this callback when the local user changes the camera focus position by calling the setCameraFocusPositionInPreview method. - * @see RtcEngine.setCameraFocusPositionInPreview + * + * The SDK triggers this callback when the local user changes the camera focus position by calling the {@link RtcEngine.setCameraFocusPositionInPreview} method. + * + * @event CameraFocusAreaChanged */ CameraFocusAreaChanged: RectCallback /** * The camera exposure area has changed. - * The SDK triggers this callback when the local user changes the camera exposure position by calling the setCameraExposurePosition method. - * @see RtcEngine.setCameraExposurePosition + * + * The SDK triggers this callback when the local user changes the camera exposure position by calling the {@link RtcEngine.setCameraExposurePosition} method. + * + * @event CameraExposureAreaChanged */ CameraExposureAreaChanged: RectCallback /** * Reports the face detection result of the local user. - * Once you enable face detection by calling enableFaceDetection, you can get the following information on the local user in real-time: - * @see RtcEngine#enableFaceDetection + * + * Once you enable face detection by calling {@link RtcEngine.enableFaceDetection}, you can get the following information on the local user in real-time: * - The width and height of the local video. * - The position of the human face in the local video. * - The distance between the human face and the device screen. This value is based on the fitting calculation of the local video size and the position of the human face. - * Note + * + * **Note** * - If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device. * - The SDK stops triggering this callback when a human face is in close proximity to the screen. * - On Android, the distance value reported in this callback may be slightly different from the actual distance. Therefore, Agora does not recommend using it for accurate calculation. + * + * @event FacePositionChanged */ FacePositionChanged: FacePositionCallback /** - * Reports the statistics of the RtcEngine once every two seconds. - * @see RtcEngine + * Reports the statistics of the {@link RtcEngine} once every two seconds. + * + * @event RtcStats */ RtcStats: RtcStatsCallback /** - * Reports the last mile network quality of the local user once every two seconds before the user joins the channel. Last mile refers to the connection between the local device and Agora's edge server. After the application calls the enableLastmileTest method, this callback reports once every two seconds the uplink and downlink last mile network conditions of the local user before the user joins the channel. - * @see RtcEngine.enableLastmileTest + * Reports the last mile network quality of the local user once every two seconds before the user joins the channel. Last mile refers to the connection between the local device and Agora's edge server. After the application calls the {@link RtcEngine.enableLastmileTest} method, this callback reports once every two seconds the uplink and downlink last mile network conditions of the local user before the user joins the channel. + * + * @event LastmileQuality */ LastmileQuality: NetworkQualityCallback /** * Reports the last mile network quality of each user in the channel once every two seconds. + * * Last mile refers to the connection between the local device and Agora's edge server. This callback reports once every two seconds the last mile network conditions of each user in the channel. If a channel includes multiple users, then this callback will be triggered as many times. + * + * @event NetworkQuality */ NetworkQuality: NetworkQualityWithUidCallback /** * Reports the last-mile network probe result. - * The SDK triggers this callback within 30 seconds after the app calls the startLastmileProbeTest method. - * @see RtcEngine.startLastmileProbeTest + * + * The SDK triggers this callback within 30 seconds after the app calls the {@link RtcEngine.startLastmileProbeTest} method. + * + * @event LastmileProbeResult */ LastmileProbeResult: LastmileProbeCallback /** * Reports the statistics of the local video streams. + * * The SDK triggers this callback once every two seconds for each user/host. If there are multiple users/hosts in the channel, the SDK triggers this callback as many times. + * + * @event LocalVideoStats */ LocalVideoStats: LocalVideoStatsCallback /** * Reports the statistics of the local audio stream. + * + * @event LocalAudioStats */ LocalAudioStats: LocalAudioStatsCallback /** * Reports the statistics of the video stream from each remote user/host. The SDK triggers this callback once every two seconds for each remote user/host. If a channel includes multiple remote users, the SDK triggers this callback as many times. + * + * @event RemoteVideoStats */ RemoteVideoStats: RemoteVideoStatsCallback /** * Reports the statistics of the audio stream from each remote user/host. + * * The SDK triggers this callback once every two seconds for each remote user/host. If a channel includes multiple remote users, the SDK triggers this callback as many times. + * * Schemes such as FEC (Forward Error Correction) or retransmission counter the frame loss rate. Hence, users may find the overall audio quality acceptable even when the packet loss rate is high. + * + * @event RemoteAudioStats */ RemoteAudioStats: RemoteAudioStatsCallback /** * Occurs when the audio mixing file playback finishes. - * @deprecated This callback is deprecated. Use onAudioMixingStateChanged instead. - * @see AudioMixingStateChanged - * You can start an audio mixing file playback by calling the startAudioMixing method. This callback is triggered when the audio mixing file playback finishes. - * @see RtcEngine.startAudioMixing - * If the startAudioMixing method call fails, an AudioMixingOpenError warning returns in the onWarning callback. - * @see RtcEngine.startAudioMixing - * @see WarningCode.AudioMixingOpenError - * @see Warning + * + * @deprecated This callback is deprecated. Use {@link AudioMixingStateChanged} instead. + * + * You can start an audio mixing file playback by calling the {@link RtcEngine.startAudioMixing} method. This callback is triggered when the audio mixing file playback finishes. + * + * If the {@link RtcEngine.startAudioMixing} method call fails, an {@link WarningCode.AudioMixingOpenError} warning returns in the {@link Warning} callback. + * + * @event AudioMixingFinished */ AudioMixingFinished: EmptyCallback /** * Occurs when the state of the local user's audio mixing file changes. - * When you call the startAudioMixing method and the state of audio mixing file changes, the Agora SDK triggers this callback. - * @see RtcEngine.startAudioMixing + * + * When you call the {@link RtcEngine.startAudioMixing} method and the state of audio mixing file changes, the Agora SDK triggers this callback. * - When the audio mixing file plays, pauses playing, or stops playing, this callback returns 710, 711, or 713 in state, and 0 in errorCode. * - When exceptions occur during playback, this callback returns 714 in state and an error in errorCode. - * - If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns AudioMixingOpenError = 701. - * @see WarningCode.AudioMixingOpenError + * - If the local audio mixing file does not exist, or if the SDK does not support the file format or cannot access the music file URL, the SDK returns {@link WarningCode.AudioMixingOpenError}. + * + * @event AudioMixingStateChanged */ AudioMixingStateChanged: AudioMixingStateCallback /** * Occurs when the audio effect file playback finishes. - * You can start a local audio effect playback by calling the playEffect method. This callback is triggered when the local audio effect file playback finishes. - * @see RtcEngine.playEffect + * + * You can start a local audio effect playback by calling the {@link RtcEngine.playEffect} method. This callback is triggered when the local audio effect file playback finishes. + * + * @event AudioEffectFinished */ AudioEffectFinished: SoundIdCallback /** * Occurs when the state of the RTMP streaming changes. - * The SDK triggers this callback to report the result of the local user calling the addPublishStreamUrl or removePublishStreamUrl method. This callback returns the URL and its current streaming state. When the streaming state is Failure(4), see the errCode parameter for details. - * @see RtcEngine.addPublishStreamUrl - * @see RtcEngine.removePublishStreamUrl - * @see RtmpStreamingState.Failure + * + * The SDK triggers this callback to report the result of the local user calling the {@link RtcEngine.addPublishStreamUrl} or {@link RtcEngine.removePublishStreamUrl} method. This callback returns the URL and its current streaming state. When the streaming state is {@link RtmpStreamingState.Failure}, see the errCode parameter for details. + * * This callback indicates the state of the RTMP streaming. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the errCode parameter. + * + * @event RtmpStreamingStateChanged */ RtmpStreamingStateChanged: RtmpStreamingStateCallback /** * Occurs when the publisher's transcoding settings are updated. - * When the LiveTranscoding class in the setLiveTranscoding method updates, the SDK triggers this callback to report the update information. - * @see RtcEngine.setLiveTranscoding - * Note + * + * When the LiveTranscoding class in the {@link RtcEngine.setLiveTranscoding} method updates, the SDK triggers this callback to report the update information. + * + * **Note** * - If you call the setLiveTranscoding method to set the LiveTranscoding class for the first time, the SDK does not trigger this callback. + * + * @event TranscodingUpdated */ TranscodingUpdated: EmptyCallback /** * Reports the status of injecting the online media stream. + * + * @event StreamInjectedStatus */ StreamInjectedStatus: StreamInjectedStatusCallback /** * Occurs when the local user receives a remote data stream. - * The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the sendStreamMessage method. - * @see RtcEngine.sendStreamMessage + * + * The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the {@link RtcEngine.sendStreamMessage} method. + * + * @event StreamMessage */ StreamMessage: StreamMessageCallback /** * Occurs when the local user fails to receive a remote data stream. - * The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the sendStreamMessage method. - * @see RtcEngine.sendStreamMessage + * + * The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the {@link RtcEngine.sendStreamMessage} method. + * + * @event StreamMessageError */ StreamMessageError: StreamMessageErrorCallback /** * Occurs when the media engine is loaded. + * + * @event MediaEngineLoadSuccess */ MediaEngineLoadSuccess: EmptyCallback /** * Occurs when the media engine starts. + * + * @event MediaEngineStartCallSuccess */ MediaEngineStartCallSuccess: EmptyCallback /** * Occurs when the state of the media stream relay changes. + * * The SDK reports the state of the current media relay and possible error messages in this callback. + * + * @event ChannelMediaRelayStateChanged */ ChannelMediaRelayStateChanged: MediaRelayStateCallback /** * Reports events during the media stream relay. + * + * @event ChannelMediaRelayEvent */ ChannelMediaRelayEvent: MediaRelayEventCallback /** * Occurs when the first remote video frame is rendered. - * @deprecated Use Starting(1) or Decoding(2) in the onRemoteVideoStateChanged callback instead. - * @see VideoRemoteState.Starting - * @see VideoRemoteState.Decoding - * @see RemoteVideoStateChanged + * + * @deprecated Use {@link VideoRemoteState.Starting} or {@link VideoRemoteState.Decoding} in the {@link RemoteVideoStateChanged} callback instead. + * * This callback is triggered after the first frame of the remote video is rendered on the video window. The application can retrieve the data of the time elapsed from the user joining the channel until the first video frame is displayed. + * + * @event FirstRemoteVideoFrame */ FirstRemoteVideoFrame: VideoFrameWithUidCallback /** * Occurs when the first remote audio frame is received. - * @deprecated Use Starting(1) in onRemoteAudioStateChanged instead. - * @see AudioRemoteState.Starting - * @see RemoteAudioStateChanged + * + * @deprecated Use {@link AudioRemoteState.Starting} in {@link RemoteAudioStateChanged} instead. + * + * @event FirstRemoteAudioFrame */ FirstRemoteAudioFrame: UidWithElapsedCallback /** * Occurs when the engine receives the first audio frame from a specified remote user. - * @deprecated Use Decoding(2) in onRemoteAudioStateChanged instead. - * @see VideoRemoteState.Decoding - * @see RemoteAudioStateChanged + * + * @deprecated Use {@link VideoRemoteState.Decoding} in {@link RemoteAudioStateChanged} instead. + * * This callback is triggered in either of the following scenarios: * - The remote user joins the channel and sends the audio stream. * - The remote user stops sending the audio stream and re-sends it after 15 seconds. Possible reasons include: - * -- The remote user leaves channel. - * -- The remote user drops offline. - * -- The remote user calls the muteLocalAudioStream method. - * @see RtcEngine.muteLocalAudioStream - * -- The remote user calls the disableAudio method. - * @see RtcEngine.disableAudio + * - The remote user leaves channel. + * - The remote user drops offline. + * - The remote user calls the {@link RtcEngine.muteLocalAudioStream} method. + * - The remote user calls the {@link RtcEngine.disableAudio} method. + * + * @event FirstRemoteAudioDecoded */ FirstRemoteAudioDecoded: UidWithElapsedCallback /** * Occurs when a remote user stops/resumes sending the audio stream. - * @deprecated Use the onRemoteAudioStateChanged callback with the following parameters instead: - * @see RemoteAudioStateChanged - * - Stopped(0) and RemoteMuted(5). - * @see VideoRemoteState.Stopped - * @see VideoRemoteStateReason.RemoteMuted - * - Decoding(2) and RemoteUnmuted(6). - * @see VideoRemoteState.Decoding - * @see VideoRemoteStateReason.RemoteUnmuted - * The SDK triggers this callback when the remote user stops or resumes sending the audio stream by calling the muteLocalAudioStream method. - * @see RtcEngine.muteLocalAudioStream - * Note + * + * @deprecated Use the {@link RemoteAudioStateChanged} callback with the following parameters instead: + * - {@link VideoRemoteState.Stopped} and {@link VideoRemoteStateReason.RemoteMuted}. + * - {@link VideoRemoteState.Decoding} and {@link VideoRemoteStateReason.RemoteUnmuted}. + * + * The SDK triggers this callback when the remote user stops or resumes sending the audio stream by calling the {@link RtcEngine.muteLocalAudioStream} method. + * + * **Note** * - This callback is invalid when the number of users or broadcasters in the channel exceeds 20. + * + * @event UserMuteAudio */ UserMuteAudio: UidWithMutedCallback /** - * Reports the result of calling the addPublishStreamUrl method. - * @see RtcEngine.addPublishStreamUrl - * @deprecated Use onRtmpStreamingStateChanged instead. - * @see RtmpStreamingStateChanged + * Reports the result of calling the {@link RtcEngine.addPublishStreamUrl} method. + * + * @deprecated Use {@link RtmpStreamingStateChanged} instead. + * * This callback indicates whether you have successfully added an RTMP stream to the CDN. + * + * @event StreamPublished */ StreamPublished: UrlWithErrorCallback /** - * Reports the result of calling the removePublishStreamUrl method. - * @see RtcEngine.removePublishStreamUrl - * @deprecated Use onRtmpStreamingStateChanged instead. - * @see RtmpStreamingStateChanged + * Reports the result of calling the {@link RtcEngine.removePublishStreamUrl} method. + * + * @deprecated Use {@link RtmpStreamingStateChanged} instead. + * * This callback indicates whether you have successfully removed an RTMP stream from the CDN. + * + * @event StreamUnpublished */ StreamUnpublished: UrlCallback /** * Reports the transport-layer statistics of each remote audio stream. - * @deprecated This callback is deprecated. Use onRemoteAudioStats instead. - * @see RemoteAudioStats + * + * @deprecated This callback is deprecated. Use {@link RemoteAudioStats} instead. + * * This callback reports the transport-layer statistics, such as the packet loss rate and time delay, once every two seconds after the local user receives an audio packet from a remote user. + * + * @event RemoteAudioTransportStats */ RemoteAudioTransportStats: TransportStatsCallback /** * Reports the transport-layer statistics of each remote video stream. - * @deprecated This callback is deprecated. Use onRemoteVideoStats instead. - * @see RemoteVideoStats + * + * @deprecated This callback is deprecated. Use {@link RemoteVideoStats} instead. + * * This callback reports the transport-layer statistics, such as the packet loss rate and time delay, once every two seconds after the local user receives the video packet from a remote user. + * + * @event RemoteVideoTransportStats */ RemoteVideoTransportStats: TransportStatsCallback /** * Occurs when a remote user enables/disables the video module. - * @deprecated This callback is deprecated and replaced by the onRemoteVideoStateChanged callback with the following parameters: - * @see RemoteVideoStateChanged - * - Stopped(0) and RemoteMuted(5). - * @see VideoRemoteState.Stopped - * @see VideoRemoteStateReason.RemoteMuted - * - Decoding(2) and RemoteUnmuted(6). - * @see VideoRemoteState.Decoding - * @see VideoRemoteStateReason.RemoteUnmuted + * + * @deprecated This callback is deprecated and replaced by the {@link RemoteVideoStateChanged} callback with the following parameters: + * - {@link VideoRemoteState.Stopped} and {@link VideoRemoteStateReason.RemoteMuted}. + * - {@link VideoRemoteState.Decoding} and {@link VideoRemoteStateReason.RemoteUnmuted}. + * * Once the video module is disabled, the remote user can only use a voice call. The remote user cannot send or receive any video from other users. - * The SDK triggers this callback when the remote user enables or disables the video module by calling the enableVideo or disableVideo method. - * @see RtcEngine.enableVideo - * @see RtcEngine.disableVideo - * Note + * + * The SDK triggers this callback when the remote user enables or disables the video module by calling the {@link RtcEngine.enableVideo} or {@link RtcEngine.disableVideo} method. + * + * **Note** * - This callback is invalid when the number of users or broadcasters in the channel exceeds 20. + * + * @event UserEnableVideo */ UserEnableVideo: UidWithEnabledCallback /** * Occurs when a remote user enables/disables the local video capture function. - * @deprecated This callback is deprecated and replaced by the onRemoteVideoStateChanged callback with the following parameters: - * @see RemoteVideoStateChanged - * - Stopped(0) and RemoteMuted(5). - * @see VideoRemoteState.Stopped - * @see VideoRemoteStateReason.RemoteMuted - * - Decoding(2) and RemoteUnmuted(6). - * @see VideoRemoteState.Decoding - * @see VideoRemoteStateReason.RemoteUnmuted - * The SDK triggers this callback when the remote user resumes or stops capturing the video stream by calling the enableLocalVideo method. - * @see RtcEngine.enableLocalVideo + * + * @deprecated This callback is deprecated and replaced by the {@link RemoteVideoStateChanged} callback with the following parameters: + * - {@link VideoRemoteState.Stopped} and {@link VideoRemoteStateReason.RemoteMuted}. + * - {@link VideoRemoteState.Decoding} and {@link VideoRemoteStateReason.RemoteUnmuted}. + * + * The SDK triggers this callback when the remote user resumes or stops capturing the video stream by calling the {@link RtcEngine.enableLocalVideo} method. + * * This callback is only applicable to the scenario when the remote user only wants to watch the remote video without sending any video stream to the other user. + * + * @event UserEnableLocalVideo */ UserEnableLocalVideo: UidWithEnabledCallback /** * Occurs when the first remote video frame is received and decoded. - * @deprecated This callback is deprecated. Use Starting(1) or Decoding(2) in the onRemoteVideoStateChanged callback instead. - * @see VideoRemoteState.Starting - * @see VideoRemoteState.Decoding - * @see RemoteVideoStateChanged + * + * @deprecated This callback is deprecated. Use {@link VideoRemoteState.Starting} or {@link VideoRemoteState.Decoding} in the {@link RemoteVideoStateChanged} callback instead. + * * This callback is triggered in either of the following scenarios: * - The remote user joins the channel and sends the video stream. * - The remote user stops sending the video stream and re-sends it after 15 seconds. Possible reasons include: - * -- The remote user leaves channel. - * -- The remote user drops offline. - * -- The remote user calls the muteLocalVideoStream method. - * @see RtcEngine.muteLocalVideoStream - * -- The remote user calls the disableVideo method. - * @see RtcEngine.disableVideo + * - The remote user leaves channel. + * - The remote user drops offline. + * - The remote user calls the {@link RtcEngine.muteLocalVideoStream} method. + * - The remote user calls the {@link RtcEngine.disableVideo} method. + * + * @event FirstRemoteVideoDecoded */ FirstRemoteVideoDecoded: VideoFrameWithUidCallback /** * Occurs when the microphone is enabled/disabled. - * @deprecated This callback is deprecated. Use Stopped(0) or Recording(1) in the onLocalAudioStateChanged callback instead. - * @see AudioLocalState.Stopped - * @see AudioLocalState.Recording - * @see LocalAudioStateChanged - * The SDK triggers this callback when the local user resumes or stops capturing the local audio stream by calling the enableLocalAudio method. - * @see RtcEngine.enableLocalAudio + * + * @deprecated This callback is deprecated. Use {@link AudioLocalState.Stopped} or {@link AudioLocalState.Recording} in the {@link LocalAudioStateChanged} callback instead. + * + * The SDK triggers this callback when the local user resumes or stops capturing the local audio stream by calling the {@link RtcEngine.enableLocalAudio} method. + * + * @event MicrophoneEnabled */ MicrophoneEnabled: EnabledCallback /** * Occurs when the connection between the SDK and the server is interrupted. - * @deprecated Use onConnectionStateChanged instead. - * @see ConnectionStateChanged - * The SDK triggers this callback when it loses connection to the server for more than four seconds after the connection is established. After triggering this callback, the SDK tries to reconnect to the server. You can use this callback to implement pop-up reminders. This callback is different from onConnectionLost: - * @see ConnectionLost - * - The SDK triggers the onConnectionInterrupted callback when the SDK loses connection with the server for more than four seconds after it joins the channel. - * @see ConnectionInterrupted - * - The SDK triggers the onConnectionLost callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not. - * @see ConnectionLost + * + * @deprecated Use {@link ConnectionStateChanged} instead. + * + * The SDK triggers this callback when it loses connection to the server for more than four seconds after the connection is established. After triggering this callback, the SDK tries to reconnect to the server. You can use this callback to implement pop-up reminders. This callback is different from {@link ConnectionLost}: + * - The SDK triggers the {@link ConnectionInterrupted} callback when the SDK loses connection with the server for more than four seconds after it joins the channel. + * - The SDK triggers the {@link ConnectionLost} callback when it loses connection with the server for more than 10 seconds, regardless of whether it joins the channel or not. + * * If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel. + * + * @event ConnectionInterrupted */ ConnectionInterrupted: EmptyCallback /** * Occurs when your connection is banned by the Agora Server. - * @deprecated Use onConnectionStateChanged instead. - * @see ConnectionStateChanged + * + * @deprecated Use {@link ConnectionStateChanged} instead. + * + * @event ConnectionBanned */ ConnectionBanned: EmptyCallback /** * Reports the statistics of the audio stream from each remote user/host. - * @deprecated Use onRemoteAudioStats instead. - * @see RemoteAudioStats + * + * @deprecated Use {@link RemoteAudioStats} instead. + * * The SDK triggers this callback once every two seconds to report the audio quality of each remote user/host sending an audio stream. If a channel has multiple remote users/hosts sending audio streams, the SDK trggers this callback as many times. + * + * @event AudioQuality */ AudioQuality: AudioQualityCallback /** * Occurs when the camera is turned on and ready to capture video. - * @deprecated Use Capturing(1) in the onLocalVideoStateChanged callback instead. If the camera fails to turn on, fix the error reported in the onError callback. - * @see LocalVideoStreamState.Capturing - * @see LocalVideoStateChanged - * @see Error + * + * @deprecated Use {@link LocalVideoStreamState.Capturing} in the {@link LocalVideoStateChanged} callback instead. If the camera fails to turn on, fix the error reported in the {@link Error} callback. + * + * @event CameraReady */ CameraReady: EmptyCallback /** * Occurs when the video stops playing. - * @deprecated Use Stopped(0) in the onLocalVideoStateChanged callback instead. The application can use this callback to change the configuration of the view (for example, displaying other pictures in the view) after the video stops playing. - * @see LocalVideoStreamState.Stopped - * @see LocalVideoStateChanged + * + * @deprecated Use {@link LocalVideoStreamState.Stopped} in the {@link LocalVideoStateChanged} callback instead. The application can use this callback to change the configuration of the view (for example, displaying other pictures in the view) after the video stops playing. + * + * @event VideoStopped */ VideoStopped: EmptyCallback /** * Occurs when the local user receives the metadata. + * + * @event MetadataReceived */ MetadataReceived: MetadataCallback } @@ -722,42 +853,54 @@ export interface RtcEngineEvents { */ export interface RtcChannelEvents { /** - * Reports the warning code of the RtcChannel instance. - * @see RtcChannel + * Reports the warning code of the {@link RtcChannel} instance. + * + * @event Warning */ Warning: WarningCallback /** - * Reports the error code of the RtcChannel instance. - * @see RtcChannel + * Reports the error code of the {@link RtcChannel} instance. + * + * @event Error */ Error: ErrorCallback /** * Occurs when the local user joins a specified channel. - * If the uid is not specified when calling joinChannel, the server automatically assigns a uid. - * @see RtcChannel.joinChannel + * + * If the uid is not specified when calling {@link RtcChannel.joinChannel}, the server automatically assigns a uid. + * + * @event JoinChannelSuccess */ JoinChannelSuccess: UidWithElapsedCallback /** * Occurs when a user rejoins the channel after being disconnected due to network problems. + * * When a user loses connection with the server because of network problems, the SDK automatically tries to reconnect and triggers this callback upon reconnection. + * + * @event RejoinChannelSuccess */ RejoinChannelSuccess: UidWithElapsedCallback /** * Occurs when a user leaves the channel. - * When a user leaves the channel by using the leaveChannel method, the SDK uses this callback to notify the app when the user leaves the channel. - * @see RtcChannel.leaveChannel + * + * When a user leaves the channel by using the {@link RtcChannel.leaveChannel} method, the SDK uses this callback to notify the app when the user leaves the channel. + * * With this callback, the app retrieves the channel information, such as the call duration and statistics. + * + * @event LeaveChannel */ LeaveChannel: RtcStatsCallback /** * Occurs when the user role switches in a Live-Broadcast channel. For example, from broadcaster to audience or vice versa. - * The SDK triggers this callback when the local user switches the user role by calling the setClientRole method after joining the channel. - * @see RtcChannel.setClientRole + * + * The SDK triggers this callback when the local user switches the user role by calling the {@link RtcChannel.setClientRole} method after joining the channel. + * + * @event ClientRoleChanged */ ClientRoleChanged: ClientRoleCallback @@ -765,171 +908,225 @@ export interface RtcChannelEvents { * Occurs when a remote user (Communication) or a broadcaster (Live-Broadcast) joins the channel. * - Communication profile: This callback notifies the app when another user joins the channel. If other users are already in the channel, the SDK also reports to the app on the existing users. * - Live-Broadcast profile: This callback notifies the app when the host joins the channel. If other hosts are already in the channel, the SDK also reports to the app on the existing hosts. We recommend having at most 17 hosts in a channel. - * Note + * + * **Note** * - In the Live-Broadcast profile: - * -- The host receives this callback when another host joins the channel. - * -- The audience in the channel receives this callback when a new host joins the channel. - * -- When a web app joins the channel, this callback is triggered as long as the web app publishes streams. + * - The host receives this callback when another host joins the channel. + * - The audience in the channel receives this callback when a new host joins the channel. + * - When a web app joins the channel, this callback is triggered as long as the web app publishes streams. + * + * @event UserJoined */ UserJoined: UidWithElapsedCallback /** * Occurs when a remote user (Communication) or a broadcaster (Live Broadcast) leaves the channel. + * * There are two reasons for users to become offline: * - Leave the channel: When the user/broadcaster leaves the channel, the user/broadcaster sends a goodbye message. When this message is received, the SDK determines that the user/host leaves the channel. * - Go offline: When no data packet of the user or broadcaster is received for a certain period of time (around 20 seconds), the SDK assumes that the user/broadcaster drops offline. A poor network connection may lead to false detections, so we recommend using the Agora RTM SDK for reliable offline detection. + * + * @event UserOffline */ UserOffline: UserOfflineCallback /** * Occurs when the network connection state changes. + * * The Agora SDK triggers this callback to report on the current network connection state when it changes, and the reason to such change. + * + * @event ConnectionStateChanged */ ConnectionStateChanged: ConnectionStateCallback /** * Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted. - * The SDK also triggers this callback when it cannot connect to the server 10 seconds after calling joinChannel, regardless of whether it is in the channel or not. - * @see RtcChannel.joinChannel + * + * The SDK also triggers this callback when it cannot connect to the server 10 seconds after calling {@link RtcChannel.joinChannel}, regardless of whether it is in the channel or not. + * * If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK stops rejoining the channel. + * + * @event ConnectionLost */ ConnectionLost: EmptyCallback /** * Occurs when the token expires in 30 seconds. - * The user becomes offline if the token used when joining the channel expires. This callback is triggered 30 seconds before the token expires, to remind the app to get a new token. Upon receiving this callback, you need to generate a new token on the server and call renewToken to pass the new token to the SDK. - * @see RtcChannel.renewToken + * + * The user becomes offline if the token used when joining the channel expires. This callback is triggered 30 seconds before the token expires, to remind the app to get a new token. Upon receiving this callback, you need to generate a new token on the server and call {@link RtcChannel.renewToken} to pass the new token to the SDK. + * + * @event TokenPrivilegeWillExpire */ TokenPrivilegeWillExpire: TokenCallback /** * Occurs when the token has expired. - * After a token is specified when joining the channel, the token expires after a certain period of time, and a new token is required to reconnect to the server. This callback notifies the app to generate a new token and call renewToken to renew the token. - * @see RtcChannel.renewToken + * + * After a token is specified when joining the channel, the token expires after a certain period of time, and a new token is required to reconnect to the server. This callback notifies the app to generate a new token and call {@link RtcChannel.renewToken} to renew the token. + * + * @event RequestToken */ RequestToken: EmptyCallback /** * Reports which user is the loudest speaker. - * This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling enableAudioVolumeIndication, this callback returns the uid of the active speaker whose voice is detected by the audio volume detection module of the SDK. - * @see RtcChannel.enableAudioVolumeIndication - * Note - * - To receive this callback, you need to call enableAudioVolumeIndication. - * @see RtcEngine.enableAudioVolumeIndication + * + * This callback reports the speaker with the highest accumulative volume during a certain period. If the user enables the audio volume indication by calling {@link RtcEngine.enableAudioVolumeIndication}, this callback returns the uid of the active speaker whose voice is detected by the audio volume detection module of the SDK. + * + * **Note** + * - To receive this callback, you need to call {@link RtcEngine.enableAudioVolumeIndication}. * - This callback reports the ID of the user with the highest voice volume during a period of time, instead of at the moment. + * + * @event ActiveSpeaker */ ActiveSpeaker: UidCallback /** * Occurs when the video size or rotation information of a remote user changes. + * + * @event VideoSizeChanged */ VideoSizeChanged: VideoSizeCallback /** * Occurs when the remote video state changes. + * + * @event RemoteVideoStateChanged */ RemoteVideoStateChanged: RemoteVideoStateCallback /** * Occurs when the remote audio state changes. + * * This callback indicates the state change of the remote audio stream. + * + * @event RemoteAudioStateChanged */ RemoteAudioStateChanged: RemoteAudioStateCallback /** * Occurs when the published media stream falls back to an audio-only stream due to poor network conditions or switches back to video stream after the network conditions improve. - * If you call setLocalPublishFallbackOption and set option as AudioOnly(2), this callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink conditions, or when the audio stream switches back to the video after the uplink network condition improves. - * @see RtcEngine.setLocalPublishFallbackOption - * @see StreamFallbackOptions.AudioOnly + * + * If you call {@link RtcEngine.setLocalPublishFallbackOption} and set option as {@link StreamFallbackOptions.AudioOnly}, this callback is triggered when the locally published stream falls back to audio-only mode due to poor uplink conditions, or when the audio stream switches back to the video after the uplink network condition improves. + * + * @event LocalPublishFallbackToAudioOnly */ LocalPublishFallbackToAudioOnly: FallbackCallback /** * Occurs when the remote media stream falls back to audio-only stream due to poor network conditions or switches back to video stream after the network conditions improve. - * If you call setRemoteSubscribeFallbackOption and set option as AudioOnly(2), this callback is triggered when the remote media stream falls back to audio-only mode due to poor uplink conditions, or when the remote media stream switches back to the video after the uplink network condition improves. - * @see RtcEngine.setRemoteSubscribeFallbackOption - * @see StreamFallbackOptions.AudioOnly - * Note - * - Once the remote media stream is switched to the low stream due to poor network conditions, you can monitor the stream switch between a high and low stream in the onRemoteVideoStats callback. - * @see onRemoteVideoStats + * + * If you call {@link RtcEngine.setRemoteSubscribeFallbackOption} and set option as {@link StreamFallbackOptions.AudioOnly}, this callback is triggered when the remote media stream falls back to audio-only mode due to poor uplink conditions, or when the remote media stream switches back to the video after the uplink network condition improves. + * + * **Note** + * - Once the remote media stream is switched to the low stream due to poor network conditions, you can monitor the stream switch between a high and low stream in the {@link RemoteVideoStats} callback. + * + * @event RemoteSubscribeFallbackToAudioOnly */ RemoteSubscribeFallbackToAudioOnly: FallbackWithUidCallback /** - * Reports the statistics of the RtcEngine once every two seconds. - * @see RtcEngine + * Reports the statistics of the {@link RtcEngine} once every two seconds. + * + * @event RtcStats */ RtcStats: RtcStatsCallback /** * Reports the last mile network quality of each user in the channel once every two seconds. + * * Last mile refers to the connection between the local device and Agora's edge server. This callback reports once every two seconds the last mile network conditions of each user in the channel. If a channel includes multiple users, then this callback will be triggered as many times. + * + * @event NetworkQuality */ NetworkQuality: NetworkQualityWithUidCallback /** * Reports the statistics of the video stream from each remote user/broadcaster. The SDK triggers this callback once every two seconds for each remote user/broadcaster. If a channel includes multiple remote users, the SDK triggers this callback as many times. + * + * @event RemoteVideoStats */ RemoteVideoStats: RemoteVideoStatsCallback /** * Reports the statistics of the audio stream from each remote user/broadcaster. + * * The SDK triggers this callback once every two seconds for each remote user/broadcaster. If a channel includes multiple remote users, the SDK triggers this callback as many times. + * * Schemes such as FEC (Forward Error Correction) or retransmission counter the frame loss rate. Hence, users may find the overall audio quality acceptable even when the packet loss rate is high. + * + * @event RemoteAudioStats */ RemoteAudioStats: RemoteAudioStatsCallback /** * Occurs when the state of the RTMP streaming changes. - * The SDK triggers this callback to report the result of the local user calling the addPublishStreamUrl or removePublishStreamUrl method. This callback returns the URL and its current streaming state. When the streaming state is Failure(4), see the errCode parameter for details. - * @see RtcChannel.addPublishStreamUrl - * @see RtcChannel.removePublishStreamUrl - * @see RtmpStreamingState.Failure + * + * The SDK triggers this callback to report the result of the local user calling the {@link RtcChannel.addPublishStreamUrl} or {@link RtcChannel.removePublishStreamUrl} method. This callback returns the URL and its current streaming state. When the streaming state is {@link RtmpStreamingState.Failure}, see the errCode parameter for details. + * * This callback indicates the state of the RTMP streaming. When exceptions occur, you can troubleshoot issues by referring to the detailed error descriptions in the errCode parameter. + * + * @event RtmpStreamingStateChanged */ RtmpStreamingStateChanged: RtmpStreamingStateCallback /** * Occurs when the publisher's transcoding settings are updated. - * When the LiveTranscoding class in the setLiveTranscoding method updates, the SDK triggers this callback to report the update information. - * @see RtcChannel.setLiveTranscoding - * Note + * + * When the LiveTranscoding class in the {@link RtcChannel.setLiveTranscoding} method updates, the SDK triggers this callback to report the update information. + * + * **Note** * - If you call the setLiveTranscoding method to set the LiveTranscoding class for the first time, the SDK does not trigger this callback. + * + * @event TranscodingUpdated */ TranscodingUpdated: EmptyCallback /** * Reports the status of injecting the online media stream. + * + * @event StreamInjectedStatus */ StreamInjectedStatus: StreamInjectedStatusCallback /** * Occurs when the local user receives a remote data stream. - * The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the sendStreamMessage method. - * @see RtcChannel.sendStreamMessage + * + * The SDK triggers this callback when the local user receives the stream message that the remote user sends by calling the {@link RtcChannel.sendStreamMessage} method. + * + * @event StreamMessage */ StreamMessage: StreamMessageCallback /** * Occurs when the local user fails to receive a remote data stream. - * The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the sendStreamMessage method. - * @see RtcChannel.sendStreamMessage + * + * The SDK triggers this callback when the local user fails to receive the stream message that the remote user sends by calling the {@link RtcChannel.sendStreamMessage} method. + * + * @event StreamMessageError */ StreamMessageError: StreamMessageErrorCallback /** * Occurs when the state of the media stream relay changes. + * * The SDK reports the state of the current media relay and possible error messages in this callback. + * + * @event ChannelMediaRelayStateChanged */ ChannelMediaRelayStateChanged: MediaRelayStateCallback /** * Reports events during the media stream relay. + * + * @event ChannelMediaRelayEvent */ ChannelMediaRelayEvent: MediaRelayEventCallback /** * Occurs when the local user receives the metadata. + * + * @event MetadataReceived */ MetadataReceived: MetadataCallback } diff --git a/src/RtcRenderView.native.tsx b/src/src/RtcRenderView.native.tsx similarity index 59% rename from src/RtcRenderView.native.tsx rename to src/src/RtcRenderView.native.tsx index 944121e8d..57a00382a 100644 --- a/src/RtcRenderView.native.tsx +++ b/src/src/RtcRenderView.native.tsx @@ -1,13 +1,13 @@ import React, {Component} from "react"; -import {Platform, requireNativeComponent, ViewProps} from "react-native"; +import {requireNativeComponent, ViewProps} from "react-native"; -import {VideoMirrorMode, VideoRenderMode} from "./Types"; +import {VideoMirrorMode, VideoRenderMode} from "./Enums"; /** * Properties of the uid. * @property uid: int | User ID. */ -interface RtcUidProps { +export interface RtcUidProps { uid: number; } @@ -31,7 +31,7 @@ interface RtcUidProps { * @property mirrorMode: number | The video mirror mode. * @see VideoMirrorMode */ -interface RtcSurfaceViewProps extends ViewProps { +export interface RtcSurfaceViewProps extends ViewProps { zOrderMediaOverlay?: boolean; zOrderOnTop?: boolean; renderMode?: VideoRenderMode; @@ -54,93 +54,45 @@ interface RtcSurfaceViewProps extends ViewProps { * @see RtcChannel.joinChannel * @property mirror: boolean | The video mirror. */ -interface RtcTextureViewProps extends ViewProps { +export interface RtcTextureViewProps extends ViewProps { channelId?: string; mirror?: boolean; } +/** + * @ignore + */ const RCTRtcSurfaceView = requireNativeComponent('RCTAgoraRtcSurfaceView'); -class RtcSurfaceView extends Component { - render() { - return ( - - ) - } -} - -const RCTRtcTextureView = requireNativeComponent('RCTAgoraRtcTextureView'); - -class RtcTextureView extends Component { +/** + * @ignore + */ +export class RtcSurfaceView extends Component { render() { + const {channelId, uid, ...others} = this.props return ( - + ) } } /** - * View for preview local video. + * @ignore */ -export namespace RtcLocalView { - /** - * Use SurfaceView in Android. - * Use UIView in iOS. - */ - export class SurfaceView extends Component { - render() { - return ( - - ); - } - } - - /** - * Use TextureView in Android. - * Not support for iOS. - */ - export class TextureView extends Component { - render() { - if (Platform.OS === 'ios') - throw new Error('TextureView not support for iOS') - return ( - - ); - } - } -} +const RCTRtcTextureView = requireNativeComponent('RCTAgoraRtcTextureView'); /** - * View for render remote video. + * @ignore */ -export namespace RtcRemoteView { - /** - * Use SurfaceView in Android. - * Use UIView in iOS. - */ - export class SurfaceView extends Component { - render() { - return ( - - ); - } - } - - /** - * Use TextureView in Android. - * Not support for iOS. - */ - export class TextureView extends Component { - render() { - if (Platform.OS === 'ios') - throw new Error('TextureView not support for iOS') - return ( - - ); - } +export class RtcTextureView extends Component { + render() { + const {channelId, uid, ...others} = this.props + return ( + + ) } }