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