blob: 6eaf6a2cb54315c90cfdbb7940015b93a163bdfa [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 Gunnbe74de02014-08-29 14:51:48 -070024 * @hide
Tyler Gunn7c668b92014-06-27 14:38:28 -070025 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070026public final class CameraCapabilities implements Parcelable {
Tyler Gunn7c668b92014-06-27 14:38:28 -070027
28 /**
Tyler Gunn5d231e12014-07-27 14:51:29 -070029 * The width of the camera video in pixels.
30 */
31 private final int mWidth;
32
33 /**
34 * The height of the camera video in pixels.
35 */
36 private final int mHeight;
37
38 /**
Jay Shrauner85d3eec2015-04-11 12:45:39 -070039 * Whether the camera supports zoom.
40 */
41 private final boolean mZoomSupported;
42
43 /**
44 * The maximum zoom supported by the camera.
45 */
46 private final float mMaxZoom;
47
48 /**
49 * Create a call camera capabilities instance that doesn't support zoom.
Tyler Gunn7c668b92014-06-27 14:38:28 -070050 *
Tyler Gunn5d231e12014-07-27 14:51:29 -070051 * @param width The width of the camera video (in pixels).
52 * @param height The height of the camera video (in pixels).
Tyler Gunn7c668b92014-06-27 14:38:28 -070053 */
Jay Shrauner85d3eec2015-04-11 12:45:39 -070054 public CameraCapabilities(int width, int height) {
55 this(width, height, false, 1.0f);
56 }
57
58 /**
59 * Create a call camera capabilities instance.
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 Gunn5d231e12014-07-27 14:51:29 -070068 mWidth = width;
69 mHeight = height;
Jay Shrauner85d3eec2015-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 Shrauner85d3eec2015-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 Shrauner85d3eec2015-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 Shrauner85d3eec2015-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 Shrauner85d3eec2015-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}