BJLRecordingVM.h 10.2 KB
Newer Older
root's avatar
1.0.0  
root committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//
//  BJLRecordingVM.h
//  BJLiveCore
//
//  Created by MingLQ on 2016-12-10.
//  Copyright © 2016 BaijiaYun. All rights reserved.
//

#import "BJLBaseVM.h"

NS_ASSUME_NONNULL_BEGIN

/** ### 音视频采集 */
@interface BJLRecordingVM : BJLBaseVM

/** 音视频开关状态 */
@property (nonatomic, readonly) BOOL recordingAudio, recordingVideo;
/** 声音输入级别 */
@property (nonatomic, readonly) CGFloat inputVolumeLevel; // [0.0 - 1.0]
/** 采集视频宽高比 */
@property (nonatomic, readonly) CGFloat inputVideoAspectRatio;

huangjie's avatar
注释  
huangjie committed
23 24
/**
 学生: 是否禁止当前用户打开音频 - 个人实际状态
戴曦嘉's avatar
1.3.7  
戴曦嘉 committed
25 26 27 28
 #discussion 用于判断当前用户是否能打开音频
 #discussion 参考 `forbidAllRecordingAudio`
 */
@property (nonatomic, readonly) BOOL forbidRecordingAudio;
huangjie's avatar
注释  
huangjie committed
29 30 31

/**
 是否禁止所有人打开音频 - 全局开关状态
戴曦嘉's avatar
1.3.7  
戴曦嘉 committed
32 33 34 35 36 37 38 39 40
 #discussion 用于判断教室内开关状态
 #discussion 如果学生正在采集音频,收到此事件时会被自动关闭
 #discussion 课程类型为小班课、新版小班课、双师课时可用,参考 `room.roomInfo.roomType`、`BJLRoomType`
 #discussion 1. 当老师禁止所有人打开音频时,`forbidAllRecordingAudio` 和 `forbidRecordingAudio` 同时被设置为 YES,
 #discussion 2. 当老师取消禁止所有人打开音频时,`forbidAllRecordingAudio` 和 `forbidRecordingAudio` 同时被设置为 NO,
 #discussion 3. 当老师邀请/强制当前用户发言时,`forbidAllRecordingAudio` 被设置成 NO,`forbidRecordingAudio` 依然是 YES,
 #discussion 4. 当老师取消邀请/强制结束当前用户发言时,`forbidAllRecordingAudio` 会被设置为与 `forbidRecordingAudio` 一样的取值
 */
@property (nonatomic, readonly) BOOL forbidAllRecordingAudio;
huangjie's avatar
注释  
huangjie committed
41 42 43

/**
 老师: 设置全体禁音状态
huangjie's avatar
huangjie committed
44
 #param forbidAll YES:全体禁音,NO:取消禁音
huangjie's avatar
注释  
huangjie committed
45
 #discussion 设置成功后修改 `forbidAllRecordingAudio`、`forbidRecordingAudio`
戴曦嘉's avatar
1.3.7  
戴曦嘉 committed
46 47 48 49 50
 #return BJLError:
 BJLErrorCode_invalidUserRole   错误权限,要求老师或助教权限
 */
- (nullable BJLError *)sendForbidAllRecordingAudio:(BOOL)forbidAll;

戴曦嘉's avatar
戴曦嘉 committed
51 52 53 54 55 56 57 58 59
/**
  视频推流时是否打开了镜像模式
  #discussion 用于判断当前用户是否开启了推流镜像视频
  #discussion 当老师调用sendEncoderMirrorMode: 时,学生收到 mirror_mode_switch 广播时会改变 isOnEncoderMirrorMode 的值
  #discussion 学生自己不可改变
 */
@property (nonatomic, readonly) BOOL isOnEncoderMirrorMode;

/**
戴曦嘉's avatar
2.9.1  
戴曦嘉 committed
60
老师: 设置全体开启推流镜像模式,  只对webrtc专业小班课有效
戴曦嘉's avatar
戴曦嘉 committed
61 62 63 64 65 66 67
#param isOn YES:全体开启,NO:取消关闭
#return BJLError:
BJLErrorCode_invalidUserRole   错误权限,要求老师或助教权限
BJLErrorCode_invalidCalling       错误调用,只有小班课 (BJLRoomType_interactiveClass) 可以调用
*/
- (nullable BJLError *)sendEncoderMirrorMode:(BOOL)isOn;

戴曦嘉's avatar
2.3.0  
戴曦嘉 committed
68 69 70 71 72 73 74
/**
 检测麦克风和摄像头权限回调
 #disussion 在需要开启音视频时,检测对应权限之后的回调,
 #disussion microphone -> YES 需要麦克风权限,camera -> YES 需要摄像头权限,
 #disussion granted -> YES 已授权,可以不做处理,granted -> NO 未授权,抛出 alert,需要展示
 */
@property (nonatomic, nullable) void (^checkMicrophoneAndCameraAccessCallback)(BOOL microphone, BOOL camera, BOOL granted, UIAlertController * _Nullable alert);
戴曦嘉's avatar
戴曦嘉 committed
75 76
/** 检测权限的弹窗操作完成后的回调,但是未决定状态的弹窗不会通过此处回调 */
@property (nonatomic, nullable) void (^checkMicrophoneAndCameraAccessActionCompletion)(void);
戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
77

huangjie's avatar
注释  
huangjie committed
78 79
/**
 开关音视频
root's avatar
1.0.0  
root committed
80 81
 #param recordingAudio YES:打开音频采集,NO:关闭音频采集
 #param recordingVideo YES:打开视频采集,NO:关闭视频采集
huangjie's avatar
注释  
huangjie committed
82 83
 #discussion 上层自行检查麦克风、摄像头开关权限
 #discussion 上层可通过 `BJLSpeakingRequestVM` 实现学生发言需要举手的逻辑
root's avatar
update  
root committed
84
 #return BJLError:
戴曦嘉's avatar
2.2.0  
戴曦嘉 committed
85
 BJLErrorCode_invalidUserRole   错误权限,要求非试听学生权限
戴曦嘉's avatar
1.3.7  
戴曦嘉 committed
86 87 88 89 90
 BJLErrorCode_invalidCalling    错误调用,以下情况下开启音视频、在音频教室开启摄像头均会返回此错误
 登录用户分组 ID 不为 0,参考 `room.loginUser.groupID`
 非上课状态,参考 `room.roomVM.liveStarted`
 教室禁止打开音频,参考 `self.forbidRecordingAudio`
 音频禁止打开视频,参考 `featureConfig.mediaLimit`
root's avatar
1.0.0  
root committed
91 92 93 94
 */
- (nullable BJLError *)setRecordingAudio:(BOOL)recordingAudio
                          recordingVideo:(BOOL)recordingVideo;

huangjie's avatar
注释  
huangjie committed
95 96
/**
 开启音视频被服务端拒绝
戴曦嘉's avatar
1.3.7  
戴曦嘉 committed
97
 #discussion 可能因为上麦路数达到上限 */
huangjie's avatar
update  
huangjie committed
98
- (BJLObservable)recordingDidDeny;
root's avatar
1.0.0  
root committed
99

戴曦嘉's avatar
戴曦嘉 committed
100 101
/** 是否开启 PCM 音频数据回调,默认为 NO,需要在进入教室前设置,不支持进入教室后修改 */
@property (nonatomic) BOOL enablePCMData;
戴曦嘉's avatar
戴曦嘉 committed
102
/**
戴曦嘉's avatar
戴曦嘉 committed
103
 采集到的音频数据,仅支持 AVSDK 的班型
huangjie's avatar
注释  
huangjie committed
104
 #param length 音频数据长度
戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
105
 #param data PCM 音频数据
戴曦嘉's avatar
戴曦嘉 committed
106
 */
戴曦嘉's avatar
戴曦嘉 committed
107
- (BJLObservable)recordingAudioPCMDataDidUpdate:(uint8_t [_Nullable])data length:(int)length;
戴曦嘉's avatar
戴曦嘉 committed
108

huangjie's avatar
注释  
huangjie committed
109 110
/**
 音视频被远程开关通知
root's avatar
1.0.0  
root committed
111 112 113 114
 #param recordingAudio YES:打开音频采集,NO:关闭音频采集
 #param recordingVideo YES:打开视频采集,NO:关闭视频采集
 #param recordingAudioChanged 音频采集状态是否发生变化
 #param recordingVideoChanged 视频采集状态是否发生变化
huangjie's avatar
注释  
huangjie committed
115 116
 #discussion 对于学生,音、视频有一个打开就开启发言、全部关闭就结束发言
 #discussion 参考 `BJLSpeakingRequestVM` 的 `speakingDidRemoteControl:`
root's avatar
1.0.0  
root committed
117 118 119 120 121 122
 */
- (BJLObservable)recordingDidRemoteChangedRecordingAudio:(BOOL)recordingAudio
                                          recordingVideo:(BOOL)recordingVideo
                                   recordingAudioChanged:(BOOL)recordingAudioChanged
                                   recordingVideoChanged:(BOOL)recordingVideoChanged;

戴曦嘉's avatar
戴曦嘉 committed
123 124
/**
 开关全体学生麦克风
huangjie's avatar
注释  
huangjie committed
125 126
 #param mute YES:关闭,NO:打开
 #return BJLError
戴曦嘉's avatar
戴曦嘉 committed
127 128 129
 */
- (nullable BJLError *)updateAllRecordingAudioMute:(BOOL)mute;

凡义's avatar
凡义 committed
130 131
/**
 收到一键开关麦克风
戴曦嘉's avatar
2.9.2  
戴曦嘉 committed
132
 #param mute YES --> 关闭麦克风,NO --> 开启麦克风
凡义's avatar
凡义 committed
133 134
 */
- (BJLObservable)didUpadateAllRecordingAudioMute:(BOOL)mute;
huangjie's avatar
huangjie committed
135

huangjie's avatar
注释  
huangjie committed
136 137
/**
 老师: 远程开关学生音、视频
root's avatar
1.3.3  
root committed
138
 #param user 对象用户,不能是老师
root's avatar
1.0.0  
root committed
139 140
 #param audioOn YES:打开音频采集,NO:关闭音频采集
 #param videoOn YES:打开视频采集,NO:关闭视频采集
huangjie's avatar
注释  
huangjie committed
141 142 143
 #discussion 打开音频、视频会导致对方发言状态开启
 #discussion 同时关闭音频、视频会导致对方发言状态终止
 @see `speakingRequestVM.speakingEnabled`
root's avatar
update  
root committed
144
 #return BJLError:
root's avatar
1.0.0  
root committed
145 146 147 148 149 150
 BJLErrorCode_invalidArguments  错误参数;
 BJLErrorCode_invalidUserRole   错误权限,要求老师或助教权限。
 */
- (nullable BJLError *)remoteChangeRecordingWithUser:(BJLUser *)user
                                             audioOn:(BOOL)audioOn
                                             videoOn:(BOOL)videoOn;
huangjie's avatar
注释  
huangjie committed
151 152
/**
 老师: 远程开启学生音、视频被自动拒绝,因为上麦路数达到上限
huangjie's avatar
update  
huangjie committed
153 154 155
 #param user    开启失败的学生
 */
- (BJLObservable)remoteChangeRecordingDidDenyForUser:(BJLUser *)user;
root's avatar
1.0.0  
root committed
156

戴曦嘉's avatar
2.2.0  
戴曦嘉 committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
#pragma mark - 音视频采集权限

/** 被授权辅助摄像头的用户 */
@property (nonatomic, readonly, nullable) NSArray<NSString *> *authorizedExtraCameraUserNumbers;

/**
 授权辅助摄像头
 #param authorized 是否授权
 #param userNumber 用户 number
 #return BJLErrorCode_invalidUserRole 错误角色,仅老师或助教能授权给支持辅助摄像头的学生,目前仅支持一对一专业小班课 PC 端学生
 */
- (nullable BJLError *)updateStudentExtraCameraAuthorized:(BOOL)authorized userNumber:(NSString *)userNumber;


/** 被授权屏幕共享的用户 */
@property (nonatomic, readonly, nullable) NSArray<NSString *> *authorizedScreenShareUserNumbers;

/**
 授权屏幕共享
 #param authorized 是否授权
 #param userNumber 用户 number
 #return BJLErrorCode_invalidUserRole 错误角色,仅老师或助教能授权给支持屏幕共享的学生,目前仅支持一对一专业小班课 PC 端学生
 */
- (nullable BJLError *)updateStudentScreenShareAuthorized:(BOOL)authorized userNumber:(NSString *)userNumber;

root's avatar
1.0.0  
root committed
182 183 184 185 186 187 188 189 190
#pragma mark - 音视频采集设置

/**
 以下设置
 #discussion - 开始采集之前、之后均可调用
 #discussion - 开关音视频后不被重置
 #discussion - 个别设置可能会导致视频流重新发布
 */

戴曦嘉's avatar
戴曦嘉 committed
191 192
/** 当前使用的摄像头,默认使用前置摄像头 */
@property (nonatomic, readonly) BOOL usingRearCamera; // NO: Front, YES Rear(iSight)
戴曦嘉's avatar
2.2.0  
戴曦嘉 committed
193

戴曦嘉's avatar
戴曦嘉 committed
194 195 196 197 198 199
/**
 是否使用后置摄像头
 #param usingRearCamera 使用后置摄像头
 #return BJLError:
 BJLErrorCode_invalidCalling  错误调用
 */
戴曦嘉's avatar
戴曦嘉 committed
200
- (nullable BJLError *)updateUsingRearCamera:(BOOL)usingRearCamera;
戴曦嘉's avatar
戴曦嘉 committed
201

戴曦嘉's avatar
2.2.0  
戴曦嘉 committed
202 203 204
/** 视频采集模式,默认采集横屏画面 */
@property (nonatomic) BJLVideoRecordingOrientation videoRecordingOrientation;

戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
205
/** 采集画面显示模式,默认 BJLVideoContentMode_aspectFit */
戴曦嘉's avatar
2.2.0  
戴曦嘉 committed
206 207
@property (nonatomic) BJLVideoContentMode videoContentMode;

戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
208
/** 视频采集清晰度,默认标清 */
戴曦嘉's avatar
戴曦嘉 committed
209
@property (nonatomic, readonly) BJLVideoDefinition videoDefinition;
huangjie's avatar
注释  
huangjie committed
210

戴曦嘉's avatar
戴曦嘉 committed
211 212 213 214 215 216
/**
 改变视频清晰度
 #param videoDefinition 清晰度
 #return BJLError:
 BJLErrorCode_invalidCalling  错误调用
 */
戴曦嘉's avatar
戴曦嘉 committed
217
- (nullable BJLError *)updateVideoDefinition:(BJLVideoDefinition)videoDefinition;
戴曦嘉's avatar
戴曦嘉 committed
218

root's avatar
1.0.0  
root committed
219
/** 美颜,默认关闭 */
戴曦嘉's avatar
戴曦嘉 committed
220
@property (nonatomic, readonly) BJLVideoBeautifyLevel videoBeautifyLevel;
huangjie's avatar
注释  
huangjie committed
221

戴曦嘉's avatar
戴曦嘉 committed
222
/**
戴曦嘉's avatar
戴曦嘉 committed
223
 改变美颜等级
戴曦嘉's avatar
戴曦嘉 committed
224 225 226 227
 #param videoBeautifyLevel videoBeautifyLevel
 #return BJLError:
 BJLErrorCode_invalidCalling  错误调用
 */
戴曦嘉's avatar
戴曦嘉 committed
228
- (nullable BJLError *)updateVideoBeautifyLevel:(BJLVideoBeautifyLevel)videoBeautifyLevel;
root's avatar
1.0.0  
root committed
229

huangjie's avatar
source  
huangjie committed
230 231 232 233 234 235 236 237 238 239 240
#pragma mark - webRTC 课程 API

/**
 开启摄像头预览
 #return BJLError:
 BJLErrorCode_invalidCalling  错误调用
 */
- (nullable BJLError *)startCameraPreview;

/**
 关闭摄像头预览
戴曦嘉's avatar
2.9.2  
戴曦嘉 committed
241
 #return BJError:
huangjie's avatar
source  
huangjie committed
242 243 244 245
 BJLErrorCode_invalidCalling  错误调用
 */
- (nullable BJLError *)stopCameraPreview;

戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
246
/** 推流重试中 */
戴曦嘉's avatar
2.5.0  
戴曦嘉 committed
247 248
- (BJLObservable)republishing;

戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
249
/** 推流失败 */
戴曦嘉's avatar
2.5.0  
戴曦嘉 committed
250 251
- (BJLObservable)publishFailed;

戴曦嘉's avatar
2.9.3  
戴曦嘉 committed
252 253 254 255 256 257
#pragma mark - DEPRECATED

@property (nonatomic, readonly) BJLVideoOrientation videoOrientation DEPRECATED_MSG_ATTRIBUTE("use `videoRecordingOrientation` instead");

- (nullable BJLError *)updateVideoOrientation:(BJLVideoOrientation)videoOrientation DEPRECATED_MSG_ATTRIBUTE("use `videoRecordingOrientation` instead");

root's avatar
1.0.0  
root committed
258 259 260
@end

NS_ASSUME_NONNULL_END