| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.telecom; |
| 18 |
|
| 19 |
import com.android.internal.os.SomeArgs; |
| 20 |
import com.android.internal.telecom.IVideoCallback; |
| 21 |
|
| 22 |
import android.os.Handler; |
| 23 |
import android.os.Message; |
| 24 |
import android.os.RemoteException; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
final class VideoCallbackServant { |
| 35 |
private static final int MSG_RECEIVE_SESSION_MODIFY_REQUEST = 0; |
| 36 |
private static final int MSG_RECEIVE_SESSION_MODIFY_RESPONSE = 1; |
| 37 |
private static final int MSG_HANDLE_CALL_SESSION_EVENT = 2; |
| 38 |
private static final int MSG_CHANGE_PEER_DIMENSIONS = 3; |
| 39 |
private static final int MSG_CHANGE_CALL_DATA_USAGE = 4; |
| 40 |
private static final int MSG_CHANGE_CAMERA_CAPABILITIES = 5; |
| 41 |
private static final int MSG_CHANGE_VIDEO_QUALITY = 6; |
| 42 |
|
| 43 |
private final IVideoCallback mDelegate; |
| 44 |
|
| 45 |
private final Handler mHandler = new Handler() { |
| 46 |
@Override |
| 47 |
public void handleMessage(Message msg) { |
| 48 |
try { |
| 49 |
internalHandleMessage(msg); |
| 50 |
} catch (RemoteException e) { |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
private void internalHandleMessage(Message msg) throws RemoteException { |
| 56 |
switch (msg.what) { |
| 57 |
case MSG_RECEIVE_SESSION_MODIFY_REQUEST: { |
| 58 |
mDelegate.receiveSessionModifyRequest((VideoProfile) msg.obj); |
| 59 |
break; |
| 60 |
} |
| 61 |
case MSG_RECEIVE_SESSION_MODIFY_RESPONSE: { |
| 62 |
SomeArgs args = (SomeArgs) msg.obj; |
| 63 |
try { |
| 64 |
mDelegate.receiveSessionModifyResponse( |
| 65 |
args.argi1, |
| 66 |
(VideoProfile) args.arg1, |
| 67 |
(VideoProfile) args.arg2); |
| 68 |
} finally { |
| 69 |
args.recycle(); |
| 70 |
} |
| 71 |
break; |
| 72 |
} |
| 73 |
case MSG_HANDLE_CALL_SESSION_EVENT: { |
| 74 |
SomeArgs args = (SomeArgs) msg.obj; |
| 75 |
try { |
| 76 |
mDelegate.handleCallSessionEvent(args.argi1); |
| 77 |
} finally { |
| 78 |
args.recycle(); |
| 79 |
} |
| 80 |
break; |
| 81 |
} |
| 82 |
case MSG_CHANGE_PEER_DIMENSIONS: { |
| 83 |
SomeArgs args = (SomeArgs) msg.obj; |
| 84 |
try { |
| 85 |
mDelegate.changePeerDimensions(args.argi1, args.argi2); |
| 86 |
} finally { |
| 87 |
args.recycle(); |
| 88 |
} |
| 89 |
break; |
| 90 |
} |
| 91 |
case MSG_CHANGE_CALL_DATA_USAGE: { |
| 92 |
SomeArgs args = (SomeArgs) msg.obj; |
| 93 |
try { |
| 94 |
mDelegate.changeCallDataUsage((long) args.arg1); |
| 95 |
} finally { |
| 96 |
args.recycle(); |
| 97 |
} |
| 98 |
break; |
| 99 |
} |
| 100 |
case MSG_CHANGE_CAMERA_CAPABILITIES: { |
| 101 |
mDelegate.changeCameraCapabilities((VideoProfile.CameraCapabilities) msg.obj); |
| 102 |
break; |
| 103 |
} |
| 104 |
case MSG_CHANGE_VIDEO_QUALITY: { |
| 105 |
mDelegate.changeVideoQuality(msg.arg1); |
| 106 |
break; |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
}; |
| 111 |
|
| 112 |
private final IVideoCallback mStub = new IVideoCallback.Stub() { |
| 113 |
@Override |
| 114 |
public void receiveSessionModifyRequest(VideoProfile videoProfile) throws RemoteException { |
| 115 |
mHandler.obtainMessage(MSG_RECEIVE_SESSION_MODIFY_REQUEST, videoProfile).sendToTarget(); |
| 116 |
} |
| 117 |
|
| 118 |
@Override |
| 119 |
public void receiveSessionModifyResponse(int status, VideoProfile requestedProfile, |
| 120 |
VideoProfile responseProfile) throws RemoteException { |
| 121 |
SomeArgs args = SomeArgs.obtain(); |
| 122 |
args.argi1 = status; |
| 123 |
args.arg1 = requestedProfile; |
| 124 |
args.arg2 = responseProfile; |
| 125 |
mHandler.obtainMessage(MSG_RECEIVE_SESSION_MODIFY_RESPONSE, args).sendToTarget(); |
| 126 |
} |
| 127 |
|
| 128 |
@Override |
| 129 |
public void handleCallSessionEvent(int event) throws RemoteException { |
| 130 |
SomeArgs args = SomeArgs.obtain(); |
| 131 |
args.argi1 = event; |
| 132 |
mHandler.obtainMessage(MSG_HANDLE_CALL_SESSION_EVENT, args).sendToTarget(); |
| 133 |
} |
| 134 |
|
| 135 |
@Override |
| 136 |
public void changePeerDimensions(int width, int height) throws RemoteException { |
| 137 |
SomeArgs args = SomeArgs.obtain(); |
| 138 |
args.argi1 = width; |
| 139 |
args.argi2 = height; |
| 140 |
mHandler.obtainMessage(MSG_CHANGE_PEER_DIMENSIONS, args).sendToTarget(); |
| 141 |
} |
| 142 |
|
| 143 |
@Override |
| 144 |
public void changeCallDataUsage(long dataUsage) throws RemoteException { |
| 145 |
SomeArgs args = SomeArgs.obtain(); |
| 146 |
args.arg1 = dataUsage; |
| 147 |
mHandler.obtainMessage(MSG_CHANGE_CALL_DATA_USAGE, args).sendToTarget(); |
| 148 |
} |
| 149 |
|
| 150 |
@Override |
| 151 |
public void changeCameraCapabilities( |
| 152 |
VideoProfile.CameraCapabilities cameraCapabilities) |
| 153 |
throws RemoteException { |
| 154 |
mHandler.obtainMessage(MSG_CHANGE_CAMERA_CAPABILITIES, cameraCapabilities) |
| 155 |
.sendToTarget(); |
| 156 |
} |
| 157 |
|
| 158 |
@Override |
| 159 |
public void changeVideoQuality(int videoQuality) throws RemoteException { |
| 160 |
mHandler.obtainMessage(MSG_CHANGE_VIDEO_QUALITY, videoQuality, 0).sendToTarget(); |
| 161 |
} |
| 162 |
}; |
| 163 |
|
| 164 |
public VideoCallbackServant(IVideoCallback delegate) { |
| 165 |
mDelegate = delegate; |
| 166 |
} |
| 167 |
|
| 168 |
public IVideoCallback getStub() { |
| 169 |
return mStub; |
| 170 |
} |
| 171 |
} |