<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: livekit_models.proto

namespace Livekit;

use UnexpectedValueException;

/**
 * Policy for publisher to handle subscribers that are unable to support the primary codec of a track
 *
 * Protobuf type <code>livekit.BackupCodecPolicy</code>
 */
class BackupCodecPolicy
{
    /**
     * default behavior, the track prefer to regress to backup codec and all subscribers will receive the backup codec,
     * the sfu will try to regress codec if possible but not assured.
     *
     * Generated from protobuf enum <code>PREFER_REGRESSION = 0;</code>
     */
    const PREFER_REGRESSION = 0;
    /**
     * encoding/send the primary and backup codec simultaneously
     *
     * Generated from protobuf enum <code>SIMULCAST = 1;</code>
     */
    const SIMULCAST = 1;
    /**
     * force the track to regress to backup codec, this option can be used in video conference or the publisher has limited bandwidth/encoding power
     *
     * Generated from protobuf enum <code>REGRESSION = 2;</code>
     */
    const REGRESSION = 2;

    private static $valueToName = [
        self::PREFER_REGRESSION => 'PREFER_REGRESSION',
        self::SIMULCAST => 'SIMULCAST',
        self::REGRESSION => 'REGRESSION',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

