Skip to content

cameraStat

sunjian880928 edited this page Jun 4, 2016 · 1 revision

启停采集和消息通知

配置好采集参数之后,通过kit类的startPreview和stopPreview方法启动预览。

启动采集:

kit类内部将预览画面作为subview,插入到 view 的最底层 需要访问摄像头和麦克风的权限,若授权失败,其他API都会拒绝服务。

消息通知

采集相关的消息通知需要通过NSNotificationCenter注册 KSYCaptureStateDidChangeNotification来接收。 当收到采集状态变化的通知时,通过kit.captureState属性查询新的状态

状态名称 状态说明
KSYCaptureStateIdle 设备空闲中
KSYCaptureStateCapturing 设备工作中
KSYCaptureStateDevAuthDenied 设备授权被拒绝
KSYCaptureStateClosingCapture 关闭采集设备中
KSYCaptureStateParameterError 参数错误,无法打开(比如设置的分辨率,码率当前设备不支持)
注册通知:
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onCaptureStateChange:)
                                                 name:KSYCaptureStateDidChangeNotification
                                               object:nil];
响应事件:
- (void) onCaptureStateChange:(NSNotification *)notification {
    if ( _kit.captureState == KSYCaptureStateIdle){
        NSLog(@"idle");
    }
    else if (_kit.captureState == KSYCaptureStateCapturing ) {
        NSLog(@"capturing");
    }
    else if (_kit.captureState == KSYCaptureStateClosingCapture ) {
        NSLog(@"closing capture");
    }
    else if (_kit.captureState == KSYCaptureStateDevAuthDenied ) {
        NSLog(@"camera/mic Authorization Denied");
    }
    else if (_kit.captureState == KSYCaptureStateParameterError ) {
        NSLog(@"capture devices ParameterErro");
    }
    else if (_kit.captureState == KSYCaptureStateDevBusy ) {
        NSLog(@"device busy, try later");
    }
}
移除通知:
[[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:KSYCaptureStateDidChangeNotification
                                                  object:nil];

1. 推流环节说明

2. 特色功能说明

2.1 采集

2.2 音频处理

2.3 视频处理

2.4 编码

2.5 推流

2.6 输入多样化

2.7 集成

3. 第三方功能

4. 技术专栏

5. 已知问题

8. FAQ

金山云计算

Clone this wiki locally