接入指南 | 两步实现视频直播
融云直播 SDK
两步获得视频直播能力
准备阶段:
开启摄像头,设置视频参数,调整美颜等
/// 在viewDidLoad里一般会这样设置
- (void)viewDidLoad {
[super viewDidLoad];
/// 视频直播准备
[RCLiveVideoEngine.shared prepare];
/// 添加视频预览
UIView *previewView = [RCLiveVideoEngine.shared previewView];
previewView.frame = self.view.bounds;
[self.view addSubview:previewView];
}
/// 视频流输出回调
- (CMSampleBufferRef)didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer {
// 美颜
return sampleBuffer;
}
开始直播:
发布视频流,其他用户加入房间观看直播
/// 准备完成,点击开启
- (IBAction)begin {
/// 调用服务器创建房间接口
[network createRoom:^(NSString *roomId) {
/// 开启直播,需要传入roomId,roomId为业务服务器返回
[RCLiveVideoEngine.shared begin:roomId completion:^(RCLiveVideoErrorCode code) {
if (code == RCLiveVideoSuccess) {
/// success
} else {
/// failure
}
}];
}];
}
融云直播 SDK
封装 7 种合流布局
切换布局:
7 种布局自由切换,满足所有连麦场景需求
- (void)setupMixType:(RCLiveVideoMixType)type {
[RCLiveVideoEngine.shared setMixType:type completion:^(RCLiveVideoErrorCode code) {
/// TODO code
}];
}
- (void)roomMixTypeDidChange:(RCLiveVideoMixType)mixType {
/// TODO setup UI
}