use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.
the class GroupPreJoinActionProcessor method handlePreJoinCall.
@Override
@NonNull
protected WebRtcServiceState handlePreJoinCall(@NonNull WebRtcServiceState currentState, @NonNull RemotePeer remotePeer) {
Log.i(TAG, "handlePreJoinCall():");
byte[] groupId = currentState.getCallInfoState().getCallRecipient().requireGroupId().getDecodedId();
GroupCall groupCall = webRtcInteractor.getCallManager().createGroupCall(groupId, SignalStore.internalValues().groupCallingServer(), new byte[0], null, AudioProcessingMethodSelector.get(), webRtcInteractor.getGroupCallObserver());
try {
groupCall.setOutgoingAudioMuted(true);
groupCall.setOutgoingVideoMuted(true);
groupCall.setBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType()));
Log.i(TAG, "Connecting to group call: " + currentState.getCallInfoState().getCallRecipient().getId());
groupCall.connect();
} catch (CallException e) {
return groupCallFailure(currentState, "Unable to connect to group call", e);
}
SignalStore.tooltips().markGroupCallingLobbyEntered();
return currentState.builder().changeCallInfoState().groupCall(groupCall).groupCallState(WebRtcViewModel.GroupCallState.DISCONNECTED).activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID)).build();
}
use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.
the class SignalCallManager method onSendHttpRequest.
@Override
public void onSendHttpRequest(long requestId, @NonNull String url, @NonNull CallManager.HttpMethod httpMethod, @Nullable List<HttpHeader> headers, @Nullable byte[] body) {
if (callManager == null) {
Log.w(TAG, "Unable to send http request, call manager is not initialized");
return;
}
Log.i(TAG, "onSendHttpRequest(): request_id: " + requestId);
networkExecutor.execute(() -> {
List<Pair<String, String>> headerPairs;
if (headers != null) {
headerPairs = Stream.of(headers).map(header -> new Pair<>(header.getName(), header.getValue())).toList();
} else {
headerPairs = Collections.emptyList();
}
CallingResponse response = messageSender.makeCallingRequest(requestId, url, httpMethod.name(), headerPairs, body);
try {
if (response instanceof CallingResponse.Success) {
CallingResponse.Success success = (CallingResponse.Success) response;
callManager.receivedHttpResponse(requestId, success.getResponseStatus(), success.getResponseBody());
} else {
callManager.httpRequestFailed(requestId);
}
} catch (CallException e) {
Log.i(TAG, "Failed to process HTTP response/failure", e);
}
});
}
use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.
the class SignalCallManager method process.
private void process(@NonNull ProcessAction action) {
Throwable t = new Throwable();
String caller = t.getStackTrace().length > 1 ? t.getStackTrace()[1].getMethodName() : "unknown";
if (callManager == null) {
Log.w(TAG, "Unable to process action, call manager is not initialized");
return;
}
serviceExecutor.execute(() -> {
if (needsToSetSelfUuid) {
try {
callManager.setSelfUuid(Recipient.self().requireServiceId().uuid());
needsToSetSelfUuid = false;
} catch (CallException e) {
Log.w(TAG, "Unable to set self UUID on CallManager", e);
}
}
Log.v(TAG, "Processing action: " + caller + ", handler: " + serviceState.getActionProcessor().getTag());
WebRtcServiceState previous = serviceState;
serviceState = action.process(previous, previous.getActionProcessor());
if (previous != serviceState) {
if (serviceState.getCallInfoState().getCallState() != WebRtcViewModel.State.IDLE) {
postStateUpdate(serviceState);
}
}
});
}
use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.
the class SignalCallManager method onCallEvent.
@Override
public void onCallEvent(@Nullable Remote remote, @NonNull CallManager.CallEvent event) {
if (callManager == null) {
Log.w(TAG, "Unable to process call event, call manager is not initialized");
return;
}
if (!(remote instanceof RemotePeer)) {
return;
}
process((s, p) -> {
RemotePeer remotePeer = (RemotePeer) remote;
if (s.getCallInfoState().getPeer(remotePeer.hashCode()) == null) {
Log.w(TAG, "remotePeer not found in map with key: " + remotePeer.hashCode() + "! Dropping.");
try {
callManager.drop(remotePeer.getCallId());
} catch (CallException e) {
return p.callFailure(s, "callManager.drop() failed: ", e);
}
return s;
}
Log.i(TAG, "onCallEvent(): call_id: " + remotePeer.getCallId() + ", state: " + remotePeer.getState() + ", event: " + event);
switch(event) {
case LOCAL_RINGING:
return p.handleLocalRinging(s, remotePeer);
case REMOTE_RINGING:
return p.handleRemoteRinging(s, remotePeer);
case RECONNECTING:
Log.i(TAG, "Reconnecting: NOT IMPLEMENTED");
break;
case RECONNECTED:
Log.i(TAG, "Reconnected: NOT IMPLEMENTED");
break;
case LOCAL_CONNECTED:
case REMOTE_CONNECTED:
return p.handleCallConnected(s, remotePeer);
case REMOTE_VIDEO_ENABLE:
return p.handleRemoteVideoEnable(s, true);
case REMOTE_VIDEO_DISABLE:
return p.handleRemoteVideoEnable(s, false);
case REMOTE_SHARING_SCREEN_ENABLE:
return p.handleScreenSharingEnable(s, true);
case REMOTE_SHARING_SCREEN_DISABLE:
return p.handleScreenSharingEnable(s, false);
case ENDED_REMOTE_HANGUP:
case ENDED_REMOTE_HANGUP_NEED_PERMISSION:
case ENDED_REMOTE_HANGUP_ACCEPTED:
case ENDED_REMOTE_HANGUP_BUSY:
case ENDED_REMOTE_HANGUP_DECLINED:
case ENDED_REMOTE_BUSY:
case ENDED_REMOTE_GLARE:
return p.handleEndedRemote(s, event, remotePeer);
case ENDED_TIMEOUT:
case ENDED_INTERNAL_FAILURE:
case ENDED_SIGNALING_FAILURE:
case ENDED_CONNECTION_FAILURE:
return p.handleEnded(s, event, remotePeer);
case RECEIVED_OFFER_EXPIRED:
return p.handleReceivedOfferExpired(s, remotePeer);
case RECEIVED_OFFER_WHILE_ACTIVE:
case RECEIVED_OFFER_WITH_GLARE:
return p.handleReceivedOfferWhileActive(s, remotePeer);
case ENDED_LOCAL_HANGUP:
case ENDED_APP_DROPPED_CALL:
Log.i(TAG, "Ignoring event: " + event);
break;
default:
throw new AssertionError("Unexpected event: " + event.toString());
}
return s;
});
}
use of org.signal.ringrtc.CallException in project Signal-Android by WhisperSystems.
the class SignalCallManager method peekGroupCall.
public void peekGroupCall(@NonNull RecipientId id) {
if (callManager == null) {
Log.i(TAG, "Unable to peekGroupCall, call manager is null");
return;
}
networkExecutor.execute(() -> {
try {
Recipient group = Recipient.resolved(id);
GroupId.V2 groupId = group.requireGroupId().requireV2();
GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, groupId);
List<GroupCall.GroupMemberInfo> members = Stream.of(GroupManager.getUuidCipherTexts(context, groupId)).map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).toList();
callManager.peekGroupCall(SignalStore.internalValues().groupCallingServer(), credential.getTokenBytes().toByteArray(), members, peekInfo -> {
Long threadId = SignalDatabase.threads().getThreadIdFor(group.getId());
if (threadId != null) {
SignalDatabase.sms().updatePreviousGroupCall(threadId, peekInfo.getEraId(), peekInfo.getJoinedMembers(), WebRtcUtil.isCallFull(peekInfo));
ApplicationDependencies.getMessageNotifier().updateNotification(context, threadId, true, 0, BubbleUtil.BubbleState.HIDDEN);
EventBus.getDefault().postSticky(new GroupCallPeekEvent(id, peekInfo.getEraId(), peekInfo.getDeviceCount(), peekInfo.getMaxDevices()));
}
});
} catch (IOException | VerificationFailedException | CallException e) {
Log.e(TAG, "error peeking from active conversation", e);
}
});
}
Aggregations