1 /* 2 * Copyright (C) 2014 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.telecom; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * Represents the camera capabilities important to a Video Telephony provider. 24 * @hide 25 */ 26 public final class CameraCapabilities implements Parcelable { 27 28 /** 29 * Whether the camera supports zoom. 30 */ 31 private final boolean mZoomSupported; 32 33 /** 34 * The maximum zoom supported by the camera. 35 */ 36 private final float mMaxZoom; 37 38 /** 39 * The width of the camera video in pixels. 40 */ 41 private final int mWidth; 42 43 /** 44 * The height of the camera video in pixels. 45 */ 46 private final int mHeight; 47 48 /** 49 * Create a call camera capabilities instance. 50 * 51 * @param zoomSupported True when camera supports zoom. 52 * @param maxZoom Maximum zoom supported by camera. 53 * @param width The width of the camera video (in pixels). 54 * @param height The height of the camera video (in pixels). 55 */ CameraCapabilities(boolean zoomSupported, float maxZoom, int width, int height)56 public CameraCapabilities(boolean zoomSupported, float maxZoom, int width, int height) { 57 mZoomSupported = zoomSupported; 58 mMaxZoom = maxZoom; 59 mWidth = width; 60 mHeight = height; 61 } 62 63 /** 64 * Responsible for creating CallCameraCapabilities objects from deserialized Parcels. 65 **/ 66 public static final Parcelable.Creator<CameraCapabilities> CREATOR = 67 new Parcelable.Creator<CameraCapabilities> () { 68 /** 69 * Creates a CallCameraCapabilities instances from a parcel. 70 * 71 * @param source The parcel. 72 * @return The CallCameraCapabilities. 73 */ 74 @Override 75 public CameraCapabilities createFromParcel(Parcel source) { 76 boolean supportsZoom = source.readByte() != 0; 77 float maxZoom = source.readFloat(); 78 int width = source.readInt(); 79 int height = source.readInt(); 80 81 return new CameraCapabilities(supportsZoom, maxZoom, width, height); 82 } 83 84 @Override 85 public CameraCapabilities[] newArray(int size) { 86 return new CameraCapabilities[size]; 87 } 88 }; 89 90 /** 91 * Describe the kinds of special objects contained in this Parcelable's 92 * marshalled representation. 93 * 94 * @return a bitmask indicating the set of special object types marshalled 95 * by the Parcelable. 96 */ 97 @Override describeContents()98 public int describeContents() { 99 return 0; 100 } 101 102 /** 103 * Flatten this object in to a Parcel. 104 * 105 * @param dest The Parcel in which the object should be written. 106 * @param flags Additional flags about how the object should be written. 107 * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}. 108 */ 109 @Override writeToParcel(Parcel dest, int flags)110 public void writeToParcel(Parcel dest, int flags) { 111 dest.writeByte((byte) (isZoomSupported() ? 1 : 0)); 112 dest.writeFloat(getMaxZoom()); 113 dest.writeInt(getWidth()); 114 dest.writeInt(getHeight()); 115 } 116 117 /** 118 * Whether the camera supports zoom. 119 */ isZoomSupported()120 public boolean isZoomSupported() { 121 return mZoomSupported; 122 } 123 124 /** 125 * The maximum zoom supported by the camera. 126 */ getMaxZoom()127 public float getMaxZoom() { 128 return mMaxZoom; 129 } 130 131 /** 132 * The width of the camera video in pixels. 133 */ getWidth()134 public int getWidth() { 135 return mWidth; 136 } 137 138 /** 139 * The height of the camera video in pixels. 140 */ getHeight()141 public int getHeight() { 142 return mHeight; 143 } 144 } 145