blob: f968c13aa3582d4d5d103c70c476c7ce196c3385 [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 /**
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 Gunn5d231e12014-07-27 14:51:29 -070039 * 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 Gunn7c668b92014-06-27 14:38:28 -070049 * Create a call camera capabilities instance.
50 *
51 * @param zoomSupported True when camera supports zoom.
52 * @param maxZoom Maximum zoom supported by camera.
Tyler Gunn5d231e12014-07-27 14:51:29 -070053 * @param width The width of the camera video (in pixels).
54 * @param height The height of the camera video (in pixels).
Tyler Gunn7c668b92014-06-27 14:38:28 -070055 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -070056 public CameraCapabilities(boolean zoomSupported, float maxZoom, int width, int height) {
Tyler Gunn7c668b92014-06-27 14:38:28 -070057 mZoomSupported = zoomSupported;
58 mMaxZoom = maxZoom;
Tyler Gunn5d231e12014-07-27 14:51:29 -070059 mWidth = width;
60 mHeight = height;
Tyler Gunn7c668b92014-06-27 14:38:28 -070061 }
62
63 /**
64 * Responsible for creating CallCameraCapabilities objects from deserialized Parcels.
65 **/
Ihab Awadb19a0bc2014-08-07 19:46:01 -070066 public static final Parcelable.Creator<CameraCapabilities> CREATOR =
67 new Parcelable.Creator<CameraCapabilities> () {
Tyler Gunn7c668b92014-06-27 14:38:28 -070068 /**
69 * Creates a CallCameraCapabilities instances from a parcel.
70 *
71 * @param source The parcel.
72 * @return The CallCameraCapabilities.
73 */
74 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -070075 public CameraCapabilities createFromParcel(Parcel source) {
Tyler Gunn7c668b92014-06-27 14:38:28 -070076 boolean supportsZoom = source.readByte() != 0;
77 float maxZoom = source.readFloat();
Tyler Gunn5d231e12014-07-27 14:51:29 -070078 int width = source.readInt();
79 int height = source.readInt();
Tyler Gunn7c668b92014-06-27 14:38:28 -070080
Ihab Awadb19a0bc2014-08-07 19:46:01 -070081 return new CameraCapabilities(supportsZoom, maxZoom, width, height);
Tyler Gunn7c668b92014-06-27 14:38:28 -070082 }
83
84 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -070085 public CameraCapabilities[] newArray(int size) {
86 return new CameraCapabilities[size];
Tyler Gunn7c668b92014-06-27 14:38:28 -070087 }
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 Gunn5d231e12014-07-27 14:51:29 -0700113 dest.writeInt(getWidth());
114 dest.writeInt(getHeight());
Tyler Gunn7c668b92014-06-27 14:38:28 -0700115 }
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 Gunn5d231e12014-07-27 14:51:29 -0700130
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 Gunn7c668b92014-06-27 14:38:28 -0700144}