blob: 62429569c71efd68f0d72d83fd63ad49324fd60a [file] [log] [blame]
Tyler Gunn7c668b92014-06-27 14:38:28 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Tyler Gunn7c668b92014-06-27 14:38:28 -070018
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * Represents the camera capabilities important to a Video Telephony provider.
Tyler Gunn7c668b92014-06-27 14:38:28 -070024 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070025public final class CameraCapabilities implements Parcelable {
Tyler Gunn7c668b92014-06-27 14:38:28 -070026
27 /**
Tyler Gunn5d231e12014-07-27 14:51:29 -070028 * 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 Shrauner1b057f52015-04-11 12:45:39 -070038 * 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 Shrauner1cf9b6b2015-04-09 15:15:43 -070048 * Create a call camera capabilities instance.
Tyler Gunn7c668b92014-06-27 14:38:28 -070049 *
Tyler Gunn5d231e12014-07-27 14:51:29 -070050 * @param width The width of the camera video (in pixels).
51 * @param height The height of the camera video (in pixels).
Tyler Gunn7c668b92014-06-27 14:38:28 -070052 */
Jay Shrauner1b057f52015-04-11 12:45:39 -070053 public CameraCapabilities(int width, int height) {
54 this(width, height, false, 1.0f);
55 }
56
57 /**
Jay Shrauner1cf9b6b2015-04-09 15:15:43 -070058 * Create a call camera capabilities instance that optionally
59 * supports zoom.
Jay Shrauner1b057f52015-04-11 12:45:39 -070060 *
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 Gunn5d231e12014-07-27 14:51:29 -070068 mWidth = width;
69 mHeight = height;
Jay Shrauner1b057f52015-04-11 12:45:39 -070070 mZoomSupported = zoomSupported;
71 mMaxZoom = maxZoom;
Tyler Gunn7c668b92014-06-27 14:38:28 -070072 }
73
74 /**
75 * Responsible for creating CallCameraCapabilities objects from deserialized Parcels.
76 **/
Ihab Awadb19a0bc2014-08-07 19:46:01 -070077 public static final Parcelable.Creator<CameraCapabilities> CREATOR =
78 new Parcelable.Creator<CameraCapabilities> () {
Tyler Gunn7c668b92014-06-27 14:38:28 -070079 /**
80 * Creates a CallCameraCapabilities instances from a parcel.
81 *
82 * @param source The parcel.
83 * @return The CallCameraCapabilities.
84 */
85 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -070086 public CameraCapabilities createFromParcel(Parcel source) {
Tyler Gunn5d231e12014-07-27 14:51:29 -070087 int width = source.readInt();
88 int height = source.readInt();
Jay Shrauner1b057f52015-04-11 12:45:39 -070089 boolean supportsZoom = source.readByte() != 0;
90 float maxZoom = source.readFloat();
Tyler Gunn7c668b92014-06-27 14:38:28 -070091
Jay Shrauner1b057f52015-04-11 12:45:39 -070092 return new CameraCapabilities(width, height, supportsZoom, maxZoom);
Tyler Gunn7c668b92014-06-27 14:38:28 -070093 }
94
95 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -070096 public CameraCapabilities[] newArray(int size) {
97 return new CameraCapabilities[size];
Tyler Gunn7c668b92014-06-27 14:38:28 -070098 }
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 Gunn5d231e12014-07-27 14:51:29 -0700122 dest.writeInt(getWidth());
123 dest.writeInt(getHeight());
Jay Shrauner1b057f52015-04-11 12:45:39 -0700124 dest.writeByte((byte) (isZoomSupported() ? 1 : 0));
125 dest.writeFloat(getMaxZoom());
Tyler Gunn7c668b92014-06-27 14:38:28 -0700126 }
Tyler Gunn5d231e12014-07-27 14:51:29 -0700127
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 Shrauner1b057f52015-04-11 12:45:39 -0700141
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 Gunn7c668b92014-06-27 14:38:28 -0700157}