ObservableVideoSource

open class ObservableVideoSource : NSObject, VideoSource

Helper class handling observers: storing, releasing, notifying. Observers are held weakly by the instance of the class. You may inherit your video source from this class to avoid handling observers yourself.

Warning

The implementation uses a non-recursive lock, thus you must not call add(observer:) or remove(observer:) methods from notify closure.
  • Provides default value of isExternal parameter. Override if your video source is represented by a module separate from the device.

    Declaration

    Swift

    open var isExternal: Bool
  • Declaration

    Swift

    override public init()
  • Adds an entry to the list of observers.

    The method is a thread-safe.

    Warning

    The implementation uses a non-recursive lock, thus you must not call this method from notify(closure:) method’s closure.

    Declaration

    Swift

    open func add(observer: VideoSourceObserver)

    Parameters

    observer

    Object registering as an observer.

  • Removes matching entry from the list of observers.

    The method is a thread-safe.

    Warning

    The implementation uses a non-recursive lock, thus you must not call this method inside notify(closure:)method’s closure.

    Declaration

    Swift

    open func remove(observer: VideoSourceObserver)

    Parameters

    observer

    Object registering as an observer.

  • Use this method to notify all observers about newly available VideoSample or CameraParameters.

    The method is a thread-safe.

    Warning

    The implementation uses a non-recursive lock, thus you must not call add(observer:) or remove(observer:) methods from closure.

    Declaration

    Swift

    public func notify(_ closure: (VideoSourceObserver) -> Void)

    Parameters

    closure

    Closure that is called for each entry from the list of observers. It has a reference to a current observer as a parameter.