通过参会者事件回调开发者可获取到参会者信息,根据参会者信息可通过平台拉取音视频流。平台默认返回 20 路以内的音视频流,如需获取更多,可咨询技术支持人员。将拉流的数据结合布局策略开发者可自由定义多种布局。
入会成功后通过 xyLinkSDKOnRosterChanged 回调获取到当前参会者信息,参会者信息中的 pid 属性标记了参会者的唯一性,拉流接口需要传入参会者的 pid,同时还可以设置每一位参会者视频流的分辨率等信息,您可以根据展示的需求配置拉流策略。
- (void)xyLinkSDKOnRosterChanged:(XYSDKRosterInfo <em>)rosters {
if(rosters.elements.count == 0)
return;
XYLinkSDKCustomLayoutInfo </em>info = [[XYLinkSDKCustomLayoutInfo alloc] init];
// 视频布局模式。
info.layoutMode = SDKLayout_M_by_N;
NSMutableArray <em>cLayoutInfos = [[NSMutableArray alloc] initWithCapacity:rosters.elements.count];
for (int i=0; i<rosters.elements.count; i++)
{
XYSDKRosterElement </em>e = rosters.elements[i];
// 拼接请流参数
XYLinkSDKCustomLayoutElement *infoElement = [[XYLinkSDKCustomLayoutElement alloc] init];
infoElement.participantId = e.pid;
// 设置分辨率,可以参考demo的请求策略
infoElement.width = 1920;
infoElement.height = 1080;
infoElement.priority = SDKLayoutPriorityHigh;
infoElement.quality = SDKVideoQualityHigh;
[cLayoutInfos addObject:infoElement];
}
info.layoutElements = cLayoutInfos;
[[AppDelegate sharedInstance].linkSDK customLayout:info forceRequest:NO];
- (void)xyLinkSDKOnVideoStreamChanged:(NSArray <em>)videos {
//videos数组返回请到的视频流信息,接下来就可以在UI上展示了
for (int i = 0; i < [videos count] ; i++) {
// 按需布局
XYLinkSDKVideoView </em>videoView = [[XYLinkSDKVideoView alloc]initWithFrame:CGRectZero];
[videoView setLayoutInfo:layoutInfo];
......
}
拉流&布局