// 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 Output Terminal (OT) is used as an interface between Units inside the video function and the "outside world".
 * It serves as an outlet for video information, flowing out of the video function. Its function is to represent a
 * sink of outgoing data. The video data stream enters the Output Terminal through a single Input Pin.
 * An Output Terminal can represent outputs from the video function other than USB IN endpoints. A Liquid Crystal
 * Display (LCD) screen built into a video device or a composite video out connector are examples of such an output.
 * However, if the video stream is leaving the video function by means of a USB IN endpoint, there is a one-to-one
 * relationship between that endpoint and its associated Output Terminal. The class-specific Input Header descriptor
 * contains a field that holds a direct reference to this Output Terminal (see section 3.9.2.1, “Input Header
 * Descriptor”). The Host needs to use both the endpoint descriptors and the Output Terminal descriptor to fully
 * understand the characteristics and capabilities of the Output 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 VideoOutputTerminal extends VideoTerminal {

    protected static final int MIN_LENGTH = 9;

    protected static final int bSourceID = 7;
    protected static final int iTerminal = 8;

    private final int sourceID;

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

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


/**
 * The Output Terminal (OT) is used as an interface between Units inside the video function and the "outside world".
 * It serves as an outlet for video information, flowing out of the video function. Its function is to represent a
 * sink of outgoing data. The video data stream enters the Output Terminal through a single Input Pin.
 * An Output Terminal can represent outputs from the video function other than USB IN endpoints. A Liquid Crystal
 * Display (LCD) screen built into a video device or a composite video out connector are examples of such an output.
 * However, if the video stream is leaving the video function by means of a USB IN endpoint, there is a one-to-one
 * relationship between that endpoint and its associated Output Terminal. The class-specific Input Header descriptor
 * contains a field that holds a direct reference to this Output Terminal (see section 3.9.2.1, “Input Header
 * Descriptor”). The Host needs to use both the endpoint descriptors and the Output Terminal descriptor to fully
 * understand the characteristics and capabilities of the Output 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 VideoOutputTerminal extends VideoTerminal {

    protected static final int MIN_LENGTH = 9;

    protected static final int bSourceID = 7;
    protected static final int iTerminal = 8;

    private final int sourceID;

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