Skip to content

Commit 0d6101e

Browse files
committed
Merge branch 'staging' of https://github.com/AgoraIO/Docs-Source
2 parents 702437b + 844a7b2 commit 0d6101e

File tree

16 files changed

+494
-13
lines changed

16 files changed

+494
-13
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<PlatformWrapper platform="android">
2+
3+
Before joining a channel, set up multi-resolution video streaming by calling the `setSimulcastConfig` method and configuring the `simulcastConfig` parameters.
4+
5+
```java
6+
public abstract int setSimulcastConfig(SimulcastConfig simulcastConfig);
7+
```
8+
9+
The following snippet shows how `SimulcastConfig` and related classes are defined in the SDK:
10+
11+
```java
12+
public class SimulcastConfig {
13+
// Define configurations
14+
public static enum StreamLayerIndex {
15+
STREAM_LAYER_1(0),
16+
STREAM_LAYER_2(1),
17+
STREAM_LAYER_3(2),
18+
STREAM_LAYER_4(3),
19+
STREAM_LAYER_5(4),
20+
STREAM_LAYER_6(5),
21+
STREAM_LOW(6),
22+
STREAM_LAYER_COUNT_MAX(7);
23+
}
24+
25+
// Configure video properties for each configuration
26+
public class StreamLayerConfig {
27+
// Resolution
28+
public VideoEncoderConfiguration.VideoDimensions dimensions;
29+
// Frame rate
30+
public int framerate;
31+
// Whether this layer is enabled
32+
public boolean enable;
33+
}
34+
35+
// Stream configuration
36+
public final StreamLayerConfig[] configs =
37+
new StreamLayerConfig[StreamLayerIndex.STREAM_LAYER_COUNT_MAX.getValue()];
38+
39+
public SimulcastConfig() {
40+
for (int i = 0; i < StreamLayerIndex.STREAM_LAYER_COUNT_MAX.getValue(); i++) {
41+
configs[i] = new StreamLayerConfig();
42+
}
43+
this.publishFallbackEnable = false;
44+
}
45+
46+
// Whether to allow disabling multiple streams dynamically
47+
// when the sender's performance or uplink network is poor
48+
public boolean publishFallbackEnable;
49+
}
50+
```
51+
52+
### Configure parameters
53+
54+
When adding additional configurations, follow these rules:
55+
56+
- Configure the resolution and frame rate of each stream before joining a channel. After joining, you cannot change resolution or frame rate; you can only enable or disable streams using `StreamLayerConfig.enable`.
57+
58+
- Set the resolution and frame rate of each configuration lower than the source stream, defined in `VideoEncoderConfiguration`.
59+
60+
- Decrease the resolution and frame rate for each additional layer. For example, `STREAM_LAYER_2` must have a lower resolution and frame rate than `STREAM_LAYER_1`, and so on.
61+
62+
- Enable up to three configurations at the same time, including the small stream.
63+
64+
### Sample code
65+
66+
Set the resolution and frame rate of configurations based on your use case and bandwidth. <Vg k="COMPANY" /> recommends configuring only the `StreamLayerConfig` layers you need and setting the others to `enable = false`. The following sample shows how to configure a multi-resolution video stream:
67+
68+
```java
69+
import io.agora.rtc2.SimulcastConfig;
70+
71+
private SimulcastConfig simulcastConfig = new SimulcastConfig();
72+
73+
// Configure video resolution and frame rate for STREAM_LAYER_1
74+
int layer1 = SimulcastConfig.StreamLayerIndex.STREAM_LAYER_1.getValue();
75+
simulcastConfig.configs[layer1].dimensions.width = 1280;
76+
simulcastConfig.configs[layer1].dimensions.height = 720;
77+
simulcastConfig.configs[layer1].framerate = 30;
78+
simulcastConfig.configs[layer1].enable = true;
79+
80+
// Configure video resolution and frame rate for STREAM_LAYER_2
81+
int layer2 = SimulcastConfig.StreamLayerIndex.STREAM_LAYER_2.getValue();
82+
simulcastConfig.configs[layer2].dimensions.width = 960;
83+
simulcastConfig.configs[layer2].dimensions.height = 540;
84+
simulcastConfig.configs[layer2].framerate = 15;
85+
simulcastConfig.configs[layer2].enable = true;
86+
87+
// Configure video resolution and frame rate for STREAM_LAYER_3
88+
int layer3 = SimulcastConfig.StreamLayerIndex.STREAM_LAYER_3.getValue();
89+
simulcastConfig.configs[layer3].dimensions.width = 640;
90+
simulcastConfig.configs[layer3].dimensions.height = 360;
91+
simulcastConfig.configs[layer3].framerate = 15;
92+
simulcastConfig.configs[layer3].enable = false;
93+
94+
// Configure video resolution and frame rate for STREAM_LAYER_4
95+
int layer4 = SimulcastConfig.StreamLayerIndex.STREAM_LAYER_4.getValue();
96+
simulcastConfig.configs[layer4].dimensions.width = 480;
97+
simulcastConfig.configs[layer4].dimensions.height = 270;
98+
simulcastConfig.configs[layer4].framerate = 15;
99+
simulcastConfig.configs[layer4].enable = true;
100+
101+
// Apply the Simulcast configuration
102+
engine.setSimulcastConfig(simulcastConfig);
103+
```
104+
105+
### Subscribe to a stream
106+
107+
A remote user subscribes to the desired video quality level by setting the `streamType` parameter in `setRemoteVideoStreamType`.
108+
109+
```java
110+
Constants.VideoStreamType videoStreamType = Constants.VideoStreamType.valueOf(videoStream);
111+
engine.setRemoteVideoStreamType(uid, videoStreamType);
112+
```
113+
114+
To update the subscribed video quality level during real-time interaction, you can call `setRemoteVideoStreamType` multiple times.
115+
116+
</PlatformWrapper>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Android from './android.mdx'
2+
import Ios from './ios.mdx';
3+
import Windows from './windows.mdx'
4+
5+
<Android />
6+
<Ios />
7+
<Windows />
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<PlatformWrapper platform="ios, macos">
2+
3+
Before joining a channel, set up multi-resolution video streaming by calling the `setSimulcastConfig` method and configuring the `simulcastConfig` parameters.
4+
5+
```objc
6+
- (int)setSimulcastConfig:(AgoraSimulcastConfig* _Nonnull)simulcastConfig NS_SWIFT_NAME(setSimulcastConfig(_:));
7+
```
8+
9+
The following snippet shows how `SimulcastConfig` and related classes are defined in the SDK:
10+
11+
```objc
12+
__attribute__((visibility("default"))) @interface AgoraSimulcastConfig: NSObject
13+
// The configuration of each simulcast video stream.
14+
@property (copy, nonatomic, readonly) NSArray<AgoraStreamLayerConfig*>* _Nonnull configs;
15+
// Whether to allow the SDK to dynamically disable simulcast streams when the sender's
16+
// device performance or uplink network conditions are poor.
17+
@property (assign, nonatomic) BOOL publishFallbackEnable;
18+
@end
19+
20+
// The video properties for a simulcast stream.
21+
__attribute__((visibility("default"))) @interface AgoraStreamLayerConfig: NSObject
22+
// The resolution of the video stream.
23+
@property (assign, nonatomic) CGSize dimensions;
24+
// The frame rate of the video stream.
25+
@property (assign, nonatomic) int framerate;
26+
// Whether this stream layer is enabled.
27+
@property (assign, nonatomic) BOOL enable;
28+
@end
29+
30+
// The index of simulcast stream layers.
31+
typedef NS_ENUM(NSInteger, AgoraStreamLayerIndex) {
32+
AgoraStreamLayer1 = 0,
33+
AgoraStreamLayer2 = 1,
34+
AgoraStreamLayer3 = 2,
35+
AgoraStreamLayer4 = 3,
36+
AgoraStreamLayer5 = 4,
37+
AgoraStreamLayer6 = 5,
38+
AgoraStreamLow = 6,
39+
AgoraStreamLayerCountMax = 7,
40+
};
41+
```
42+
43+
### Configure parameters
44+
45+
When configuring extended streams, follow these rules:
46+
47+
- Configure the resolution and frame rate of each stream before joining a channel. After joining, you cannot change resolution or frame rate; you can only enable or disable streams using `AgoraStreamLayerConfig.enable`.
48+
49+
- Set the resolution and frame rate of each configuration lower than the source stream, defined in `AgoraVideoEncoderConfiguration`.
50+
51+
- Decrease the resolution and frame rate with each additional layer. For example, `AgoraStreamLayerIndex.layer2` must have a lower resolution and frame rate than `AgoraStreamLayerIndex.layer1`, and so on.
52+
53+
- Enable up to three configurations at the same time, including the small stream.
54+
55+
### Sample code
56+
57+
Set the resolution and frame rate of configurations based on your use case and bandwidth. <Vg k="COMPANY" /> recommends configuring only the layers you need and setting `AgoraStreamLayerConfig.enable = false` for others. The following sample shows how to configure a multi-resolution video stream:
58+
59+
```swift
60+
private func setupSimulcast() {
61+
let layer1_index = AgoraStreamLayerIndex.layer1.rawValue
62+
let layer2_index = AgoraStreamLayerIndex.layer2.rawValue
63+
let layer3_index = AgoraStreamLayerIndex.layer3.rawValue
64+
let layer4_index = AgoraStreamLayerIndex.layer4.rawValue
65+
66+
// Configure layer 1 (high resolution)
67+
simulcastConfig.configs[layer1_index].dimensions.width = 1280
68+
simulcastConfig.configs[layer1_index].dimensions.height = 720
69+
simulcastConfig.configs[layer1_index].framerate = 30
70+
simulcastConfig.configs[layer1_index].enable = true
71+
72+
// Configure layer 2 (medium resolution)
73+
simulcastConfig.configs[layer2_index].dimensions.width = 960
74+
simulcastConfig.configs[layer2_index].dimensions.height = 540
75+
simulcastConfig.configs[layer2_index].framerate = 15
76+
simulcastConfig.configs[layer2_index].enable = true
77+
78+
// Configure layer 3 (optional, disabled by default)
79+
simulcastConfig.configs[layer3_index].dimensions.width = 640
80+
simulcastConfig.configs[layer3_index].dimensions.height = 360
81+
simulcastConfig.configs[layer3_index].framerate = 15
82+
simulcastConfig.configs[layer3_index].enable = false
83+
84+
// Configure layer 4 (low resolution)
85+
simulcastConfig.configs[layer4_index].dimensions.width = 480
86+
simulcastConfig.configs[layer4_index].dimensions.height = 270
87+
simulcastConfig.configs[layer4_index].framerate = 15
88+
simulcastConfig.configs[layer4_index].enable = true
89+
90+
// Apply simulcast configuration
91+
let ret = agoraKit.setSimulcastConfig(simulcastConfig)
92+
LogUtils.log(message: "setSimulcastConfig: \(ret) ", level: .info)
93+
}
94+
```
95+
96+
### Subscribe to a stream
97+
98+
A remote user subscribes to the desired video quality level by setting the `streamType` parameter in `setRemoteVideoStreamType`.
99+
100+
```swift
101+
let ret = agoraKit.setRemoteVideoStream(uid, type: .layer1)
102+
LogUtils.log(message: "set remote layer, ret: \(ret) ", level: .info)
103+
```
104+
105+
To update the subscribed video quality level during real-time interaction, you can call `setRemoteVideoStreamType` multiple times.
106+
107+
</PlatformWrapper>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<PlatformWrapper platform="windows">
2+
3+
Before joining a channel, set up multi-resolution video streaming by calling the `setSimulcastConfig` method and configuring the `simulcastConfig` parameters.
4+
5+
```cpp
6+
virtual int setSimulcastConfig(const SimulcastConfig& simulcastConfig) = 0;
7+
```
8+
9+
The following snippet shows how `SimulcastConfig` and related classes are defined in the SDK:
10+
11+
```cpp
12+
struct SimulcastConfig {
13+
// Define extended stream layers
14+
enum StreamLayerIndex {
15+
STREAM_LAYER_1 = 0,
16+
STREAM_LAYER_2 = 1,
17+
STREAM_LAYER_3 = 2,
18+
STREAM_LAYER_4 = 3,
19+
STREAM_LAYER_5 = 4,
20+
STREAM_LAYER_6 = 5,
21+
STREAM_LOW = 6,
22+
STREAM_LAYER_COUNT_MAX = 7
23+
};
24+
25+
// Configure video properties for each extended stream
26+
struct StreamLayerConfig {
27+
// Resolution
28+
VideoDimensions dimensions;
29+
// Frame rate
30+
int framerate;
31+
// Whether this layer is enabled
32+
bool enable;
33+
StreamLayerConfig() : dimensions(0, 0), framerate(0), enable(false) {}
34+
};
35+
36+
// Parameter configuration for each extended stream
37+
StreamLayerConfig configs[STREAM_LAYER_COUNT_MAX];
38+
39+
// Whether to allow disabling multiple streams dynamically
40+
// when the sender's performance or uplink network is poor
41+
bool publish_fallback_enable;
42+
43+
SimulcastConfig(): publish_fallback_enable(false) {}
44+
};
45+
```
46+
47+
### Configure parameters
48+
49+
When configuring extended streams, follow these rules:
50+
51+
- Configure the resolution and frame rate of each stream before joining a channel. After joining, you cannot change resolution or frame rate; you can only enable or disable streams using `StreamLayerConfig.enable`.
52+
53+
- Set the resolution and frame rate of each configuration lower than the source stream, defined in `VideoEncoderConfiguration`.
54+
55+
- Decrease the resolution and frame rate for each additional layer. For example, `STREAM_LAYER_2` must have a lower resolution and frame rate than `STREAM_LAYER_1`, and so on.
56+
57+
- Enable up to three configurations at the same time, including the small stream.
58+
59+
### Sample code
60+
61+
Set the resolution and frame rate of configurations based on your use case and bandwidth. <Vg k="COMPANY" /> recommends configuring only the `StreamLayerConfig` layers you need and setting the others to `enable = false`. The following sample shows how to configure a multi-resolution video stream:
62+
63+
```cpp
64+
#include "IAgoraRtcEngine.h"
65+
#include "AgoraBase.h"
66+
67+
using namespace agora::rtc;
68+
69+
// Create simulcast configuration
70+
SimulcastConfig config;
71+
72+
// Configure low layer (for low-resolution stream if needed)
73+
config.configs[SimulcastConfig::STREAM_LOW].dimensions.width = 320;
74+
config.configs[SimulcastConfig::STREAM_LOW].dimensions.height = 180;
75+
config.configs[SimulcastConfig::STREAM_LOW].framerate = 15;
76+
config.configs[SimulcastConfig::STREAM_LOW].enable = true;
77+
78+
// Configure high layer (for high-resolution stream if needed)
79+
config.configs[SimulcastConfig::STREAM_LAYER_1].dimensions.width = 1280;
80+
config.configs[SimulcastConfig::STREAM_LAYER_1].dimensions.height = 720;
81+
config.configs[SimulcastConfig::STREAM_LAYER_1].framerate = 30;
82+
config.configs[SimulcastConfig::STREAM_LAYER_1].enable = true;
83+
84+
// Optional: enable on-demand streaming and performance fallback
85+
// Default is false, meaning multiple streams are not automatically disabled
86+
// when performance or uplink network is poor
87+
config.publish_fallback_enable = false;
88+
89+
// Set simulcast configuration
90+
int ret = rtcEngine->setSimulcastConfig(config);
91+
if (ret != 0) {
92+
// Error handling
93+
}
94+
```
95+
96+
### Subscribe to a stream
97+
98+
A remote user subscribes to the desired video quality level by setting the `streamType` parameter in `setRemoteVideoStreamType`.
99+
100+
```cpp
101+
// Subscribe to the high-resolution stream
102+
rtcEngine->setRemoteVideoStreamType(remoteUid, VIDEO_STREAM_HIGH);
103+
104+
// Subscribe to video quality layer 1
105+
rtcEngine->setRemoteVideoStreamType(remoteUid, VIDEO_STREAM_LAYER_1);
106+
107+
// Subscribe to the low-resolution stream
108+
rtcEngine->setRemoteVideoStreamType(remoteUid, VIDEO_STREAM_LOW);
109+
```
110+
111+
To update the subscribed video quality level during real-time interaction, you can call `setRemoteVideoStreamType` multiple times.
112+
113+
</PlatformWrapper>

0 commit comments

Comments
 (0)