All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.red5.io.CapsExMask Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.red5.io;

import java.util.EnumSet;

/**
 * Extended capability flags define specific functionalities, such as the ability to reconnect or multitrack.
 *
 * @author Paul Gregoire
 */
public enum CapsExMask {

    Reconnect((byte) 0x01), Multitrack((byte) 0x02);

    private final byte mask;

    CapsExMask(byte b) {
        mask = b;
    }

    public byte getMask() {
        return mask;
    }

    public static EnumSet fromMask(byte b) {
        EnumSet result = EnumSet.noneOf(CapsExMask.class);
        for (CapsExMask mask : values()) {
            if ((b & mask.getMask()) == mask.getMask()) {
                result.add(mask);
            }
        }
        return result;
    }

    public static byte toMask(EnumSet set) {
        byte result = 0;
        for (CapsExMask mask : set) {
            result |= mask.getMask();
        }
        return result;
    }

    public static EnumSet all() {
        return EnumSet.allOf(CapsExMask.class);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy