//
//  OTVideoEventReason.h
//
//  Copyright (c) 2014 Tokbox, Inc. All rights reserved.
//

/**
 * Describes the primary reason impacting network condition.
 *
 * These values indicate the primary factor affecting the current
 * network condition assessment, such as bandwidth constraints,
 * or packet loss.
 */
typedef NS_ENUM(int32_t, OTNetworkReason) {
    /** No notable reason. */
    OTNetworkReasonNone = 0,
    /** Unknown reason. */
    OTNetworkReasonUnknown = 1,
    /** Network condition score impacted by bandwidth. */
    OTNetworkReasonBandwidth = 2,
    /** Network condition score impacted by packet loss. */
    OTNetworkReasonPacketLoss = 3,
    /** Indicates that the local or remote participant network condition has
        changed. Triggered when a significant change is detected in the
        local participant network. */
    OTNetworkReasonNetworkConditionChange = 4
};

/**
 * Video enabled and disabled events are accompanied with a reason code, for
 * determining why the video track was enabled/disabled.
 *
 */
typedef NS_ENUM(int32_t, OTPublisherVideoEventReason) {
    /**
     * No notable video event or quality degradation. Default or unknown reason.
     */
    OTPublisherVideoEventNone = 0,
    
    /**
     * The video event was caused by this publisher changing the value
     * for OTPublisherKit.publishVideo.
     */
    OTPublisherVideoEventPublisherPropertyChanged = 1,
    
    /**
     * The video event was caused by a change in the network congestion level.
     * The <[OTPublisherKitDelegate publisherVideoDisabled:reason:]> message
     * is sent. When conditions improve, the video stream resumes, and the
     * <[OTPublisherKitDelegate publisherVideoEnabled:reason:]> message is
     * sent.
     *
     * When the video stream is dropped, the publisher continues to send
     * the audio stream, if there is one. Moreover, the capturer corresponding
     * to this publisher will not be disabled, and the captured frames will still
     * be seen on the publisher side.
     *
     * When the congestion level deteriorates to a level that
     * is low enough that the video stream is at risk of being disabled, the
     * <[OTPublisherKitDelegate publisherVideoDisableWarning:]> message is
     * sent.
     *
     * You can disable this publisher audio-only fallback feature, by setting the
     * <[OTPublisherKit publisherAudioFallbackEnabled]> property to <code>NO</code>
     * for the publisher of the stream.
     */
    OTPublisherVideoEventQualityChanged = 3,

    /**
     * Quality degradation due to insufficient network bandwidth.
     */
    OTPublisherVideoEventQualityDegradationBandwidth = 5,

    /**
     * Quality degradation caused by CPU limitations on the client device.
     */
    OTPublisherVideoEventQualityDegradationCPU = 6,

    /**
     * Quality degradation caused by other reasons.
     */
    OTPublisherVideoEventQualityDegradationOther = 7,

    /**
     * The video codec for the stream has changed.
     */
    OTPublisherVideoEventCodecChange = 8,

    /**
     * Change in video resolution or number of layers.
     * This can occur due to bitrate constraints, encoder adaptation, camera source changes
     * (e.g., switching cameras or changing input resolution), or configuration changes.
     * Does not always imply quality degradation.
     */
    OTPublisherVideoEventResolutionChange = 9
};

/**
 * Video enabled and disabled events are accompanied with a reason code, for
 * determining why the video track was enabled/disabled.
 */
typedef NS_ENUM(int32_t, OTSubscriberVideoEventReason) {
    /**
     * No notable video event or quality degradation. Default or unknown reason.
     */
    OTSubscriberVideoEventNone = 0,
    
    /**
     * The video event was caused by the stream's publisher changing the value
     * for OTPublisherKit.publishVideo.
     */
    OTSubscriberVideoEventPublisherPropertyChanged = 1,
    
    /**
     * The video event was caused by a change to this subscriber's
     * OTSubscriberKit.subscribeToVideo property.
     */
    OTSubscriberVideoEventSubscriberPropertyChanged = 2,
    
    /**
     * The video event was caused by a change to the video stream quality.
     * Stream quality may change due to network conditions or CPU usage
     * on either the subscriber or publisher.
     * <p>
     * When enabled, audio fallback provides an event when the subscriber
     * drops the video stream due to degraded video quality, resulting
     * <[OTSubscriberKitDelegate subscriberVideoDisabled:reason:]> message
     * is sent. When conditions improve, the video stream resumes, and the
     * <[OTSubscriberKitDelegate subscriberVideoEnabled:reason:]> message is
     * sent.
     * <p>
     * When the video stream is dropped, the subscriber continues to receive
     * the audio stream, if there is one.
     * <p>
     * When the Subscriber's stream quality deteriorates to a level that
     * is low enough that the video stream is at risk of being disabled, the
     * <[OTSubscriberKitDelegate subscriberVideoDisableWarning:]> message is
     * sent. The <[OTSubscriberKitDelegate subscriberVideoDisableWarning:]>
     * message is sent before the
     * <[OTSubscriberKitDelegate subscriberVideoDisabled:reason:]> message is
     * sent.
     * <p>
     * In routed sessions, the source of this video event can be either the Vonage
     * Video Media Router (Subscriber Audio Fallback) or the publishing
     * client (Publisher Audio Fallback). When the publishing client is the
     * source, the corresponding stream for that subscriber will have its
     * <[OTStream hasVideo]> property updated to <code>NO</code> as
     * an additional change alongside the video disabled message. Although
     * this typically indicates network degradation on the publisher’s side,
     * subscriber-reported metrics can influence fallback decisions, which may
     * make the exact source of the degradation less clear.
     * <p>
     * In relayed sessions, audio-only fallback is applied exclusively due to the
     * publisher’s internal audio-fallback logic (Publisher Audio Fallback).
     * In this case, the subscriber may stop receiving video due to network
     * degradation, but the associated stream object will not have its
     * <[OTStream hasVideo]> property updated, since the stream may still
     * include video data for other subscribers with better network conditions.
     * Note that although fallback originates from the publisher in relayed sessions,
     * degradation may occur on either the publisher or subscriber side.
     * <p>
     * You can control audio-only fallback behavior by setting the corresponding
     * properties when creating the publisher. By
     * default, <[OTPublisherKitSettings subscriberAudioFallbackEnabled]> is set
     * to <code>YES</code> (except for screen-sharing publishers in routed
     * sessions, where it is <code>NO</code>), and
     * <[OTPublisherKitSettings publisherAudioFallbackEnabled]> is set to
     * <code>NO</code>. To change this, set
     * <[OTPublisherKitSettings subscriberAudioFallbackEnabled]> to
     * <code>NO</code> to disable subscriber fallback, or set
     * <[OTPublisherKitSettings publisherAudioFallbackEnabled]> to <code>YES</code>
     * to enable publisher fallback. See <OTPublisherKitSettings>.
     */
    OTSubscriberVideoEventQualityChanged = 3,
    
    /**
     * The video event was caused when video in the the subscriber stream
     * was disabled because the stream uses a video codec (such as H.264)
     * that is not supported on the device.
     */
    OTSubscriberVideoEventCodecNotSupported = 4,
    
    /**
     * The video codec for the stream has changed.
     */
    OTSubscriberVideoEventCodecChange = 8,
    
    /**
     * Change in video resolution.
     *
     * This can occur due to bitrate constraints, encoder adaptation, camera source changes
     * (e.g., switching cameras or changing input resolution), or configuration changes.
     * Does not always imply quality degradation.
     */
    OTSubscriberVideoEventResolutionChange = 9,
    
    /**
     * The video stream was interrupted.
     *
     * This event indicates that video delivery to the subscriber was paused
     * for a sustained period (typically longer than five seconds).
     *
     * When this event occurs, you can inspect the subscriber's
     * statistics (for example, bitrate, frame rate, or packet loss) to
     * identify the underlying cause.
     */
    OTSubscriberVideoEventVideoInterruption = 10,
};

