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, int minMillis) { 38 mDefaultMillis = defaultMillis; 39 mMaxMillis = maxMillis; 40 mMinMillis = minMillis; 41 } 42 BufferConstraint(Parcel in)43 BufferConstraint(Parcel in) { 44 mDefaultMillis = in.readInt(); 45 mMaxMillis = in.readInt(); 46 mMinMillis = in.readInt(); 47 } 48 49 public static final @NonNull Parcelable.Creator<BufferConstraint> CREATOR = 50 new Parcelable.Creator<BufferConstraint>() { 51 public BufferConstraint createFromParcel(Parcel in) { 52 return new BufferConstraint(in); 53 } 54 55 public BufferConstraint[] newArray(int size) { 56 return new BufferConstraint[size]; 57 } 58 }; 59 60 @Override writeToParcel(@onNull Parcel out, int flags)61 public void writeToParcel(@NonNull Parcel out, int flags) { 62 out.writeInt(mDefaultMillis); 63 out.writeInt(mMaxMillis); 64 out.writeInt(mMinMillis); 65 } 66 67 @Override describeContents()68 public int describeContents() { 69 return 0; 70 } 71 72 /** 73 * Get the default buffer millis 74 * 75 * @return default buffer millis 76 * @hide 77 */ 78 @SystemApi getDefaultMillis()79 public int getDefaultMillis() { 80 return mDefaultMillis; 81 } 82 83 /** 84 * Get the maximum buffer millis 85 * 86 * @return maximum buffer millis 87 * @hide 88 */ 89 @SystemApi getMaxMillis()90 public int getMaxMillis() { 91 return mMaxMillis; 92 } 93 94 /** 95 * Get the minimum buffer millis 96 * 97 * @return minimum buffer millis 98 * @hide 99 */ 100 @SystemApi getMinMillis()101 public int getMinMillis() { 102 return mMinMillis; 103 } 104 } 105