| 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 | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 24 | * @hide |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 25 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 26 | public final class CameraCapabilities implements Parcelable { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 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 | /** |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 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 | /** |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 49 | * Create a call camera capabilities instance. |
| 50 | * |
| 51 | * @param zoomSupported True when camera supports zoom. |
| 52 | * @param maxZoom Maximum zoom supported by camera. |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 53 | * @param width The width of the camera video (in pixels). |
| 54 | * @param height The height of the camera video (in pixels). |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 55 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 56 | public CameraCapabilities(boolean zoomSupported, float maxZoom, int width, int height) { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 57 | mZoomSupported = zoomSupported; |
| 58 | mMaxZoom = maxZoom; |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 59 | mWidth = width; |
| 60 | mHeight = height; |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Responsible for creating CallCameraCapabilities objects from deserialized Parcels. |
| 65 | **/ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 66 | public static final Parcelable.Creator<CameraCapabilities> CREATOR = |
| 67 | new Parcelable.Creator<CameraCapabilities> () { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 68 | /** |
| 69 | * Creates a CallCameraCapabilities instances from a parcel. |
| 70 | * |
| 71 | * @param source The parcel. |
| 72 | * @return The CallCameraCapabilities. |
| 73 | */ |
| 74 | @Override |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 75 | public CameraCapabilities createFromParcel(Parcel source) { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 76 | boolean supportsZoom = source.readByte() != 0; |
| 77 | float maxZoom = source.readFloat(); |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 78 | int width = source.readInt(); |
| 79 | int height = source.readInt(); |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 80 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 81 | return new CameraCapabilities(supportsZoom, maxZoom, width, height); |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | @Override |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 85 | public CameraCapabilities[] newArray(int size) { |
| 86 | return new CameraCapabilities[size]; |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 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 |
| 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 |
| 110 | public void writeToParcel(Parcel dest, int flags) { |
| 111 | dest.writeByte((byte) (isZoomSupported() ? 1 : 0)); |
| 112 | dest.writeFloat(getMaxZoom()); |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 113 | dest.writeInt(getWidth()); |
| 114 | dest.writeInt(getHeight()); |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Whether the camera supports zoom. |
| 119 | */ |
| 120 | public boolean isZoomSupported() { |
| 121 | return mZoomSupported; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * The maximum zoom supported by the camera. |
| 126 | */ |
| 127 | public float getMaxZoom() { |
| 128 | return mMaxZoom; |
| 129 | } |
| Tyler Gunn | 5d231e1 | 2014-07-27 14:51:29 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * The width of the camera video in pixels. |
| 133 | */ |
| 134 | public int getWidth() { |
| 135 | return mWidth; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * The height of the camera video in pixels. |
| 140 | */ |
| 141 | public int getHeight() { |
| 142 | return mHeight; |
| 143 | } |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 144 | } |