mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Display remote peer video
This commit is contained in:
parent
9e559ed568
commit
ce409d3713
@ -9,7 +9,9 @@ import android.support.v4.app.ActivityCompat;
|
|||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -111,6 +113,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
*/
|
*/
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private ImageButton mHangUpButton;
|
private ImageButton mHangUpButton;
|
||||||
|
private LinearLayout mRemoteVideosLayout;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -195,14 +198,11 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
mProgressBar = findViewById(R.id.progressBar);
|
mProgressBar = findViewById(R.id.progressBar);
|
||||||
mHangUpButton = findViewById(R.id.hangUp);
|
mHangUpButton = findViewById(R.id.hangUp);
|
||||||
mHangUpButton.setOnClickListener(v -> hangUp());
|
mHangUpButton.setOnClickListener(v -> hangUp());
|
||||||
|
mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initVideos(){
|
private void initVideos(){
|
||||||
|
|
||||||
rootEglBase = EglBase.create();
|
rootEglBase = EglBase.create();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -321,10 +321,12 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
CallPeerConnection callPeer = new CallPeerConnection(member);
|
CallPeerConnection callPeer = new CallPeerConnection(member);
|
||||||
mList.add(callPeer);
|
mList.add(callPeer);
|
||||||
|
|
||||||
|
EglBase eglBase = EglBase.create();
|
||||||
|
|
||||||
//Create peer connection
|
//Create peer connection
|
||||||
PeerConnectionClient peerConnectionClient = new PeerConnectionClient(
|
PeerConnectionClient peerConnectionClient = new PeerConnectionClient(
|
||||||
getApplicationContext(),
|
getApplicationContext(),
|
||||||
rootEglBase,
|
eglBase,
|
||||||
new PeerConnectionClient.PeerConnectionParameters(
|
new PeerConnectionClient.PeerConnectionParameters(
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
@ -369,15 +371,18 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
|
|
||||||
//Initialize video view
|
//Initialize video view
|
||||||
SurfaceViewRenderer localView = new SurfaceViewRenderer(this);
|
SurfaceViewRenderer localView = new SurfaceViewRenderer(this);
|
||||||
localView.init(rootEglBase.getEglBaseContext(), null);
|
localView.init(eglBase.getEglBaseContext(), null);
|
||||||
localView.setZOrderMediaOverlay(true);
|
localView.setZOrderMediaOverlay(true);
|
||||||
callPeer.setLocalVideoView(localView);
|
callPeer.setLocalVideoView(localView);
|
||||||
|
|
||||||
SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this);
|
SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this);
|
||||||
remoteView.init(rootEglBase.getEglBaseContext(), null);
|
remoteView.init(eglBase.getEglBaseContext(), null);
|
||||||
remoteView.setZOrderMediaOverlay(false);
|
remoteView.setZOrderMediaOverlay(false);
|
||||||
callPeer.setRemoteViewView(remoteView);
|
callPeer.setRemoteViewView(remoteView);
|
||||||
|
|
||||||
|
mRemoteVideosLayout.addView(remoteView, new LinearLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
|
||||||
|
|
||||||
|
|
||||||
ProxyVideoSink localProxyVideoSink = new ProxyVideoSink();
|
ProxyVideoSink localProxyVideoSink = new ProxyVideoSink();
|
||||||
localProxyVideoSink.setTarget(callPeer.getLocalVideoView());
|
localProxyVideoSink.setTarget(callPeer.getLocalVideoView());
|
||||||
@ -414,8 +419,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
if(mSignalExchangerClient != null)
|
if(mSignalExchangerClient != null)
|
||||||
mSignalExchangerClient.close();
|
mSignalExchangerClient.close();
|
||||||
|
|
||||||
for (CallPeerConnection client : mList)
|
while(mList.size() > 0)
|
||||||
disconnectFromPeer(client.getMember());
|
disconnectFromPeer(mList.get(0).getMember());
|
||||||
|
|
||||||
HangUpCallTask hangUpCallTask = new HangUpCallTask(getApplicationContext());
|
HangUpCallTask hangUpCallTask = new HangUpCallTask(getApplicationContext());
|
||||||
hangUpCallTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mCallID);
|
hangUpCallTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mCallID);
|
||||||
@ -439,6 +444,9 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
|
|
||||||
callPeer.getPeerConnectionClient().close();
|
callPeer.getPeerConnectionClient().close();
|
||||||
|
|
||||||
|
//Remove the views
|
||||||
|
mRemoteVideosLayout.removeView(callPeer.getRemoteViewView());
|
||||||
|
|
||||||
mList.remove(callPeer);
|
mList.remove(callPeer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,6 +481,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.e(TAG, "Could not get user camera!");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,17 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/remoteVideosLayout"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/hangUp"
|
android:id="@+id/hangUp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -35,4 +46,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:contentDescription="@string/action_hang_up"/>
|
android:contentDescription="@string/action_hang_up"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user