mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-15 16:55:03 +01:00
parent
3b92415493
commit
82e5d69000
@ -25,6 +25,8 @@
|
|||||||
package com.nextcloud.talk.activities;
|
package com.nextcloud.talk.activities;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -42,6 +44,8 @@ import android.util.TypedValue;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -111,6 +115,7 @@ import javax.inject.Inject;
|
|||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
@ -136,6 +141,16 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
RelativeLayout relativeLayout;
|
RelativeLayout relativeLayout;
|
||||||
@BindView(R.id.remote_renderers_layout)
|
@BindView(R.id.remote_renderers_layout)
|
||||||
LinearLayout remoteRenderersLayout;
|
LinearLayout remoteRenderersLayout;
|
||||||
|
|
||||||
|
@BindView(R.id.call_controls)
|
||||||
|
RelativeLayout callControls;
|
||||||
|
@BindView(R.id.call_control_microphone)
|
||||||
|
ImageButton microphoneControlButton;
|
||||||
|
@BindView(R.id.call_control_camera)
|
||||||
|
ImageButton cameraControlButton;
|
||||||
|
@BindView(R.id.call_control_switch_camera)
|
||||||
|
ImageButton cameraSwitchButton;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
@Inject
|
@Inject
|
||||||
@ -157,6 +172,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
Disposable signalingDisposable;
|
Disposable signalingDisposable;
|
||||||
Disposable pingDisposable;
|
Disposable pingDisposable;
|
||||||
List<PeerConnection.IceServer> iceServers;
|
List<PeerConnection.IceServer> iceServers;
|
||||||
|
private CameraEnumerator cameraEnumerator;
|
||||||
private String roomToken;
|
private String roomToken;
|
||||||
private UserEntity userEntity;
|
private UserEntity userEntity;
|
||||||
private String callSession;
|
private String callSession;
|
||||||
@ -165,6 +181,9 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
private String credentials;
|
private String credentials;
|
||||||
private List<MagicPeerConnectionWrapper> magicPeerConnectionWrapperList = new ArrayList<>();
|
private List<MagicPeerConnectionWrapper> magicPeerConnectionWrapperList = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean videoOn = true;
|
||||||
|
private boolean audioOn = true;
|
||||||
|
|
||||||
private static int getSystemUiVisibility() {
|
private static int getSystemUiVisibility() {
|
||||||
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||||
@ -213,6 +232,12 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
localMediaStream.videoTracks.get(0).setEnabled(enable);
|
localMediaStream.videoTracks.get(0).setEnabled(enable);
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
pipVideoView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
pipVideoView.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message = "audioOff";
|
message = "audioOff";
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@ -227,21 +252,55 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchCamera() {
|
@OnClick(R.id.call_control_microphone)
|
||||||
|
public void onMicrophoneClick() {
|
||||||
|
audioOn = !audioOn;
|
||||||
|
|
||||||
|
if (audioOn) {
|
||||||
|
microphoneControlButton.setImageResource(R.drawable.ic_mic_white_24px);
|
||||||
|
} else {
|
||||||
|
microphoneControlButton.setImageResource(R.drawable.ic_mic_off_white_24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleMedia(audioOn, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.call_control_hangup)
|
||||||
|
public void onHangupClick() {
|
||||||
|
hangup(false);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.call_control_camera)
|
||||||
|
public void onCameraClick() {
|
||||||
|
videoOn = !videoOn;
|
||||||
|
|
||||||
|
if (videoOn) {
|
||||||
|
cameraControlButton.setImageResource(R.drawable.ic_videocam_white_24px);
|
||||||
|
} else {
|
||||||
|
cameraControlButton.setImageResource(R.drawable.ic_videocam_off_white_24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleMedia(videoOn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick(R.id.call_control_switch_camera)
|
||||||
|
public void switchCamera() {
|
||||||
CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
|
CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
|
||||||
cameraVideoCapturer.switchCamera(null);
|
cameraVideoCapturer.switchCamera(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private VideoCapturer createVideoCapturer() {
|
private void createCameraEnumerator() {
|
||||||
CameraEnumerator cameraEnumerator;
|
|
||||||
|
|
||||||
if (Camera2Enumerator.isSupported(this)) {
|
if (Camera2Enumerator.isSupported(this)) {
|
||||||
cameraEnumerator = new Camera2Enumerator(this);
|
cameraEnumerator = new Camera2Enumerator(this);
|
||||||
} else {
|
} else {
|
||||||
cameraEnumerator = new Camera1Enumerator(false);
|
cameraEnumerator = new Camera1Enumerator(false);
|
||||||
}
|
}
|
||||||
videoCapturer = createCameraCapturer(cameraEnumerator);
|
}
|
||||||
|
|
||||||
|
private VideoCapturer createVideoCapturer() {
|
||||||
|
videoCapturer = createCameraCapturer(cameraEnumerator);
|
||||||
return videoCapturer;
|
return videoCapturer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +337,12 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initViews() {
|
public void initViews() {
|
||||||
|
createCameraEnumerator();
|
||||||
|
|
||||||
|
if (cameraEnumerator.getDeviceNames().length < 2) {
|
||||||
|
cameraSwitchButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
// setting this to true because it's not shown by default
|
// setting this to true because it's not shown by default
|
||||||
pipVideoView.setMirror(true);
|
pipVideoView.setMirror(true);
|
||||||
rootEglBase = EglBase.create();
|
rootEglBase = EglBase.create();
|
||||||
@ -372,14 +437,24 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("internalSctpDataChannels", "true"));
|
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("internalSctpDataChannels", "true"));
|
||||||
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
|
sdpConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));
|
||||||
|
|
||||||
|
animateCallControls(false, 5000);
|
||||||
startPullingSignalingMessages(false);
|
startPullingSignalingMessages(false);
|
||||||
registerNetworkReceiver();
|
registerNetworkReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick({R.id.full_screen_surface_view, R.id.remote_renderers_layout})
|
||||||
|
public void showCallControls() {
|
||||||
|
if (callControls.getVisibility() != View.VISIBLE) {
|
||||||
|
animateCallControls(true, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void startPullingSignalingMessages(boolean restart) {
|
public void startPullingSignalingMessages(boolean restart) {
|
||||||
|
|
||||||
if (restart) {
|
if (restart) {
|
||||||
dispose(null);
|
dispose(null);
|
||||||
|
hangupNetworkCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
leavingCall = false;
|
leavingCall = false;
|
||||||
@ -744,6 +819,11 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
pipVideoView.release();
|
pipVideoView.release();
|
||||||
|
|
||||||
if (!dueToNetworkChange) {
|
if (!dueToNetworkChange) {
|
||||||
|
hangupNetworkCalls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hangupNetworkCalls() {
|
||||||
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
||||||
ncApi.leaveCall(credentials, ApiHelper.getUrlForCall(userEntity.getBaseUrl(), roomToken))
|
ncApi.leaveCall(credentials, ApiHelper.getUrlForCall(userEntity.getBaseUrl(), roomToken))
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
@ -794,7 +874,6 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void gotNick(String sessionId, String nick) {
|
private void gotNick(String sessionId, String nick) {
|
||||||
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
||||||
@ -804,6 +883,24 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void gotAudioOrVideoChange(boolean video, String sessionId, boolean change) {
|
||||||
|
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
||||||
|
if (relativeLayout != null) {
|
||||||
|
ImageView imageView;
|
||||||
|
if (video) {
|
||||||
|
imageView = relativeLayout.findViewById(R.id.remote_video_off);
|
||||||
|
} else {
|
||||||
|
imageView = relativeLayout.findViewById(R.id.remote_audio_off);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (change && imageView.getVisibility() != View.INVISIBLE) {
|
||||||
|
imageView.setVisibility(View.INVISIBLE);
|
||||||
|
} else if (!change && imageView.getVisibility() != View.VISIBLE) {
|
||||||
|
imageView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void gotRemoteStream(MediaStream stream, String session) {
|
private void gotRemoteStream(MediaStream stream, String session) {
|
||||||
if (fullScreenVideoView != null) {
|
if (fullScreenVideoView != null) {
|
||||||
remoteRenderersLayout.setVisibility(View.VISIBLE);
|
remoteRenderersLayout.setVisibility(View.VISIBLE);
|
||||||
@ -893,11 +990,20 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
.PeerConnectionEventType.SENSOR_FAR) ||
|
.PeerConnectionEventType.SENSOR_FAR) ||
|
||||||
peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||||
.PeerConnectionEventType.SENSOR_NEAR)) {
|
.PeerConnectionEventType.SENSOR_NEAR)) {
|
||||||
|
|
||||||
boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||||
.PeerConnectionEventType.SENSOR_FAR);
|
.PeerConnectionEventType.SENSOR_FAR);
|
||||||
|
|
||||||
toggleMedia(enableVideo, true);
|
toggleMedia(enableVideo, true);
|
||||||
|
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||||
|
.PeerConnectionEventType.NICK_CHANGE)) {
|
||||||
|
runOnUiThread(() -> gotNick(peerConnectionEvent.getSessionId(), peerConnectionEvent.getNick()));
|
||||||
|
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||||
|
.PeerConnectionEventType.VIDEO_CHANGE)) {
|
||||||
|
runOnUiThread(() -> gotAudioOrVideoChange(true, peerConnectionEvent.getSessionId(),
|
||||||
|
peerConnectionEvent.getChangeValue()));
|
||||||
|
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||||
|
.PeerConnectionEventType.AUDIO_CHANGE)) {
|
||||||
|
runOnUiThread(() -> gotAudioOrVideoChange(false, peerConnectionEvent.getSessionId(),
|
||||||
|
peerConnectionEvent.getChangeValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1046,4 +1152,38 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
this.registerReceiver(broadcastReceiver, intentFilter);
|
this.registerReceiver(broadcastReceiver, intentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void animateCallControls(boolean show, long startDelay) {
|
||||||
|
float alpha;
|
||||||
|
long duration;
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
alpha = 1.0f;
|
||||||
|
duration = 500;
|
||||||
|
} else {
|
||||||
|
alpha = 0.0f;
|
||||||
|
duration = 2500;
|
||||||
|
}
|
||||||
|
|
||||||
|
callControls.animate()
|
||||||
|
.translationY(0)
|
||||||
|
.alpha(alpha)
|
||||||
|
.setDuration(duration)
|
||||||
|
.setStartDelay(startDelay)
|
||||||
|
.setListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
super.onAnimationEnd(animation);
|
||||||
|
if (callControls != null) {
|
||||||
|
if (!show) {
|
||||||
|
callControls.setVisibility(View.INVISIBLE);
|
||||||
|
} else {
|
||||||
|
callControls.setVisibility(View.VISIBLE);
|
||||||
|
animateCallControls(false, 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,18 @@ import lombok.Data;
|
|||||||
public class PeerConnectionEvent {
|
public class PeerConnectionEvent {
|
||||||
private final PeerConnectionEventType peerConnectionEventType;
|
private final PeerConnectionEventType peerConnectionEventType;
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
|
private final String nick;
|
||||||
|
private final Boolean changeValue;
|
||||||
|
|
||||||
public PeerConnectionEvent(PeerConnectionEventType peerConnectionEventType, @Nullable String sessionId) {
|
public PeerConnectionEvent(PeerConnectionEventType peerConnectionEventType, @Nullable String sessionId,
|
||||||
|
@Nullable String nick, Boolean changeValue) {
|
||||||
this.peerConnectionEventType = peerConnectionEventType;
|
this.peerConnectionEventType = peerConnectionEventType;
|
||||||
|
this.nick = nick;
|
||||||
|
this.changeValue = changeValue;
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PeerConnectionEventType {
|
public enum PeerConnectionEventType {
|
||||||
CLOSE_PEER, SENSOR_FAR, SENSOR_NEAR
|
CLOSE_PEER, SENSOR_FAR, SENSOR_NEAR, NICK_CHANGE, AUDIO_CHANGE, VIDEO_CHANGE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ public class MagicAudioManager {
|
|||||||
|
|
||||||
if (proximitySensor.sensorReportsNearState()) {
|
if (proximitySensor.sensorReportsNearState()) {
|
||||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
.SENSOR_NEAR, null));
|
.SENSOR_NEAR, null, null, null));
|
||||||
} else {
|
} else {
|
||||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
.SENSOR_FAR, null));
|
.SENSOR_FAR, null, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useSpeakerphone.equals(SPEAKERPHONE_AUTO)) {
|
if (!useSpeakerphone.equals(SPEAKERPHONE_AUTO)) {
|
||||||
|
@ -58,8 +58,8 @@ public class MagicPeerConnectionWrapper {
|
|||||||
private DataChannel magicDataChannel;
|
private DataChannel magicDataChannel;
|
||||||
private MagicSdpObserver magicSdpObserver;
|
private MagicSdpObserver magicSdpObserver;
|
||||||
|
|
||||||
private boolean audioOn;
|
private boolean remoteVideoOn;
|
||||||
private boolean videoOn;
|
private boolean remoteAudioOn;
|
||||||
|
|
||||||
private boolean hasInitiated;
|
private boolean hasInitiated;
|
||||||
|
|
||||||
@ -167,14 +167,41 @@ public class MagicPeerConnectionWrapper {
|
|||||||
Log.d(TAG, "Received binary msg over " + TAG + " " + sessionId);
|
Log.d(TAG, "Received binary msg over " + TAG + " " + sessionId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer data = buffer.data;
|
ByteBuffer data = buffer.data;
|
||||||
final byte[] bytes = new byte[data.capacity()];
|
final byte[] bytes = new byte[data.capacity()];
|
||||||
data.get(bytes);
|
data.get(bytes);
|
||||||
String strData = new String(bytes);
|
String strData = new String(bytes);
|
||||||
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
||||||
|
|
||||||
// We use media stream to determine if audio or video is on rather than data
|
try {
|
||||||
// channel messages
|
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
||||||
|
|
||||||
|
if ("nickChanged".equals(dataChannelMessage.getType())) {
|
||||||
|
nick = dataChannelMessage.getPayload();
|
||||||
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
|
.NICK_CHANGE, sessionId, nick, null));
|
||||||
|
} else if ("audioOn".equals(dataChannelMessage.getType())) {
|
||||||
|
remoteAudioOn = true;
|
||||||
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
|
.AUDIO_CHANGE, sessionId, null, remoteAudioOn));
|
||||||
|
} else if ("audioOff".equals(dataChannelMessage.getType())) {
|
||||||
|
remoteAudioOn = false;
|
||||||
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
|
.AUDIO_CHANGE, sessionId, null, remoteAudioOn));
|
||||||
|
} else if ("videoOn".equals(dataChannelMessage.getType())) {
|
||||||
|
remoteVideoOn = true;
|
||||||
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
|
.VIDEO_CHANGE, sessionId, null, remoteVideoOn));
|
||||||
|
} else if ("videoOff".equals(dataChannelMessage.getType())) {
|
||||||
|
remoteVideoOn = false;
|
||||||
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
|
.VIDEO_CHANGE, sessionId, null, remoteVideoOn));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.d(TAG, "Failed to parse data channel message");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +212,7 @@ public class MagicPeerConnectionWrapper {
|
|||||||
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
||||||
if (signalingState.equals(PeerConnection.SignalingState.CLOSED)) {
|
if (signalingState.equals(PeerConnection.SignalingState.CLOSED)) {
|
||||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
.CLOSE_PEER, sessionId));
|
.CLOSE_PEER, sessionId, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +223,7 @@ public class MagicPeerConnectionWrapper {
|
|||||||
sendChannelData(new DataChannelMessage("audioOn"));
|
sendChannelData(new DataChannelMessage("audioOn"));
|
||||||
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.FAILED)) {
|
} else if (iceConnectionState.equals(PeerConnection.IceConnectionState.FAILED)) {
|
||||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||||
.CLOSE_PEER, sessionId));
|
.CLOSE_PEER, sessionId, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,21 +254,13 @@ public class MagicPeerConnectionWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAddStream(MediaStream mediaStream) {
|
public void onAddStream(MediaStream mediaStream) {
|
||||||
videoOn = mediaStream.videoTracks != null && mediaStream.videoTracks.size() == 1;
|
|
||||||
audioOn = mediaStream.audioTracks != null && mediaStream.audioTracks.size() == 1;
|
|
||||||
if (!sessionId.equals(localSession)) {
|
|
||||||
EventBus.getDefault().post(new MediaStreamEvent(mediaStream, sessionId));
|
EventBus.getDefault().post(new MediaStreamEvent(mediaStream, sessionId));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoveStream(MediaStream mediaStream) {
|
public void onRemoveStream(MediaStream mediaStream) {
|
||||||
videoOn = mediaStream.videoTracks != null && mediaStream.videoTracks.size() == 1;
|
|
||||||
audioOn = mediaStream.audioTracks != null && mediaStream.audioTracks.size() == 1;
|
|
||||||
if (!sessionId.equals(localSession)) {
|
|
||||||
EventBus.getDefault().post(new MediaStreamEvent(null, sessionId));
|
EventBus.getDefault().post(new MediaStreamEvent(null, sessionId));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataChannel(DataChannel dataChannel) {
|
public void onDataChannel(DataChannel dataChannel) {
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
tools:context=".activities.CallActivity">
|
tools:context=".activities.CallActivity">
|
||||||
|
|
||||||
<org.webrtc.SurfaceViewRenderer
|
<org.webrtc.SurfaceViewRenderer
|
||||||
|
android:id="@+id/full_screen_surface_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"/>
|
||||||
android:id="@+id/full_screen_surface_view"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/remote_renderers_layout"
|
android:id="@+id/remote_renderers_layout"
|
||||||
@ -50,4 +50,49 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/call_controls"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/call_control_hangup"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginEnd="@dimen/margin_between_elements"
|
||||||
|
android:background="?android:selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_call_end_white_24px"
|
||||||
|
android:tint="@color/nc_darkRed"
|
||||||
|
android:tintMode="src_in"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/call_control_camera"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginEnd="@dimen/margin_between_elements"
|
||||||
|
android:layout_toEndOf="@id/call_control_hangup"
|
||||||
|
android:background="?android:selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_videocam_white_24px"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/call_control_microphone"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginEnd="@dimen/margin_between_elements"
|
||||||
|
android:layout_toEndOf="@id/call_control_camera"
|
||||||
|
android:background="?android:selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_mic_white_24px"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/call_control_switch_camera"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_toEndOf="@id/call_control_microphone"
|
||||||
|
android:background="?android:selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_switch_video_white_24px"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -31,13 +31,34 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/remote_video_off"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_above="@id/peer_nick_text_view"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:src="@drawable/ic_videocam_off_white_24px"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/remote_audio_off"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_above="@id/peer_nick_text_view"
|
||||||
|
android:layout_toEndOf="@id/remote_video_off"
|
||||||
|
android:src="@drawable/ic_mic_off_white_24px"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/peer_nick_text_view"
|
android:id="@+id/peer_nick_text_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_margin="8dp"
|
android:layout_marginTop="4dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:textColor="@color/nc_white_color_complete"/>
|
android:textColor="@color/nc_white_color_complete"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -7,7 +7,6 @@
|
|||||||
<color name="nc_darkRed">#D32F2F</color>
|
<color name="nc_darkRed">#D32F2F</color>
|
||||||
<color name="nc_white_color">@color/per70white</color>
|
<color name="nc_white_color">@color/per70white</color>
|
||||||
<color name="nc_white_color_complete">#FFFFFF</color>
|
<color name="nc_white_color_complete">#FFFFFF</color>
|
||||||
<color name="nc_light_blue_color">#7fC0E3</color>
|
<color name="nc_light_blue_color">#7FC0E3</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user