// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/Descriptor.java
// public static enum Protocol {
//     PC_PROTOCOL_UNDEFINED(0x00),
//     PC_PROTOCOL_15(0x01);
// 
//     public final byte protocol;
// 
//     private Protocol(int protocol) {
//         this.protocol = (byte) (protocol & 0xFF);
//     }
// }


import com.jwoolston.android.uvc.interfaces.Descriptor.Protocol;
import timber.log.Timber;
package com.jwoolston.android.uvc.interfaces;



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

    private static final int LENGTH_DESCRIPTOR = 8;

    protected static final int bFirstInterface   = 2;
    protected static final int bInterfaceCount   = 3;
    protected static final int bFunctionClass    = 4;
    protected static final int bFunctionSubClass = 5;
    protected static final int bFunctionProtocol = 6;
    protected static final int iFunction         = 7;

    private final int firstInterface;

    private final int interfaceCount;

    private final int indexFunction;

    protected static InterfaceAssociationDescriptor parseIAD(byte[] descriptor) throws IllegalArgumentException {
        Timber.d("Parsing Interface Association Descriptor.");
        if (descriptor.length < LENGTH_DESCRIPTOR) {
            throw new IllegalArgumentException("The provided descriptor is not long enough. Have " + descriptor.length + " need " + LENGTH_DESCRIPTOR);
        }
        if (descriptor[bFunctionClass] == Descriptor.VIDEO_CLASS_CODE) {
// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/Descriptor.java
// public static enum Protocol {
//     PC_PROTOCOL_UNDEFINED(0x00),
//     PC_PROTOCOL_15(0x01);
// 
//     public final byte protocol;
// 
//     private Protocol(int protocol) {
//         this.protocol = (byte) (protocol & 0xFF);
//     }
// }


// Path: library/src/main/java/com/jwoolston/android/uvc/interfaces/InterfaceAssociationDescriptor.java
import com.jwoolston.android.uvc.interfaces.Descriptor.Protocol;
import timber.log.Timber;

package com.jwoolston.android.uvc.interfaces;



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

    private static final int LENGTH_DESCRIPTOR = 8;

    protected static final int bFirstInterface   = 2;
    protected static final int bInterfaceCount   = 3;
    protected static final int bFunctionClass    = 4;
    protected static final int bFunctionSubClass = 5;
    protected static final int bFunctionProtocol = 6;
    protected static final int iFunction         = 7;

    private final int firstInterface;

    private final int interfaceCount;

    private final int indexFunction;

    protected static InterfaceAssociationDescriptor parseIAD(byte[] descriptor) throws IllegalArgumentException {
        Timber.d("Parsing Interface Association Descriptor.");
        if (descriptor.length < LENGTH_DESCRIPTOR) {
            throw new IllegalArgumentException("The provided descriptor is not long enough. Have " + descriptor.length + " need " + LENGTH_DESCRIPTOR);
        }
        if (descriptor[bFunctionClass] == Descriptor.VIDEO_CLASS_CODE) {
            if (descriptor[bFunctionProtocol] != Protocol.PC_PROTOCOL_UNDEFINED.protocol) {