// 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;
//         }
//     }
// }


import com.jwoolston.android.uvc.interfaces.VideoClassInterface;
import java.util.Arrays;
package com.jwoolston.android.uvc.interfaces.units;


/**
 * The Selector Unit (SU) selects from n input data streams and routes them unaltered to the single output stream. It
 * represents a source selector, capable of selecting among a number of sources. It has an Input Pin for each source
 * stream and a single Output Pin
 *
 * @author Jared Woolston (Jared.Woolston@gmail.com)
 * @see <a href=http://www.usb.org/developers/docs/devclass_docs/USB_Video_Class_1_5.zip>UVC 1.5 Class
 * Specification §2.3.4</a>
 */
public class VideoSelectorUnit extends VideoUnit {

    private static final int MIN_LENGTH = 6;

    private static final int bNrInPins  = 4;
    private static final int baSourceID = 5;
    private static final int iSelector  = 5;

    private final int   numInPins;
    private final int[] sourceIDs;
    private final int   selectorValue;

    public static boolean isVideoSelectorUnit(byte[] descriptor) {
        return (descriptor.length >= MIN_LENGTH
// 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/units/VideoSelectorUnit.java
import com.jwoolston.android.uvc.interfaces.VideoClassInterface;
import java.util.Arrays;

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


/**
 * The Selector Unit (SU) selects from n input data streams and routes them unaltered to the single output stream. It
 * represents a source selector, capable of selecting among a number of sources. It has an Input Pin for each source
 * stream and a single Output Pin
 *
 * @author Jared Woolston (Jared.Woolston@gmail.com)
 * @see <a href=http://www.usb.org/developers/docs/devclass_docs/USB_Video_Class_1_5.zip>UVC 1.5 Class
 * Specification §2.3.4</a>
 */
public class VideoSelectorUnit extends VideoUnit {

    private static final int MIN_LENGTH = 6;

    private static final int bNrInPins  = 4;
    private static final int baSourceID = 5;
    private static final int iSelector  = 5;

    private final int   numInPins;
    private final int[] sourceIDs;
    private final int   selectorValue;

    public static boolean isVideoSelectorUnit(byte[] descriptor) {
        return (descriptor.length >= MIN_LENGTH
                & descriptor[bDescriptorSubtype] == VideoClassInterface.VC_INF_SUBTYPE.VC_SELECTOR_UNIT.subtype);