From ce409d3713674b85a18a499a628ef8d80d0b6f88 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 27 Feb 2019 09:11:08 +0100 Subject: [PATCH] Display remote peer video --- .../client/ui/activities/CallActivity.java | 28 +++++++++++++------ app/src/main/res/layout/activity_call.xml | 13 +++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java index e0f277f..f0c8ce5 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CallActivity.java @@ -9,7 +9,9 @@ import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageButton; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.Toast; @@ -111,6 +113,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac */ private ProgressBar mProgressBar; private ImageButton mHangUpButton; + private LinearLayout mRemoteVideosLayout; @Override @@ -195,14 +198,11 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac mProgressBar = findViewById(R.id.progressBar); mHangUpButton = findViewById(R.id.hangUp); mHangUpButton.setOnClickListener(v -> hangUp()); - + mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout); } - private void initVideos(){ - rootEglBase = EglBase.create(); - } @@ -321,10 +321,12 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac CallPeerConnection callPeer = new CallPeerConnection(member); mList.add(callPeer); + EglBase eglBase = EglBase.create(); + //Create peer connection PeerConnectionClient peerConnectionClient = new PeerConnectionClient( getApplicationContext(), - rootEglBase, + eglBase, new PeerConnectionClient.PeerConnectionParameters( true, false, @@ -369,15 +371,18 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac //Initialize video view SurfaceViewRenderer localView = new SurfaceViewRenderer(this); - localView.init(rootEglBase.getEglBaseContext(), null); + localView.init(eglBase.getEglBaseContext(), null); localView.setZOrderMediaOverlay(true); callPeer.setLocalVideoView(localView); SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this); - remoteView.init(rootEglBase.getEglBaseContext(), null); + remoteView.init(eglBase.getEglBaseContext(), null); remoteView.setZOrderMediaOverlay(false); callPeer.setRemoteViewView(remoteView); + mRemoteVideosLayout.addView(remoteView, new LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, 0, 1)); + ProxyVideoSink localProxyVideoSink = new ProxyVideoSink(); localProxyVideoSink.setTarget(callPeer.getLocalVideoView()); @@ -414,8 +419,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac if(mSignalExchangerClient != null) mSignalExchangerClient.close(); - for (CallPeerConnection client : mList) - disconnectFromPeer(client.getMember()); + while(mList.size() > 0) + disconnectFromPeer(mList.get(0).getMember()); HangUpCallTask hangUpCallTask = new HangUpCallTask(getApplicationContext()); hangUpCallTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mCallID); @@ -439,6 +444,9 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac callPeer.getPeerConnectionClient().close(); + //Remove the views + mRemoteVideosLayout.removeView(callPeer.getRemoteViewView()); + mList.remove(callPeer); } @@ -473,6 +481,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac } } + Log.e(TAG, "Could not get user camera!"); + return null; } diff --git a/app/src/main/res/layout/activity_call.xml b/app/src/main/res/layout/activity_call.xml index 178cd6d..61f6f2f 100644 --- a/app/src/main/res/layout/activity_call.xml +++ b/app/src/main/res/layout/activity_call.xml @@ -20,6 +20,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + \ No newline at end of file