trtc-cloud-js-sdk 2.0.0 → 2.1.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/package.json +7 -57
  2. package/trtc-cloud-js-sdk.js +1 -0
  3. package/.eslintrc.js +0 -88
  4. package/.prettierrc +0 -5
  5. package/CHANGELOG.md +0 -58
  6. package/build/jsdoc/clean-doc.js +0 -12
  7. package/build/jsdoc/fix-doc.js +0 -141
  8. package/build/jsdoc/jsdoc.json +0 -42
  9. package/build/package-bundle.js +0 -29
  10. package/build/rollup.config.dev.js +0 -88
  11. package/build/rollup.config.prod.js +0 -93
  12. package/build/rollup.js +0 -359
  13. package/build/template/npm-package/package.json +0 -24
  14. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/base.css +0 -213
  15. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/index.html +0 -80
  16. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.css +0 -1
  17. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.js +0 -1
  18. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sort-arrow-sprite.png +0 -0
  19. package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sorter.js +0 -158
  20. package/examples/apiExample/.env +0 -2
  21. package/examples/apiExample/README.md +0 -70
  22. package/examples/apiExample/package-lock.json +0 -30915
  23. package/examples/apiExample/package.json +0 -51
  24. package/examples/apiExample/public/audio.js +0 -195
  25. package/examples/apiExample/public/audio.js.map +0 -7
  26. package/examples/apiExample/public/av_processing.js +0 -1
  27. package/examples/apiExample/public/basic/av_processing.wasm +0 -0
  28. package/examples/apiExample/public/basic/worker.js +0 -10434
  29. package/examples/apiExample/public/favicon.ico +0 -0
  30. package/examples/apiExample/public/index.html +0 -47
  31. package/examples/apiExample/public/logo192.png +0 -0
  32. package/examples/apiExample/public/logo512.png +0 -0
  33. package/examples/apiExample/public/manifest.json +0 -25
  34. package/examples/apiExample/public/robots.txt +0 -3
  35. package/examples/apiExample/src/App.css +0 -37
  36. package/examples/apiExample/src/App.js +0 -25
  37. package/examples/apiExample/src/api/http.js +0 -127
  38. package/examples/apiExample/src/api/nav.js +0 -44
  39. package/examples/apiExample/src/components/BasicInfoComponent.css +0 -16
  40. package/examples/apiExample/src/components/BasicInfoComponent.js +0 -27
  41. package/examples/apiExample/src/config/gen-test-user-sig.js +0 -64
  42. package/examples/apiExample/src/config/lib-generate-test-usersig.min.js +0 -7052
  43. package/examples/apiExample/src/config/nav.js +0 -136
  44. package/examples/apiExample/src/home.js +0 -16
  45. package/examples/apiExample/src/index.css +0 -21
  46. package/examples/apiExample/src/index.js +0 -12
  47. package/examples/apiExample/src/logo.svg +0 -1
  48. package/examples/apiExample/src/page/basic/screen-share/index.css +0 -52
  49. package/examples/apiExample/src/page/basic/screen-share/index.js +0 -223
  50. package/examples/apiExample/src/page/basic/setDevice/index.js +0 -262
  51. package/examples/apiExample/src/page/basic/setDevice/index.scss +0 -93
  52. package/examples/apiExample/src/page/basic/video-call/index.js +0 -521
  53. package/examples/apiExample/src/page/basic/video-call/index.scss +0 -93
  54. package/examples/apiExample/src/page/basic/video-call-init/index.js +0 -382
  55. package/examples/apiExample/src/page/basic/video-call-init/index.scss +0 -93
  56. package/examples/apiExample/src/page/basic/video-live/index.css +0 -37
  57. package/examples/apiExample/src/page/basic/video-live/index.js +0 -188
  58. package/examples/apiExample/src/page/layout.js +0 -22
  59. package/examples/apiExample/src/page/layout.scss +0 -76
  60. package/examples/apiExample/src/utils/utils.js +0 -35
  61. package/examples/jsExample/assets/css/bootstrap-material-design.css +0 -12169
  62. package/examples/jsExample/assets/css/bootstrap-material-design.min.css +0 -8
  63. package/examples/jsExample/assets/css/common.css +0 -48
  64. package/examples/jsExample/assets/icon/iconfont.js +0 -1
  65. package/examples/jsExample/assets/js/bootstrap-material-design.js +0 -6939
  66. package/examples/jsExample/assets/js/bootstrap-material-design.js.map +0 -1
  67. package/examples/jsExample/assets/js/bootstrap-material-design.min.js +0 -1
  68. package/examples/jsExample/assets/js/graph.js +0 -695
  69. package/examples/jsExample/assets/js/jquery-3.2.1.min.js +0 -4
  70. package/examples/jsExample/assets/js/jquery-3.2.1.slim.min.js +0 -4
  71. package/examples/jsExample/assets/js/lib-generate-test-usersig.min.js +0 -2
  72. package/examples/jsExample/assets/js/popper.js +0 -2442
  73. package/examples/jsExample/index.html +0 -57
  74. package/examples/jsExample/rtc/css/common.css +0 -82
  75. package/examples/jsExample/rtc/index.html +0 -107
  76. package/examples/jsExample/rtc/js/index.js +0 -142
  77. package/examples/vueDemo/LICENSE +0 -21
  78. package/examples/vueDemo/README.md +0 -144
  79. package/examples/vueDemo/README_EN.md +0 -136
  80. package/examples/vueDemo/av_processing.wasm +0 -0
  81. package/examples/vueDemo/index.html +0 -23
  82. package/examples/vueDemo/package-lock.json +0 -1375
  83. package/examples/vueDemo/package.json +0 -36
  84. package/examples/vueDemo/src/App.vue +0 -12
  85. package/examples/vueDemo/src/api/index.js +0 -59
  86. package/examples/vueDemo/src/assets/css/color-dark.css +0 -28
  87. package/examples/vueDemo/src/assets/css/icon.css +0 -4
  88. package/examples/vueDemo/src/assets/css/main.css +0 -177
  89. package/examples/vueDemo/src/assets/img/img.jpg +0 -0
  90. package/examples/vueDemo/src/assets/img/login-bg.jpg +0 -0
  91. package/examples/vueDemo/src/components/Header.vue +0 -172
  92. package/examples/vueDemo/src/components/Sidebar.vue +0 -117
  93. package/examples/vueDemo/src/components/Tags.vue +0 -174
  94. package/examples/vueDemo/src/components/tendency.vue +0 -206
  95. package/examples/vueDemo/src/components/trtc/main-menu.vue +0 -50
  96. package/examples/vueDemo/src/components/trtc/nav-bar.vue +0 -53
  97. package/examples/vueDemo/src/components/trtc/show-screen-capture.vue +0 -118
  98. package/examples/vueDemo/src/components/trtc/trtc-state-check.vue +0 -117
  99. package/examples/vueDemo/src/config/gen-test-user-sig.js +0 -67
  100. package/examples/vueDemo/src/config/lib-generate-test-usersig.min.js +0 -7052
  101. package/examples/vueDemo/src/main.js +0 -11
  102. package/examples/vueDemo/src/plugins/element.js +0 -17
  103. package/examples/vueDemo/src/router/index.js +0 -73
  104. package/examples/vueDemo/src/store/sidebar.js +0 -17
  105. package/examples/vueDemo/src/store/tags.js +0 -48
  106. package/examples/vueDemo/src/utils/i18n.js +0 -24
  107. package/examples/vueDemo/src/utils/request.js +0 -34
  108. package/examples/vueDemo/src/utils/utils.js +0 -35
  109. package/examples/vueDemo/src/views/Home.vue +0 -46
  110. package/examples/vueDemo/src/views/I18n.vue +0 -40
  111. package/examples/vueDemo/src/views/Icon.vue +0 -229
  112. package/examples/vueDemo/src/views/basic/trtc.vue +0 -194
  113. package/examples/vueDemo/src/views/feature/index.vue +0 -259
  114. package/examples/vueDemo/src/views/github/index.vue +0 -243
  115. package/examples/vueDemo/src/views/improve/live-index.vue +0 -256
  116. package/examples/vueDemo/src/views/improve/live-room-anchor.vue +0 -689
  117. package/examples/vueDemo/src/views/improve/live-room-audience.vue +0 -383
  118. package/examples/vueDemo/src/views/sdkAppId/index.vue +0 -284
  119. package/examples/vueDemo/vite.config.js +0 -18
  120. package/examples/vueDemo/worker.js +0 -22
  121. package/karma.conf.js +0 -99
  122. package/scripts/publish.js +0 -86
  123. package/src/Camera.ts +0 -80
  124. package/src/Mic.ts +0 -145
  125. package/src/common/IError.ts +0 -6
  126. package/src/common/ITRTCCloud.ts +0 -68
  127. package/src/common/constants.ts +0 -116
  128. package/src/common/trtc-code.ts +0 -43
  129. package/src/common/trtc-define.ts +0 -1007
  130. package/src/common/trtc-event.ts +0 -29
  131. package/src/index.ts +0 -1672
  132. package/src/utils/environment.js +0 -297
  133. package/src/utils/raf.js +0 -131
  134. package/src/utils/time.js +0 -22
  135. package/src/utils/utils.ts +0 -71
  136. package/src/utils/uuid.js +0 -12
  137. package/test/unit/env.test.js +0 -25
  138. package/test/unit/get-user-media.test.js +0 -40
  139. package/test/unit/ice-parser.test.js +0 -23
  140. package/test/unit/sdp.test.js +0 -45
  141. package/test/unit/signal.test.js +0 -78
  142. package/tsconfig.json +0 -32
  143. /package/{build/template/npm-package/README.md → README.md} +0 -0
@@ -1,86 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const excludesPath = [
4
- 'node_modules',
5
- ].map(excludePath => path.resolve(path.join('./examples/apiExample', excludePath)));
6
-
7
- function copyDir(fromPath, toPath) {
8
- fs.mkdirSync(toPath);
9
- const dirsPath = fs.readdirSync(fromPath);
10
- dirsPath.forEach((dirPath) => {
11
- const from = path.join(fromPath, dirPath);
12
- const to = path.join(toPath, dirPath);
13
- if (excludesPath.indexOf(from) >= 0) {
14
- return;
15
- }
16
- if (fs.statSync(from).isDirectory()) {
17
- copyDir(from, to);
18
- } else {
19
- copyFile(from, to);
20
- }
21
- });
22
- }
23
-
24
- function copyFile(fromPath, toPath) {
25
- fs.copyFileSync(fromPath, toPath);
26
- }
27
-
28
- function removeDir(originPath) {
29
- let stats;
30
- try {
31
- stats = fs.statSync(originPath);
32
- } catch (error) {
33
- return;
34
- }
35
- if (stats.isFile()) {
36
- fs.unlinkSync(originPath);
37
- } else if (stats.isDirectory()) {
38
- const dirs = fs.readdirSync(originPath);
39
- const dirsPath = dirs.map(dir => path.join(originPath, dir));
40
- dirsPath.forEach((dirPath) => {
41
- removeDir(dirPath);
42
- });
43
- fs.rmdirSync(originPath);
44
- }
45
- }
46
-
47
- // 【1】apiExample 发布到 cos
48
- const apiExampleName = 'apiExample';
49
- const apiExternalName = 'cos';
50
- const apiFromPath = path.resolve(`./examples/${apiExampleName}`);
51
- const apiToPath = path.resolve(`./${apiExternalName}/${apiExampleName}`);
52
- // 清除原有的文件
53
- removeDir(`./${apiExternalName}/${apiExampleName}`);
54
- // 将 TRTC-UniApp 拷贝到目标文件夹
55
- copyDir(apiFromPath, apiToPath);
56
- // 脱敏操作
57
- const apiModifyFile = path.resolve(`./${apiExternalName}/${apiExampleName}/src/config/gen-test-user-sig.js`);
58
-
59
- fs.readFile(apiModifyFile, 'utf-8', (err, data) => {
60
- if (err) throw err;
61
- let newValue = data.replace(/const SDKAPPID = (\d{10});/, 'const SDKAPPID = 0;'); // 清除 sdkAppId
62
- newValue = newValue.replace(/const SECRETKEY = ('\w{64}');/, 'const SECRETKEY = \'\';'); // 清除 secretKey
63
- fs.writeFile(apiModifyFile, newValue, 'utf-8', (err) => {
64
- if (err) throw err;
65
- });
66
- });
67
-
68
- // 【2】jsExample 发布到 cos
69
- const jsExampleName = 'jsExample';
70
- const jsExternalName = 'cos';
71
- const jsFromPath = path.resolve(`./examples/${jsExampleName}`);
72
- const jsToPath = path.resolve(`./${jsExternalName}/${jsExampleName}`);
73
- // 清除原有的文件
74
- removeDir(`./${jsExternalName}/${jsExampleName}`);
75
- // 将 TRTC-UniApp 拷贝到目标文件夹
76
- copyDir(jsFromPath, jsToPath);
77
- // 脱敏操作
78
- const jsModifyFile = path.resolve(`./${jsExternalName}/${jsExampleName}/rtc/js/index.js`);
79
- fs.readFile(jsModifyFile, 'utf-8', (err, data) => {
80
- if (err) throw err;
81
- let newValue = data.replace(/const sdkAppId = (\d{10});/, 'const sdkAppId = 0;'); // 清除 sdkAppId
82
- // newValue = newValue.replace(/const userSig = ('(\w*){196}}');/, 'const userSig = \'\';'); // 清除 userSig
83
- fs.writeFile(jsModifyFile, newValue, 'utf-8', (err) => {
84
- if (err) throw err;
85
- });
86
- });
package/src/Camera.ts DELETED
@@ -1,80 +0,0 @@
1
- import { TRTCDeviceInfo, TRTCDeviceType, TRTCDeviceState } from './common/trtc_define';
2
- import { BaseCommon } from './BaseCommon';
3
- import { MixinsClass, hasVideoTrack } from './utils/utils';
4
- import { NAME } from './common/constants';
5
-
6
- /**
7
- * 摄像头相关接口<br>
8
- * @memberof TRTCClouds
9
- */
10
- class Camera extends MixinsClass(BaseCommon) {
11
- /**
12
- * 获取摄像头设备列表<br>
13
- * @returns {Promise(Array<TRTCDeviceInfo>)} 摄像头管理器列表
14
- * @memberof TRTCCloud
15
- * @example
16
- * var cameralist = await trtcCloud.getCameraDevicesList();
17
- * for (i = 0; i < cameralist.length; i++) {
18
- * var camera = cameralist[i];
19
- * console.info("camera deviceName: " + camera.deviceName + " deviceId:" + camera.deviceId);
20
- * }
21
- */
22
- async getCameraDevicesList(): Promise<TRTCDeviceInfo[]> {
23
- try {
24
- const cameraList = await this.TRTC.getCameras();
25
- this.cameraList = cameraList.map((item: TRTCDeviceInfo) => ({
26
- ...item,
27
- deviceName: item.label, // 就是 deviceName
28
- }));
29
- return Promise.resolve(this.cameraList);
30
- } catch (error: any) {
31
- this.callFunctionErrorManage(error, 'getCameraDevicesList');
32
- this.cameraList = [];
33
- return Promise.resolve([]);
34
- }
35
- }
36
-
37
- /**
38
- * 设置要使用的摄像头<br>
39
- * @param {String} deviceId - 从 getCameraDevicesList 中得到的设备 ID
40
- * @returns {Promise}
41
- * @memberof TRTCCloud
42
- */
43
- async setCurrentCameraDevice(deviceId: string): Promise<boolean> {
44
- try {
45
- if (!deviceId) {
46
- return Promise.resolve(false);
47
- }
48
- if (this.currentCameraId === deviceId) {
49
- return Promise.resolve(true);
50
- }
51
- this.currentCameraId = deviceId || '';
52
- if (hasVideoTrack(this.localStream)) {
53
- await this.localStream.switchDevice(NAME.VIDEO, deviceId);
54
- }
55
- if (hasVideoTrack(this.localPlayStream)) {
56
- await this.localPlayStream.switchDevice(NAME.VIDEO, deviceId);
57
- }
58
- if (hasVideoTrack(this.testCameraStream)) {
59
- await this.testCameraStream.switchDevice('video', deviceId);
60
- }
61
- this.emitOnDeviceChange(deviceId, TRTCDeviceType.TRTCDeviceTypeCamera, TRTCDeviceState.TRTCDeviceStateActive);
62
- return Promise.resolve(true);
63
- } catch (error: any) {
64
- this.callFunctionErrorManage(error, 'setCurrentCameraDevice');
65
- this.cameraList = [];
66
- return Promise.resolve(false);
67
- }
68
- }
69
-
70
- /**
71
- * 获取当前使用的摄像头<br>
72
- * @memberof TRTCCloud
73
- * @returns {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
74
- */
75
- getCurrentCameraDevice(): TRTCDeviceInfo {
76
- return (this.cameraList || []).filter((obj: any) => obj.deviceId === this.currentCameraId)[0] || {};
77
- }
78
- }
79
-
80
- export { Camera };
package/src/Mic.ts DELETED
@@ -1,145 +0,0 @@
1
- import { TRTCDeviceInfo, TRTCDeviceType, TRTCDeviceState } from './common/trtc_define';
2
- import { BaseCommon } from './BaseCommon';
3
- import { MixinsClass, hasAudioTrack } from './utils/utils';
4
- import { NAME } from './common/constants';
5
-
6
- /**
7
- * 音频设备相关接口<br>
8
- * @memberof TRTCClouds
9
- */
10
- class Mic extends MixinsClass(BaseCommon) {
11
- /**
12
- * 获取麦克风设备列表<br>
13
- * @returns {Promise(Array<TRTCDeviceInfo>)} 麦克风管理器列表
14
- * @memberof TRTCCloud
15
- * @example
16
- * var micList = await trtcCloud.getMicDevicesList();
17
- * for (i = 0; i < micList.length; i++) {
18
- * var mic = micList[i];
19
- * console.info("mic deviceName: " + mic.deviceName + " deviceId:" + mic.deviceId);
20
- * }
21
- */
22
- async getMicDevicesList(): Promise<TRTCDeviceInfo[]> {
23
- try {
24
- const micList = await this.TRTC.getMicrophones();
25
- this.micList = micList.map((item: TRTCDeviceInfo) => ({
26
- ...item,
27
- deviceName: item.label, // 就是 deviceName
28
- }));
29
- return Promise.resolve(this.micList);
30
- } catch (error: any) {
31
- this.callFunctionErrorManage(error, 'getMicDevicesList');
32
- return Promise.resolve([]);
33
- }
34
- }
35
-
36
- /**
37
- * 获取当前选择的麦克风<br>
38
- * @memberof TRTCCloud
39
- * @return {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
40
- */
41
- getCurrentMicDevice(): TRTCDeviceInfo {
42
- if (this.currentMicId) {
43
- return (this.micList || []).filter((obj: any) => obj.deviceId === this.currentMicId)[0] || {};
44
- }
45
- return new TRTCDeviceInfo();
46
- }
47
-
48
- /**
49
- * 设置要使用的麦克风<br>
50
- * 选择指定的麦克风作为录音设备,不调用该接口时,默认选择索引为0的麦克风
51
- *
52
- * @param {String} micId - 从 getMicDevicesList 中得到的设备 ID
53
- * @memberof TRTCCloud
54
- * @returns {Promise}
55
- */
56
- async setCurrentMicDevice(micId: string): Promise<boolean> {
57
- try {
58
- if (!micId) {
59
- return Promise.resolve(false);
60
- }
61
- if (this.currentMicId === micId) {
62
- return Promise.resolve(true);
63
- }
64
- this.currentMicId = micId || '';
65
- if (hasAudioTrack(this.localStream)) {
66
- await this.localStream.switchDevice(NAME.AUDIO, micId);
67
- }
68
- if (hasAudioTrack(this.localPlayStream)) {
69
- await this.localPlayStream.switchDevice(NAME.AUDIO, micId);
70
- }
71
- this.emitOnDeviceChange(micId, TRTCDeviceType.TRTCDeviceTypeMic, TRTCDeviceState.TRTCDeviceStateActive);
72
- return Promise.resolve(true);
73
- } catch (error: any) {
74
- this.callFunctionErrorManage(error, 'setCurrentMicDevice');
75
- return Promise.resolve(false);
76
- }
77
- }
78
-
79
- /**
80
- * 获取扬声器设备列表<br>
81
- * - 出于安全的考虑,在用户未授权摄像头或麦克风访问权限前,deviceId 字段可能都是空的。因此建议在用户授权访问后 再调用该接口获取设备详情
82
- * - 移动端不支持获取扬声器列表
83
- * @return {Promise(Array<TRTCDeviceInfo>)} 扬声器管理器列表
84
- * @memberof TRTCCloud
85
- * @example
86
- * var speakerList = await trtcCloud.getSpeakerDevicesList();
87
- * for (i = 0; i < speakerList.length; i++) {
88
- * var speaker = speakerList[i];
89
- * console.info("mic deviceName: " + speaker.deviceName + " deviceId:" + speaker.deviceId);
90
- * }
91
- */
92
- async getSpeakerDevicesList(): Promise<TRTCDeviceInfo[]> {
93
- try {
94
- const speakerList = await this.TRTC.getSpeakers();
95
- this.speakerList = speakerList.map((item: TRTCDeviceInfo) => ({
96
- ...item,
97
- deviceName: item.label, // 就是 deviceName
98
- }));
99
- return Promise.resolve(this.speakerList);
100
- } catch (error: any) {
101
- this.callFunctionErrorManage(error, 'getSpeakerDevicesList');
102
- return Promise.resolve([]);
103
- }
104
- }
105
-
106
- /**
107
- * 获取当前的扬声器设备<br>
108
- * @memberof TRTCCloud
109
- * @return {TRTCDeviceInfo} 设备信息,能获取设备 ID 和设备名称
110
- */
111
- getCurrentSpeakerDevice(): TRTCDeviceInfo {
112
- if (this.currentSpeakerId) {
113
- return (this.speakerList || []).filter((obj: any) => obj.deviceId === this.currentSpeakerId)[0] || {};
114
- }
115
- return new TRTCDeviceInfo();
116
- }
117
-
118
- /**
119
- * 设置要使用的扬声器<br>
120
- * - 移动端不支持设置扬声器。
121
- * @param {String} speakerId - 从 getSpeakerDevicesList 中得到的设备 ID
122
- * @returns {Promise}
123
- * @memberof TRTCCloud
124
- */
125
- async setCurrentSpeakerDevice(speakerId: string): Promise<boolean> {
126
- try {
127
- if (!speakerId) {
128
- return Promise.resolve(false);
129
- }
130
- this.currentSpeakerId = speakerId || '';
131
- if (this.remoteStreamMap.size > 0) {
132
- const remoteStreamList = this.getRemoteStreamList();
133
- // TODO: 如果某个 remoteStream 出现切换失败呢?
134
- // eslint-disable-next-line max-len
135
- await Promise.all(remoteStreamList.map(async (stream: any) => await stream.setAudioOutput(this.currentSpeakerId)));
136
- }
137
- return Promise.resolve(true);
138
- } catch (error: any) {
139
- this.callFunctionErrorManage(error, 'setCurrentSpeakerDevice');
140
- return Promise.resolve(false);
141
- }
142
- }
143
- }
144
-
145
- export { Mic };
@@ -1,6 +0,0 @@
1
- interface IError {
2
- code: number;
3
- message: string;
4
- }
5
-
6
- export { IError };
@@ -1,68 +0,0 @@
1
- import { NAME } from './constants';
2
-
3
- interface ITRTCCloudConfig {
4
- frameWorkType?: number;
5
- component?: number;
6
- }
7
- interface TurnServerOptions {
8
- url: string;
9
- username?: string;
10
- credential?: string;
11
- credentialType?: 'password';
12
- }
13
-
14
- export interface ProxyServer {
15
- websocketProxy?: string;
16
- loggerProxy?: string;
17
- turnServer?: TurnServerOptions | TurnServerOptions[];
18
- webtransportProxy?: string;
19
- }
20
-
21
- export const enum Scene {
22
- 'LIVE' = 'live',
23
- 'RTC' = 'rtc',
24
- };
25
-
26
- interface IEnterRoomParams {
27
- sdkAppId: number;
28
- userId: string;
29
- userSig: string;
30
- roomId: number | string;
31
- role?: string; // webRtc 为 "anchor" | "audience", TrtcCloud 为 TRTCRoleAnchor - 20; TRTCRoleAudience - 21
32
- receiveMode?: number; // webRtc 为 MANUAL = 0; AUTO = 1; TrtcCloud 详见 trtc_define.ts 中说明
33
- privateMapKey?: string;
34
- businessInfo?: string;
35
- enableAutoPlayDialog?: boolean; // 默认为 true
36
- proxy?: ProxyServer | string;
37
- scene?: string; // webRtc 为 "rtc" | "live", TrtcCloud 参考 trtc_define.ts 中 TRTCAppScene 说明
38
- useStringRoomId?: boolean;
39
- streamId?: string;
40
- userDefineRecordId?: string;
41
- // 下面两个是 TrtcCloud 自己额外的参数
42
- frameWorkType?: number;
43
- component?: number;
44
- }
45
-
46
- interface IVideoProfile {
47
- width?: number;
48
- height?: number;
49
- frameRate?: number;
50
- bitrate?: number;
51
- }
52
- interface IVideoPlayOption {
53
- mirror?: boolean;
54
- fillMode?: VideoFillMode;
55
- }
56
-
57
- export const enum VideoFillMode {
58
- 'CONTAIN' = 'contain',
59
- 'COVER' = 'cover',
60
- 'FILL' = 'fill',
61
- }
62
-
63
- export {
64
- ITRTCCloudConfig,
65
- IEnterRoomParams,
66
- IVideoProfile,
67
- IVideoPlayOption,
68
- };
@@ -1,116 +0,0 @@
1
- // --------------------------------常量--------------------------------
2
- export const EnterRoomFailure: number = -1;
3
- export const NAME = {
4
- DEFAULT: 'default',
5
- VIDEO: 'video',
6
- AUDIO: 'audio',
7
- ON_ERROR: 'onError',
8
- MAIN: 'main',
9
- // 场景:音视频、直播
10
- RTC: 'rtc',
11
- LIVE: 'live',
12
- // 用户角色
13
- ANCHOR: 'anchor',
14
- AUDIENCE: 'audience',
15
- // 音频 profile
16
- AUDIO_STANDARD: 'standard',
17
- AUDIO_HIGH: 'high',
18
- AUDIO_STANDARD_STEREO: 'standard_stereo',
19
- AUDIO_HIGH_STEREO: 'high_stereo',
20
- // 音频 profile
21
- SMALL: 'small',
22
- BIG: 'big',
23
- AUXILIARY: 'auxiliary',
24
- // 屏幕分享用户名的前缀
25
- SCREEN_SHARE_USER_ID_PREFIX: 'share_',
26
- NUMBER: 'number',
27
- STRING: 'string',
28
- };
29
-
30
- // 网络类型与仪表盘传参的对应关系
31
- export const NETWORK_TYPE = {
32
- unknown: 0,
33
- wifi: 1,
34
- '3g': 2,
35
- '2g': 3,
36
- '4g': 4,
37
- wired: 5,
38
- };
39
- interface IRoleMap {
40
- [key: number]: string;
41
- }
42
-
43
- // webRTC 仅在 'live' 模式下有意义, 仅支持以下两种角色. TRTCRoleAnchor = 20, TRTCRoleAudience = 21,
44
- export const RoleMap: IRoleMap = {
45
- 20: NAME.ANCHOR,
46
- 21: NAME.AUDIENCE,
47
- };
48
-
49
- // TRTCAppSceneVideoCall = 0, 视频通话场景
50
- // TRTCAppSceneLIVE = 1, 视频互动直播
51
- // TRTCAppSceneAudioCall = 2, 语音通话场景
52
- // TRTCAppSceneVoiceChatRoom = 3, 语音互动直播
53
- // webRTC 仅在 'live' 模式下有意义, 仅支持以下两种角色
54
- export const SceneMap = {
55
- 0: NAME.RTC,
56
- 1: NAME.LIVE,
57
- 2: NAME.RTC,
58
- 3: NAME.LIVE,
59
- };
60
-
61
- // webRTC 音频 https://web.sdk.qcloud.com/trtc/webrtc/doc/zh-cn/LocalStream.html#setAudioProfile
62
- export const audioQualityMap = {
63
- 0: NAME.AUDIO_STANDARD,
64
- 1: NAME.AUDIO_HIGH,
65
- 2: NAME.AUDIO_STANDARD_STEREO,
66
- 3: NAME.AUDIO_HIGH_STEREO,
67
- };
68
-
69
- // webRTC 视频
70
- export const streamTypeMap = {
71
- 0: NAME.BIG,
72
- 1: NAME.SMALL,
73
- 2: NAME.AUXILIARY,
74
- };
75
-
76
- // * WebRTC 视频分辨率和 TRTCCloud 的映射关系
77
- // * export enum TRTCVideoResolution {
78
- // TRTCVideoResolution_120_120 = 1,
79
- // TRTCVideoResolution_160_160 = 3,
80
- // TRTCVideoResolution_270_270 = 5,
81
- // TRTCVideoResolution_480_480 = 7,
82
- // TRTCVideoResolution_160_120 = 50,
83
- // TRTCVideoResolution_240_180 = 52,
84
- // TRTCVideoResolution_280_210 = 54,
85
- // TRTCVideoResolution_320_240 = 56,
86
- // TRTCVideoResolution_400_300 = 58,
87
- // TRTCVideoResolution_480_360 = 60,
88
- // TRTCVideoResolution_640_480 = 62,
89
- // TRTCVideoResolution_960_720 = 64,
90
- // TRTCVideoResolution_160_90 = 100,
91
- // TRTCVideoResolution_256_144 = 102,
92
- // TRTCVideoResolution_320_180 = 104,
93
- // TRTCVideoResolution_480_270 = 106,
94
- // TRTCVideoResolution_640_360 = 108,
95
- // TRTCVideoResolution_960_540 = 110,
96
- // TRTCVideoResolution_1280_720 = 112,
97
- // TRTCVideoResolution_1920_1080 = 114
98
- // }
99
- // * | 视频Profile | 分辨率(宽 x 高)| 帧率(fps)| 码率(kbps)|
100
- // * | :--- | :--- | :--- | :--- |
101
- // * | 120p | 160 x 120 | 15 | 200 |
102
- // * | 180p | 320 x 180 | 15 | 350 |
103
- // * | 240p | 320 x 240 | 15 | 400 |
104
- // * | 360p | 640 x 360 | 15 | 800 |
105
- // * | 480p | 640 x 480 | 15 | 900 |
106
- // * | 720p | 1280 x 720 | 15 | 1500 |
107
- // * | 1080p | 1920 x 1080 | 15 | 2000 |
108
- // * | 1440p | 2560 x 1440 | 30 | 4860 |
109
- // * | 4K | 3840 x 2160 | 30 | 9000 |
110
- export const videoResolutionMap = {};
111
- export const videoProfileMap = {};
112
-
113
- export enum ExitRoomCode {
114
- 'ActiveExitRoom' = 0,
115
- 'KickedExitRoom' = 1,
116
- }
@@ -1,43 +0,0 @@
1
- import { IError } from './IError';
2
-
3
-
4
- export const jsExecuteError: IError = {
5
- code: -1000,
6
- message: 'js 执行报错',
7
- };
8
- export const ParametersError: IError = {
9
- code: -1001,
10
- message: '参数错误, 请检查参数格式、是否非空等',
11
- };
12
- export const enterRoomError: IError = {
13
- code: -1002,
14
- message: '进房失败:进房中或已进房',
15
- };
16
- export const exitRoomError: IError = {
17
- code: -1003,
18
- message: '退房失败:未进房或退房中',
19
- };
20
- export const conditionsError: IError = {
21
- code: -1004,
22
- message: '调用该函数所需要条件不满足',
23
- };
24
- export const NotSupportError: IError = {
25
- code: -1005,
26
- message: 'not supported',
27
- };
28
- export const NotSupportBeforeJoinRoomError: IError = {
29
- code: -1006,
30
- message: 'not supported before join room',
31
- };
32
- export const EnterRoomUserIdError: IError = {
33
- code: -1007,
34
- message: '进房 userId 不能包含前缀 share_',
35
- };
36
- export const ScreenShareUserIdError: IError = {
37
- code: -1008,
38
- message: '屏幕分享 userId 必须包含前缀 share_',
39
- };
40
- export const ScreenShareTypeError: IError = {
41
- code: -1009,
42
- message: '不支持小流推屏幕分享',
43
- };