IVSBroadcastSessionDelegate

Objective-C

@protocol IVSBroadcastSessionDelegate <NSObject>

Swift

protocol Delegate : NSObjectProtocol

Provide a delegate to receive status updates and errors from the SDK. Updates may be run on arbitrary threads and not the main thread.

  • Indicates that the broadcast state changed.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
              didChangeState:(IVSBroadcastSessionState)state;

    Swift

    func broadcastSession(_ session: IVSBroadcastSession, didChange state: IVSBroadcastSession.State)

    Parameters

    session

    The IVSBroadcastSession that just changed state

    state

    current broadcast state

  • Indicates that an error occurred. Errors may or may not be fatal and will be marked as such with the IVSBroadcastErrorIsFatalKey in the userInfo property of the error.

    Note

    In the case of a fatal error the broadcast session moves into disconnected state.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
                didEmitError:(nonnull NSError *)error;

    Swift

    func broadcastSession(_ session: IVSBroadcastSession, didEmitError error: Error)

    Parameters

    session

    The IVSBroadcastSession that just emitted the error.

    error

    error emitted by the SDK.

  • Indicates that a device has become available.

    Note

    In the case of audio devices, it is possible the system has automatically rerouted audio to this device. You can check listAttachedDevices to see if the attached audio devices have changed.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
                didAddDevice:(nonnull IVSDeviceDescriptor *)descriptor;

    Swift

    optional func broadcastSession(_ session: IVSBroadcastSession, didAddDevice descriptor: IVSDeviceDescriptor)

    Parameters

    session

    The IVSBroadcastSession that added the device

    descriptor

    the device’s descriptor

  • Indicates that a device has become unavailable.

    Note

    In the case of audio devices, it is possible the system has automatically rerouted audio from this device to another device. You can check listAttachedDevices to see if the attached audio devices have changed.

    It is possible that this will not be called if a device that is not in use gets disconnected. For example, if you have attached the built-in microphone to the broadcast session, but also have a bluetooth microphone paired with the device, this may not be called if the bluetooth device disconnects. Anything impacting an attached device will result in this being called however.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
             didRemoveDevice:(nonnull IVSDeviceDescriptor *)descriptor;

    Swift

    optional func broadcastSession(_ session: IVSBroadcastSession, didRemoveDevice descriptor: IVSDeviceDescriptor)

    Parameters

    session

    The IVSBroadcastSession that removed the device

    descriptor

    the device’s descriptor. This may not contain specific hardware information other than IDs.

  • Periodically called with audio peak and rms in dBFS. Range is -100 (silent) to 0.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
        audioStatsUpdatedWithPeak:(double)peak
                              rms:(double)rms;

    Swift

    optional func broadcastSession(_ session: IVSBroadcastSession, audioStatsUpdatedWithPeak peak: Double, rms: Double)

    Parameters

    session

    The IVSBroadcastSession associated with the audio stats.

    peak

    Audio Peak over the time period

    rms

    Audio RMS over the time period

  • A number between 0 and 1 that represents the qualty of the stream based on bitrate minimum and maximum provided on session configuration. 0 means the stream is at the lowest possible quality, or streaming is not possible at all. 1 means the bitrate is near the maximum allowed.

    @discussion If the video configuration looks like: initial bitrate = 1000 kbps minimum bitrate = 300 kbps maximum bitrate = 5,000 kbps

    It will be expected that a low quality is provided to this callback initially, since the initial bitrate is much closer to the minimum allowed bitrate than the maximum. If network conditions are good the quality should improve over time towards the allowed maximum.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
        broadcastQualityChanged:(double)quality;

    Swift

    optional func broadcastSession(_ session: IVSBroadcastSession, broadcastQualityChanged quality: Double)

    Parameters

    session

    The IVSBroadcastSession associated with the quality change.

    quality

    The quality of the stream

  • A number between 0 and 1 that represents the current health of the network. 0 means the network is struggling to keep up and the broadcast may be experiencing latency spikes. The SDK may also reduce the quality of the broadcast on low values in order to keep it stable, depending on the minimum allowed bitrate in the broadcast configuration. A value of 1 means the network is easily able to keep up with the current demand and the SDK will be trying to increase the broadcast quality over time, depending on the maximum allowed bitrate.

    Lower values like 0.5 are not necessarily bad, it just means the network is being saturated, but it is still able to keep up.

    Declaration

    Objective-C

    - (void)broadcastSession:(nonnull IVSBroadcastSession *)session
        networkHealthChanged:(double)health;

    Swift

    optional func broadcastSession(_ session: IVSBroadcastSession, networkHealthChanged health: Double)

    Parameters

    session

    The IVSBroadcastSession that associated with the quality change.

    health

    The instantaneous health of the network