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.4.2.1 Extended Type II Format Type Descriptor 24 */ 25 public final class Usb20ASFormatIIEx extends UsbASFormat { 26 private static final String TAG = "Usb20ASFormatIIEx"; 27 28 // Frmts20.pdf Table 2-7: Extended 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 mSamplesPerFrame; // 6:2 Indicates the number of PCM audio 32 // samples contained in one encoded audio frame. 33 private byte mHeaderLength; // 8:1 Size of the Packet Header, in bytes. 34 private byte mSidebandProtocol; // 9:1 Constant, identifying the Side Band 35 // Protocol used for the Packet Header content. 36 Usb20ASFormatIIEx(int length, byte type, byte subtype, byte formatType, byte subclass)37 public Usb20ASFormatIIEx(int length, byte type, byte subtype, byte formatType, byte subclass) { 38 super(length, type, subtype, formatType, subclass); 39 } 40 getMaxBitRate()41 public int getMaxBitRate() { 42 return mMaxBitRate; 43 } 44 getSamplesPerFrame()45 public int getSamplesPerFrame() { 46 return mSamplesPerFrame; 47 } 48 getHeaderLength()49 public byte getHeaderLength() { 50 return mHeaderLength; 51 } 52 getSidebandProtocol()53 public byte getSidebandProtocol() { 54 return mSidebandProtocol; 55 } 56 57 @Override parseRawDescriptors(ByteStream stream)58 public int parseRawDescriptors(ByteStream stream) { 59 mMaxBitRate = stream.unpackUsbShort(); 60 mSamplesPerFrame = stream.unpackUsbShort(); 61 mHeaderLength = stream.getByte(); 62 mSidebandProtocol = stream.getByte(); 63 64 return mLength; 65 } 66 67 @Override report(ReportCanvas canvas)68 public void report(ReportCanvas canvas) { 69 super.report(canvas); 70 71 canvas.openList(); 72 canvas.writeListItem("Max Bit Rate: " + getMaxBitRate()); 73 canvas.writeListItem("Samples Per Frame: " + getSamplesPerFrame()); 74 canvas.writeListItem("Header Length: " + getHeaderLength()); 75 canvas.writeListItem("Sideband Protocol: " + getSidebandProtocol()); 76 canvas.closeList(); 77 } 78 } 79