// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/VideoClassInterface.java
// public abstract class VideoClassInterface extends UvcInterface {
// 
//     VideoClassInterface(UsbInterface usbInterface, byte[] descriptor) {
//         super(usbInterface, descriptor);
//     }
// 
//     public static enum VC_INF_SUBTYPE {
//         VC_DESCRIPTOR_UNDEFINED(0x00),
//         VC_HEADER(0x01),
//         VC_INPUT_TERMINAL(0x02),
//         VC_OUTPUT_TERMINAL(0x03),
//         VC_SELECTOR_UNIT(0x04),
//         VC_PROCESSING_UNIT(0x05),
//         VC_EXTENSION_UNIT(0x06),
//         VC_ENCODING_UNIT(0x07);
// 
//         public final byte subtype;
// 
//         private VC_INF_SUBTYPE(int subtype) {
//             this.subtype = (byte) (subtype & 0xFF);
//         }
// 
//         public static VC_INF_SUBTYPE getSubtype(byte subtype) {
//             for (VC_INF_SUBTYPE s : VC_INF_SUBTYPE.values()) {
//                 if (s.subtype == subtype) {
//                     return s;
//                 }
//             }
//             return null;
//         }
//     }
// }
// 
// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/Descriptor.java
// public static enum Type {
//     DEVICE(0x01),
//     CONFIGURATION(0x02),
//     STRING(0x03),
//     INTERFACE(0x04),
//     ENDPOINT(0x05),
//     DEVICE_QUALIFIER(0x06),
//     INTERFACE_ASSOCIATION(0x0B),
//     CS_UNDEFINED(0x20),
//     CS_DEVICE(0x21),
//     CS_CONFIGURATION(0x22),
//     CS_STRING(0x23),
//     CS_INTERFACE(0x24),
//     CS_ENDPOINT(0x25);
// 
//     public final byte type;
// 
//     private Type(int type) {
//         this.type = (byte) (type & 0xFF);
//     }
// 
//     public static Type getType(byte[] raw) {
//         for (Type t : Type.values()) {
//             if (t.type == raw[INDEX_DESCRIPTOR_TYPE]) {
//                 return t;
//             }
//         }
//         throw new IllegalArgumentException("Unknown descriptor? " + Hexdump.dumpHexString(raw));
//     }
// }


import com.jwoolston.android.uvc.interfaces.VideoClassInterface;
import com.jwoolston.android.uvc.interfaces.Descriptor.Type;
package com.jwoolston.android.uvc.interfaces.units;


/**
 * @author Jared Woolston (Jared.Woolston@gmail.com)
 */
public class VideoUnit {

    protected static final int bLength = 0;
    protected static final int bDescriptorType = 1;
    protected static final int bDescriptorSubtype = 2;
    protected static final int bUnitID = 3;

    private final int mUnitID;

    public static boolean isVideoUnit(byte[] descriptor) {
        if (descriptor[bDescriptorType] != Type.CS_INTERFACE.type) return false;
        final byte subtype = descriptor[bDescriptorSubtype];
// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/VideoClassInterface.java
// public abstract class VideoClassInterface extends UvcInterface {
// 
//     VideoClassInterface(UsbInterface usbInterface, byte[] descriptor) {
//         super(usbInterface, descriptor);
//     }
// 
//     public static enum VC_INF_SUBTYPE {
//         VC_DESCRIPTOR_UNDEFINED(0x00),
//         VC_HEADER(0x01),
//         VC_INPUT_TERMINAL(0x02),
//         VC_OUTPUT_TERMINAL(0x03),
//         VC_SELECTOR_UNIT(0x04),
//         VC_PROCESSING_UNIT(0x05),
//         VC_EXTENSION_UNIT(0x06),
//         VC_ENCODING_UNIT(0x07);
// 
//         public final byte subtype;
// 
//         private VC_INF_SUBTYPE(int subtype) {
//             this.subtype = (byte) (subtype & 0xFF);
//         }
// 
//         public static VC_INF_SUBTYPE getSubtype(byte subtype) {
//             for (VC_INF_SUBTYPE s : VC_INF_SUBTYPE.values()) {
//                 if (s.subtype == subtype) {
//                     return s;
//                 }
//             }
//             return null;
//         }
//     }
// }
// 
// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/Descriptor.java
// public static enum Type {
//     DEVICE(0x01),
//     CONFIGURATION(0x02),
//     STRING(0x03),
//     INTERFACE(0x04),
//     ENDPOINT(0x05),
//     DEVICE_QUALIFIER(0x06),
//     INTERFACE_ASSOCIATION(0x0B),
//     CS_UNDEFINED(0x20),
//     CS_DEVICE(0x21),
//     CS_CONFIGURATION(0x22),
//     CS_STRING(0x23),
//     CS_INTERFACE(0x24),
//     CS_ENDPOINT(0x25);
// 
//     public final byte type;
// 
//     private Type(int type) {
//         this.type = (byte) (type & 0xFF);
//     }
// 
//     public static Type getType(byte[] raw) {
//         for (Type t : Type.values()) {
//             if (t.type == raw[INDEX_DESCRIPTOR_TYPE]) {
//                 return t;
//             }
//         }
//         throw new IllegalArgumentException("Unknown descriptor? " + Hexdump.dumpHexString(raw));
//     }
// }


// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/units/VideoUnit.java
import com.jwoolston.android.uvc.interfaces.VideoClassInterface;
import com.jwoolston.android.uvc.interfaces.Descriptor.Type;

package com.jwoolston.android.uvc.interfaces.units;


/**
 * @author Jared Woolston (Jared.Woolston@gmail.com)
 */
public class VideoUnit {

    protected static final int bLength = 0;
    protected static final int bDescriptorType = 1;
    protected static final int bDescriptorSubtype = 2;
    protected static final int bUnitID = 3;

    private final int mUnitID;

    public static boolean isVideoUnit(byte[] descriptor) {
        if (descriptor[bDescriptorType] != Type.CS_INTERFACE.type) return false;
        final byte subtype = descriptor[bDescriptorSubtype];
        return (subtype == VideoClassInterface.VC_INF_SUBTYPE.VC_SELECTOR_UNIT.subtype ||