AVCaptureSessionNotification

本文详细记录了AVCaptureSession从启动到运行过程中的一系列状态变更,包括开始运行、受到电话打断、应用进入后台导致的停止、打断结束后的自动重启等关键节点。通过观察这些状态变化,有助于理解iOS应用中摄像头捕获流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.session开始运行

-[RTAVVideoCaputre sessionDidStartRunning:] 
notif = NSConcreteNotification 0x1740536b0 
{name = AVCaptureSessionDidStartRunningNotification; object = <AVCaptureSession: 0x1700142f0 [AVCaptureSessionPreset1280x720]>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17402e380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17002d380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x17402e420>}

2.电话打进来,收到打断通知

-[RTAVVideoCaputre captureSessionWasInterrupt:] [Line 39] notif = NSConcreteNotification 0x170053e60 {name = AVCaptureSessionWasInterruptedNotification; object = <AVCaptureSession: 0x1700142f0 [AVCaptureSessionPreset1280x720]>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17402e380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17002d380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x17402e420>; userInfo = {
    AVCaptureSessionInterruptionReasonKey = 1;
}}

3.app进入后台,session停止通知

-[RTAVVideoCaputre sessionDidStopRunning:] [Line 47] notif = NSConcreteNotification 0x170053e60 {name = AVCaptureSessionDidStopRunningNotification; object = <AVCaptureSession: 0x1700142f0 [AVCaptureSessionPreset1280x720]>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17402e380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17002d380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x17402e420>}

4.电话结束,收到打断结束通知

-[RTAVVideoCaputre sessionInterruptionEnded:] [Line 43] notif = NSConcreteNotification 0x170052f60 {name = AVCaptureSessionInterruptionEndedNotification; object = <AVCaptureSession: 0x1700142f0 [AVCaptureSessionPreset1280x720]>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17402e380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17002d380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x17402e420>}

5.打断结束后,默认session自动restart通知

-[RTAVVideoCaputre sessionDidStartRunning:] [Line 51] notif = NSConcreteNotification 0x170052f60 {name = AVCaptureSessionDidStartRunningNotification; object = <AVCaptureSession: 0x1700142f0 [AVCaptureSessionPreset1280x720]>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureStillImageOutput: 0x17402e380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x17002d380>
    <AVCaptureDeviceInput: 0x17002d320 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x17402e420>}

用系统提供的通知

这样object应该传 session实例,传nil 好像也可用,但是穿个其他的通知收不到,还是没有发出来??

//session 已经运转
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionDidStartRunning:) name:AVCaptureSessionDidStartRunningNotification object:@{@"name":@"小明",@"心别":@"man"}];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值