CBLCameraLiveView

Objective-C

@protocol CBLCameraLiveView <NSObject>

Swift

protocol CameraLiveView : NSObjectProtocol

Camera live view methods.

  • Start streaming the live view image from the camera.

    Note

    The frame delivery block has a completion handler, which MUST be called in order to receive the next frame. The completion handler can be called from any thread, and should be called when you’re ready for the next frame. This allows frame delivery to correctly throttle without backing up frames if your image processing/display is slower than the delivery rate from the camera.

    Declaration

    Objective-C

    - (void)beginLiveViewStreamWithDelivery:
                (nonnull CBLCameraLiveViewFrameDelivery)delivery
                              deliveryQueue:(nullable dispatch_queue_t)deliveryQueue
                         terminationHandler:
                             (nonnull CBLCameraLiveViewTerminationHandler)
                                 terminationHandler;

    Swift

    func beginStream(delivery: @escaping LiveViewFrameDelivery, deliveryQueue: dispatch_queue_t?, terminationHandler: @escaping LiveViewTerminationHandler)

    Parameters

    delivery

    The frame delivery block.

    deliveryQueue

    The queue on which to deliver frames. If you pass nil, the main queue will be used.

    terminationHandler

    The callback to call when the live view stream ends. Will be called on the main queue.

  • Start streaming the live view image from the camera with the given options.

    Note

    The frame delivery block has a completion handler, which MUST be called in order to receive the next frame. The completion handler can be called from any thread, and should be called when you’re ready for the next frame. This allows frame delivery to correctly throttle without backing up frames if your image processing/display is slower than the delivery rate from the camera.

    Declaration

    Objective-C

    - (void)beginLiveViewStreamWithDelivery:
                (nonnull CBLCameraLiveViewFrameDelivery)delivery
                              deliveryQueue:(nullable dispatch_queue_t)deliveryQueue
                                    options:
                                        (nullable NSDictionary<NSString *, id> *)
                                            options
                         terminationHandler:
                             (nonnull CBLCameraLiveViewTerminationHandler)
                                 terminationHandler;

    Swift

    func beginStream(delivery: @escaping LiveViewFrameDelivery, deliveryQueue: dispatch_queue_t?, options: [String : Any]? = nil, terminationHandler: @escaping LiveViewTerminationHandler)

    Parameters

    delivery

    The frame delivery block.

    deliveryQueue

    The queue on which to deliver frames. If you pass nil, the main queue will be used.

    options

    Custom options for the live view session. See CBLLiveViewOption… constants for details.

    terminationHandler

    The callback to call when the live view stream ends. Will be called on the main queue.

  • Apply new options to the running stream live view stream. Options not included in the passed dictionary will not be changed.

    Due to the threaded nature of live view streaming, a number of frames may be delivered between calling this method and the new options taking effect.

    Note

    If no live view stream is running, this method has no effect.

    Declaration

    Objective-C

    - (void)applyLiveViewStreamOptions:
        (nonnull NSDictionary<NSString *, id> *)options;

    Swift

    func applyStreamOptions(_ options: [String : Any] = [:])

    Parameters

    options

    The options to apply to the running live view stream.

  • Ends the current live view stream, if one is running. Will cause the stream’s termination handler to be called with CBLCameraLiveViewTerminationReasonEndedNormally.

    Declaration

    Objective-C

    - (void)endLiveViewStream;

    Swift

    func endStream()
  • Returns YES if the camera is currently streaming a live view image.

    Declaration

    Objective-C

    @property (readonly) BOOL liveViewStreamActive;

    Swift

    var liveViewStreamActive: Bool { get }
  • Attempt to zoom in to live view by cropping in on the camera’s side.

    The given crop rectangle must match the aspect ratio of the live view frame’s aspect, must be completely contained within it, and must be larger or equal in size to the live view frame’s minimumCropSize. The rect may be adjusted by CascableCore to match the camera’s requirements. To check the final cropped frame, see live view frame’s imageFrameInAspect property once the operation completes.

    Note that it may take a few frames for crop geometry to update after this operation finishes, due to frame buffers and etc.

    If the camera doesn’t support the functionality CBLCameraSupportedFunctionalityCroppableLiveView, this operation will fail.

    Declaration

    Objective-C

    - (void)setLiveViewCrop:(CGRect)cropRect
         completionCallback:(nullable CBLErrorableOperationCallback)block;

    Swift

    func setLiveViewCrop(_ cropRect: CGRect, completionCallback block: ErrorableOperationCallback? = nil)

    Parameters

    cropRect

    The rectangle at which to crop live view, relative to a live view frame’s aspect.

    block

    The callback to call when the operation is complete.

  • Attempt to reset the live view crop to the uncropped state.

    If the camera doesn’t support the functionality CBLCameraSupportedFunctionalityCroppableLiveView, this operation will fail.

    Declaration

    Objective-C

    - (void)resetLiveViewCrop:(nullable CBLErrorableOperationCallback)block;

    Swift

    func resetLiveViewCrop(_ block: ErrorableOperationCallback? = nil)

    Parameters

    block

    The callback to call when the operation is complete.

  • Attempt to set the live view zoom’s center point to the given point without changing the zoom level.

    The given point must be within the live view frame’s aspect. The point may be adjusted by CascableCore to match the camera’s requirements. To check the final position, see live view frame’s imageFrameInAspect property once the operation completes.

    Note that it may take a few frames for zoom geometry to update after this operation finishes, due to frame buffers and etc.

    If the camera doesn’t support the CBLCameraSupportedFunctionalityCroppableLiveView or CBLCameraSupportedFunctionalityPannableLiveView functionalities, this operation will fail.

    Declaration

    Objective-C

    - (void)setLiveViewZoomCenterPoint:(CGPoint)centerPoint
                    completionCallback:
                        (nullable CBLErrorableOperationCallback)block;

    Swift

    func setLiveViewZoomCenterPoint(_ centerPoint: CGPoint, completionCallback block: ErrorableOperationCallback? = nil)