trtc-cloud-js-sdk 1.0.13 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.eslintrc.js +88 -0
  2. package/.prettierrc +5 -0
  3. package/CHANGELOG.md +58 -0
  4. package/build/jsdoc/clean-doc.js +12 -0
  5. package/build/jsdoc/fix-doc.js +141 -0
  6. package/build/jsdoc/jsdoc.json +42 -0
  7. package/build/package-bundle.js +29 -0
  8. package/build/rollup.config.dev.js +88 -0
  9. package/build/rollup.config.prod.js +93 -0
  10. package/build/rollup.js +359 -0
  11. package/build/template/npm-package/package.json +24 -0
  12. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/base.css +213 -0
  13. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/index.html +80 -0
  14. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.css +1 -0
  15. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.js +1 -0
  16. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sort-arrow-sprite.png +0 -0
  17. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sorter.js +158 -0
  18. package/examples/apiExample/.env +2 -0
  19. package/examples/apiExample/README.md +70 -0
  20. package/examples/apiExample/package-lock.json +30915 -0
  21. package/examples/apiExample/package.json +51 -0
  22. package/examples/apiExample/public/audio.js +195 -0
  23. package/examples/apiExample/public/audio.js.map +7 -0
  24. package/examples/apiExample/public/av_processing.js +1 -0
  25. package/examples/apiExample/public/basic/av_processing.wasm +0 -0
  26. package/examples/apiExample/public/basic/worker.js +10434 -0
  27. package/examples/apiExample/public/favicon.ico +0 -0
  28. package/examples/apiExample/public/index.html +47 -0
  29. package/examples/apiExample/public/logo192.png +0 -0
  30. package/examples/apiExample/public/logo512.png +0 -0
  31. package/examples/apiExample/public/manifest.json +25 -0
  32. package/examples/apiExample/public/robots.txt +3 -0
  33. package/examples/apiExample/src/App.css +37 -0
  34. package/examples/apiExample/src/App.js +25 -0
  35. package/examples/apiExample/src/api/http.js +127 -0
  36. package/examples/apiExample/src/api/nav.js +44 -0
  37. package/examples/apiExample/src/components/BasicInfoComponent.css +16 -0
  38. package/examples/apiExample/src/components/BasicInfoComponent.js +27 -0
  39. package/examples/apiExample/src/config/gen-test-user-sig.js +64 -0
  40. package/examples/apiExample/src/config/lib-generate-test-usersig.min.js +7052 -0
  41. package/examples/apiExample/src/config/nav.js +136 -0
  42. package/examples/apiExample/src/home.js +16 -0
  43. package/examples/apiExample/src/index.css +21 -0
  44. package/examples/apiExample/src/index.js +12 -0
  45. package/examples/apiExample/src/logo.svg +1 -0
  46. package/examples/apiExample/src/page/basic/screen-share/index.css +52 -0
  47. package/examples/apiExample/src/page/basic/screen-share/index.js +223 -0
  48. package/examples/apiExample/src/page/basic/setDevice/index.js +262 -0
  49. package/examples/apiExample/src/page/basic/setDevice/index.scss +93 -0
  50. package/examples/apiExample/src/page/basic/video-call/index.js +521 -0
  51. package/examples/apiExample/src/page/basic/video-call/index.scss +93 -0
  52. package/examples/apiExample/src/page/basic/video-call-init/index.js +382 -0
  53. package/examples/apiExample/src/page/basic/video-call-init/index.scss +93 -0
  54. package/examples/apiExample/src/page/basic/video-live/index.css +37 -0
  55. package/examples/apiExample/src/page/basic/video-live/index.js +188 -0
  56. package/examples/apiExample/src/page/layout.js +22 -0
  57. package/examples/apiExample/src/page/layout.scss +76 -0
  58. package/examples/apiExample/src/utils/utils.js +35 -0
  59. package/examples/jsExample/assets/css/bootstrap-material-design.css +12169 -0
  60. package/examples/jsExample/assets/css/bootstrap-material-design.min.css +8 -0
  61. package/examples/jsExample/assets/css/common.css +48 -0
  62. package/examples/jsExample/assets/icon/iconfont.js +1 -0
  63. package/examples/jsExample/assets/js/bootstrap-material-design.js +6939 -0
  64. package/examples/jsExample/assets/js/bootstrap-material-design.js.map +1 -0
  65. package/examples/jsExample/assets/js/bootstrap-material-design.min.js +1 -0
  66. package/examples/jsExample/assets/js/graph.js +695 -0
  67. package/examples/jsExample/assets/js/jquery-3.2.1.min.js +4 -0
  68. package/examples/jsExample/assets/js/jquery-3.2.1.slim.min.js +4 -0
  69. package/examples/jsExample/assets/js/lib-generate-test-usersig.min.js +2 -0
  70. package/examples/jsExample/assets/js/popper.js +2442 -0
  71. package/examples/jsExample/index.html +57 -0
  72. package/examples/jsExample/rtc/css/common.css +82 -0
  73. package/examples/jsExample/rtc/index.html +107 -0
  74. package/examples/jsExample/rtc/js/index.js +142 -0
  75. package/examples/vueDemo/LICENSE +21 -0
  76. package/examples/vueDemo/README.md +144 -0
  77. package/examples/vueDemo/README_EN.md +136 -0
  78. package/examples/vueDemo/av_processing.wasm +0 -0
  79. package/examples/vueDemo/index.html +23 -0
  80. package/examples/vueDemo/package-lock.json +1375 -0
  81. package/examples/vueDemo/package.json +36 -0
  82. package/examples/vueDemo/src/App.vue +12 -0
  83. package/examples/vueDemo/src/api/index.js +59 -0
  84. package/examples/vueDemo/src/assets/css/color-dark.css +28 -0
  85. package/examples/vueDemo/src/assets/css/icon.css +4 -0
  86. package/examples/vueDemo/src/assets/css/main.css +177 -0
  87. package/examples/vueDemo/src/assets/img/img.jpg +0 -0
  88. package/examples/vueDemo/src/assets/img/login-bg.jpg +0 -0
  89. package/examples/vueDemo/src/components/Header.vue +172 -0
  90. package/examples/vueDemo/src/components/Sidebar.vue +117 -0
  91. package/examples/vueDemo/src/components/Tags.vue +174 -0
  92. package/examples/vueDemo/src/components/tendency.vue +206 -0
  93. package/examples/vueDemo/src/components/trtc/main-menu.vue +50 -0
  94. package/examples/vueDemo/src/components/trtc/nav-bar.vue +53 -0
  95. package/examples/vueDemo/src/components/trtc/show-screen-capture.vue +118 -0
  96. package/examples/vueDemo/src/components/trtc/trtc-state-check.vue +117 -0
  97. package/examples/vueDemo/src/config/gen-test-user-sig.js +67 -0
  98. package/examples/vueDemo/src/config/lib-generate-test-usersig.min.js +7052 -0
  99. package/examples/vueDemo/src/main.js +11 -0
  100. package/examples/vueDemo/src/plugins/element.js +17 -0
  101. package/examples/vueDemo/src/router/index.js +73 -0
  102. package/examples/vueDemo/src/store/sidebar.js +17 -0
  103. package/examples/vueDemo/src/store/tags.js +48 -0
  104. package/examples/vueDemo/src/utils/i18n.js +24 -0
  105. package/examples/vueDemo/src/utils/request.js +34 -0
  106. package/examples/vueDemo/src/utils/utils.js +35 -0
  107. package/examples/vueDemo/src/views/Home.vue +46 -0
  108. package/examples/vueDemo/src/views/I18n.vue +40 -0
  109. package/examples/vueDemo/src/views/Icon.vue +229 -0
  110. package/examples/vueDemo/src/views/basic/trtc.vue +194 -0
  111. package/examples/vueDemo/src/views/feature/index.vue +259 -0
  112. package/examples/vueDemo/src/views/github/index.vue +243 -0
  113. package/examples/vueDemo/src/views/improve/live-index.vue +256 -0
  114. package/examples/vueDemo/src/views/improve/live-room-anchor.vue +689 -0
  115. package/examples/vueDemo/src/views/improve/live-room-audience.vue +383 -0
  116. package/examples/vueDemo/src/views/sdkAppId/index.vue +284 -0
  117. package/examples/vueDemo/vite.config.js +18 -0
  118. package/examples/vueDemo/worker.js +22 -0
  119. package/karma.conf.js +99 -0
  120. package/package.json +57 -7
  121. package/scripts/publish.js +86 -0
  122. package/src/Camera.ts +80 -0
  123. package/src/Mic.ts +145 -0
  124. package/src/common/IError.ts +6 -0
  125. package/src/common/ITRTCCloud.ts +68 -0
  126. package/src/common/constants.ts +116 -0
  127. package/src/common/trtc-code.ts +43 -0
  128. package/src/common/trtc-define.ts +1007 -0
  129. package/src/common/trtc-event.ts +29 -0
  130. package/src/index.ts +1672 -0
  131. package/src/utils/environment.js +297 -0
  132. package/src/utils/raf.js +131 -0
  133. package/src/utils/time.js +22 -0
  134. package/src/utils/utils.ts +71 -0
  135. package/src/utils/uuid.js +12 -0
  136. package/test/unit/env.test.js +25 -0
  137. package/test/unit/get-user-media.test.js +40 -0
  138. package/test/unit/ice-parser.test.js +23 -0
  139. package/test/unit/sdp.test.js +45 -0
  140. package/test/unit/signal.test.js +78 -0
  141. package/tsconfig.json +32 -0
  142. package/trtc-cloud-js-sdk.js +0 -1
  143. /package/{README.md → build/template/npm-package/README.md} +0 -0
@@ -0,0 +1,1007 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * TRTC 关键类型定义<br>
4
+ * @description 分辨率、质量等级等枚举和常量值的定义
5
+ */
6
+ /////////////////////////////////////////////////////////////////////////////////
7
+ //
8
+ // 【(一)视频相关枚举值定义】
9
+ //
10
+ /////////////////////////////////////////////////////////////////////////////////
11
+ /**
12
+ * 视频分辨率<br>
13
+ * 此处仅定义了横屏分辨率,如果要使用360 × 640这样的竖屏分辨率,需要同时指定 TRTCVideoResolutionMode 为 Portrait。
14
+ * @enum {Number}
15
+ */
16
+ const TRTCVideoResolution_HACK_JSDOC = {
17
+ /// 宽高比1:1
18
+ /** [C] 建议码率80kbps */
19
+ TRTCVideoResolution_120_120: 1,
20
+ /** [C] 建议码率100kbps */
21
+ TRTCVideoResolution_160_160: 3,
22
+ /** [C] 建议码率200kbps */
23
+ TRTCVideoResolution_270_270: 5,
24
+ /** [C] 建议码率350kbps */
25
+ TRTCVideoResolution_480_480: 7,
26
+
27
+ /// 宽高比4:3
28
+ /** [C] 建议码率100kbps */
29
+ TRTCVideoResolution_160_120: 50,
30
+ /** [C] 建议码率150kbps */
31
+ TRTCVideoResolution_240_180: 52,
32
+ /** [C] 建议码率200kbps */
33
+ TRTCVideoResolution_280_210: 54,
34
+ /** [C] 建议码率250kbps */
35
+ TRTCVideoResolution_320_240: 56,
36
+ /** [C] 建议码率300kbps */
37
+ TRTCVideoResolution_400_300: 58,
38
+ /** [C] 建议码率400kbps */
39
+ TRTCVideoResolution_480_360: 60,
40
+ /** [C] 建议码率600kbps */
41
+ TRTCVideoResolution_640_480: 62,
42
+ /** [C] 建议码率1000kbps */
43
+ TRTCVideoResolution_960_720: 64,
44
+
45
+ /// 宽高比16:9
46
+ /** [C] 建议码率150kbps */
47
+ TRTCVideoResolution_160_90: 100,
48
+ /** [C] 建议码率200kbps */
49
+ TRTCVideoResolution_256_144: 102,
50
+ /** [C] 建议码率250kbps */
51
+ TRTCVideoResolution_320_180: 104,
52
+ /** [C] 建议码率350kbps */
53
+ TRTCVideoResolution_480_270: 106,
54
+ /** [C] 建议码率550kbps */
55
+ TRTCVideoResolution_640_360: 108,
56
+ /** [C] 建议码率850kbps */
57
+ TRTCVideoResolution_960_540: 110,
58
+ /**
59
+ * [C] 摄像头采集 - 建议码率1200kbps<br>
60
+ * [S] 屏幕分享 - 建议码率 低清:1000kbps 高清:1600kbps
61
+ */
62
+ TRTCVideoResolution_1280_720: 112,
63
+ /** [S] 屏幕分享 - 建议码率2000kbps */
64
+ TRTCVideoResolution_1920_1080: 114,
65
+ };
66
+ export enum TRTCVideoResolution {
67
+ TRTCVideoResolution_120_120 = 1,
68
+ TRTCVideoResolution_160_160 = 3,
69
+ TRTCVideoResolution_270_270 = 5,
70
+ TRTCVideoResolution_480_480 = 7,
71
+ TRTCVideoResolution_160_120 = 50,
72
+ TRTCVideoResolution_240_180 = 52,
73
+ TRTCVideoResolution_280_210 = 54,
74
+ TRTCVideoResolution_320_240 = 56,
75
+ TRTCVideoResolution_400_300 = 58,
76
+ TRTCVideoResolution_480_360 = 60,
77
+ TRTCVideoResolution_640_480 = 62,
78
+ TRTCVideoResolution_960_720 = 64,
79
+ TRTCVideoResolution_160_90 = 100,
80
+ TRTCVideoResolution_256_144 = 102,
81
+ TRTCVideoResolution_320_180 = 104,
82
+ TRTCVideoResolution_480_270 = 106,
83
+ TRTCVideoResolution_640_360 = 108,
84
+ TRTCVideoResolution_960_540 = 110,
85
+ TRTCVideoResolution_1280_720 = 112,
86
+ TRTCVideoResolution_1920_1080 = 114,
87
+ }
88
+ /**
89
+ * 视频流类型<br>
90
+ * TRTC 内部有三种不同的音视频流,分别是:
91
+ * - 主画面:最常用的一条线路,一般用来传输摄像头的视频数据。
92
+ * - 小画面:跟主画面的内容相同,但是分辨率和码率更低。
93
+ * - 辅流画面:一般用于屏幕分享,以及远程播片(比如老师放一段视频给学生)。
94
+ * 注意:
95
+ * - 如果主播的上行网络和性能比较好,则可以同时送出大小两路画面。
96
+ * - SDK 不支持单独开启小画面,小画面必须依附于主画面而存在。
97
+ * @enum {Number}
98
+ */
99
+ const TRTCVideoStreamType_HACK_JSDOC = {
100
+ /** 大画面视频流 */
101
+ TRTCVideoStreamTypeBig: 0,
102
+ /** 小画面视频流 */
103
+ TRTCVideoStreamTypeSmall: 1,
104
+ /** 辅流(屏幕分享) */
105
+ TRTCVideoStreamTypeSub: 2,
106
+ };
107
+ export enum TRTCVideoStreamType {
108
+ TRTCVideoStreamTypeBig = 0,
109
+ TRTCVideoStreamTypeSmall = 1,
110
+ TRTCVideoStreamTypeSub = 2,
111
+ }
112
+ /**
113
+ * 视频画面填充模式<br>
114
+ * 如果画面的显示分辨率不等于画面的原始分辨率,就需要您设置画面的填充模式:
115
+ * - TRTCVideoFillMode_Fill,图像铺满屏幕,超出显示视窗的视频部分将被截掉,所以画面显示可能不完整。
116
+ * - TRTCVideoFillMode_Fit,图像长边填满屏幕,短边区域会被填充黑色,但画面的内容肯定是完整的。
117
+ * @enum {Number}
118
+ */
119
+ const TRTCVideoFillMode_HACK_JSDOC = {
120
+ /** 图像铺满屏幕,超出显示视窗的视频部分将被截掉 */
121
+ TRTCVideoFillMode_Fill: 0,
122
+ /** 图像长边填满屏幕,短边区域会被填充黑色 */
123
+ TRTCVideoFillMode_Fit: 1,
124
+ };
125
+ export enum TRTCVideoFillMode {
126
+ TRTCVideoFillMode_Fill = 0,
127
+ TRTCVideoFillMode_Fit = 1,
128
+ }
129
+ /**
130
+ * 画面渲染镜像类型<br>
131
+ * TRTC 的画面镜像提供下列设置模式
132
+ * @enum {Number}
133
+ */
134
+ const TRTCVideoMirrorType_HACK_JSDOC = {
135
+ /** 只适用于移动端, 本地预览时,前置摄像头镜像,后置摄像头不镜像 */
136
+ TRTCVideoMirrorType_Auto: 0,
137
+ /** 所有画面均镜像 */
138
+ TRTCVideoMirrorType_Enable: 1,
139
+ /** 所有画面均不镜像 */
140
+ TRTCVideoMirrorType_Disable: 2,
141
+ };
142
+ export enum TRTCVideoMirrorType {
143
+ TRTCVideoMirrorType_Auto = 0,
144
+ TRTCVideoMirrorType_Enable = 1,
145
+ TRTCVideoMirrorType_Disable = 2,
146
+ }
147
+ /**
148
+ * 美颜(磨皮)算法<br>
149
+ * TRTC SDK 内置了多种不同的磨皮算法,您可以选择最适合您产品定位的方案。
150
+ * @enum {Number}
151
+ */
152
+ const TRTCBeautyStyle_HACK_JSDOC = {
153
+ /** 光滑,适用于美女秀场,效果比较明显。 */
154
+ TRTCBeautyStyleSmooth: 0,
155
+ /** 自然,磨皮算法更多地保留了面部细节,主观感受上会更加自然。 */
156
+ TRTCBeautyStyleNature: 1,
157
+ };
158
+ export enum TRTCBeautyStyle {
159
+ TRTCBeautyStyleSmooth = 0,
160
+ TRTCBeautyStyleNature = 1,
161
+ }
162
+
163
+ /////////////////////////////////////////////////////////////////////////////////
164
+ //
165
+ // 【(二)网络相关枚举值定义】
166
+ //
167
+ /////////////////////////////////////////////////////////////////////////////////
168
+ /**
169
+ * 应用场景<br>
170
+ * TRTC 可用于视频会议和在线直播等多种应用场景,针对不同的应用场景,TRTC SDK 的内部会进行不同的优化配置:
171
+ * - TRTCAppSceneVideoCall :视频通话场景,适合[1对1视频通话]、[300人视频会议]、[在线问诊]、[视频聊天]、[远程面试]等。
172
+ * - TRTCAppSceneLIVE :视频互动直播,适合[视频低延时直播]、[十万人互动课堂]、[视频直播 PK]、[视频相亲房]、[互动课堂]、[远程培训]、[超大型会议]等。
173
+ * - TRTCAppSceneAudioCall :语音通话场景,适合[1对1语音通话]、[300人语音会议]、[语音聊天]、[语音会议]、[在线狼人杀]等。
174
+ * - TRTCAppSceneVoiceChatRoom:语音互动直播,适合:[语音低延时直播]、[语音直播连麦]、[语聊房]、[K 歌房]、[FM 电台]等。
175
+ * @enum {Number}
176
+ */
177
+ const TRTCAppScene_HACK_JSDOC = {
178
+ /**
179
+ * 视频通话场景,支持720P、1080P高清画质,单个房间最多支持300人同时在线,最高支持50人同时发言。<br>
180
+ * 适合:[视频低延时直播]、[十万人互动课堂]、[视频直播 PK]、[视频相亲房]、[互动课堂]、[远程培训]、[超大型会议]等。<br>
181
+ * 注意:此场景下,您必须通过 TRTCParams 中的 role 字段指定当前用户的角色。
182
+ */
183
+ TRTCAppSceneVideoCall: 0,
184
+ /**
185
+ * 视频互动直播,支持平滑上下麦,切换过程无需等待,主播延时小于300ms;支持十万级别观众同时播放,播放延时低至1000ms。<br>
186
+ * 在线直播场景,内部编码器和网络协议优化侧重性能和兼容性,性能和清晰度表现更佳。
187
+ */
188
+ TRTCAppSceneLIVE: 1,
189
+ /**
190
+ * 语音通话场景,支持 48kHz,支持双声道。单个房间最多支持300人同时在线,最高支持50人同时发言。<br>
191
+ * 适合:[1对1语音通话]、[300人语音会议]、[语音聊天]、[语音会议]、[在线狼人杀]等。
192
+ */
193
+ TRTCAppSceneAudioCall: 2,
194
+ /**
195
+ * 语音互动直播,支持平滑上下麦,切换过程无需等待,主播延时小于300ms;支持十万级别观众同时播放,播放延时低至1000ms。<br>
196
+ * 适合:[语音低延时直播]、[语音直播连麦]、[语聊房]、[K 歌房]、[FM 电台]等。<br>
197
+ * 注意:此场景下,您必须通过 TRTCParams 中的 role 字段指定当前用户的角色。
198
+ */
199
+ TRTCAppSceneVoiceChatRoom: 3,
200
+ };
201
+ export enum TRTCAppScene {
202
+ TRTCAppSceneVideoCall = 0,
203
+ TRTCAppSceneLIVE = 1,
204
+ TRTCAppSceneAudioCall = 2,
205
+ TRTCAppSceneVoiceChatRoom = 3,
206
+ }
207
+ /**
208
+ * 角色,仅适用于直播场景(TRTCAppSceneLIVE 和 TRTCAppSceneVoiceChatRoom)<br>
209
+ * 在直播场景中,多数用户只是观众,只有个别用户是主播,这种角色区分可以有利于 TRTC 进行更好的定向优化。
210
+ * - Anchor:主播,可以上行视频和音频,一个房间里最多支持50个主播同时上行音视频。
211
+ * - Audience:观众,只能观看,不能上行视频和音频,一个房间里的观众人数没有上限。
212
+ * @enum {Number}
213
+ */
214
+ const TRTCRoleType_HACK_JSDOC = {
215
+ /** 主播 */
216
+ TRTCRoleAnchor: 20,
217
+ /** 观众 */
218
+ TRTCRoleAudience: 21,
219
+ };
220
+ export enum TRTCRoleType {
221
+ TRTCRoleAnchor = 20,
222
+ TRTCRoleAudience = 21,
223
+ }
224
+
225
+ /////////////////////////////////////////////////////////////////////////////////
226
+ //
227
+ // 【(三)继承 TXLiteAVBase 的定义】
228
+ //
229
+ /////////////////////////////////////////////////////////////////////////////////
230
+ /**
231
+ * 音频质量<br>
232
+ * @enum {Number}
233
+ */
234
+ const TRTCAudioQuality_HACK_JSDOC = {
235
+ /** 标准模式(或者默认模式):采样率:48k;单声道;音频码率:40kbps;SDK 默认的音频质量 */
236
+ TRTCAudioQualityDefault: 0,
237
+ /** 高音质模式:采样率:48k;单声道;音频码率:128kbps */
238
+ TRTCAudioQualitySpeech: 1,
239
+ /** 标准立体声模式:采样率:48k;双声道;音频码率:64kbps */
240
+ // WebRTCAudioQualityStandardStereo: 2, // electron 没有该参数
241
+ /** 高音质立体声模式:采样率:48k;双声道;音频码率:192kbps */
242
+ TRTCAudioQualityMusic: 3,
243
+ };
244
+ export enum TRTCAudioQuality {
245
+ TRTCAudioQualityDefault = 0, // electron TRTCAudioQualityDefault = 2,
246
+ TRTCAudioQualitySpeech = 1,
247
+ TRTCAudioQualityMusic = 3,
248
+ }
249
+ /**
250
+ * 设备信息<br>
251
+ * @param {String} deviceId - 设备PID,字符编码格式是UTF-8
252
+ * @param {String} deviceName - 设备名称,字符编码格式是UTF-8
253
+ * @param {String} kind - 设备类型,['videoinput' | 'audioinput']
254
+ * @param {String} deviceName - 设备名称,字符编码格式是UTF-8
255
+ */
256
+ export class TRTCDeviceInfo {
257
+ public deviceId: string;
258
+ public deviceName: string;
259
+ public kind?: string;
260
+ public label?: string; // 就是 deviceName
261
+ public groupId?: string;
262
+ constructor(deviceId = '', deviceName = '', kind = '', label = '', groupId = '') {
263
+ this.deviceId = deviceId;
264
+ this.deviceName = deviceName;
265
+ this.kind = kind;
266
+ this.label = label;
267
+ this.groupId = groupId;
268
+ }
269
+ }
270
+ // /**
271
+ // * 视频帧数据<br/>
272
+ // * @param {TRTCVideoPixelFormat} videoFormat - 视频帧的格式
273
+ // * @param {TRTCVideoBufferType} bufferType - 视频数据结构类型
274
+ // * @param {ArrayBuffer} data - 视频数据,字段 bufferType 是 LiteAVVideoBufferType_Buffer 时生效
275
+ // * @param {Number} textureId - 视频纹理ID,字段bufferType是LiteAVVideoBufferType_Texture时生效
276
+ // * @param {Number} length - 视频数据的长度,单位是字节,对于i420而言, length = width * height * 3 / 2,对于BGRA32而言, length = width * height * 4
277
+ // * @param {Number} width - 画面的宽度
278
+ // * @param {Number} height - 画面的高度
279
+ // * @param {Number} timestamp - 时间戳,单位ms
280
+ // * @param {Number} rotation - 画面旋转角度
281
+ // */
282
+ // export class TRTCVideoFrame {
283
+ // public videoFormat: number;
284
+ // public bufferType: number;
285
+ // public data: null | ArrayBuffer;
286
+ // public textureId: number;
287
+ // public length: number;
288
+ // public width: number;
289
+ // public height: number;
290
+ // public timestamp: number;
291
+ // public rotation: number;
292
+ // constructor(
293
+ // videoFormat = TRTCVideoPixelFormat.TRTCVideoPixelFormat_Unknown,
294
+ // bufferType = TRTCVideoBufferType.TRTCVideoBufferType_Unknown,
295
+ // data: null | ArrayBuffer = null,
296
+ // textureId = 0,
297
+ // length = 0,
298
+ // width = 0,
299
+ // height = 0,
300
+ // timestamp = 0,
301
+ // rotation = 0,
302
+ // ) {
303
+ // this.videoFormat = videoFormat;
304
+ // this.bufferType = bufferType;
305
+ // this.data = data;
306
+ // this.textureId = textureId;
307
+ // this.length = length;
308
+ // this.width = width;
309
+ // this.height = height;
310
+ // this.timestamp = timestamp;
311
+ // this.rotation = rotation;
312
+ // }
313
+ // }
314
+
315
+ /////////////////////////////////////////////////////////////////////////////////
316
+ //
317
+ // 【(四)更多枚举值定义】
318
+ //
319
+ /////////////////////////////////////////////////////////////////////////////////
320
+ /**
321
+ * 设备操作<br>
322
+ * @enum {Number}
323
+ */
324
+ const TRTCDeviceState_HACK_JSDOC = {
325
+ /** 添加设备 */
326
+ TRTCDeviceStateAdd: 0,
327
+ /** 移除设备 */
328
+ TRTCDeviceStateRemove: 1,
329
+ /** 设备已启用 */
330
+ TRTCDeviceStateActive: 2,
331
+ };
332
+ export enum TRTCDeviceState {
333
+ TRTCDeviceStateAdd = 0,
334
+ TRTCDeviceStateRemove = 1,
335
+ TRTCDeviceStateActive = 2,
336
+ }
337
+
338
+ /**
339
+ * 设备类型<br>
340
+ * @enum {Number}
341
+ */
342
+ const TRTCDeviceType_HACK_JSDOC = {
343
+ /** 未知类型 */
344
+ TRTCDeviceTypeUnknow: -1,
345
+ /** 麦克风 */
346
+ TRTCDeviceTypeMic: 0,
347
+ /** 扬声器 */
348
+ TRTCDeviceTypeSpeaker: 1,
349
+ /** 摄像头 */
350
+ TRTCDeviceTypeCamera: 2,
351
+ };
352
+ export enum TRTCDeviceType {
353
+ TRTCDeviceTypeUnknow = -1,
354
+ TRTCDeviceTypeMic = 0,
355
+ TRTCDeviceTypeSpeaker = 1,
356
+ TRTCDeviceTypeCamera = 2,
357
+ }
358
+
359
+ /////////////////////////////////////////////////////////////////////////////////
360
+ //
361
+ // 【(五)TRTC 核心类型定义】
362
+ //
363
+ /////////////////////////////////////////////////////////////////////////////////
364
+ /**
365
+ * 进房相关参数<br>
366
+ * 只有该参数填写正确,才能顺利调用 enterRoom 进入 roomId 所指定的音视频房间。
367
+ * @param {Number} sdkAppId - 【字段含义】应用标识(必填),腾讯视频云基于 sdkAppId 完成计费统计。<br>
368
+ * 【推荐取值】在腾讯云 [TRTC 控制台](https://console.cloud.tencent.com/rav/) 中创建应用,之后可以在账号信息页面中得到该 ID。<br>
369
+ * @param {String} userId - 【字段含义】用户标识(必填)。当前用户的 userId,相当于用户名,UTF-8编码。<br>
370
+ * 【推荐取值】如果一个用户在您的账号系统中的 ID 为“abc”,则 userId 即可设置为“abc”。<br>
371
+ * @param {String} userSig - 【字段含义】用户签名(必填),当前 userId 对应的验证签名,相当于登录密码。<br>
372
+ * 【推荐取值】请参考 [如何计算UserSig](https://cloud.tencent.com/document/product/647/17275)。<br>
373
+ * @param {Number} roomId - 【字段含义】房间号码(必填),指定房间号,在同一个房间里的用户(userId)可以彼此看到对方并进行视频通话, roomId 和 strRoomId 必须填一个, 若您选用 strRoomId,则 roomId 需要填写为0。<br>
374
+ * 【推荐取值】您可以随意指定,但请不要重复,如果您的用户账号 ID 是数字类型的,可以直接用创建者的用户 ID 作为 roomId。<br>
375
+ * @param {String} strRoomId - 【字段含义】字符串房间号码(选填),roomId 和 strRoomId 必须填一个。若两者都填,则优先选择 roomId。<br>
376
+ * 【推荐取值】您可以随意指定,但请不要重复。<br>
377
+ * @param {TRTCRoleType} role - 【字段含义】直播场景下的角色,仅适用于直播场景(TRTCAppSceneLIVE 和 TRTCAppSceneVoiceChatRoom),视频通话场景下指定无效。<br>
378
+ * 【推荐取值】默认值:主播(TRTCRoleAnchor)<br>
379
+ * @param {String} privateMapKey - 【字段含义】房间签名(非必填),如果您希望某个房间只能让特定的某些 userId 进入,就需要使用 privateMapKey 进行权限保护。<br>
380
+ * 【推荐取值】仅建议有高级别安全需求的客户使用,参考文档:[进房权限保护](https://cloud.tencent.com/document/product/647/32240)<br>
381
+ * @param {String} businessInfo - 【字段含义】业务数据(非必填),某些非常用的高级特性才需要用到此字段。<br>
382
+ * 【推荐取值】不建议使用<br>
383
+ * @param {String} streamId - 【字段含义】绑定腾讯云直播 CDN 流 ID[非必填],设置之后,您就可以在腾讯云直播 CDN 上通过标准直播方案(FLV或HLS)播放该用户的音视频流。<br>
384
+ * 【推荐取值】限制长度为64字节,可以不填写,一种推荐的方案是使用 “sdkappid_roomid_userid_main” 作为 streamid,这样比较好辨认且不会在您的多个应用中发生冲突。<br>
385
+ * 【特殊说明】要使用腾讯云直播 CDN,您需要先在[控制台](https://console.cloud.tencent.com/trtc/) 中的功能配置页开启“启动自动旁路直播”开关。<br>
386
+ * 【参考文档】[CDN 旁路直播](https://cloud.tencent.com/document/product/647/16826)。
387
+ * @param {String} userDefineRecordId - 【字段含义】设置云端录制完成后的回调消息中的 "userdefinerecordid" 字段内容,便于您更方便的识别录制回调。<br>
388
+ * 【推荐取值】限制长度为64字节,只允许包含大小写英文字母(a-zA-Z)、数字(0-9)及下划线和连词符。<br>
389
+ * 【参考文档】[云端录制](https://cloud.tencent.com/document/product/647/16823)。
390
+ */
391
+ export class TRTCParams {
392
+ public sdkAppId: number;
393
+ public userId: string;
394
+ public userSig: string;
395
+ public roomId: number;
396
+ public strRoomId: string;
397
+ public role: number;
398
+ public privateMapKey: null | string;
399
+ // public businessInfo: null | string;
400
+ public streamId: null | string;
401
+ public userDefineRecordId: null | string;
402
+ public frameWorkType: number;
403
+ constructor(
404
+ sdkAppId = 0,
405
+ userId = '',
406
+ userSig = '',
407
+ roomId = 0,
408
+ strRoomId = '',
409
+ role = TRTCRoleType.TRTCRoleAnchor,
410
+ privateMapKey: null | string = null,
411
+ businessInfo: null | string = null,
412
+ streamId: null | string = null,
413
+ userDefineRecordId: null | string = null,
414
+ frameWorkType: number = 30,
415
+ ) {
416
+ this.sdkAppId = sdkAppId;
417
+ this.userId = userId;
418
+ this.userSig = userSig;
419
+ this.roomId = roomId;
420
+ this.strRoomId = strRoomId;
421
+ this.role = role;
422
+ this.privateMapKey = privateMapKey;
423
+ // this.businessInfo = businessInfo;
424
+ this.streamId = streamId;
425
+ this.userDefineRecordId = userDefineRecordId;
426
+ this.frameWorkType = frameWorkType;
427
+ }
428
+ }
429
+ /**
430
+ * 视频编码参数<br>
431
+ * 该设置决定了远端用户看到的画面质量(同时也是云端录制出的视频文件的画面质量)。
432
+ * @param {TRTCVideoResolution} videoResolution - 【字段含义】 视频分辨率<br>
433
+ * 【推荐取值】 <br>
434
+ * - 视频通话建议选择360 × 640及以下分辨率,resMode 选择 Portrait。<br>
435
+ * - 手机直播建议选择 540 × 960,resMode 选择 Portrait。<br>
436
+ * - Window 和 iMac 建议选择 640 × 360 及以上分辨率,resMode 选择 Landscape。
437
+ * 【特别说明】 TRTCVideoResolution 默认只能横屏模式的分辨率,例如640 × 360。<br>
438
+ * 如需使用竖屏分辨率,请指定 resMode 为 Portrait,例如640 × 360结合 Portrait 则为360 × 640。<br>
439
+ * @param {Number} videoFps - 【字段含义】视频采集帧率<br>
440
+ * 【推荐取值】15fps 或 20fps,10fps 以下会有轻微卡顿感,5fps 以下卡顿感明显,20fps 以上的帧率则过于浪费(电影的帧率也只有 24fps)。<br>
441
+ * 【特别说明】很多 Android 手机的前置摄像头并不支持15fps以上的采集帧率,部分过于突出美颜功能的 Android 手机前置摄像头的采集帧率可能低于10fps。<br>
442
+ * @param {Number} videoBitrate - 【字段含义】视频上行码率<br>
443
+ * 【推荐取值】推荐设置请参考本文件前半部分 TRTCVideoResolution 定义处的注释说明<br>
444
+ * 【特别说明】码率太低会导致视频中有很多的马赛克<br>
445
+ */
446
+ export class TRTCVideoEncParam {
447
+ public videoResolution: TRTCVideoResolution;
448
+ // public resMode: TRTCVideoResolutionMode;
449
+ public videoFps: number;
450
+ public videoBitrate: number;
451
+ // public minVideoBitrate: number;
452
+ // public enableAdjustRes: boolean;
453
+ constructor(
454
+ videoResolution: TRTCVideoResolution = TRTCVideoResolution.TRTCVideoResolution_640_360,
455
+ // resMode = TRTCVideoResolutionMode.TRTCVideoResolutionModeLandscape,
456
+ videoFps: number = 15,
457
+ videoBitrate: number = 550,
458
+ // minVideoBitrate = 0,
459
+ // enableAdjustRes = false,
460
+ ) {
461
+ this.videoResolution = videoResolution;
462
+ // this.resMode = resMode;
463
+ this.videoFps = videoFps;
464
+ this.videoBitrate = videoBitrate;
465
+ // this.minVideoBitrate = minVideoBitrate;
466
+ // this.enableAdjustRes = enableAdjustRes;
467
+ }
468
+ }
469
+ /**
470
+ * 视频画面旋转方向<br>
471
+ * TRTC SDK 提供了对本地和远程画面的旋转角度设置 API,如下的旋转角度都是指顺时针方向的。
472
+ * @enum {Number}
473
+ */
474
+ const TRTCVideoRotation_HACK_JSDOC = {
475
+ /** 顺时针旋转0度 */
476
+ TRTCVideoRotation0: 0,
477
+ /** 顺时针旋转90度 */
478
+ TRTCVideoRotation90: 1,
479
+ /** 顺时针旋转180度 */
480
+ TRTCVideoRotation180: 2,
481
+ /** 顺时针旋转270度 */
482
+ TRTCVideoRotation270: 3,
483
+ };
484
+ export enum TRTCVideoRotation {
485
+ TRTCVideoRotation0 = 0,
486
+ TRTCVideoRotation90 = 1,
487
+ TRTCVideoRotation180 = 2,
488
+ TRTCVideoRotation270 = 3,
489
+ }
490
+ /**
491
+ * 画面渲染参数<br>
492
+ * 您可以通过设置此参数来控制画面的旋转、填充、镜像模式
493
+ * @param {TRTCVideoRotation} rotation - 【字段含义】视频画面旋转方向
494
+ * @param {TRTCVideoFillMode} fillMode - 【字段含义】视频画面填充模式
495
+ * @param {TRTCVideoMirrorType} mirrorType - 【字段含义】画面渲染镜像类型
496
+ */
497
+ export class TRTCRenderParams {
498
+ public rotation: TRTCVideoRotation;
499
+ public fillMode: TRTCVideoFillMode;
500
+ public mirrorType: TRTCVideoMirrorType;
501
+ constructor(rotation = TRTCVideoRotation.TRTCVideoRotation0, fillMode = TRTCVideoFillMode.TRTCVideoFillMode_Fit, mirrorType = TRTCVideoMirrorType.TRTCVideoMirrorType_Disable) {
502
+ this.rotation = rotation;
503
+ this.fillMode = fillMode;
504
+ this.mirrorType = mirrorType;
505
+ }
506
+ }
507
+ /**
508
+ * 网络质量<br>
509
+ * @enum {Number}
510
+ */
511
+ const TRTCQuality_HACK_JSDOC = {
512
+ /** 网络状况未知,表示当前 client 实例还没有建立上行/下行连接 */
513
+ TRTCQuality_Unknown: 0,
514
+ /** 网络状况极佳 */
515
+ TRTCQuality_Excellent: 1,
516
+ /** 网络状况较好 */
517
+ TRTCQuality_Good: 2,
518
+ /** 网络状况一般 */
519
+ TRTCQuality_Poor: 3,
520
+ /** 网络状况差 */
521
+ TRTCQuality_Bad: 4,
522
+ /** 网络状况极差 */
523
+ TRTCQuality_Vbad: 5,
524
+ /** 网络连接已断开,注意:若下行网络质量为此值,则表示所有下行连接都断开了 */
525
+ TRTCQuality_Down: 6,
526
+ };
527
+ export enum TRTCQuality {
528
+ TRTCQuality_Unknown = 0,
529
+ TRTCQuality_Excellent = 1,
530
+ TRTCQuality_Good = 2,
531
+ TRTCQuality_Poor = 3,
532
+ TRTCQuality_Bad = 4,
533
+ TRTCQuality_Vbad = 5,
534
+ TRTCQuality_Down = 6
535
+ }
536
+ /**
537
+ * 网络质量<br>
538
+ * 表示视频质量的好坏,通过这个数值,您可以在 UI 界面上用图标表征 userId 的通话线路质量
539
+ * @param {String} userId - 用户标识
540
+ * @param {TRTCQuality} quality - 视频质量
541
+ */
542
+ export class TRTCQualityInfo {
543
+ public userId: string;
544
+ public quality: TRTCQuality;
545
+ constructor(userId = '', quality = TRTCQuality.TRTCQuality_Unknown,) {
546
+ this.userId = userId;
547
+ this.quality = quality;
548
+ }
549
+ }
550
+ /**
551
+ * 音量大小<br>
552
+ * 表示语音音量的评估大小,通过这个数值,您可以在 UI 界面上用图标表征 userId 是否有在说话。
553
+ * @param {String} userId - 说话者的 userId,字符编码格式是 UTF-8
554
+ * @param {Number} volume - 说话者的音量, 取值范围0 - 100
555
+ */
556
+ export class TRTCVolumeInfo {
557
+ public userId: string;
558
+ public volume: number;
559
+ constructor(userId: string = '', volume: number = 0) {
560
+ this.userId = userId;
561
+ this.volume = volume;
562
+ }
563
+ }
564
+ /**
565
+ * CDN 旁路推流参数<br>
566
+ * @param {Number} appId - 腾讯云 AppID,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
567
+ * @param {Number} bizId - 腾讯云直播 bizId,请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
568
+ * @param {String} url - 旁路转推的 URL
569
+ */
570
+ export class TRTCPublishCDNParam {
571
+ public appId: number;
572
+ public bizId: number;
573
+ public url: null | string;
574
+ constructor(appId: number = 0, bizId: number = 0, url: null | string = null) {
575
+ this.appId = appId;
576
+ this.bizId = bizId;
577
+ this.url = url;
578
+ }
579
+ }
580
+ /**
581
+ * 本地的音视频统计信息<br>
582
+ * @param {Number} width - 视频宽度
583
+ * @param {Number} height - 视频高度
584
+ * @param {Number} frameRate - 帧率(fps)
585
+ * @param {Number} videoBitrate - 视频发送码率(Kbps)
586
+ * @param {Number} audioSampleRate - 音频采样率(Hz)
587
+ * @param {Number} audioBitrate - 音频发送码率(Kbps)
588
+ * @param {TRTCVideoStreamType} streamType - 流类型(大画面 | 小画面 | 辅路画面)
589
+ */
590
+ export class TRTCLocalStatistics {
591
+ public width: number;
592
+ public height: number;
593
+ public frameRate: number;
594
+ public videoBitrate: number;
595
+ public audioSampleRate: number;
596
+ public audioBitrate: number;
597
+ public streamType: TRTCVideoStreamType;
598
+ constructor(width = 0, height = 0, frameRate = 0, videoBitrate = 0, audioSampleRate = 0, audioBitrate = 0, streamType = TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
599
+ this.width = width;
600
+ this.height = height;
601
+ this.frameRate = frameRate;
602
+ this.videoBitrate = videoBitrate;
603
+ this.audioSampleRate = audioSampleRate;
604
+ this.audioBitrate = audioBitrate;
605
+ this.streamType = streamType;
606
+ }
607
+ }
608
+ /**
609
+ * 统计数据<br>
610
+ * @param {Number} upLoss - C -> S 上行丢包率(%),这个值越小越好,例如,0%的丢包率代表网络很好,
611
+ * 而 30% 的丢包率则意味着 SDK 向服务器发送的每10个数据包中就会有3个会在上行传输中丢失。
612
+ * @param {Number} downLoss - S -> C 下行丢包率(%),这个值越小越好,例如,0%的丢包率代表网络很好,
613
+ * 而 30% 的丢包率则意味着服务器向 SDK 发送的每10个数据包中就会有3个会在下行传输中丢失。
614
+ * @param {Number} appCpu - 当前 App 的 CPU 使用率(%)
615
+ * @param {Number} systemCpu - 当前系统的 CPU 使用率(%)
616
+ * @param {Number} rtt - 延迟(毫秒),代表 SDK 跟服务器一来一回之间所消耗的时间,这个值越小越好。
617
+ * 一般低于50ms的 rtt 是比较理想的情况,而高于100ms的 rtt 会引入较大的通话延时。
618
+ * 由于数据上下行共享一条网络连接,所以 local 和 remote 的 rtt 相同。
619
+ * @param {Number} receivedBytes - 总接收字节数(包含信令和音视频)
620
+ * @param {Number} sentBytes - 总发送字节总数(包含信令和音视频)
621
+ * @param {TRTCLocalStatistics[]} localStatisticsArray - 自己本地的音视频统计信息,由于可能有大画面、小画面以及辅路画面等多路的情况,所以是一个数组
622
+ * @param {Number} localStatisticsArraySize - 数组 localStatisticsArray 的大小
623
+ * @param {TRTCRemoteStatistics[]} remoteStatisticsArray - 远端成员的音视频统计信息,由于可能有大画面、小画面以及辅路画面等多路的情况,所以是一个数组
624
+ * @param {Number} remoteStatisticsArraySize - 数组 remoteStatisticsArray 的大小
625
+ */
626
+ export class TRTCStatistics {
627
+ public upLoss: number;
628
+ public downLoss: number;
629
+ public appCpu: number;
630
+ public systemCpu: number;
631
+ public rtt: number;
632
+ public receivedBytes: number;
633
+ public sentBytes: number;
634
+ public localStatisticsArray: TRTCLocalStatistics[];
635
+ public localStatisticsArraySize: number;
636
+ // public remoteStatisticsArray: TRTCRemoteStatistics[];
637
+ public remoteStatisticsArraySize: number;
638
+ constructor(
639
+ upLoss = 0,
640
+ downLoss = 0,
641
+ appCpu = 0,
642
+ systemCpu = 0,
643
+ rtt = 0,
644
+ receivedBytes = 0,
645
+ sentBytes = 0,
646
+ localStatisticsArray: TRTCLocalStatistics[] = [],
647
+ localStatisticsArraySize = 0,
648
+ // remoteStatisticsArray: TRTCRemoteStatistics[] = [],
649
+ remoteStatisticsArraySize = 0,
650
+ ) {
651
+ this.upLoss = upLoss;
652
+ this.downLoss = downLoss;
653
+ this.appCpu = appCpu;
654
+ this.systemCpu = systemCpu;
655
+ this.rtt = rtt;
656
+ this.receivedBytes = receivedBytes;
657
+ this.sentBytes = sentBytes;
658
+ this.localStatisticsArray = localStatisticsArray;
659
+ this.localStatisticsArraySize = localStatisticsArraySize;
660
+ // this.remoteStatisticsArray = remoteStatisticsArray;
661
+ this.remoteStatisticsArraySize = remoteStatisticsArraySize;
662
+ }
663
+ }
664
+
665
+ // ------------------------------------------------------------------------------
666
+ // 下面是 Electron 用的类型,因为 TUIRoom 中要统一,因此对外暴露。但是并不会放到 API 文档中
667
+ // ------------------------------------------------------------------------------
668
+ export enum TRTCVideoResolutionMode {
669
+ TRTCVideoResolutionModeLandscape = 0,
670
+ TRTCVideoResolutionModePortrait = 1,
671
+ };
672
+ /**
673
+ * 画质偏好<br>
674
+ * 指当 TRTC SDK 在遇到弱网络环境时,您是希望“保清晰”还是“保流畅”:<br>
675
+ * - Smooth:弱网下保流畅,在遭遇弱网环境时首先确保声音的流畅和优先发送,画面会变得模糊且会有较多马赛克,但可以保持流畅不卡顿。
676
+ * - Clear:弱网下保清晰,在遭遇弱网环境时,画面会尽可能保持清晰,但可能会更容易出现卡顿。
677
+ * @enum {Number}
678
+ */
679
+ export enum TRTCVideoQosPreference {
680
+ TRTCVideoQosPreferenceSmooth = 1,
681
+ TRTCVideoQosPreferenceClear = 2,
682
+ }
683
+ /**
684
+ * 流控模式<br>
685
+ * TRTC SDK 内部需要时刻根据网络情况调整内部的编解码器和网络模块,以便能够对网络的变化做出反应。<br>
686
+ * 为了支持快速算法升级,SDK 内部设置了两种不同的流控模式:
687
+ * - ModeClient: 本地控制,用于 SDK 开发内部调试,客户请勿使用。
688
+ * - ModeServer: 云端控制,推荐模式,也是默认默认。
689
+ * > 推荐您使用云端控制,这样每当我们升级 Qos 算法时,您无需升级 SDK 即可体验更好的效果。
690
+ * @enum {Number}
691
+ */
692
+ export enum TRTCQosControlMode {
693
+ TRTCQosControlModeClient = 0,
694
+ TRTCQosControlModeServer = 1,
695
+ }
696
+ /**
697
+ * 网络流控相关参数<br>
698
+ * 网络流控相关参数,该设置决定了SDK在各种网络环境下的调控方向(比如弱网下是“保清晰”还是“保流畅”)
699
+ * @param {TRTCVideoQosPreference} preference - 【字段含义】弱网下是“保清晰”还是“保流畅”<br>
700
+ * 【特别说明】<br>
701
+ * - 弱网下保流畅:在遭遇弱网环境时,画面会变得模糊,且会有较多马赛克,但可以保持流畅不卡顿
702
+ * - 弱网下保清晰:在遭遇弱网环境时,画面会尽可能保持清晰,但可能会更容易出现卡顿
703
+ * @param {TRTCQosControlMode} controlMode - 【字段含义】流控模式(云端控制 - 客户端控制)<br>
704
+ * 【推荐取值】云端控制<br>
705
+ * 【特别说明】<br>
706
+ * - Client 模式:客户端控制模式,用于 SDK 开发内部调试,客户请勿使用
707
+ * - Server 模式(默认):云端控制模式,若没有特殊原因,请直接使用该模式
708
+ *
709
+ */
710
+ export class TRTCNetworkQosParam {
711
+ public preference: TRTCVideoQosPreference;
712
+ public controlMode: TRTCQosControlMode;
713
+ constructor(preference = TRTCVideoQosPreference.TRTCVideoQosPreferenceClear, controlMode = TRTCQosControlMode.TRTCQosControlModeServer) {
714
+ this.preference = preference;
715
+ this.controlMode = controlMode;
716
+ }
717
+ }
718
+ /**
719
+ * 图缓存<br>
720
+ * @param {ArrayBuffer} buffer - 图内容
721
+ * @param {Number} length - 图缓存大小
722
+ * @param {Number} width - 图宽
723
+ * @param {Number} heigth - 图高
724
+ */
725
+ export class TRTCImageBuffer {
726
+ public buffer: ArrayBuffer;
727
+ public length: number;
728
+ public width: number;
729
+ public height: number;
730
+ constructor(buffer = new ArrayBuffer(0), length = 0, width = 0, height = 0) {
731
+ this.buffer = buffer;
732
+ this.length = length;
733
+ this.width = width;
734
+ this.height = height;
735
+ }
736
+ }
737
+ /**
738
+ * 屏幕分享目标信息<br>
739
+ * @enum {Number}
740
+ */
741
+ export enum TRTCScreenCaptureSourceType {
742
+ TRTCScreenCaptureSourceTypeUnknown = -1,
743
+ TRTCScreenCaptureSourceTypeWindow = 0,
744
+ TRTCScreenCaptureSourceTypeScreen = 1,
745
+ TRTCScreenCaptureSourceTypeCustom = 2,
746
+ }
747
+ /**
748
+ * 屏幕采集源信息<br>
749
+ * @param {TRTCScreenCaptureSourceType} type - 采集源类型
750
+ * @param {String} sourceId - 采集源ID;对于窗口,该字段指示窗口句柄;对于屏幕,该字段指示屏幕ID
751
+ * @param {String} sourceName - 采集源名称,UTF8编码
752
+ * @param {TRTCImageBuffer} thumbBGRA - 缩略图内容
753
+ * @param {TRTCImageBuffer} iconBGRA - 图标内容
754
+ * @param {Boolean} isMinimizeWindow - 是否最小化窗口
755
+ */
756
+ export class TRTCScreenCaptureSourceInfo {
757
+ public type: number;
758
+ public sourceId: string;
759
+ public sourceName: string;
760
+ public thumbBGRA: TRTCImageBuffer;
761
+ public iconBGRA: TRTCImageBuffer;
762
+ public isMinimizeWindow: boolean;
763
+ constructor(
764
+ type = TRTCScreenCaptureSourceType.TRTCScreenCaptureSourceTypeUnknown,
765
+ sourceId = '',
766
+ sourceName = '',
767
+ thumbBGRA = new TRTCImageBuffer(),
768
+ iconBGRA = new TRTCImageBuffer(),
769
+ isMinimizeWindow = false,
770
+ ) {
771
+ this.type = type;
772
+ this.sourceId = sourceId;
773
+ this.sourceName = sourceName;
774
+ this.thumbBGRA = thumbBGRA;
775
+ this.iconBGRA = iconBGRA;
776
+ this.isMinimizeWindow = isMinimizeWindow;
777
+ }
778
+ }
779
+ /**
780
+ * 记录矩形的四个点坐标<br>
781
+ * @param {Number} left - 左坐标
782
+ * @param {Number} top - 上坐标
783
+ * @param {Number} right - 右坐标
784
+ * @param {Number} bottom - 下坐标
785
+ */
786
+ export class Rect {
787
+ public left: number;
788
+ public top: number;
789
+ public right: number;
790
+ public bottom: number;
791
+ constructor(left = 0, top = 0, right = 0, bottom = 0) {
792
+ this.left = left;
793
+ this.top = top;
794
+ this.right = right;
795
+ this.bottom = bottom;
796
+ }
797
+ }
798
+
799
+ /**
800
+ * 5.13 云端混流(转码)配置
801
+ *
802
+ * 包括最终编码质量和各路画面的摆放位置
803
+ *
804
+ * @param {TRTCTranscodingConfigMode} mode - 【字段含义】转码 config 模式
805
+ * @param {Number} appId - 【字段含义】腾讯云直播 AppID<br>
806
+ * 【推荐取值】请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
807
+ * @param {Number} bizId - 【字段含义】腾讯云直播 bizid<br>
808
+ * 【推荐取值】请在 [实时音视频控制台](https://console.cloud.tencent.com/rav) 选择已经创建的应用,单击【帐号信息】后,在“直播信息”中获取
809
+ * @param {Number} videoWidth - 【字段含义】最终转码后的视频分辨率的宽度。<br>
810
+ * 【推荐取值】推荐值:360px ,如果你是纯音频推流,请将 width × height 设为 0px × 0px,否则混流后会携带一条画布背景的视频流。
811
+ * @param {Number} videoHeight - 【字段含义】最终转码后的视频分辨率的高度。<br>
812
+ * 【推荐取值】推荐值:640px ,如果你是纯音频推流,请将 width × height 设为 0px × 0px,否则混流后会携带一条画布背景的视频流。
813
+ * @param {Number} videoBitrate - 【字段含义】最终转码后的视频分辨率的码率(kbps)<br>
814
+ * 【推荐取值】如果填0,后台会根据videoWidth和videoHeight来估算码率,您也可以参考枚举定义TRTCVideoResolution_640_480的注释。
815
+ * @param {Number} videoFramerate - 【字段含义】最终转码后的视频分辨率的帧率(FPS)<br>
816
+ * 【推荐取值】默认值:15fps,取值范围是 (0,30]。
817
+ * @param {Number} videoGOP - 【字段含义】最终转码后的视频分辨率的关键帧间隔(又称为 GOP)。<br>
818
+ * 【推荐取值】默认值:2,单位为秒,取值范围是 [1,8]。
819
+ * @param {Number} backgroundColor - 【字段含义】混合后画面的底色颜色,默认为黑色,格式为十六进制数字,比如:“0x61B9F1” 代表 RGB 分别为(97,158,241)。<br>
820
+ * 【推荐取值】默认值:0x000000,黑色
821
+ * @param {String} backgroundImage - 【字段含义】混合后画面的背景图。<br>
822
+ * 【推荐取值】默认值:'',即不设置背景图<br>
823
+ * 【特别说明】背景图需要您事先在 “[控制台](https://console.cloud.tencent.com/trtc) => 应用管理 => 功能配置 => 素材管理” 中上传,<br>
824
+ * 上传成功后可以获得对应的“图片ID”,然后将“图片ID”转换成字符串类型并设置到 backgroundImage 里即可。<br>
825
+ * 例如:假设“图片ID” 为 63,可以设置 backgroundImage = @"63";
826
+ * @param {Number} audioSampleRate - 【字段含义】最终转码后的音频采样率。<br>
827
+ * 【推荐取值】默认值:48000Hz。支持12000HZ、16000HZ、22050HZ、24000HZ、32000HZ、44100HZ、48000HZ。
828
+ * @param {Number} audioBitrate - 【字段含义】最终转码后的音频码率。<br>
829
+ * 【推荐取值】默认值:64kbps,取值范围是 [32,192]。
830
+ * @param {Number} audioChannels - 【字段含义】最终转码后的音频声道数<br>
831
+ * 【推荐取值】默认值:1。取值范围为 [1,2] 中的整型。
832
+ * @param {TRTCMixUser[]} mixUsersArray - 【字段含义】每一路子画面的位置信息
833
+ * @param {String} streamId - 【字段含义】输出到 CDN 上的直播流 ID。<br>
834
+ * 如不设置该参数,SDK 会执行默认逻辑,即房间里的多路流会混合到该接口调用者的视频流上,也就是 A+B =>A;<br>
835
+ * 如果设置该参数,SDK 会将房间里的多路流混合到您指定的直播流 ID 上,也就是 A+B =>C。<br>
836
+ * 【推荐取值】默认值:'',即房间里的多路流会混合到该接口调用者的视频流上。
837
+ */
838
+ export class TRTCTranscodingConfig {
839
+ public mode: TRTCTranscodingConfigMode;
840
+ public appId: number;
841
+ public bizId: number;
842
+ public videoWidth: number;
843
+ public videoHeight: number;
844
+ public videoBitrate: number;
845
+ public videoFramerate: number;
846
+ public videoGOP: number;
847
+ public backgroundColor: number;
848
+ public backgroundImage: string;
849
+ public audioSampleRate: number;
850
+ public audioBitrate: number;
851
+ public audioChannels: number;
852
+ public mixUsersArray: TRTCMixUser[];
853
+ public mixUsersArraySize: number;
854
+ public streamId: string;
855
+ constructor(
856
+ mode = TRTCTranscodingConfigMode.TRTCTranscodingConfigMode_Unknown,
857
+ appId = 0,
858
+ bizId = 0,
859
+ videoWidth = 0,
860
+ videoHeight = 0,
861
+ videoBitrate = 0,
862
+ videoFramerate = 15,
863
+ videoGOP = 2,
864
+ backgroundColor = 0,
865
+ backgroundImage = '',
866
+ audioSampleRate = 64,
867
+ audioBitrate = 48000,
868
+ audioChannels = 1,
869
+ mixUsersArray = [],
870
+ streamId = ''
871
+ ) {
872
+ this.mode = mode;
873
+ this.appId = appId;
874
+ this.bizId = bizId;
875
+ this.videoWidth = videoWidth;
876
+ this.videoHeight = videoHeight;
877
+ this.videoBitrate = videoBitrate;
878
+ this.videoFramerate = videoFramerate;
879
+ this.videoGOP = videoGOP;
880
+ this.backgroundColor = backgroundColor;
881
+ this.backgroundImage = backgroundImage;
882
+ this.audioSampleRate = audioSampleRate;
883
+ this.audioBitrate = audioBitrate;
884
+ this.audioChannels = audioChannels;
885
+ this.mixUsersArray = mixUsersArray;
886
+ this.mixUsersArraySize = mixUsersArray.length;
887
+ this.streamId = streamId;
888
+ }
889
+ };
890
+
891
+ /**
892
+ * 5.10 混流参数配置模式
893
+ *
894
+ * 目前暂仅支持手动配置这一种模式,即需要指定 TRTCTranscodingConfig 的全部参数。
895
+ *
896
+ * @enum {Number}
897
+ *
898
+ */
899
+ const TRTCTranscodingConfigMode_HACK_JSDOC = {
900
+ /** 非法值 */
901
+ TRTCTranscodingConfigMode_Unknown: 0,
902
+
903
+ /** 全手动模式,灵活性最高,可以自由组合出各种混流方案,但易用性最差。
904
+ * 此模式下,您需要填写 TRTCTranscodingConfig 中的所有参数,并需要监听 TRTCCloudDelegate 中的 onUserVideoAvailable() 和 onUserAudioAvailable() 回调,
905
+ * 以便根据当前房间中各个上麦用户的音视频状态不断地调整 mixUsers 参数,否则会导致混流失败。
906
+ */
907
+ TRTCTranscodingConfigMode_Manual: 1,
908
+
909
+ /** 预排版模式,通过占位符提前对各路画面进行排布
910
+ * 此模式下,您依然需要设置 mixUsers 参数,但可以将 userId 设置为占位符,可选的占位符有:
911
+ * - "$PLACE_HOLDER_REMOTE$" : 指代远程用户的画面,可以设置多个。
912
+ * - "$PLACE_HOLDER_LOCAL_MAIN$" : 指代本地摄像头画面,只允许设置一个。
913
+ * - "$PLACE_HOLDER_LOCAL_SUB$" : 指代本地屏幕分享画面,只允许设置一个。
914
+ * 但是您可以不需要监听 TRTCCloudDelegate 中的 onUserVideoAvailable() 和 onUserAudioAvailable() 回调进行实时调整,
915
+ * 只需要在进房成功后调用一次 setMixTranscodingConfig() 即可,之后 SDK 会自动将真实的 userId 补位到您设置的占位符上。
916
+ */
917
+ TRTCTranscodingConfigMode_Template_PresetLayout: 3,
918
+ };
919
+
920
+ export enum TRTCTranscodingConfigMode {
921
+ TRTCTranscodingConfigMode_Unknown = 0,
922
+ TRTCTranscodingConfigMode_Manual = 1,
923
+ TRTCTranscodingConfigMode_Template_PureAudio = 2,
924
+ TRTCTranscodingConfigMode_Template_PresetLayout = 3,
925
+ TRTCTranscodingConfigMode_Template_ScreenSharing = 4,
926
+ TRTC_TranscodingConfigMode_Unknown = 5,
927
+ TRTC_TranscodingConfigMode_Manual = 6,
928
+ TRTC_TranscodingConfigMode_Template_PureAudio = 7,
929
+ TRTC_TranscodingConfigMode_Template_PresetLayout = 8,
930
+ TRTC_TranscodingConfigMode_Template_ScreenSharing = 9,
931
+ };
932
+
933
+ /**
934
+ * 5.9 云端混流中每一路子画面的位置信息
935
+ *
936
+ * TRTCMixUser 用于指定每一路(即每一个 userId)视频画面的具体摆放位置
937
+ *
938
+ * @param {String} userId - 参与混流的 userId
939
+ * @param {String} roomId - 参与混流的 roomId,跨房流传入的实际 roomId,当前房间流传入 roomId = ''
940
+ * @param {Rect} rect - 图层位置坐标以及大小,左上角为坐标原点(0,0) (绝对像素值)
941
+ * @param {Number} rect.left - 图层位置的左坐标
942
+ * @param {Number} rect.top - 图层位置的上坐标
943
+ * @param {Number} rect.right - 图层位置的右坐标
944
+ * @param {Number} rect.bottom - 图层位置的下坐标
945
+ * @param {Number} zOrder - 图层层次(1 - 15)不可重复
946
+ * @param {Boolean} pureAudio - 是否纯音频
947
+ * @param {TRTCVideoStreamType} streamType - 参与混合的是主路画面(TRTCVideoStreamTypeBig)或屏幕分享(TRTCVideoStreamTypeSub)画面
948
+ * @param {TRTCMixInputType} inputType - 指定该路流的混合内容(只混合音频、只混合视频、混合音频和视频),该字段是对 pureAudio 字段的升级。
949
+ * 默认值:TRTCMixInputTypeUndefined,代表参考 pureAudio 的取值。
950
+ * 如果您是第一次使用 TRTC,之前并没有对 pureAudio 字段进行过设置,您可以根据实际需要设置该字段,不建议您再设置 pureAudio。
951
+ * 如果您之前在老版本中已经使用了 pureAudio 字段,并期望保持其设置,则可以将 inputType 设置为 TRTCMixInputTypeUndefined。
952
+ * @param {Number} renderMode - 该画面在输出时的显示模式。默认值:视频流默认为0。0为裁剪,1为缩放,2为缩放并显示黑底。
953
+ *
954
+ */
955
+ export class TRTCMixUser {
956
+ public userId: string;
957
+ public roomId: string;
958
+ public rect: null | Rect;
959
+ public zOrder: number;
960
+ public pureAudio: boolean;
961
+ public streamType: TRTCVideoStreamType;
962
+ public inputType: TRTCMixInputType;
963
+ public renderMode: Number;
964
+ constructor(
965
+ userId = '',
966
+ roomId = '',
967
+ rect: null | Rect = null,
968
+ zOrder = 0,
969
+ pureAudio = false,
970
+ streamType = TRTCVideoStreamType.TRTCVideoStreamTypeBig,
971
+ inputType = TRTCMixInputType.TRTCMixInputTypeUndefined,
972
+ renderMode = 0,
973
+ ) {
974
+ this.userId = userId;
975
+ this.roomId = roomId;
976
+ this.rect = rect;
977
+ this.zOrder = zOrder;
978
+ this.pureAudio = pureAudio;
979
+ this.streamType = streamType;
980
+ this.inputType = inputType;
981
+ this.renderMode = renderMode;
982
+ }
983
+ };
984
+
985
+ /**
986
+ * 5.11 混流输入类型
987
+ *
988
+ * @enum {Number}
989
+ *
990
+ */
991
+ const TRTCMixInputType_HACK_JSDOC = {
992
+ /** 不指定,SDK 会根据另一个参数 pureAudio 的数值决定混流输入类型 */
993
+ TRTCMixInputTypeUndefined: 0,
994
+ /** 混入音频和视频 */
995
+ TRTCMixInputTypeAudioVideo: 1,
996
+ /** 只混入视频 */
997
+ TRTCMixInputTypePureVideo: 2,
998
+ /** 只混入音频 */
999
+ TRTCMixInputTypePureAudio: 3
1000
+ }
1001
+
1002
+ export enum TRTCMixInputType {
1003
+ TRTCMixInputTypeUndefined = 0,
1004
+ TRTCMixInputTypeAudioVideo = 1,
1005
+ TRTCMixInputTypePureVideo = 2,
1006
+ TRTCMixInputTypePureAudio = 3,
1007
+ }