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