| 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 | |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 23 | import java.lang.annotation.Retention; |
| 24 | import java.lang.annotation.RetentionPolicy; |
| 25 | |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Represents attributes of video calls. |
| 28 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 29 | public class VideoProfile implements Parcelable { |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 30 | |
| 31 | /** @hide */ |
| 32 | @Retention(RetentionPolicy.SOURCE) |
| 33 | @IntDef({QUALITY_UNKNOWN, QUALITY_HIGH, QUALITY_MEDIUM, QUALITY_LOW, QUALITY_DEFAULT}) |
| 34 | public @interface VideoQuality {} |
| 35 | |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 36 | /** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 37 | * "Unknown" video quality. |
| 38 | * @hide |
| 39 | */ |
| 40 | public static final int QUALITY_UNKNOWN = 0; |
| 41 | /** |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 42 | * "High" video quality. |
| 43 | */ |
| 44 | public static final int QUALITY_HIGH = 1; |
| 45 | |
| 46 | /** |
| 47 | * "Medium" video quality. |
| 48 | */ |
| 49 | public static final int QUALITY_MEDIUM = 2; |
| 50 | |
| 51 | /** |
| 52 | * "Low" video quality. |
| 53 | */ |
| 54 | public static final int QUALITY_LOW = 3; |
| 55 | |
| 56 | /** |
| 57 | * Use default video quality. |
| 58 | */ |
| 59 | public static final int QUALITY_DEFAULT = 4; |
| 60 | |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 61 | /** @hide */ |
| 62 | @Retention(RetentionPolicy.SOURCE) |
| 63 | @IntDef( |
| 64 | flag = true, |
| Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 65 | prefix = { "STATE_" }, |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 66 | value = {STATE_AUDIO_ONLY, STATE_TX_ENABLED, STATE_RX_ENABLED, STATE_BIDIRECTIONAL, |
| 67 | STATE_PAUSED}) |
| 68 | public @interface VideoState {} |
| 69 | |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 70 | /** |
| Tyler Gunn | bc6f12e | 2015-06-09 14:34:11 -0700 | [diff] [blame] | 71 | * Used when answering or dialing a call to indicate that the call does not have a video |
| 72 | * component. |
| 73 | * <p> |
| 74 | * Should <b>not</b> be used in comparison checks to determine if a video state represents an |
| 75 | * audio-only call. |
| 76 | * <p> |
| 77 | * The following, for example, is not the correct way to check if a call is audio-only: |
| 78 | * <pre> |
| 79 | * {@code |
| 80 | * // This is the incorrect way to check for an audio-only call. |
| 81 | * if (videoState == VideoProfile.STATE_AUDIO_ONLY) { |
| 82 | * // Handle audio-only call. |
| 83 | * } |
| 84 | * } |
| 85 | * </pre> |
| 86 | * <p> |
| 87 | * Instead, use the {@link VideoProfile#isAudioOnly(int)} helper function to check if a |
| 88 | * video state represents an audio-only call: |
| 89 | * <pre> |
| 90 | * {@code |
| 91 | * // This is the correct way to check for an audio-only call. |
| 92 | * if (VideoProfile.isAudioOnly(videoState)) { |
| 93 | * // Handle audio-only call. |
| 94 | * } |
| 95 | * } |
| 96 | * </pre> |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 97 | */ |
| 98 | public static final int STATE_AUDIO_ONLY = 0x0; |
| 99 | |
| 100 | /** |
| 101 | * Video transmission is enabled. |
| 102 | */ |
| 103 | public static final int STATE_TX_ENABLED = 0x1; |
| 104 | |
| 105 | /** |
| 106 | * Video reception is enabled. |
| 107 | */ |
| 108 | public static final int STATE_RX_ENABLED = 0x2; |
| 109 | |
| 110 | /** |
| 111 | * Video signal is bi-directional. |
| 112 | */ |
| 113 | public static final int STATE_BIDIRECTIONAL = STATE_TX_ENABLED | STATE_RX_ENABLED; |
| 114 | |
| 115 | /** |
| 116 | * Video is paused. |
| 117 | */ |
| 118 | public static final int STATE_PAUSED = 0x4; |
| 119 | |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 120 | private final int mVideoState; |
| 121 | |
| 122 | private final int mQuality; |
| 123 | |
| 124 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 125 | * Creates an instance of the VideoProfile |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 126 | * |
| 127 | * @param videoState The video state. |
| Andrew Lee | 055e5a2 | 2014-07-21 12:14:11 -0700 | [diff] [blame] | 128 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 129 | public VideoProfile(@VideoState int videoState) { |
| Andrew Lee | 055e5a2 | 2014-07-21 12:14:11 -0700 | [diff] [blame] | 130 | this(videoState, QUALITY_DEFAULT); |
| 131 | } |
| 132 | |
| 133 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 134 | * Creates an instance of the VideoProfile |
| Andrew Lee | 055e5a2 | 2014-07-21 12:14:11 -0700 | [diff] [blame] | 135 | * |
| 136 | * @param videoState The video state. |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 137 | * @param quality The video quality. |
| 138 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 139 | public VideoProfile(@VideoState int videoState, @VideoQuality int quality) { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 140 | mVideoState = videoState; |
| 141 | mQuality = quality; |
| 142 | } |
| 143 | |
| 144 | /** |
| Andrew Lee | 48332d6 | 2014-07-28 14:04:20 -0700 | [diff] [blame] | 145 | * The video state of the call. |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 146 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 147 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 148 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 149 | * {@link VideoProfile#STATE_RX_ENABLED}, |
| 150 | * {@link VideoProfile#STATE_PAUSED}. |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 151 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 152 | @VideoState |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 153 | public int getVideoState() { |
| 154 | return mVideoState; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * The desired video quality for the call. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 159 | * Valid values: {@link VideoProfile#QUALITY_HIGH}, {@link VideoProfile#QUALITY_MEDIUM}, |
| 160 | * {@link VideoProfile#QUALITY_LOW}, {@link VideoProfile#QUALITY_DEFAULT}. |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 161 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 162 | @VideoQuality |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 163 | public int getQuality() { |
| 164 | return mQuality; |
| 165 | } |
| 166 | |
| 167 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 168 | * Responsible for creating VideoProfile objects from deserialized Parcels. |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 169 | **/ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 170 | public static final Parcelable.Creator<VideoProfile> CREATOR = |
| 171 | new Parcelable.Creator<VideoProfile> () { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 172 | /** |
| 173 | * Creates a MediaProfile instances from a parcel. |
| 174 | * |
| 175 | * @param source The parcel. |
| 176 | * @return The MediaProfile. |
| 177 | */ |
| 178 | @Override |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 179 | public VideoProfile createFromParcel(Parcel source) { |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 180 | int state = source.readInt(); |
| 181 | int quality = source.readInt(); |
| 182 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 183 | ClassLoader classLoader = VideoProfile.class.getClassLoader(); |
| 184 | return new VideoProfile(state, quality); |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | @Override |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 188 | public VideoProfile[] newArray(int size) { |
| 189 | return new VideoProfile[size]; |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 190 | } |
| 191 | }; |
| 192 | |
| 193 | /** |
| 194 | * Describe the kinds of special objects contained in this Parcelable's |
| 195 | * marshalled representation. |
| 196 | * |
| 197 | * @return a bitmask indicating the set of special object types marshalled |
| 198 | * by the Parcelable. |
| 199 | */ |
| 200 | @Override |
| 201 | public int describeContents() { |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Flatten this object in to a Parcel. |
| 207 | * |
| 208 | * @param dest The Parcel in which the object should be written. |
| 209 | * @param flags Additional flags about how the object should be written. |
| 210 | * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}. |
| 211 | */ |
| 212 | @Override |
| 213 | public void writeToParcel(Parcel dest, int flags) { |
| 214 | dest.writeInt(mVideoState); |
| 215 | dest.writeInt(mQuality); |
| 216 | } |
| Andrew Lee | 48332d6 | 2014-07-28 14:04:20 -0700 | [diff] [blame] | 217 | |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 218 | @Override |
| 219 | public String toString() { |
| 220 | StringBuilder sb = new StringBuilder(); |
| 221 | sb.append("[VideoProfile videoState = "); |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 222 | sb.append(videoStateToString(mVideoState)); |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 223 | sb.append(" videoQuality = "); |
| 224 | sb.append(mQuality); |
| 225 | sb.append("]"); |
| 226 | return sb.toString(); |
| 227 | } |
| 228 | |
| Andrew Lee | 48332d6 | 2014-07-28 14:04:20 -0700 | [diff] [blame] | 229 | /** |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 230 | * Generates a string representation of a video state. |
| 231 | * |
| 232 | * @param videoState The video state. |
| 233 | * @return String representation of the video state. |
| 234 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 235 | public static String videoStateToString(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 236 | StringBuilder sb = new StringBuilder(); |
| 237 | sb.append("Audio"); |
| Andrew Lee | 48332d6 | 2014-07-28 14:04:20 -0700 | [diff] [blame] | 238 | |
| Tyler Gunn | 1aee66f | 2017-02-21 15:19:43 -0800 | [diff] [blame] | 239 | if (videoState == STATE_AUDIO_ONLY) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 240 | sb.append(" Only"); |
| 241 | } else { |
| 242 | if (isTransmissionEnabled(videoState)) { |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 243 | sb.append(" Tx"); |
| 244 | } |
| 245 | |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 246 | if (isReceptionEnabled(videoState)) { |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 247 | sb.append(" Rx"); |
| 248 | } |
| 249 | |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 250 | if (isPaused(videoState)) { |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 251 | sb.append(" Pause"); |
| 252 | } |
| Tyler Gunn | bde0b1e | 2015-04-24 15:09:58 -0700 | [diff] [blame] | 253 | } |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 254 | |
| 255 | return sb.toString(); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Indicates whether the video state is audio only. |
| Tyler Gunn | 1aee66f | 2017-02-21 15:19:43 -0800 | [diff] [blame] | 260 | * <p> |
| 261 | * Note: Considers only whether either both the {@link #STATE_RX_ENABLED} or |
| 262 | * {@link #STATE_TX_ENABLED} bits are off, but not {@link #STATE_PAUSED}. |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 263 | * |
| 264 | * @param videoState The video state. |
| 265 | * @return {@code True} if the video state is audio only, {@code false} otherwise. |
| 266 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 267 | public static boolean isAudioOnly(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 268 | return !hasState(videoState, VideoProfile.STATE_TX_ENABLED) |
| 269 | && !hasState(videoState, VideoProfile.STATE_RX_ENABLED); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Indicates whether video transmission or reception is enabled for a video state. |
| 274 | * |
| 275 | * @param videoState The video state. |
| 276 | * @return {@code True} if video transmission or reception is enabled, {@code false} otherwise. |
| 277 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 278 | public static boolean isVideo(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 279 | return hasState(videoState, VideoProfile.STATE_TX_ENABLED) |
| 280 | || hasState(videoState, VideoProfile.STATE_RX_ENABLED) |
| 281 | || hasState(videoState, VideoProfile.STATE_BIDIRECTIONAL); |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Indicates whether the video state has video transmission enabled. |
| 286 | * |
| 287 | * @param videoState The video state. |
| 288 | * @return {@code True} if video transmission is enabled, {@code false} otherwise. |
| 289 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 290 | public static boolean isTransmissionEnabled(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 291 | return hasState(videoState, VideoProfile.STATE_TX_ENABLED); |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Indicates whether the video state has video reception enabled. |
| 296 | * |
| 297 | * @param videoState The video state. |
| 298 | * @return {@code True} if video reception is enabled, {@code false} otherwise. |
| 299 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 300 | public static boolean isReceptionEnabled(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 301 | return hasState(videoState, VideoProfile.STATE_RX_ENABLED); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Indicates whether the video state is bi-directional. |
| 306 | * |
| 307 | * @param videoState The video state. |
| 308 | * @return {@code True} if the video is bi-directional, {@code false} otherwise. |
| 309 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 310 | public static boolean isBidirectional(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 311 | return hasState(videoState, VideoProfile.STATE_BIDIRECTIONAL); |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Indicates whether the video state is paused. |
| 316 | * |
| 317 | * @param videoState The video state. |
| 318 | * @return {@code True} if the video is paused, {@code false} otherwise. |
| 319 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 320 | public static boolean isPaused(@VideoState int videoState) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 321 | return hasState(videoState, VideoProfile.STATE_PAUSED); |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * Indicates if a specified state is set in a videoState bit-mask. |
| 326 | * |
| 327 | * @param videoState The video state bit-mask. |
| 328 | * @param state The state to check. |
| 329 | * @return {@code True} if the state is set. |
| 330 | */ |
| Tyler Gunn | 48d0210 | 2016-01-08 13:20:25 -0800 | [diff] [blame] | 331 | private static boolean hasState(@VideoState int videoState, @VideoState int state) { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 332 | return (videoState & state) == state; |
| Andrew Lee | 48332d6 | 2014-07-28 14:04:20 -0700 | [diff] [blame] | 333 | } |
| Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 334 | |
| 335 | /** |
| 336 | * Represents the camera capabilities important to a Video Telephony provider. |
| 337 | */ |
| 338 | public static final class CameraCapabilities implements Parcelable { |
| 339 | |
| 340 | /** |
| 341 | * The width of the camera video in pixels. |
| 342 | */ |
| 343 | private final int mWidth; |
| 344 | |
| 345 | /** |
| 346 | * The height of the camera video in pixels. |
| 347 | */ |
| 348 | private final int mHeight; |
| 349 | |
| 350 | /** |
| 351 | * Whether the camera supports zoom. |
| 352 | */ |
| 353 | private final boolean mZoomSupported; |
| 354 | |
| 355 | /** |
| 356 | * The maximum zoom supported by the camera. |
| 357 | */ |
| 358 | private final float mMaxZoom; |
| 359 | |
| 360 | /** |
| 361 | * Create a call camera capabilities instance. |
| 362 | * |
| 363 | * @param width The width of the camera video (in pixels). |
| 364 | * @param height The height of the camera video (in pixels). |
| 365 | */ |
| 366 | public CameraCapabilities(int width, int height) { |
| 367 | this(width, height, false, 1.0f); |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * Create a call camera capabilities instance that optionally |
| 372 | * supports zoom. |
| 373 | * |
| 374 | * @param width The width of the camera video (in pixels). |
| 375 | * @param height The height of the camera video (in pixels). |
| 376 | * @param zoomSupported True when camera supports zoom. |
| 377 | * @param maxZoom Maximum zoom supported by camera. |
| 378 | * @hide |
| 379 | */ |
| 380 | public CameraCapabilities(int width, int height, boolean zoomSupported, float maxZoom) { |
| 381 | mWidth = width; |
| 382 | mHeight = height; |
| 383 | mZoomSupported = zoomSupported; |
| 384 | mMaxZoom = maxZoom; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Responsible for creating CallCameraCapabilities objects from deserialized Parcels. |
| 389 | **/ |
| 390 | public static final Parcelable.Creator<CameraCapabilities> CREATOR = |
| 391 | new Parcelable.Creator<CameraCapabilities> () { |
| 392 | /** |
| 393 | * Creates a CallCameraCapabilities instances from a parcel. |
| 394 | * |
| 395 | * @param source The parcel. |
| 396 | * @return The CallCameraCapabilities. |
| 397 | */ |
| 398 | @Override |
| 399 | public CameraCapabilities createFromParcel(Parcel source) { |
| 400 | int width = source.readInt(); |
| 401 | int height = source.readInt(); |
| 402 | boolean supportsZoom = source.readByte() != 0; |
| 403 | float maxZoom = source.readFloat(); |
| 404 | |
| 405 | return new CameraCapabilities(width, height, supportsZoom, maxZoom); |
| 406 | } |
| 407 | |
| 408 | @Override |
| 409 | public CameraCapabilities[] newArray(int size) { |
| 410 | return new CameraCapabilities[size]; |
| 411 | } |
| 412 | }; |
| 413 | |
| 414 | /** |
| 415 | * Describe the kinds of special objects contained in this Parcelable's |
| 416 | * marshalled representation. |
| 417 | * |
| 418 | * @return a bitmask indicating the set of special object types marshalled |
| 419 | * by the Parcelable. |
| 420 | */ |
| 421 | @Override |
| 422 | public int describeContents() { |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * Flatten this object in to a Parcel. |
| 428 | * |
| 429 | * @param dest The Parcel in which the object should be written. |
| 430 | * @param flags Additional flags about how the object should be written. |
| 431 | * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}. |
| 432 | */ |
| 433 | @Override |
| 434 | public void writeToParcel(Parcel dest, int flags) { |
| 435 | dest.writeInt(getWidth()); |
| 436 | dest.writeInt(getHeight()); |
| 437 | dest.writeByte((byte) (isZoomSupported() ? 1 : 0)); |
| 438 | dest.writeFloat(getMaxZoom()); |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * The width of the camera video in pixels. |
| 443 | */ |
| 444 | public int getWidth() { |
| 445 | return mWidth; |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * The height of the camera video in pixels. |
| 450 | */ |
| 451 | public int getHeight() { |
| 452 | return mHeight; |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Whether the camera supports zoom. |
| 457 | * @hide |
| 458 | */ |
| 459 | public boolean isZoomSupported() { |
| 460 | return mZoomSupported; |
| 461 | } |
| 462 | |
| 463 | /** |
| 464 | * The maximum zoom supported by the camera. |
| 465 | * @hide |
| 466 | */ |
| 467 | public float getMaxZoom() { |
| 468 | return mMaxZoom; |
| 469 | } |
| 470 | } |
| 471 | |
| Tyler Gunn | 7c668b9 | 2014-06-27 14:38:28 -0700 | [diff] [blame] | 472 | } |