Home | History | Annotate | Download | only in descriptors
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.server.usb.descriptors;
     17 
     18 import com.android.server.usb.descriptors.report.ReportCanvas;
     19 
     20 /**
     21  * @hide
     22  * An audio class-specific Format II interface.
     23  * see Frmts20.pdf section 2.3.2.6 Type II Format Type Descriptor
     24  */
     25 public final class Usb20ASFormatII extends UsbASFormat {
     26     private static final String TAG = "Usb20ASFormatII";
     27 
     28     // Frmts20.pdf Table 2-3: Type II Format Type Descriptor
     29     private int mMaxBitRate;    // 4:2 Indicates the maximum number of bits per
     30                                 // second this interface can handle in kbits/s.
     31     private int mSlotsPerFrame; // 6:2 Indicates the number of PCM audio slots
     32                                 // contained in one encoded audio frame.
     33 
     34     /**
     35      * TBD
     36      */
     37     public Usb20ASFormatII(int length, byte type, byte subtype, byte formatType, int subclass) {
     38         super(length, type, subtype, formatType, subclass);
     39     }
     40 
     41     /**
     42      * TBD
     43      */
     44     public int getmaxBitRate() {
     45         return mMaxBitRate;
     46     }
     47 
     48     /**
     49      * TBD
     50      */
     51     public int getSlotsPerFrame() {
     52         return mSlotsPerFrame;
     53     }
     54 
     55     @Override
     56     public int parseRawDescriptors(ByteStream stream) {
     57         mMaxBitRate = stream.unpackUsbShort();
     58         mSlotsPerFrame = stream.unpackUsbShort();
     59 
     60         return mLength;
     61     }
     62 
     63     @Override
     64     public void report(ReportCanvas canvas) {
     65         super.report(canvas);
     66 
     67         canvas.openList();
     68         canvas.writeListItem("Max Bit Rate: " + getmaxBitRate());
     69         canvas.writeListItem("slots Per Frame: " + getSlotsPerFrame());
     70         canvas.closeList();
     71     }
     72 }
     73