Show local video

This commit is contained in:
Pierre HUBERT 2019-02-27 09:30:33 +01:00
parent f9432ddcf0
commit f818028920
3 changed files with 21 additions and 29 deletions

View File

@ -106,6 +106,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
* WebRTC attributes
*/
private EglBase rootEglBase;
ProxyVideoSink mLocalProxyVideoSink;
/**
@ -114,6 +115,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
private ProgressBar mProgressBar;
private ImageButton mHangUpButton;
private LinearLayout mRemoteVideosLayout;
private SurfaceViewRenderer mLocalVideoView;
@Override
@ -199,10 +201,18 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
mHangUpButton = findViewById(R.id.hangUp);
mHangUpButton.setOnClickListener(v -> hangUp());
mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout);
mLocalVideoView = findViewById(R.id.local_video);
}
private void initVideos(){
rootEglBase = EglBase.create();
mLocalVideoView.init(rootEglBase.getEglBaseContext(), null);
mLocalVideoView.setZOrderMediaOverlay(true);
mLocalProxyVideoSink = new ProxyVideoSink();
mLocalProxyVideoSink.setTarget(mLocalVideoView);
}
@ -370,11 +380,6 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
//Initialize video view
SurfaceViewRenderer localView = new SurfaceViewRenderer(this);
localView.init(eglBase.getEglBaseContext(), null);
localView.setZOrderMediaOverlay(true);
callPeer.setLocalVideoView(localView);
SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this);
remoteView.init(eglBase.getEglBaseContext(), null);
remoteView.setZOrderMediaOverlay(false);
@ -384,9 +389,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
ProxyVideoSink localProxyVideoSink = new ProxyVideoSink();
localProxyVideoSink.setTarget(callPeer.getLocalVideoView());
callPeer.setLocalProxyVideoSink(localProxyVideoSink);
//callPeer.setLocalProxyVideoSink(mLocalProxyVideoSink);
ProxyVideoSink remoteProxyRenderer = new ProxyVideoSink();
remoteProxyRenderer.setTarget(callPeer.getRemoteViewView());
@ -395,7 +399,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
//Start connection
peerConnectionClient.createPeerConnection(
localProxyVideoSink,
mLocalProxyVideoSink,
callPeer.getRemoteSinks(),
createCameraCapturer(new Camera1Enumerator(false)),
parameters
@ -439,7 +443,6 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
if(callPeer == null)
return;
((ProxyVideoSink)callPeer.getLocalProxyVideoSink()).setTarget(null);
((ProxyVideoSink)callPeer.getRemoteProxyRenderer()).setTarget(null);
callPeer.getPeerConnectionClient().close();

View File

@ -18,12 +18,10 @@ public class CallPeerConnection {
private CallMember member;
private PeerConnectionClient peerConnectionClient;
private boolean connected = false;
private VideoSink localProxyVideoSink;
private VideoSink remoteProxyRenderer;
private ArrayList<VideoSink> remoteSinks = new ArrayList<>();
//Views
private SurfaceViewRenderer mLocalVideoView;
private SurfaceViewRenderer mRemoteViewView;
public CallPeerConnection(CallMember member) {
@ -70,23 +68,6 @@ public class CallPeerConnection {
this.mRemoteViewView = mRemoteViewView;
}
public SurfaceViewRenderer getLocalVideoView() {
return mLocalVideoView;
}
public void setLocalVideoView(SurfaceViewRenderer mLocalVideoView) {
this.mLocalVideoView = mLocalVideoView;
}
public VideoSink getLocalProxyVideoSink() {
return localProxyVideoSink;
}
public void setLocalProxyVideoSink(VideoSink localProxyVideoSink) {
this.localProxyVideoSink = localProxyVideoSink;
}
public VideoSink getRemoteProxyRenderer() {
return remoteProxyRenderer;
}

View File

@ -46,6 +46,14 @@
app:layout_constraintStart_toStartOf="parent"
android:contentDescription="@string/action_hang_up"/>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/hangUp"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>