pub unsafe trait AVCapturePhotoCaptureDelegate: NSObjectProtocol {
// Provided methods
unsafe fn captureOutput_willBeginCaptureForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_willCapturePhotoForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didCapturePhotoForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishProcessingPhoto_error(
&self,
output: &AVCapturePhotoOutput,
photo: &AVCapturePhoto,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishCapturingDeferredPhotoProxy_error(
&self,
output: &AVCapturePhotoOutput,
deferred_photo_proxy: Option<&AVCaptureDeferredPhotoProxy>,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishProcessingPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error(
&self,
output: &AVCapturePhotoOutput,
photo_sample_buffer: Option<&CMSampleBuffer>,
preview_photo_sample_buffer: Option<&CMSampleBuffer>,
resolved_settings: &AVCaptureResolvedPhotoSettings,
bracket_settings: Option<&AVCaptureBracketedStillImageSettings>,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishProcessingRawPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error(
&self,
output: &AVCapturePhotoOutput,
raw_sample_buffer: Option<&CMSampleBuffer>,
preview_photo_sample_buffer: Option<&CMSampleBuffer>,
resolved_settings: &AVCaptureResolvedPhotoSettings,
bracket_settings: Option<&AVCaptureBracketedStillImageSettings>,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishRecordingLivePhotoMovieForEventualFileAtURL_resolvedSettings(
&self,
output: &AVCapturePhotoOutput,
output_file_url: &NSURL,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishProcessingLivePhotoToMovieFileAtURL_duration_photoDisplayTime_resolvedSettings_error(
&self,
output: &AVCapturePhotoOutput,
output_file_url: &NSURL,
duration: CMTime,
photo_display_time: CMTime,
resolved_settings: &AVCaptureResolvedPhotoSettings,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
unsafe fn captureOutput_didFinishCaptureForResolvedSettings_error(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
error: Option<&NSError>,
)
where Self: Sized + Message { ... }
}AVCapturePhotoOutput only.Expand description
A set of delegate callbacks to be implemented by a client who calls AVCapturePhotoOutput’s -capturePhotoWithSettings:delegate.
AVCapturePhotoOutput invokes the AVCapturePhotoCaptureDelegate callbacks on a common dispatch queue — not necessarily the main queue. While the -captureOutput:willBeginCaptureForResolvedSettings: callback always comes first and the -captureOutput:didFinishCaptureForResolvedSettings: callback always comes last, none of the other callbacks can be assumed to come in any particular order. The AVCaptureResolvedPhotoSettings instance passed to the client with each callback has the same uniqueID as the AVCapturePhotoSettings instance passed in -capturePhotoWithSettings:delegate:. All callbacks are marked optional, but depending on the features you’ve specified in your AVCapturePhotoSettings, some callbacks become mandatory and are validated in -capturePhotoWithSettings:delegate:. If your delegate does not implement the mandatory callbacks, an NSInvalidArgumentException is thrown.
- If you initialize your photo settings with a format dictionary, or use one of the default constructors (that is, if you’re not requesting a RAW-only capture), your delegate must respond to either - captureOutput:didFinishProcessingPhoto:error: or the deprecated -captureOutput:didFinishProcessingPhotoSampleBuffer:previewPhotoSampleBuffer:resolvedSettings:bracketSettings:error:. If your delegate responds to both of these callbacks, only the undeprecated variant will be called.
- If you initialize your photo settings with a rawPhotoPixelFormatType, your delegate must respond to either -captureOutput:didFinishProcessingPhoto:error: or the deprecated -captureOutput:didFinishProcessingRawPhotoSampleBuffer:previewPhotoSampleBuffer:resolvedSettings:bracketSettings:error:. If your delegate responds to both of these callbacks, only the undeprecated variant will be called.
- If you set livePhotoMovieFileURL to non-nil, your delegate must respond to -captureOutput:didFinishProcessingLivePhotoToMovieFileAtURL:duration:photoDisplayTime:resolvedSettings:error:.
In the event of an error, all expected callbacks are fired with an appropriate error.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn captureOutput_willBeginCaptureForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_willBeginCaptureForResolvedSettings( &self, output: &AVCapturePhotoOutput, resolved_settings: &AVCaptureResolvedPhotoSettings, )
AVCaptureOutputBase only.A callback fired as soon as the capture settings have been resolved.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
This callback is always delivered first for a particular capture request. It is delivered as soon as possible after you call -capturePhotoWithSettings:delegate:, so you can know what to expect in the remainder of your callbacks.
Sourceunsafe fn captureOutput_willCapturePhotoForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_willCapturePhotoForResolvedSettings( &self, output: &AVCapturePhotoOutput, resolved_settings: &AVCaptureResolvedPhotoSettings, )
AVCaptureOutputBase only.A callback fired just as the photo is being taken.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
The timing of this callback is analogous to AVCaptureStillImageOutput’s capturingStillImage property changing from NO to YES. The callback is delivered right after the shutter sound is heard (note that shutter sounds are suppressed when Live Photos are being captured).
Sourceunsafe fn captureOutput_didCapturePhotoForResolvedSettings(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_didCapturePhotoForResolvedSettings( &self, output: &AVCapturePhotoOutput, resolved_settings: &AVCaptureResolvedPhotoSettings, )
AVCaptureOutputBase only.A callback fired just after the photo is taken.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
The timing of this callback is analogous to AVCaptureStillImageOutput’s capturingStillImage property changing from YES to NO.
Sourceunsafe fn captureOutput_didFinishProcessingPhoto_error(
&self,
output: &AVCapturePhotoOutput,
photo: &AVCapturePhoto,
error: Option<&NSError>,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_didFinishProcessingPhoto_error( &self, output: &AVCapturePhotoOutput, photo: &AVCapturePhoto, error: Option<&NSError>, )
AVCaptureOutputBase only.A callback fired when photos are ready to be delivered to you (RAW or processed).
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter photo: An instance of AVCapturePhoto.
Parameter error: An error indicating what went wrong. If the photo was processed successfully, nil is returned.
This callback fires resolvedSettings.expectedPhotoCount number of times for a given capture request. Note that the photo parameter is always non nil, even if an error is returned. The delivered AVCapturePhoto’s rawPhoto property can be queried to know if it’s a RAW image or processed image.
Sourceunsafe fn captureOutput_didFinishCapturingDeferredPhotoProxy_error(
&self,
output: &AVCapturePhotoOutput,
deferred_photo_proxy: Option<&AVCaptureDeferredPhotoProxy>,
error: Option<&NSError>,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_didFinishCapturingDeferredPhotoProxy_error( &self, output: &AVCapturePhotoOutput, deferred_photo_proxy: Option<&AVCaptureDeferredPhotoProxy>, error: Option<&NSError>, )
AVCaptureOutputBase only.A callback fired just after the photo proxy has been taken.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter deferredPhotoProxy: The AVCaptureDeferredPhotoProxy instance which contains a proxy CVPixelBuffer as a placeholder for the final image. The fileDataRepresentation from this object may be used with PHAssetCreation to eventually produce the final, processed photo into the user’s Photo Library. The in-memory proxy fileDataRepresentation should be added to the photo library as quickly as possible after receipt to ensure that the photo library can begin background processing and also so that the intermediates are not removed by a periodic clean-up job looking for abandoned intermediates produced by using the deferred photo processing APIs.
Parameter error: An error indicating what went wrong if the photo proxy or any of the underlying intermediate files couldn’t be created.
Delegates are required to implement this method if they opt in for deferred photo processing, otherwise an NSInvalidArgumentException will be thrown from the -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] method.
Sourceunsafe fn captureOutput_didFinishProcessingPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error(
&self,
output: &AVCapturePhotoOutput,
photo_sample_buffer: Option<&CMSampleBuffer>,
preview_photo_sample_buffer: Option<&CMSampleBuffer>,
resolved_settings: &AVCaptureResolvedPhotoSettings,
bracket_settings: Option<&AVCaptureBracketedStillImageSettings>,
error: Option<&NSError>,
)
👎DeprecatedAvailable on crate features AVCaptureOutputBase and AVCaptureStillImageOutput and objc2-core-media only.
unsafe fn captureOutput_didFinishProcessingPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error( &self, output: &AVCapturePhotoOutput, photo_sample_buffer: Option<&CMSampleBuffer>, preview_photo_sample_buffer: Option<&CMSampleBuffer>, resolved_settings: &AVCaptureResolvedPhotoSettings, bracket_settings: Option<&AVCaptureBracketedStillImageSettings>, error: Option<&NSError>, )
AVCaptureOutputBase and AVCaptureStillImageOutput and objc2-core-media only.A callback fired when the primary processed photo or photos are done.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter photoSampleBuffer: A CMSampleBuffer containing an uncompressed pixel buffer or compressed data, along with timing information and metadata. May be nil if there was an error.
Parameter previewPhotoSampleBuffer: An optional CMSampleBuffer containing an uncompressed, down-scaled preview pixel buffer. Note that the preview sample buffer contains no metadata. Refer to the photoSampleBuffer for metadata (e.g., the orientation). May be nil.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
Parameter bracketSettings: If this image is being delivered as part of a bracketed capture, the bracketSettings corresponding to this image. Otherwise nil.
Parameter error: An error indicating what went wrong if photoSampleBuffer is nil.
If you’ve requested a single processed image (uncompressed or compressed) capture, the photo is delivered here. If you’ve requested a bracketed capture, this callback is fired bracketedSettings.count times (once for each photo in the bracket).
Sourceunsafe fn captureOutput_didFinishProcessingRawPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error(
&self,
output: &AVCapturePhotoOutput,
raw_sample_buffer: Option<&CMSampleBuffer>,
preview_photo_sample_buffer: Option<&CMSampleBuffer>,
resolved_settings: &AVCaptureResolvedPhotoSettings,
bracket_settings: Option<&AVCaptureBracketedStillImageSettings>,
error: Option<&NSError>,
)
👎DeprecatedAvailable on crate features AVCaptureOutputBase and AVCaptureStillImageOutput and objc2-core-media only.
unsafe fn captureOutput_didFinishProcessingRawPhotoSampleBuffer_previewPhotoSampleBuffer_resolvedSettings_bracketSettings_error( &self, output: &AVCapturePhotoOutput, raw_sample_buffer: Option<&CMSampleBuffer>, preview_photo_sample_buffer: Option<&CMSampleBuffer>, resolved_settings: &AVCaptureResolvedPhotoSettings, bracket_settings: Option<&AVCaptureBracketedStillImageSettings>, error: Option<&NSError>, )
AVCaptureOutputBase and AVCaptureStillImageOutput and objc2-core-media only.A callback fired when the RAW photo or photos are done.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter rawSampleBuffer: A CMSampleBuffer containing Bayer RAW pixel data, along with timing information and metadata. May be nil if there was an error.
Parameter previewPhotoSampleBuffer: An optional CMSampleBuffer containing an uncompressed, down-scaled preview pixel buffer. Note that the preview sample buffer contains no metadata. Refer to the rawSampleBuffer for metadata (e.g., the orientation). May be nil.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
Parameter bracketSettings: If this image is being delivered as part of a bracketed capture, the bracketSettings corresponding to this image. Otherwise nil.
Parameter error: An error indicating what went wrong if rawSampleBuffer is nil.
Single RAW image and bracketed RAW photos are delivered here. If you’ve requested a RAW bracketed capture, this callback is fired bracketedSettings.count times (once for each photo in the bracket).
Sourceunsafe fn captureOutput_didFinishRecordingLivePhotoMovieForEventualFileAtURL_resolvedSettings(
&self,
output: &AVCapturePhotoOutput,
output_file_url: &NSURL,
resolved_settings: &AVCaptureResolvedPhotoSettings,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_didFinishRecordingLivePhotoMovieForEventualFileAtURL_resolvedSettings( &self, output: &AVCapturePhotoOutput, output_file_url: &NSURL, resolved_settings: &AVCaptureResolvedPhotoSettings, )
AVCaptureOutputBase only.A callback fired when the Live Photo movie has captured all its media data, though all media has not yet been written to file.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter outputFileURL: The URL to which the movie file will be written. This URL is equal to your AVCapturePhotoSettings.livePhotoMovieURL.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
When this callback fires, no new media is being written to the file. If you are displaying a “Live” badge, this is an appropriate time to dismiss it. The movie file itself is not done being written until the -captureOutput:didFinishProcessingLivePhotoToMovieFileAtURL:duration:photoDisplayTime:resolvedSettings:error: callback fires.
Sourceunsafe fn captureOutput_didFinishProcessingLivePhotoToMovieFileAtURL_duration_photoDisplayTime_resolvedSettings_error(
&self,
output: &AVCapturePhotoOutput,
output_file_url: &NSURL,
duration: CMTime,
photo_display_time: CMTime,
resolved_settings: &AVCaptureResolvedPhotoSettings,
error: Option<&NSError>,
)
Available on crate features AVCaptureOutputBase and objc2-core-media only.
unsafe fn captureOutput_didFinishProcessingLivePhotoToMovieFileAtURL_duration_photoDisplayTime_resolvedSettings_error( &self, output: &AVCapturePhotoOutput, output_file_url: &NSURL, duration: CMTime, photo_display_time: CMTime, resolved_settings: &AVCaptureResolvedPhotoSettings, error: Option<&NSError>, )
AVCaptureOutputBase and objc2-core-media only.A callback fired when the Live Photo movie is finished being written to disk.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter outputFileURL: The URL where the movie file resides. This URL is equal to your AVCapturePhotoSettings.livePhotoMovieURL.
Parameter duration: A CMTime indicating the duration of the movie file.
Parameter photoDisplayTime: A CMTime indicating the time in the movie at which the still photo should be displayed.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features have been selected.
Parameter error: An error indicating what went wrong if the outputFileURL is damaged.
When this callback fires, the movie on disk is fully finished and ready for consumption.
Sourceunsafe fn captureOutput_didFinishCaptureForResolvedSettings_error(
&self,
output: &AVCapturePhotoOutput,
resolved_settings: &AVCaptureResolvedPhotoSettings,
error: Option<&NSError>,
)
Available on crate feature AVCaptureOutputBase only.
unsafe fn captureOutput_didFinishCaptureForResolvedSettings_error( &self, output: &AVCapturePhotoOutput, resolved_settings: &AVCaptureResolvedPhotoSettings, error: Option<&NSError>, )
AVCaptureOutputBase only.A callback fired when the photo capture is completed and no more callbacks will be fired.
Parameter output: The calling instance of AVCapturePhotoOutput.
Parameter resolvedSettings: An instance of AVCaptureResolvedPhotoSettings indicating which capture features were selected.
Parameter error: An error indicating whether the capture was unsuccessful. Nil if there were no problems.
This callback always fires last and when it does, you may clean up any state relating to this photo capture.