// 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;
package com.jwoolston.android.uvc.interfaces.terminals;


/**
 * The Input Terminal (IT) is used as an interface between the video function’s "outside world" and other Units
 * inside the video function. It serves as a receptacle for data flowing into the video function. Its function is to
 * represent a source of incoming data after this data has been extracted from the data source. The data may include
 * audio and metadata associated with a video stream. These physical streams are grouped into a cluster of logical
 * streams, leaving the Input Terminal through a single Output Pin.
 * An Input Terminal can represent inputs to the video function other than USB OUT endpoints. A CCD sensor on a video
 * camera or a composite video input is an example of such a non-USB input. However, if the video stream is entering
 * the video function by means of a USB OUT endpoint, there is a one-to-one relationship between that endpoint and
 * its associated Input Terminal. The class-specific Output Header descriptor contains a field that holds a direct
 * reference to this Input Terminal (see section 3.9.2.2, “Output Header Descriptor”). The Host needs to use both the
 * endpoint descriptors and the Input Terminal descriptor to get a full understanding of the characteristics and
 * capabilities of the Input Terminal. Stream-related parameters are stored in the endpoint descriptors.
 * Control-related parameters are stored in the Terminal descriptor.
 *
 * @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.2</a>
 */
public class VideoInputTerminal extends VideoTerminal {

    protected static final int MIN_LENGTH = 8;

    protected static final int iTerminal = 7;

    public static boolean isInputTerminal(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/terminals/VideoInputTerminal.java
import com.jwoolston.android.uvc.interfaces.VideoClassInterface;

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


/**
 * The Input Terminal (IT) is used as an interface between the video function’s "outside world" and other Units
 * inside the video function. It serves as a receptacle for data flowing into the video function. Its function is to
 * represent a source of incoming data after this data has been extracted from the data source. The data may include
 * audio and metadata associated with a video stream. These physical streams are grouped into a cluster of logical
 * streams, leaving the Input Terminal through a single Output Pin.
 * An Input Terminal can represent inputs to the video function other than USB OUT endpoints. A CCD sensor on a video
 * camera or a composite video input is an example of such a non-USB input. However, if the video stream is entering
 * the video function by means of a USB OUT endpoint, there is a one-to-one relationship between that endpoint and
 * its associated Input Terminal. The class-specific Output Header descriptor contains a field that holds a direct
 * reference to this Input Terminal (see section 3.9.2.2, “Output Header Descriptor”). The Host needs to use both the
 * endpoint descriptors and the Input Terminal descriptor to get a full understanding of the characteristics and
 * capabilities of the Input Terminal. Stream-related parameters are stored in the endpoint descriptors.
 * Control-related parameters are stored in the Terminal descriptor.
 *
 * @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.2</a>
 */
public class VideoInputTerminal extends VideoTerminal {

    protected static final int MIN_LENGTH = 8;

    protected static final int iTerminal = 7;

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