1 /*
2  * Copyright (C) 2017 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 
17 package com.android.incallui.videotech;
18 
19 import android.content.Context;
20 import android.support.annotation.NonNull;
21 import android.support.annotation.Nullable;
22 import android.telecom.PhoneAccountHandle;
23 import com.android.dialer.logging.DialerImpression;
24 import com.android.incallui.video.protocol.VideoCallScreen;
25 import com.android.incallui.video.protocol.VideoCallScreenDelegate;
26 import com.android.incallui.videotech.utils.SessionModificationState;
27 
28 /** Video calling interface. */
29 public interface VideoTech {
30 
isAvailable(Context context, PhoneAccountHandle phoneAccountHandle)31   boolean isAvailable(Context context, PhoneAccountHandle phoneAccountHandle);
32 
isTransmittingOrReceiving()33   boolean isTransmittingOrReceiving();
34 
35   /**
36    * Determines if the answer video UI should open the camera directly instead of letting the video
37    * tech manage the camera.
38    */
isSelfManagedCamera()39   boolean isSelfManagedCamera();
40 
shouldUseSurfaceView()41   boolean shouldUseSurfaceView();
42 
43   /**
44    * Returns true if the video is paused. This is different than if the video stream has been turned
45    * off.
46    *
47    * <p>See {@link #isTransmitting()}
48    */
isPaused()49   boolean isPaused();
50 
createVideoCallScreenDelegate( Context context, VideoCallScreen videoCallScreen)51   VideoCallScreenDelegate createVideoCallScreenDelegate(
52       Context context, VideoCallScreen videoCallScreen);
53 
onCallStateChanged(Context context, int newState, PhoneAccountHandle phoneAccountHandle)54   void onCallStateChanged(Context context, int newState, PhoneAccountHandle phoneAccountHandle);
55 
onRemovedFromCallList()56   void onRemovedFromCallList();
57 
58   @SessionModificationState
getSessionModificationState()59   int getSessionModificationState();
60 
upgradeToVideo(@onNull Context context)61   void upgradeToVideo(@NonNull Context context);
62 
acceptVideoRequest(@onNull Context context)63   void acceptVideoRequest(@NonNull Context context);
64 
acceptVideoRequestAsAudio()65   void acceptVideoRequestAsAudio();
66 
declineVideoRequest()67   void declineVideoRequest();
68 
isTransmitting()69   boolean isTransmitting();
70 
stopTransmission()71   void stopTransmission();
72 
resumeTransmission(@onNull Context context)73   void resumeTransmission(@NonNull Context context);
74 
pause()75   void pause();
76 
unpause()77   void unpause();
78 
setCamera(@ullable String cameraId)79   void setCamera(@Nullable String cameraId);
80 
setDeviceOrientation(int rotation)81   void setDeviceOrientation(int rotation);
82 
83   /**
84    * Called on {@code VideoTechManager.savedTech} when it's first selected and it will always be
85    * used.
86    */
becomePrimary()87   void becomePrimary();
88 
getVideoTechType()89   com.android.dialer.logging.VideoTech.Type getVideoTechType();
90 
91   /** Listener for video call events. */
92   interface VideoTechListener {
93 
onVideoTechStateChanged()94     void onVideoTechStateChanged();
95 
onSessionModificationStateChanged()96     void onSessionModificationStateChanged();
97 
onCameraDimensionsChanged(int width, int height)98     void onCameraDimensionsChanged(int width, int height);
99 
onPeerDimensionsChanged(int width, int height)100     void onPeerDimensionsChanged(int width, int height);
101 
onVideoUpgradeRequestReceived()102     void onVideoUpgradeRequestReceived();
103 
onUpgradedToVideo(boolean switchToSpeaker)104     void onUpgradedToVideo(boolean switchToSpeaker);
105 
onImpressionLoggingNeeded(DialerImpression.Type impressionType)106     void onImpressionLoggingNeeded(DialerImpression.Type impressionType);
107   }
108 }
109