mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Show local video
This commit is contained in:
parent
f9432ddcf0
commit
f818028920
@ -106,6 +106,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
* WebRTC attributes
|
* WebRTC attributes
|
||||||
*/
|
*/
|
||||||
private EglBase rootEglBase;
|
private EglBase rootEglBase;
|
||||||
|
ProxyVideoSink mLocalProxyVideoSink;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,6 +115,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private ImageButton mHangUpButton;
|
private ImageButton mHangUpButton;
|
||||||
private LinearLayout mRemoteVideosLayout;
|
private LinearLayout mRemoteVideosLayout;
|
||||||
|
private SurfaceViewRenderer mLocalVideoView;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,10 +201,18 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
mHangUpButton = findViewById(R.id.hangUp);
|
mHangUpButton = findViewById(R.id.hangUp);
|
||||||
mHangUpButton.setOnClickListener(v -> hangUp());
|
mHangUpButton.setOnClickListener(v -> hangUp());
|
||||||
mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout);
|
mRemoteVideosLayout = findViewById(R.id.remoteVideosLayout);
|
||||||
|
mLocalVideoView = findViewById(R.id.local_video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initVideos(){
|
private void initVideos(){
|
||||||
rootEglBase = EglBase.create();
|
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
|
//Initialize video view
|
||||||
SurfaceViewRenderer localView = new SurfaceViewRenderer(this);
|
|
||||||
localView.init(eglBase.getEglBaseContext(), null);
|
|
||||||
localView.setZOrderMediaOverlay(true);
|
|
||||||
callPeer.setLocalVideoView(localView);
|
|
||||||
|
|
||||||
SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this);
|
SurfaceViewRenderer remoteView = new SurfaceViewRenderer(this);
|
||||||
remoteView.init(eglBase.getEglBaseContext(), null);
|
remoteView.init(eglBase.getEglBaseContext(), null);
|
||||||
remoteView.setZOrderMediaOverlay(false);
|
remoteView.setZOrderMediaOverlay(false);
|
||||||
@ -384,9 +389,8 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
|
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
|
||||||
|
|
||||||
|
|
||||||
ProxyVideoSink localProxyVideoSink = new ProxyVideoSink();
|
|
||||||
localProxyVideoSink.setTarget(callPeer.getLocalVideoView());
|
//callPeer.setLocalProxyVideoSink(mLocalProxyVideoSink);
|
||||||
callPeer.setLocalProxyVideoSink(localProxyVideoSink);
|
|
||||||
|
|
||||||
ProxyVideoSink remoteProxyRenderer = new ProxyVideoSink();
|
ProxyVideoSink remoteProxyRenderer = new ProxyVideoSink();
|
||||||
remoteProxyRenderer.setTarget(callPeer.getRemoteViewView());
|
remoteProxyRenderer.setTarget(callPeer.getRemoteViewView());
|
||||||
@ -395,7 +399,7 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
|
|
||||||
//Start connection
|
//Start connection
|
||||||
peerConnectionClient.createPeerConnection(
|
peerConnectionClient.createPeerConnection(
|
||||||
localProxyVideoSink,
|
mLocalProxyVideoSink,
|
||||||
callPeer.getRemoteSinks(),
|
callPeer.getRemoteSinks(),
|
||||||
createCameraCapturer(new Camera1Enumerator(false)),
|
createCameraCapturer(new Camera1Enumerator(false)),
|
||||||
parameters
|
parameters
|
||||||
@ -439,7 +443,6 @@ public class CallActivity extends BaseActivity implements SignalExchangerCallbac
|
|||||||
if(callPeer == null)
|
if(callPeer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
((ProxyVideoSink)callPeer.getLocalProxyVideoSink()).setTarget(null);
|
|
||||||
((ProxyVideoSink)callPeer.getRemoteProxyRenderer()).setTarget(null);
|
((ProxyVideoSink)callPeer.getRemoteProxyRenderer()).setTarget(null);
|
||||||
|
|
||||||
callPeer.getPeerConnectionClient().close();
|
callPeer.getPeerConnectionClient().close();
|
||||||
|
@ -18,12 +18,10 @@ public class CallPeerConnection {
|
|||||||
private CallMember member;
|
private CallMember member;
|
||||||
private PeerConnectionClient peerConnectionClient;
|
private PeerConnectionClient peerConnectionClient;
|
||||||
private boolean connected = false;
|
private boolean connected = false;
|
||||||
private VideoSink localProxyVideoSink;
|
|
||||||
private VideoSink remoteProxyRenderer;
|
private VideoSink remoteProxyRenderer;
|
||||||
private ArrayList<VideoSink> remoteSinks = new ArrayList<>();
|
private ArrayList<VideoSink> remoteSinks = new ArrayList<>();
|
||||||
|
|
||||||
//Views
|
//Views
|
||||||
private SurfaceViewRenderer mLocalVideoView;
|
|
||||||
private SurfaceViewRenderer mRemoteViewView;
|
private SurfaceViewRenderer mRemoteViewView;
|
||||||
|
|
||||||
public CallPeerConnection(CallMember member) {
|
public CallPeerConnection(CallMember member) {
|
||||||
@ -70,23 +68,6 @@ public class CallPeerConnection {
|
|||||||
this.mRemoteViewView = mRemoteViewView;
|
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() {
|
public VideoSink getRemoteProxyRenderer() {
|
||||||
return remoteProxyRenderer;
|
return remoteProxyRenderer;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,14 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:contentDescription="@string/action_hang_up"/>
|
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>
|
</android.support.constraint.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user