Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -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; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 18 | |
Mathew Inwood | 42346d1 | 2018-08-01 11:33:05 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 20 | import android.net.Uri; |
Tyler Gunn | 17933eb | 2019-03-05 13:58:45 -0800 | [diff] [blame^] | 21 | import android.os.Build; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 22 | import android.os.Handler; |
| 23 | import android.os.IBinder; |
| 24 | import android.os.Looper; |
| 25 | import android.os.Message; |
| 26 | import android.os.RemoteException; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 27 | import android.telecom.InCallService.VideoCall; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 28 | import android.view.Surface; |
| 29 | |
Brad Ebinger | 0d55a30 | 2017-03-20 13:16:28 -0700 | [diff] [blame] | 30 | import com.android.internal.annotations.VisibleForTesting; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 31 | import com.android.internal.os.SomeArgs; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 32 | import com.android.internal.telecom.IVideoCallback; |
| 33 | import com.android.internal.telecom.IVideoProvider; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Implementation of a Video Call, which allows InCallUi to communicate commands to the underlying |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 37 | * {@link Connection.VideoProvider}, and direct callbacks from the |
| 38 | * {@link Connection.VideoProvider} to the appropriate {@link VideoCall.Listener}. |
| 39 | * |
| 40 | * {@hide} |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 41 | */ |
| 42 | public class VideoCallImpl extends VideoCall { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 43 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 44 | private final IVideoProvider mVideoProvider; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 45 | private final VideoCallListenerBinder mBinder; |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 46 | private VideoCall.Callback mCallback; |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 47 | private int mVideoQuality = VideoProfile.QUALITY_UNKNOWN; |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 48 | private int mVideoState = VideoProfile.STATE_AUDIO_ONLY; |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 49 | private final String mCallingPackageName; |
Brad Ebinger | 0d55a30 | 2017-03-20 13:16:28 -0700 | [diff] [blame] | 50 | |
| 51 | private int mTargetSdkVersion; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 52 | |
| 53 | private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() { |
| 54 | @Override |
| 55 | public void binderDied() { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 56 | mVideoProvider.asBinder().unlinkToDeath(this, 0); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 57 | } |
| 58 | }; |
| 59 | |
| 60 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 61 | * IVideoCallback stub implementation. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 62 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 63 | private final class VideoCallListenerBinder extends IVideoCallback.Stub { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 64 | @Override |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 65 | public void receiveSessionModifyRequest(VideoProfile videoProfile) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 66 | if (mHandler == null) { |
| 67 | return; |
| 68 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 69 | mHandler.obtainMessage(MessageHandler.MSG_RECEIVE_SESSION_MODIFY_REQUEST, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 70 | videoProfile).sendToTarget(); |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 71 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | @Override |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 75 | public void receiveSessionModifyResponse(int status, VideoProfile requestProfile, |
| 76 | VideoProfile responseProfile) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 77 | if (mHandler == null) { |
| 78 | return; |
| 79 | } |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 80 | SomeArgs args = SomeArgs.obtain(); |
| 81 | args.arg1 = status; |
| 82 | args.arg2 = requestProfile; |
| 83 | args.arg3 = responseProfile; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 84 | mHandler.obtainMessage(MessageHandler.MSG_RECEIVE_SESSION_MODIFY_RESPONSE, args) |
| 85 | .sendToTarget(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public void handleCallSessionEvent(int event) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 90 | if (mHandler == null) { |
| 91 | return; |
| 92 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 93 | mHandler.obtainMessage(MessageHandler.MSG_HANDLE_CALL_SESSION_EVENT, event) |
| 94 | .sendToTarget(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public void changePeerDimensions(int width, int height) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 99 | if (mHandler == null) { |
| 100 | return; |
| 101 | } |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 102 | SomeArgs args = SomeArgs.obtain(); |
| 103 | args.arg1 = width; |
| 104 | args.arg2 = height; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 105 | mHandler.obtainMessage(MessageHandler.MSG_CHANGE_PEER_DIMENSIONS, args).sendToTarget(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | @Override |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 109 | public void changeVideoQuality(int videoQuality) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 110 | if (mHandler == null) { |
| 111 | return; |
| 112 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 113 | mHandler.obtainMessage(MessageHandler.MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0) |
| 114 | .sendToTarget(); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public void changeCallDataUsage(long dataUsage) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 119 | if (mHandler == null) { |
| 120 | return; |
| 121 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 122 | mHandler.obtainMessage(MessageHandler.MSG_CHANGE_CALL_DATA_USAGE, dataUsage) |
| 123 | .sendToTarget(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | @Override |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 127 | public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) { |
Tyler Gunn | e988cf7 | 2015-05-28 15:47:06 -0700 | [diff] [blame] | 128 | if (mHandler == null) { |
| 129 | return; |
| 130 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 131 | mHandler.obtainMessage(MessageHandler.MSG_CHANGE_CAMERA_CAPABILITIES, |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 132 | cameraCapabilities).sendToTarget(); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /** Default handler used to consolidate binder method calls onto a single thread. */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 137 | private final class MessageHandler extends Handler { |
| 138 | private static final int MSG_RECEIVE_SESSION_MODIFY_REQUEST = 1; |
| 139 | private static final int MSG_RECEIVE_SESSION_MODIFY_RESPONSE = 2; |
| 140 | private static final int MSG_HANDLE_CALL_SESSION_EVENT = 3; |
| 141 | private static final int MSG_CHANGE_PEER_DIMENSIONS = 4; |
| 142 | private static final int MSG_CHANGE_CALL_DATA_USAGE = 5; |
| 143 | private static final int MSG_CHANGE_CAMERA_CAPABILITIES = 6; |
| 144 | private static final int MSG_CHANGE_VIDEO_QUALITY = 7; |
| 145 | |
| 146 | public MessageHandler(Looper looper) { |
| 147 | super(looper); |
| 148 | } |
| 149 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 150 | @Override |
| 151 | public void handleMessage(Message msg) { |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 152 | if (mCallback == null) { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 153 | return; |
| 154 | } |
| 155 | |
| 156 | SomeArgs args; |
| 157 | switch (msg.what) { |
| 158 | case MSG_RECEIVE_SESSION_MODIFY_REQUEST: |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 159 | mCallback.onSessionModifyRequestReceived((VideoProfile) msg.obj); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 160 | break; |
| 161 | case MSG_RECEIVE_SESSION_MODIFY_RESPONSE: |
| 162 | args = (SomeArgs) msg.obj; |
| 163 | try { |
| 164 | int status = (int) args.arg1; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 165 | VideoProfile requestProfile = (VideoProfile) args.arg2; |
| 166 | VideoProfile responseProfile = (VideoProfile) args.arg3; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 167 | |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 168 | mCallback.onSessionModifyResponseReceived( |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 169 | status, requestProfile, responseProfile); |
| 170 | } finally { |
| 171 | args.recycle(); |
| 172 | } |
| 173 | break; |
| 174 | case MSG_HANDLE_CALL_SESSION_EVENT: |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 175 | mCallback.onCallSessionEvent((int) msg.obj); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 176 | break; |
| 177 | case MSG_CHANGE_PEER_DIMENSIONS: |
| 178 | args = (SomeArgs) msg.obj; |
| 179 | try { |
| 180 | int width = (int) args.arg1; |
| 181 | int height = (int) args.arg2; |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 182 | mCallback.onPeerDimensionsChanged(width, height); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 183 | } finally { |
| 184 | args.recycle(); |
| 185 | } |
| 186 | break; |
| 187 | case MSG_CHANGE_CALL_DATA_USAGE: |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 188 | mCallback.onCallDataUsageChanged((long) msg.obj); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 189 | break; |
| 190 | case MSG_CHANGE_CAMERA_CAPABILITIES: |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 191 | mCallback.onCameraCapabilitiesChanged( |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 192 | (VideoProfile.CameraCapabilities) msg.obj); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 193 | break; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 194 | case MSG_CHANGE_VIDEO_QUALITY: |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 195 | mVideoQuality = msg.arg1; |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 196 | mCallback.onVideoQualityChanged(msg.arg1); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 197 | break; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 198 | default: |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | }; |
| 203 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 204 | private Handler mHandler; |
| 205 | |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 206 | VideoCallImpl(IVideoProvider videoProvider, String callingPackageName, int targetSdkVersion) |
| 207 | throws RemoteException { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 208 | mVideoProvider = videoProvider; |
| 209 | mVideoProvider.asBinder().linkToDeath(mDeathRecipient, 0); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 210 | |
| 211 | mBinder = new VideoCallListenerBinder(); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 212 | mVideoProvider.addVideoCallback(mBinder); |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 213 | mCallingPackageName = callingPackageName; |
Brad Ebinger | 0d55a30 | 2017-03-20 13:16:28 -0700 | [diff] [blame] | 214 | setTargetSdkVersion(targetSdkVersion); |
| 215 | } |
| 216 | |
| 217 | @VisibleForTesting |
| 218 | public void setTargetSdkVersion(int sdkVersion) { |
| 219 | mTargetSdkVersion = sdkVersion; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Tyler Gunn | 17933eb | 2019-03-05 13:58:45 -0800 | [diff] [blame^] | 222 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 127403196) |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 223 | public void destroy() { |
| 224 | unregisterCallback(mCallback); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | /** {@inheritDoc} */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 228 | public void registerCallback(VideoCall.Callback callback) { |
| 229 | registerCallback(callback, null); |
| 230 | } |
| 231 | |
| 232 | /** {@inheritDoc} */ |
| 233 | public void registerCallback(VideoCall.Callback callback, Handler handler) { |
| 234 | mCallback = callback; |
| 235 | if (handler == null) { |
| 236 | mHandler = new MessageHandler(Looper.getMainLooper()); |
| 237 | } else { |
| 238 | mHandler = new MessageHandler(handler.getLooper()); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /** {@inheritDoc} */ |
| 243 | public void unregisterCallback(VideoCall.Callback callback) { |
| 244 | if (callback != mCallback) { |
| 245 | return; |
| 246 | } |
| 247 | |
Etan Cohen | 8942724 | 2015-04-23 12:26:37 -0700 | [diff] [blame] | 248 | mCallback = null; |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 249 | try { |
| 250 | mVideoProvider.removeVideoCallback(mBinder); |
| 251 | } catch (RemoteException e) { |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /** {@inheritDoc} */ |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 256 | public void setCamera(String cameraId) { |
| 257 | try { |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 258 | Log.w(this, "setCamera: cameraId=%s, calling=%s", cameraId, mCallingPackageName); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 259 | mVideoProvider.setCamera(cameraId, mCallingPackageName, mTargetSdkVersion); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 260 | } catch (RemoteException e) { |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /** {@inheritDoc} */ |
| 265 | public void setPreviewSurface(Surface surface) { |
| 266 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 267 | mVideoProvider.setPreviewSurface(surface); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 268 | } catch (RemoteException e) { |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | /** {@inheritDoc} */ |
| 273 | public void setDisplaySurface(Surface surface) { |
| 274 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 275 | mVideoProvider.setDisplaySurface(surface); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 276 | } catch (RemoteException e) { |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** {@inheritDoc} */ |
| 281 | public void setDeviceOrientation(int rotation) { |
| 282 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 283 | mVideoProvider.setDeviceOrientation(rotation); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 284 | } catch (RemoteException e) { |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /** {@inheritDoc} */ |
| 289 | public void setZoom(float value) { |
| 290 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 291 | mVideoProvider.setZoom(value); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 292 | } catch (RemoteException e) { |
| 293 | } |
| 294 | } |
| 295 | |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 296 | /** |
| 297 | * Sends a session modification request to the video provider. |
| 298 | * <p> |
| 299 | * The {@link InCallService} will create the {@code requestProfile} based on the current |
| 300 | * video state (i.e. {@link Call.Details#getVideoState()}). It is, however, possible that the |
| 301 | * video state maintained by the {@link InCallService} could get out of sync with what is known |
| 302 | * by the {@link android.telecom.Connection.VideoProvider}. To remove ambiguity, the |
| 303 | * {@link VideoCallImpl} passes along the pre-modify video profile to the {@code VideoProvider} |
| 304 | * to ensure it has full context of the requested change. |
| 305 | * |
| 306 | * @param requestProfile The requested video profile. |
| 307 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 308 | public void sendSessionModifyRequest(VideoProfile requestProfile) { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 309 | try { |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 310 | VideoProfile originalProfile = new VideoProfile(mVideoState, mVideoQuality); |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 311 | |
| 312 | mVideoProvider.sendSessionModifyRequest(originalProfile, requestProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 313 | } catch (RemoteException e) { |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /** {@inheritDoc} */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 318 | public void sendSessionModifyResponse(VideoProfile responseProfile) { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 319 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 320 | mVideoProvider.sendSessionModifyResponse(responseProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 321 | } catch (RemoteException e) { |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | /** {@inheritDoc} */ |
| 326 | public void requestCameraCapabilities() { |
| 327 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 328 | mVideoProvider.requestCameraCapabilities(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 329 | } catch (RemoteException e) { |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /** {@inheritDoc} */ |
| 334 | public void requestCallDataUsage() { |
| 335 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 336 | mVideoProvider.requestCallDataUsage(); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 337 | } catch (RemoteException e) { |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** {@inheritDoc} */ |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 342 | public void setPauseImage(Uri uri) { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 343 | try { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 344 | mVideoProvider.setPauseImage(uri); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 345 | } catch (RemoteException e) { |
| 346 | } |
| 347 | } |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 348 | |
| 349 | /** |
| 350 | * Sets the video state for the current video call. |
| 351 | * @param videoState the new video state. |
| 352 | */ |
| 353 | public void setVideoState(int videoState) { |
| 354 | mVideoState = videoState; |
| 355 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 356 | } |