Я пытаюсь создать приложение для обмена экранами с помощью WebRTC.Все работает как положено, но мне нужно позвонить в addSing со стоком.Единственным приемником, который работал, был SurfaceViewRenderer.
VideoTrack videoTrack = mPeerConnectionFactory.createVideoTrack("100", videoSource);
SurfaceViewRenderer localView = mChatHeadView.findViewById(R.id.localView);
localView.setMirror(true);
localView.init(mEglBaseContext, null);
videoTrack.addSink(localView);
Я хочу, чтобы он работал без отображения локального потока в приложении.
Спасибо
больше кода: init:PeerConnectionFactory.initialize (PeerConnectionFactory.InitializationOptions.builder (this) .createInitializationOptions ());
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
DefaultVideoEncoderFactory defaultVideoEncoderFactory new DefaultVideoEncoderFactory(mEglBaseContext, true, true);
DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(mEglBaseContext);
mPeerConnectionFactory = PeerConnectionFactory.builder()
.setOptions(options)
.setVideoEncoderFactory(defaultVideoEncoderFactory)
.setVideoDecoderFactory(defaultVideoDecoderFactory)
.createPeerConnectionFactory();
SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("sThread", mEglBaseContext);
VideoCapturer videoCapturer = createScreenCapturer();//usign org.webrtc.ScreenCapturerAndroid
VideoSource videoSource = mPeerConnectionFactory.createVideoSource(videoCapturer.isScreencast());
videoCapturer.initialize( surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver() );
videoCapturer.startCapture(mScreenW, mScreenH, 30);
VideoTrack videoTrack = mPeerConnectionFactory.createVideoTrack("100", videoSource);
SurfaceViewRenderer localView = mChatHeadView.findViewById(R.id.localView);
localView.setMirror(true);
localView.init(mEglBaseContext, null);
// если я это закомментирую, то ничего не будет работать на другой стороне канала videoTrack.addSink (localView);
mMediaStream = mPeerConnectionFactory.createLocalMediaStream("mediaStream");
mMediaStream.addTrack(videoTrack);
mSignalingClient = new SignalingClient();
mSignalingClient.init(this,mServURI);
//create the connection:
private PeerConnection getConnection() {
PeerConnection peerConnection = mPeerConnectionFactory.createPeerConnection(mIceServers, new PeerConnectionAdapter() {
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
super.onIceCandidate(iceCandidate);
try {
mSignalingClient.sendIceCandidate(iceCandidate, socketId);
}
catch (Exception e){
showError("",e);
}
}
@Override
public void onAddStream(MediaStream mediaStream) {
super.onAddStream(mediaStream);
}
});
peerConnection.addStream(mMediaStream);
return peerConnection;
}
public void onOfferReceived(JSONObject data){
PeerConnection peerConnection = getConnection();
....
//set remote description
peerConnection.setRemoteDescription(
new SdpAdapter(),
new SessionDescription(SessionDescription.Type.OFFER, sdpData)
);
peerConnection.createAnswer(new SdpAdapter() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
super.onCreateSuccess(sdp);
mPeerConnectionMap.get(socketId).setLocalDescription(new SdpAdapter(),sdp);
.....
}
}, new MediaConstraints());
}