CamoController

public class CamoController

The Camo controller is the starting point for interacting with Camo Studio. From here, you can control the Camo connection service.

You can only have one active instance in your application at a given time.

At the moment, all API methods for CamoProducerKit are provided by CamoController, to provide a simple public-facing implementation.

  • The delegate for this Camo controller. You are required to implement and set it before making use of CamoController.

    Declaration

    Swift

    public weak var delegate: CamoControllerDelegate?
  • Number of audio samples required for one audio packet. Might be different for macOS and Windows

    Declaration

    Swift

    public var audioSamplesRequired: Int { get }
  • The Camo service’s state, such as if its running or not, and if it is running, more information on the active connection.

    Declaration

    Swift

    public private(set) var state: CamoControllerState { get }
  • Initialise a Camo controller. You should only have one instance at any given time.

    Declaration

    Swift

    public init()

Controlling the service

  • Start the Camo service to facilitate connections with Camo Studio.

    Declaration

    Swift

    public func start()
  • Stop the Camo service, disconnecting any existing connections to Camo Studio.

    Note

    You must wait for the service to fully stop before starting it again. You can use the completion handler to determine when the service has stopped.

    Declaration

    Swift

    public func stop(completion: (() -> Void)? = nil)

Sending audiovisual data

  • Send a video frame to Camo Studio. Currently, you should aim to send video at a goal of 30 FPS. Your frame duration should match this.

    You can view an example of sending video in the provided demo application. This method will not send video if there is no connection, but you should also be checking to avoid any unnecessary processing in your app.

    Declaration

    Swift

    public func enqueueVideo(sampleBuffer: CMSampleBuffer)

    Parameters

    sampleBuffer

    The sample buffer to send. It must be using the pixel format kCVPixelFormatType_32BGRA.

  • Send an audio packet to Camo Studio.

    You can view an example of sending audio in the provided demo application. This method will not send audio if there is no connection, but you should also be checking to avoid any unnecessary processing in your app.

    Audio requirements:

    • Sample rate: 48 kHz
    • Audio codec: LPCM
    • Number of channels: 2
    • Bit depth: 32
    • Samples per audio packet: 256

    LPCM sample size is 8 bytes, so expected data length is 8 * 256 = 2048 bytes

    Declaration

    Swift

    public func enqueueAudio(pcmData data: Data)

    Parameters

    data

    The encoded audio data to send.