1 /* 2 * Copyright (C) 2020 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 17 package android.bluetooth; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 /** 25 * Stores a codec's constraints on buffering length in milliseconds. 26 * 27 * {@hide} 28 */ 29 @SystemApi 30 public final class BufferConstraint implements Parcelable { 31 32 private static final String TAG = "BufferConstraint"; 33 private int mDefaultMillis; 34 private int mMaxMillis; 35 private int mMinMillis; 36 BufferConstraint(int defaultMillis, int maxMillis, int minMillis)37 public BufferConstraint(int defaultMillis, int maxMillis, 38 int minMillis) { 39 mDefaultMillis = defaultMillis; 40 mMaxMillis = maxMillis; 41 mMinMillis = minMillis; 42 } 43 BufferConstraint(Parcel in)44 BufferConstraint(Parcel in) { 45 mDefaultMillis = in.readInt(); 46 mMaxMillis = in.readInt(); 47 mMinMillis = in.readInt(); 48 } 49 50 public static final @NonNull Parcelable.Creator<BufferConstraint> CREATOR = 51 new Parcelable.Creator<BufferConstraint>() { 52 public BufferConstraint createFromParcel(Parcel in) { 53 return new BufferConstraint(in); 54 } 55 56 public BufferConstraint[] newArray(int size) { 57 return new BufferConstraint[size]; 58 } 59 }; 60 61 @Override writeToParcel(@onNull Parcel out, int flags)62 public void writeToParcel(@NonNull Parcel out, int flags) { 63 out.writeInt(mDefaultMillis); 64 out.writeInt(mMaxMillis); 65 out.writeInt(mMinMillis); 66 } 67 68 @Override describeContents()69 public int describeContents() { 70 return 0; 71 } 72 73 /** 74 * Get the default buffer millis 75 * 76 * @return default buffer millis 77 * @hide 78 */ 79 @SystemApi getDefaultMillis()80 public int getDefaultMillis() { 81 return mDefaultMillis; 82 } 83 84 /** 85 * Get the maximum buffer millis 86 * 87 * @return maximum buffer millis 88 * @hide 89 */ 90 @SystemApi getMaxMillis()91 public int getMaxMillis() { 92 return mMaxMillis; 93 } 94 95 /** 96 * Get the minimum buffer millis 97 * 98 * @return minimum buffer millis 99 * @hide 100 */ 101 @SystemApi getMinMillis()102 public int getMinMillis() { 103 return mMinMillis; 104 } 105 } 106