@tencent-rtc/mcp 1.3.4 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/resource/doc/chatuikit/android/features/theme.md +363 -0
- package/resource/doc/chatuikit/{android/client_api_Android.md → faq/android_sdk/client-api.md} +0 -2
- package/resource/doc/chatuikit/faq/common/product.md +8 -0
- package/resource/doc/chatuikit/faq/flutter_sdk/faq.md +53 -0
- package/resource/doc/chatuikit/{iOS/client_api_iOS.md → faq/ios_sdk/client-api.md} +0 -2
- package/resource/doc/chatuikit/flutter/features/theme.md +379 -0
- package/resource/doc/chatuikit/flutter/integration.md +413 -0
- package/resource/doc/chatuikit/flutter/workflow.md +941 -0
- package/resource/doc/chatuikit/iOS/features/theme.md +416 -0
- package/resource/doc/chatuikit/react/components/chat-setting.md +86 -0
- package/resource/doc/chatuikit/react/components/contact-list.md +1093 -0
- package/resource/doc/chatuikit/react/components/search.md +745 -0
- package/resource/doc/chatuikit/vue/components/chat-setting.md +64 -0
- package/resource/doc/chatuikit/vue/components/contact-list.md +679 -0
- package/resource/doc/chatuikit/vue/components/search.md +1384 -0
- package/resource/doc/livekit/live/android/workflow.md +137 -6
- package/resource/doc/livekit/live/ios/live-audience-list.md +339 -0
- package/resource/doc/livekit/live/ios/live-audio-effect.md +370 -0
- package/resource/doc/livekit/live/ios/live-barrage.md +517 -0
- package/resource/doc/livekit/live/ios/live-base-beauty.md +247 -0
- package/resource/doc/livekit/live/ios/live-co-guest-interaction.md +518 -0
- package/resource/doc/livekit/live/ios/live-gift.md +783 -0
- package/resource/doc/livekit/live/ios/live-host-interaction.md +815 -0
- package/resource/doc/livekit/live/ios/live-integration.md +931 -0
- package/resource/doc/livekit/live/ios/live-live-list.md +485 -0
- package/resource/doc/livekit/live/ios/workflow.md +454 -0
- package/resource/doc/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +87 -0
- package/resource/doc/rtcengine/web/plugin/21-advanced-auto-play-policy.md +87 -0
- package/resource/doc/rtcengine/web/plugin/22-advanced-audio-mixer.md +175 -0
- package/resource/doc/rtcengine/web/plugin/23-advanced-support-detection.md +221 -0
- package/resource/doc/rtcengine/web/plugin/24-advanced-network-quality.md +140 -0
- package/resource/doc/rtcengine/web/plugin/25-advanced-device-change.md +99 -0
- package/resource/doc/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +451 -0
- package/resource/doc/rtcengine/web/plugin/27-advanced-small-stream.md +151 -0
- package/resource/doc/rtcengine/web/plugin/28-advanced-beauty.md +322 -0
- package/resource/doc/rtcengine/web/plugin/29-advanced-water-mark.md +149 -0
- package/resource/doc/rtcengine/web/plugin/30-advanced-cross-room-link.md +96 -0
- package/resource/doc/rtcengine/web/plugin/31-advanced-plugins-overview.md +330 -0
- package/resource/doc/rtcengine/web/plugin/34-advanced-proxy.md +248 -0
- package/resource/doc/rtcengine/web/plugin/35-advanced-ai-denoiser.md +81 -0
- package/resource/doc/rtcengine/web/plugin/36-advanced-virtual-background.md +242 -0
- package/resource/doc/rtcengine/web/plugin/37-advanced-voice-changer.md +99 -0
- package/resource/doc/rtcengine/web/plugin/39-advanced-video-decoder.md +33 -0
- package/resource/doc/rtcengine/web/plugin/40-advanced-video-mixer.md +379 -0
- package/resource/doc/rtcengine/web/plugin/41-advanced-small-stream-auto-switcher.md +91 -0
- package/resource/doc/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +315 -0
- package/resource/doc/rtcengine/web/plugin/43-advanced-face-detection.md +180 -0
- package/resource/doc/tuicallkit/android/workflow.md +0 -0
- package/resource/doc/tuicallkit/flutter/workflow.md +331 -0
- package/tools/call/get-native-call-integration.js +27 -11
- package/tools/call/get-native-call-integration.js.map +1 -1
- package/tools/chat/get-native-chat-feature-detail.js +30 -0
- package/tools/chat/get-native-chat-feature-detail.js.map +1 -0
- package/tools/chat/get-native-chat-integration.js +30 -12
- package/tools/chat/get-native-chat-integration.js.map +1 -1
- package/tools/common/get-faq.js +2 -4
- package/tools/common/get-faq.js.map +1 -1
- package/tools/definitions/get_native_call_uikit_integration_def.js +17 -7
- package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_chat_feature_detail_def.js +32 -0
- package/tools/definitions/get_native_chat_feature_detail_def.js.map +1 -0
- package/tools/definitions/get_native_chat_uikit_integration_def.js +19 -7
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/{get_native_live_extra_features_def.js → get_native_live_uikit_extra_features_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_extra_features_def.js.map +1 -0
- package/tools/definitions/{get_native_live_interaction_def.js → get_native_live_uikit_interaction_def.js} +3 -3
- package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -0
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js +49 -10
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js.map +1 -1
- package/tools/index.js +6 -4
- package/tools/index.js.map +1 -1
- package/tools/live/{get_native_live_extra_features.js → get_native_live_uikit_extra_features.js} +4 -4
- package/tools/live/get_native_live_uikit_extra_features.js.map +1 -0
- package/tools/live/{get_native_live_interaction.js → get_native_live_uikit_interaction.js} +4 -4
- package/tools/live/get_native_live_uikit_interaction.js.map +1 -0
- package/tools/rtcengine/get-rtcengine-web-sdk-integration.js.map +1 -1
- package/tools/rtcengine/get-trtc-sdk-faq.js +32 -0
- package/tools/rtcengine/get-trtc-sdk-faq.js.map +1 -0
- package/tools/rtcengine/get-trtc-web-sdk-faq.js +1 -1
- package/tools/rtcengine/get-trtc-web-sdk-integration.js.map +1 -1
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js +45 -0
- package/tools/rtcengine/get-trtc-web-sdk-plugin.js.map +1 -0
- package/utils/handle-component-name.js +0 -16
- package/utils/handle-component-name.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/chatuikit/android/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/android/integrarte_only_tuichat_Android.md +0 -290
- package/resource/doc/chatuikit/android/quick_start_Android.md +0 -138
- package/resource/doc/chatuikit/android/show_typing_Android.md +0 -43
- package/resource/doc/chatuikit/flutter/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/flutter/integrate_tuikit_Flutter.md +0 -133
- package/resource/doc/chatuikit/iOS/generate_UserSig.md +0 -306
- package/resource/doc/chatuikit/iOS/integrate_only_tuichat_iOS.md +0 -748
- package/resource/doc/chatuikit/iOS/quick_start_iOS.md +0 -163
- package/resource/doc/chatuikit/iOS/show_typing_iOS.md +0 -52
- package/resource/doc/tuicallkit/flutter/how_to_run_flutter_callkit_demo.md +0 -101
- package/resource/doc/tuicallkit/iOS/how_to_run_iOS_callkit_demo.md +0 -98
- package/tools/definitions/get_native_live_extra_features_def.js.map +0 -1
- package/tools/definitions/get_native_live_interaction_def.js.map +0 -1
- package/tools/live/get_native_live_extra_features.js.map +0 -1
- package/tools/live/get_native_live_interaction.js.map +0 -1
- /package/resource/doc/chatuikit/android/{integrate_tuikit_Android.md → integration.md} +0 -0
- /package/resource/doc/chatuikit/{faq/native_sdk/faq.md → android/workflow.md} +0 -0
- /package/resource/doc/chatuikit/{flutter/client_api_Flutter.md → faq/flutter_sdk/client-api.md} +0 -0
- /package/resource/doc/chatuikit/iOS/{integrate_tuikit_iOS.md → integration.md} +0 -0
- /package/resource/doc/{tuicallkit/android/.gitkeep → chatuikit/iOS/workflow.md} +0 -0
- /package/resource/doc/chatuikit/react/components/{chatheader.md → chat-header.md} +0 -0
- /package/resource/doc/chatuikit/vue/components/{chatheader.md → chat-header.md} +0 -0
- /package/resource/doc/tuicallkit/android/{how_to_integrated_android_callkit.md → integration.md} +0 -0
- /package/resource/doc/tuicallkit/{android/api_TUICallObserver.md → faq/android_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{android/api_TUICallKit.md → faq/android_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallDefine.md → faq/flutter_sdk/call-define-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallObserver.md → faq/flutter_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{flutter/api_TUICallKit.md → faq/flutter_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/{iOS/api_TUICallObserver.md → faq/ios_sdk/call-observer-api.md} +0 -0
- /package/resource/doc/tuicallkit/{iOS/api_TUICallKit.md → faq/ios_sdk/callkit-api.md} +0 -0
- /package/resource/doc/tuicallkit/flutter/{how_to_integrated_flutter_callkit.md → integration.md} +0 -0
- /package/resource/doc/tuicallkit/iOS/{how_to_integrated_iOS_callkit.md → integration.md} +0 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
## Feature Description
|
|
2
|
+
|
|
3
|
+
This document describes how to use the CDNStreaming plugin to implement cloud-based stream mixing, relaying streams to CDN, and pushing mixed streams back to TRTC rooms.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. [TRTC SDK](https://www.npmjs.com/package/trtc-sdk-v5) version must be >= 5.1.
|
|
8
|
+
2. Enable [Tencent Cloud Live service](https://console.tencentcloud.com/live/domainmanage).
|
|
9
|
+
3. In the [TRTC Console - Advanced Features](https://console.trtc.io/features), click "Relay to CDN", and enable the "Enable relay to CDN" switch.
|
|
10
|
+
- When the "Global auto relay" switch is enabled, all upstream audio and video streams in TRTC will be automatically relayed to Tencent Cloud CDN ("Global Auto relay" mode).
|
|
11
|
+
- When the "Global auto relay" switch is disabled, you can use this plugin or the server REST API to relay specific audio and video streams to the CDN and specify the playback address ("Designated Stream relay" mode).
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
<img src="assets/en-cdn-relay-switch.png" style="max-width: 1000px;" />
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
### Install & Register
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import TRTC from 'trtc-sdk-v5';
|
|
23
|
+
import { CDNStreaming, PublishMode } from 'trtc-sdk-v5/plugins/cdn-streaming';
|
|
24
|
+
|
|
25
|
+
const trtc = TRTC.create({ plugins: [CDNStreaming] });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Plugin Modes Overview
|
|
29
|
+
|
|
30
|
+
This plugin provides four streaming modes:
|
|
31
|
+
|
|
32
|
+
| Mode | PublishMode | Description |
|
|
33
|
+
|------|-------------|-------------|
|
|
34
|
+
| A | `PublishMainStreamToCDN` | Relay camera and microphone stream to CDN |
|
|
35
|
+
| B | `PublishSubStreamToCDN` | Relay screen sharing stream to CDN |
|
|
36
|
+
| C | `PublishMixStreamToCDN` | Mix multiple streams and relay to CDN |
|
|
37
|
+
| D | `PublishMixStreamToRoom` | Mix multiple streams and push back to TRTC room |
|
|
38
|
+
|
|
39
|
+
For each mode, the following lifecycle applies:
|
|
40
|
+
|
|
41
|
+
- `trtc.startPlugin('CDNStreaming', options)` - Start the plugin
|
|
42
|
+
- `trtc.updatePlugin('CDNStreaming', options)` - Update parameters (0 or N times)
|
|
43
|
+
- `trtc.stopPlugin('CDNStreaming', options)` - Stop the plugin
|
|
44
|
+
|
|
45
|
+
For detailed `options` parameters, see [CDNStreamingOptions](./global.html#CDNStreamingOptions).
|
|
46
|
+
|
|
47
|
+
## Relay Single Stream to CDN
|
|
48
|
+
|
|
49
|
+
Relay camera stream (Mode A) or screen sharing stream (Mode B) to Tencent Cloud CDN.
|
|
50
|
+
|
|
51
|
+
### Step 1: Select Relay Mode
|
|
52
|
+
|
|
53
|
+
In [TRTC Console - Advanced Features](https://console.trtc.io/features), select your relay mode:
|
|
54
|
+
|
|
55
|
+
**Global Auto-Relay Mode:**
|
|
56
|
+
|
|
57
|
+
Streams will be **automatically** pushed to CDN with default playback address:
|
|
58
|
+
|
|
59
|
+
`http://[playback-domain]/live/[streamId].flv`
|
|
60
|
+
|
|
61
|
+
- `[playback-domain]`: The playback domain configured in [Domain Management](https://console.tencentcloud.com/live/livestat)
|
|
62
|
+
- Default `[streamId]` for camera: `${sdkAppId}_${roomId}_${userId}_main`
|
|
63
|
+
- Default `[streamId]` for screen sharing: `${sdkAppId}_${roomId}_${userId}_aux`
|
|
64
|
+
- When roomId or userId contains special characters, streamId uses MD5: `${sdkAppId}_${md5(${roomId}_${userId}_main)}`
|
|
65
|
+
|
|
66
|
+
**Manual Relay Mode:**
|
|
67
|
+
|
|
68
|
+
Streams will **not** be automatically pushed. Follow Step 2 to manually enable streaming.
|
|
69
|
+
|
|
70
|
+
### Step 2: Start Relay
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// Start relaying camera stream
|
|
74
|
+
const options = {
|
|
75
|
+
target: {
|
|
76
|
+
publishMode: PublishMode.PublishMainStreamToCDN
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
await trtc.startPlugin('CDNStreaming', options);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('CDNStreaming start failed', error);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Playback address: `http://[playback-domain]/live/${sdkAppId}_${roomId}_${userId}_main.flv`
|
|
87
|
+
|
|
88
|
+
### Step 3: Update StreamId (Optional)
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// Customize the playback address
|
|
92
|
+
const options = {
|
|
93
|
+
target: {
|
|
94
|
+
publishMode: PublishMode.PublishMainStreamToCDN,
|
|
95
|
+
streamId: 'stream001'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await trtc.updatePlugin('CDNStreaming', options);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('CDNStreaming update failed', error);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
New playback address: `http://[playback-domain]/live/stream001.flv`
|
|
106
|
+
|
|
107
|
+
### Step 4: Stop Relay
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const options = {
|
|
111
|
+
target: {
|
|
112
|
+
publishMode: PublishMode.PublishMainStreamToCDN,
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
await trtc.stopPlugin('CDNStreaming', options);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('CDNStreaming stop failed', error);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You can view the current stream status through the [Stream Management Interface](https://console.tencentcloud.com/live/domainmanage).
|
|
123
|
+
|
|
124
|
+
## Relay Mixed Stream to CDN
|
|
125
|
+
|
|
126
|
+
Mix multiple audio and video streams in the room into one stream and relay to CDN.
|
|
127
|
+
|
|
128
|
+
For other platform implementations, please refer to [Cloud-Based Stream Mixing and Transcoding](https://trtc.io/document/47858).
|
|
129
|
+
|
|
130
|
+
### How It Works
|
|
131
|
+
|
|
132
|
+
This plugin sends a command to Tencent Cloud's transcoding server to mix multiple streams. You can customize:
|
|
133
|
+
- `encoding`: Output stream quality (resolution, bitrate, framerate)
|
|
134
|
+
- `mix`: Layout configuration for mixed streams
|
|
135
|
+
|
|
136
|
+
<img src="https://cloudcache.intl.tencent-cloud.com/cms/backend-cms/fb99be746bf211efbd54525400f69702.png" style="width: 1000px">
|
|
137
|
+
|
|
138
|
+
### Example Workflow
|
|
139
|
+
|
|
140
|
+
1. Call `startPlugin`, the mixing layout is as shown in Figure A
|
|
141
|
+
2. Call `updatePlugin` to add screen sharing, the mixing layout is as shown in Figure B
|
|
142
|
+
3. Call `stopPlugin` when mixing is no longer needed
|
|
143
|
+
|
|
144
|
+
<img src="https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100025252093/8f489b66a80411f0bf2352540044a08e.png" style="width: 600px">
|
|
145
|
+
|
|
146
|
+
### Configuration Guide
|
|
147
|
+
|
|
148
|
+
1. Set `target.publishMode` to `PublishMode.PublishMixStreamToCDN`
|
|
149
|
+
|
|
150
|
+
2. Configure `encoding` for output quality: videoWidth, videoHeight, videoBitrate, videoFramerate, videoGOP, audioSampleRate, audioBitrate, audioChannels
|
|
151
|
+
|
|
152
|
+
3. Configure `mix.backgroundColor` and `mix.backgroundImage` for background
|
|
153
|
+
> Background images need to be uploaded in [TRTC Console - Advanced Features](https://console.trtc.io/features) > Material management. Use the "Image ID" as string for backgroundImage (e.g., "63").
|
|
154
|
+
> <img src="assets/en-cdn-console-image.png" style="width: 600px">
|
|
155
|
+
|
|
156
|
+
4. Configure `mix.audioMixUserList` for audio mixing (empty = mix all users)
|
|
157
|
+
|
|
158
|
+
5. Configure `mix.videoLayoutList` for video layout
|
|
159
|
+
|
|
160
|
+
> Coordinate system: the origin (0, 0) is the **top-left corner** of the output canvas, in pixels. locationX/locationY is the top-left position of each stream; width/height is the layout region size. Coordinates/sizes are tied to encoding.videoWidth/videoHeight - if you change resolution, scale layout parameters accordingly to avoid misalignment.
|
|
161
|
+
>
|
|
162
|
+
> For full parameter details, see [CDNStreamingOptions](./global.html#CDNStreamingOptions).
|
|
163
|
+
|
|
164
|
+
### Start Mixing
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
let options = {
|
|
168
|
+
target: {
|
|
169
|
+
publishMode: PublishMode.PublishMixStreamToCDN,
|
|
170
|
+
streamId: 'mix-stream',
|
|
171
|
+
},
|
|
172
|
+
encoding: {
|
|
173
|
+
videoWidth: 1280,
|
|
174
|
+
videoHeight: 720,
|
|
175
|
+
videoBitrate: 1500,
|
|
176
|
+
videoFramerate: 15,
|
|
177
|
+
},
|
|
178
|
+
mix: {
|
|
179
|
+
audioMixUserList: [
|
|
180
|
+
{ userId: 'current_user_id' }
|
|
181
|
+
],
|
|
182
|
+
videoLayoutList: [
|
|
183
|
+
{
|
|
184
|
+
fixedVideoUser: { userId: 'current_user_id' },
|
|
185
|
+
width: 640,
|
|
186
|
+
height: 480,
|
|
187
|
+
locationX: 0,
|
|
188
|
+
locationY: 0,
|
|
189
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
190
|
+
zOrder: 1
|
|
191
|
+
},
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
try {
|
|
196
|
+
await trtc.startPlugin('CDNStreaming', options);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error('CDNStreaming start failed', error);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Playback address: `http://[playback-domain]/live/mix-stream.flv`
|
|
203
|
+
|
|
204
|
+
### Update Layout
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
// Add screen sharing to the mix
|
|
208
|
+
let options = {
|
|
209
|
+
target: {
|
|
210
|
+
publishMode: PublishMode.PublishMixStreamToCDN,
|
|
211
|
+
streamId: 'mix-stream',
|
|
212
|
+
},
|
|
213
|
+
encoding: {
|
|
214
|
+
videoWidth: 1280,
|
|
215
|
+
videoHeight: 720,
|
|
216
|
+
videoBitrate: 1500,
|
|
217
|
+
videoFramerate: 15,
|
|
218
|
+
},
|
|
219
|
+
mix: {
|
|
220
|
+
audioMixUserList: [
|
|
221
|
+
{ userId: 'current_user_id' }
|
|
222
|
+
],
|
|
223
|
+
videoLayoutList: [
|
|
224
|
+
{
|
|
225
|
+
fixedVideoUser: { userId: 'current_user_id' },
|
|
226
|
+
width: 640,
|
|
227
|
+
height: 480,
|
|
228
|
+
locationX: 0,
|
|
229
|
+
locationY: 0,
|
|
230
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
231
|
+
zOrder: 1
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
fixedVideoUser: { userId: 'current_user_id' },
|
|
235
|
+
width: 640,
|
|
236
|
+
height: 480,
|
|
237
|
+
locationX: 640,
|
|
238
|
+
locationY: 0,
|
|
239
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_SUB,
|
|
240
|
+
zOrder: 1
|
|
241
|
+
},
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
await trtc.updatePlugin('CDNStreaming', options);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error('CDNStreaming update failed', error);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Stop Mixing
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
let options = {
|
|
256
|
+
target: {
|
|
257
|
+
publishMode: PublishMode.PublishMixStreamToCDN,
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
await trtc.stopPlugin('CDNStreaming', options);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.error('CDNStreaming stop failed', error);
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Push to Third-party CDN
|
|
268
|
+
|
|
269
|
+
Push streams to a CDN from any cloud service provider.
|
|
270
|
+
|
|
271
|
+
### Step 1: Get CDN Push Address
|
|
272
|
+
|
|
273
|
+
Obtain a CDN stream push address (url) from your cloud service provider.
|
|
274
|
+
|
|
275
|
+
### Step 2: Get bizId and appId
|
|
276
|
+
|
|
277
|
+
In [TRTC Console - Advanced Features](https://console.trtc.io/features), find your push domain (format: `xxxxx.push.tlivecloud.com`):
|
|
278
|
+
- `xxxxx` is the `bizId`
|
|
279
|
+
- Use your SDKAppId as `appId`
|
|
280
|
+
|
|
281
|
+
<div align="center">
|
|
282
|
+
<img src="assets/en-cdn-stream-manager.png" style="width: 600px">
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
### Step 3: Start Publishing
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
let options = {
|
|
289
|
+
target: {
|
|
290
|
+
publishMode: PublishMode.PublishMainStreamToCDN,
|
|
291
|
+
appId: 0, // Your appId
|
|
292
|
+
bizId: 0, // Your bizId
|
|
293
|
+
url: '' // Your CDN push address
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
try {
|
|
297
|
+
await trtc.startPlugin('CDNStreaming', options);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
console.error('CDNStreaming start customCDN failed', error);
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Stop Publishing
|
|
304
|
+
|
|
305
|
+
```javascript
|
|
306
|
+
let options = {
|
|
307
|
+
target: {
|
|
308
|
+
publishMode: PublishMode.PublishMainStreamToCDN,
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
await trtc.stopPlugin('CDNStreaming', options);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
console.error('CDNStreaming stop customCDN failed ', error);
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Push Back to TRTC Room
|
|
319
|
+
|
|
320
|
+
Mix streams and push the mixed stream back to a specified TRTC room as a robot user.
|
|
321
|
+
|
|
322
|
+
> **Note:**
|
|
323
|
+
> - A stream-pulling robot with userId `mcu_robot_${roomId}_${userId}` will automatically enter the current room. Avoid userId conflicts.
|
|
324
|
+
> - This feature will incur transcoding fees for stream mixing.
|
|
325
|
+
> - When `audioMixUserList` is empty, all users are mixed by default. Pass a non-existent userId if you don't need audio mixing.
|
|
326
|
+
> - For full parameter details, see [CDNStreamingOptions](./global.html#CDNStreamingOptions).
|
|
327
|
+
|
|
328
|
+
### Start Push Back
|
|
329
|
+
|
|
330
|
+
```javascript
|
|
331
|
+
// User user_123 in room 3333 initiates this task
|
|
332
|
+
// Mixed stream will be published as robot push_back_user_321 in room 4444
|
|
333
|
+
let options = {
|
|
334
|
+
target: {
|
|
335
|
+
publishMode: PublishMode.PublishMixStreamToRoom,
|
|
336
|
+
robotUser: {
|
|
337
|
+
userId: 'push_back_user_321', // Recommend dynamic generation
|
|
338
|
+
roomId: 4444,
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
encoding: {
|
|
342
|
+
videoWidth: 1280,
|
|
343
|
+
videoHeight: 720,
|
|
344
|
+
videoBitrate: 1500,
|
|
345
|
+
videoFramerate: 15,
|
|
346
|
+
},
|
|
347
|
+
mix: {
|
|
348
|
+
audioMixUserList: [
|
|
349
|
+
{ userId: 'user_123', roomId: 3333 }
|
|
350
|
+
],
|
|
351
|
+
videoLayoutList: [
|
|
352
|
+
{
|
|
353
|
+
fixedVideoUser: { userId: 'user_123', roomId: 3333 },
|
|
354
|
+
width: 640,
|
|
355
|
+
height: 480,
|
|
356
|
+
locationX: 0,
|
|
357
|
+
locationY: 0,
|
|
358
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
359
|
+
zOrder: 1
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
fixedVideoUser: { userId: 'user_123', roomId: 3333 },
|
|
363
|
+
width: 640,
|
|
364
|
+
height: 480,
|
|
365
|
+
locationX: 640,
|
|
366
|
+
locationY: 0,
|
|
367
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_SUB,
|
|
368
|
+
zOrder: 1
|
|
369
|
+
},
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
try {
|
|
374
|
+
await trtc.startPlugin('CDNStreaming', options);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error('CDNStreaming start push stream to room failed', error);
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Update Layout
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
let options = {
|
|
384
|
+
target: {
|
|
385
|
+
publishMode: PublishMode.PublishMixStreamToRoom
|
|
386
|
+
},
|
|
387
|
+
mix: {
|
|
388
|
+
videoLayoutList: [
|
|
389
|
+
{
|
|
390
|
+
fixedVideoUser: { userId: 'user_123', roomId: 3333 },
|
|
391
|
+
width: 640,
|
|
392
|
+
height: 480,
|
|
393
|
+
locationX: 640,
|
|
394
|
+
locationY: 0,
|
|
395
|
+
fixedVideoStreamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
396
|
+
zOrder: 1
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
try {
|
|
402
|
+
await trtc.updatePlugin('CDNStreaming', options);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
console.error('CDNStreaming update push stream to room failed', error);
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Stop Push Back
|
|
409
|
+
|
|
410
|
+
```javascript
|
|
411
|
+
let options = {
|
|
412
|
+
target: {
|
|
413
|
+
publishMode: PublishMode.PublishMixStreamToRoom,
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
await trtc.stopPlugin('CDNStreaming', options);
|
|
418
|
+
} catch (error) {
|
|
419
|
+
console.error('CDNStreaming stop push stream to room failed ', error);
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## API Description
|
|
424
|
+
|
|
425
|
+
For `startPlugin('CDNStreaming', options)` and `updatePlugin('CDNStreaming', options)`, parameter types can be found in [CDNStreamingOptions](./global.html#CDNStreamingOptions).
|
|
426
|
+
|
|
427
|
+
For `stopPlugin('CDNStreaming', options)`, the parameter only needs to fill in the `options.target.publishMode` field.
|
|
428
|
+
|
|
429
|
+
## Notes
|
|
430
|
+
|
|
431
|
+
1. To record mixed audio streams, please refer to [Cloud Recording](https://trtc.io/document/45169).
|
|
432
|
+
|
|
433
|
+
2. Cloud-based stream mixing and transcoding requires decoding and re-encoding the audio and video streams input to the MCU cluster, which will incur additional service costs. Therefore, TRTC will charge users who use the MCU cluster for cloud-based stream mixing and transcoding an additional value-added fee. Cloud-based stream mixing and transcoding fees are based on the **resolution of the transcoded output** and **transcoding duration**. The higher the resolution of the transcoded output and the longer the transcoding time, the higher the cost. For details, please refer to [Cloud-Based Stream Mixing and Transcoding Billing Description](https://trtc.io/document/47858?product=rtcengine&menulabel=core%20sdk&platform=android#25e78f25-3514-4608-a85f-f6db86685684).
|
|
434
|
+
|
|
435
|
+
3. For audio and video duration billing, please refer to [Billing Description](https://trtc.io/zh/document/47858?product=rtcengine&menulabel=core%20sdk&platform=android#25e78f25-3514-4608-a85f-f6db86685684).
|
|
436
|
+
|
|
437
|
+
4. After leaving the room, billing will not continue, but when re-entering the room, it will automatically continue to start. If you want to directly terminate CDN relay and mixing, please execute stopPlugin for the corresponding publishMode.
|
|
438
|
+
|
|
439
|
+
## FAQ
|
|
440
|
+
|
|
441
|
+
Q. Unable to stop streaming?
|
|
442
|
+
|
|
443
|
+
Please check if "Global Auto-Relay" is enabled in the console. In this mode, streaming cannot be stopped through the API.
|
|
444
|
+
|
|
445
|
+
Q. How to view all current streams?
|
|
446
|
+
|
|
447
|
+
You can view the current stream status through the [Stream Management Interface](https://console.tencentcloud.com/live/streammanage).
|
|
448
|
+
|
|
449
|
+
Q. Screen sharing is blurry?
|
|
450
|
+
|
|
451
|
+
The SDK uses `1080p` parameter configuration by default to capture screen sharing. Please refer to the interface: {@link TRTC#startScreenShare startScreenShare}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
|
|
2
|
+
## Function Description
|
|
3
|
+
|
|
4
|
+
In the multi-person video call scenario, as the number of streaming users increases, both bandwidth consumption and device performance consumption will rise for users who are subscribing streams. If no optimization is done, the experience on low-end and mid-range devices will be greatly compromised.
|
|
5
|
+
|
|
6
|
+
This article mainly introduces the best practices for multi-person video scenarios, using the "small streams + only subscribe video streams from the visible area" feature to reduce bandwidth consumption and ensure the best call experience.
|
|
7
|
+
|
|
8
|
+
## Enable small stream
|
|
9
|
+
|
|
10
|
+
The small stream refers to encoding two video streams at the same time when the camera is turned on. One is a normal resolution video (referred to as the main stream), and the other is a low-resolution video (referred to as the small stream). At the receiving end, you can choose to receive the main stream or the small stream to save bandwidth.
|
|
11
|
+
|
|
12
|
+
Applicable scenarios: The small stream is suitable for multi-person audio and video communication scenarios. Generally, in the page layout of multi-person communication scenarios, there will be "a big view and a lot of small view". The video in the big view is the main stream, and the video in the small view is the small stream. This function will increase the upstream bandwidth slightly, but it can greatly save the downstream bandwidth.
|
|
13
|
+
|
|
14
|
+
### Implementation Steps
|
|
15
|
+
|
|
16
|
+
#### Enable small streams on the publishing end
|
|
17
|
+
|
|
18
|
+
When calling [startLocalVideo](./TRTC.html#startLocalVideo), set the small parameter to enable small stream encoding. In an environment that does not support enabling small streams, the small parameter will not take effect and will not report an error.
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
await trtc.startLocalVideo({ option: { small: '120p' }});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Since version 5.3.0+, you can turn on/off dynamically the small stream.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
await trtc.startLocalVideo();
|
|
28
|
+
|
|
29
|
+
// turn on small stream
|
|
30
|
+
await trtc.updateLocalVideo({ option: { small: '120p' }});
|
|
31
|
+
|
|
32
|
+
// turn off small stream
|
|
33
|
+
await trtc.updateLocalVideo({ option: { small: false }});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Subscribe the big stream or the small stream on the receiving end
|
|
37
|
+
|
|
38
|
+
When calling [startRemoteVideo](./TRTC.html#startRemoteVideo), set the small parameter to subscribe the small stream. Otherwise, the big stream is subscribed by default. When subscribing the small stream, there is no need to check whether the remote user has published the small stream in advance. If the remote end does not publish the small stream, the SDK will automatically subscribe the big stream.
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
|
|
42
|
+
trtc.startRemoteVideo({
|
|
43
|
+
view: '', // Pass in the elementId or element instance object of the video container.
|
|
44
|
+
userId,
|
|
45
|
+
streamType,
|
|
46
|
+
option: { small: true }
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Switch to the specified userId's small stream when filling in the small parameter during updateRemoteVideo. It is commonly used to implement the following functions: when the user clicks the "small view", play remote video on "big view"; when the user clicks the "big view", play remote video on "small view".
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
// Switch to "big view" playback when the user clicks the "small view".
|
|
55
|
+
await trtc.updateRemoteVideo({
|
|
56
|
+
view: '', // Pass in the elementId or element instance object of the "big view" video container.
|
|
57
|
+
userId: '', // Pass in the userId of the remote user.
|
|
58
|
+
streamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
59
|
+
option: { small: false }
|
|
60
|
+
})
|
|
61
|
+
// Switch to "small view" playback when the user clicks the "big view".
|
|
62
|
+
await trtc.updateRemoteVideo({
|
|
63
|
+
view: '', // Pass in the elementId or element instance object of the "small view" video container.
|
|
64
|
+
userId: '', // Pass in the userId of the remote user.
|
|
65
|
+
streamType: TRTC.TYPE.STREAM_TYPE_MAIN,
|
|
66
|
+
option: { small: true }})
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Note
|
|
70
|
+
|
|
71
|
+
1. TRTC's video stream has a main stream and an sub stream. The main stream includes the big stream and the small stream, and the sub stream is generally used for screen sharing.
|
|
72
|
+
2. When subscribing the stream, the main stream defaults to subscribe the big stream, and the small parameter can be used to subscribe the small stream.
|
|
73
|
+
|
|
74
|
+
Supports subscribe the big stream + sub stream, small stream + sub stream, and does not support subscribe the big stream + small stream at the same time. The big stream and the small stream are played in the same video view.
|
|
75
|
+
|
|
76
|
+
3. Only when the publishing end enables the small stream, the remote stream will be switched to the small stream when the small parameter is specified. If there is no small stream, the SDK will automatically subscribe the big stream.
|
|
77
|
+
4. There is currently no event notification for successful switching between big and small streams.
|
|
78
|
+
5. The small stream resolution cannot be larger than the resolution of the big stream. Otherwise, the setting will be invalid and the original small stream resolution (default 120p) will be kept.
|
|
79
|
+
6. The actual encoding resolution of the small stream will be modified according to the aspect ratio of the big stream, and the aspect ratio of the big stream and the small stream will be consistent.
|
|
80
|
+
|
|
81
|
+
## Enable "receiveWhenViewVisible"
|
|
82
|
+
|
|
83
|
+
In general, in a multi-person video scenario, due to limited page space, the streaming end will not display all videos on the page. Therefore, for those remote videos that do not need to be displayed on the page, they do not need to be streamed. Only when the view is visible should the video stream be pulled. This is to save traffic and reduce performance overhead.
|
|
84
|
+
|
|
85
|
+
Implementing this feature is not easy. Starting with version 5.4.0, the SDK has built-in support for this feature. You only need to set the `receiveWhenViewVisible` and `viewRoot` parameters when calling [startRemoteVideo](./TRTC.html#startRemoteVideo) to enable this feature, which is very convenient and fast. The SDK will automatically check the visibility state of the `view` passed in when startRemoteVideo. Video streaming will start when the `view` is visible and stop when `view` is not visible.
|
|
86
|
+
|
|
87
|
+
### Sample code
|
|
88
|
+
|
|
89
|
+
Assuming your DOM structure for playing videos is as follows:
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<div id='view-list'>
|
|
93
|
+
<div id='view1_main'></div>
|
|
94
|
+
<div id='view2_main'></div>
|
|
95
|
+
<div id='view3_main'></div>
|
|
96
|
+
</div>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, ({ userId, streamType }) => {
|
|
101
|
+
trtc.startRemoteVideo({
|
|
102
|
+
view: 'view1_main',
|
|
103
|
+
userId,
|
|
104
|
+
streamType,
|
|
105
|
+
option: {
|
|
106
|
+
small: true,
|
|
107
|
+
receiveWhenViewVisible: true, // Enable "only subscribe video streams from the visible area"
|
|
108
|
+
viewRoot: document.getElementById('view-list') // Pass in the first-level parent element of all view list, which is used to calculate the reference relationship between view and viewRoot and check whether the view is visible. The default value is document.body.
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Add loading effect for better user experience
|
|
115
|
+
|
|
116
|
+
After enabling this feature, when the user scrolls through the video list:
|
|
117
|
+
|
|
118
|
+
- When the view changes from visible to invisible, the SDK will stop streaming.
|
|
119
|
+
- When the view changes from invisible to visible, the SDK will resume streaming.
|
|
120
|
+
|
|
121
|
+
Since resuming streaming until the video playback is successful is an asynchronous process, a black screen may appear during this process. To provide a better user experience, we recommend adding a loading effect to the video area during this asynchronous process. You can refer to the following code to determine whether to display the loading effect.
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
let isLoading = true;
|
|
125
|
+
|
|
126
|
+
trtc.on(TRTC.EVENT.VIDEO_PLAY_STATE_CHANGED, ({ userId, streamType, state }) => {
|
|
127
|
+
// '' is local video
|
|
128
|
+
if (userId === '') return;
|
|
129
|
+
|
|
130
|
+
// set isLoading to false when remote video is playing.
|
|
131
|
+
isLoading = state !== 'PLAYING';
|
|
132
|
+
|
|
133
|
+
// You can confirm which remote user's main/sub stream playback state has changed by userId and streamType.
|
|
134
|
+
});
|
|
135
|
+
await trtc.startRemoteVideo({ });
|
|
136
|
+
|
|
137
|
+
trtc.stopRemoteVideo()
|
|
138
|
+
isLoading = false;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## FAQ
|
|
142
|
+
|
|
143
|
+
1. How does the SDK confirm whether a view is visible?
|
|
144
|
+
|
|
145
|
+
When any pixel point of the view appears in the viewRoot area, the view is considered visible; conversely, when all pixel points of the view are not in the viewRoot area, the view is considered invisible.
|
|
146
|
+
|
|
147
|
+
2. Do I need to consider browser compatibility for big and small streams?
|
|
148
|
+
|
|
149
|
+
Although some browsers do not support enabling big and small streams (such as all browsers on iOS systems and Chrome versions below 63), enabling small stream has no side effects. If the environment does not support it, the SDK will only use the main stream, and the call can proceed normally. You do not need to write additional if-else statements.
|
|
150
|
+
|
|
151
|
+
You can call {@link TRTC.isSupported TRTC.isSupported} to get checkResult.detail.isSmallStreamSupported to confirm whether the current environment supports enabling small stream.
|