@Override public void onAddRemoteStream(final MediaStream remoteStream, final PnPeer peer) { super.onAddRemoteStream(remoteStream, peer); // Will log values VideoChatActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(VideoChatActivity.this,"Connected to " + peer.getId(), Toast.LENGTH_SHORT).show(); try { if(remoteStream.audioTracks.size()==0 || remoteStream.videoTracks.size()==0) return; mCallStatus.setVisibility(View.GONE); remoteStream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender)); VideoRendererGui.update(remoteRender, 0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); VideoRendererGui.update(localRender, 72, 65, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FIT, true); } catch (Exception e){ e.printStackTrace(); } } }); }
@Override public void onAddStream(final MediaStream stream) { executor.execute(new Runnable() { @Override public void run() { if (peerConnection == null || isError) { return; } if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) { reportError("Weird-looking stream: " + stream); return; } if (stream.videoTracks.size() == 1) { remoteVideoTrack = stream.videoTracks.get(0); remoteVideoTrack.setEnabled(renderVideo); for (VideoRenderer.Callbacks remoteRender : remoteRenders) { remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender)); } } } }); }
private void gotRemoteStream(MediaStream stream) { //we have remote video stream. add to the renderer. final VideoTrack videoTrack = stream.videoTracks.getFirst(); AudioTrack audioTrack = stream.audioTracks.getFirst(); runOnUiThread(new Runnable() { @Override public void run() { try { remoteRenderer = new VideoRenderer(remoteVideoView); remoteVideoView.setVisibility(View.VISIBLE); videoTrack.addRenderer(remoteRenderer); } catch (Exception e) { e.printStackTrace(); } } }); }
@Override public void onAddStream(final MediaStream stream) { executor.execute(new Runnable() { @Override public void run() { if (peerConnection == null || isError) { return; } if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) { reportError("Weird-looking stream: " + stream); return; } if (stream.videoTracks.size() == 1) { remoteVideoTrack = stream.videoTracks.get(0); remoteVideoTrack.setEnabled(renderVideo); remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender)); } } }); }
private void initializeOutboundCall() { id = UUID.randomUUID().toString(); final Application application = (Application) getApplication(); final PeerConnectionFactory factory = application.getWebRtcFactory(); final MediaStream mediaStream = factory.createLocalMediaStream(UUID.randomUUID().toString()); mediaStream.addTrack(factory.createAudioTrack( UUID.randomUUID().toString(), factory.createAudioSource(CONSTRAINTS) )); peerConnection = factory.createPeerConnection( application.getBuiltInIceServers(), CONSTRAINTS, new PeerConnectionObserver() ); peerConnection.addStream(mediaStream); peerConnection.createOffer(sdpObserver, CONSTRAINTS); }
@Override public void onAddStream(final MediaStream stream){ new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { if (stream.audioTracks.size() <= 1 && stream.videoTracks.size() <= 1) { if (stream.videoTracks.size() == 1) { stream.videoTracks.get(0).addRenderer( new VideoRenderer(remoteRender)); } } else { postErrorToListener("An invalid stream was added"); } } } }); }
@Override public void onRemoveStream(MediaStream mediaStream) { String streamReactTag = webRTCModule.onRemoveStream(mediaStream); if (streamReactTag == null) { return; } WritableMap params = Arguments.createMap(); params.putInt("id", id); params.putString("streamId", streamReactTag); webRTCModule.sendEvent("peerConnectionRemovedStream", params); }
@ReactProp(name = "streamURL") public void setStreamURL(WebRTCView view, String streamURL) { MediaStream mediaStream; if (streamURL == null) { mediaStream = null; } else { WebRTCModule module = mContext.getNativeModule(WebRTCModule.class); mediaStream = module.mMediaStreams.get(streamURL); } view.setStream(mediaStream); }
/** * Sets the {@code MediaStream} to be rendered by this {@code WebRTCView}. * The implementation renders the first {@link VideoTrack}, if any, of the * specified {@code mediaStream}. * * @param mediaStream The {@code MediaStream} to be rendered by this * {@code WebRTCView} or {@code null}. */ public void setStream(MediaStream mediaStream) { VideoTrack videoTrack; if (mediaStream == null) { videoTrack = null; } else { List<VideoTrack> videoTracks = mediaStream.videoTracks; videoTrack = videoTracks.isEmpty() ? null : videoTracks.get(0); } setVideoTrack(videoTrack); }
@Override public void onAddStream(MediaStream stream) { Log.w(TAG, "onAddStream:" + stream); for (AudioTrack audioTrack : stream.audioTracks) { audioTrack.setEnabled(true); } if (stream.videoTracks != null && stream.videoTracks.size() == 1) { VideoTrack videoTrack = stream.videoTracks.getFirst(); videoTrack.setEnabled(true); videoTrack.addRenderer(new VideoRenderer(remoteRenderer)); } }
public PeerConnectionWrapper(@NonNull Context context, @NonNull PeerConnectionFactory factory, @NonNull PeerConnection.Observer observer, @NonNull VideoRenderer.Callbacks localRenderer, @NonNull List<PeerConnection.IceServer> turnServers, boolean hideIp) { List<PeerConnection.IceServer> iceServers = new LinkedList<>(); iceServers.add(STUN_SERVER); iceServers.addAll(turnServers); MediaConstraints constraints = new MediaConstraints(); MediaConstraints audioConstraints = new MediaConstraints(); PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers); configuration.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; configuration.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE; if (hideIp) { configuration.iceTransportsType = PeerConnection.IceTransportsType.RELAY; } constraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); audioConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); this.peerConnection = factory.createPeerConnection(configuration, constraints, observer); this.videoCapturer = createVideoCapturer(context); MediaStream mediaStream = factory.createLocalMediaStream("ARDAMS"); this.audioSource = factory.createAudioSource(audioConstraints); this.audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource); this.audioTrack.setEnabled(false); mediaStream.addTrack(audioTrack); if (videoCapturer != null) { this.videoSource = factory.createVideoSource(videoCapturer); this.videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource); this.videoTrack.addRenderer(new VideoRenderer(localRenderer)); this.videoTrack.setEnabled(false); mediaStream.addTrack(videoTrack); } else { this.videoSource = null; this.videoTrack = null; } this.peerConnection.addStream(mediaStream); }
@Override public void onLocalStream(final MediaStream localStream) { super.onLocalStream(localStream); // Will log values VideoChatActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if(localStream.videoTracks.size()==0) return; localStream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender)); } }); }
@Override public void onRemoveStream(final MediaStream stream) { executor.execute(new Runnable() { @Override public void run() { remoteVideoTrack = null; } }); }
@Override public void onAddStream(MediaStream mediaStream) { LogUtils.e("onAddStream"); // peerConnection.addStream(mediaStream); mediaStream.videoTracks.get(0).addRenderer(remoteVideoRender); // VideoRendererGui.update(remoteRender, 0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); // VideoRendererGui.update(localRender, 72, 65, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FIT, true); }
@Override public void onRemoteStreamAdded(MediaStream mediaStream, NBMPeerConnection nbmPeerConnection) { Log.i(TAG, "onRemoteStreamAdded"); nbmWebRTCPeer.setActiveMasterStream(mediaStream); runOnUiThread(new Runnable() { @Override public void run() { mCallStatus.setText(""); } }); }
@Override public void onLocalStream(MediaStream localStream) { localStream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender)); VideoRendererGui.update(localRender, LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING, LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true); }
@Override public void onAddRemoteStream(MediaStream remoteStream, int endPoint) { remoteStream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender)); VideoRendererGui.update(remoteRender, REMOTE_X, REMOTE_Y, REMOTE_WIDTH, REMOTE_HEIGHT, scalingType, true); VideoRendererGui.update(localRender, LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED, LOCAL_WIDTH_CONNECTED, LOCAL_HEIGHT_CONNECTED, scalingType, true); }
public void onAnswerButtonClicked(final View view) { progressState.changeValue(ProgressState.NEGOTIATING); showHangButton(); final PeerConnectionFactory factory = ((Application) getApplication()).getWebRtcFactory(); final MediaStream stream = factory.createLocalMediaStream(UUID.randomUUID().toString()); stream.addTrack(factory.createAudioTrack( UUID.randomUUID().toString(), factory.createAudioSource(CONSTRAINTS) )); peerConnection.addStream(stream); peerConnection.createAnswer(sdpObserver, new MediaConstraints()); }
private void addRender(MediaStream stream, int position) { VideoRenderer.Callbacks render; L.d("addRender position is " + position); if (position == 0) { render = localRender; } else { render = VideoRendererGui.create(position % 2 == 0 ? 0 : 50, position / 2 * 50, 50, 50, scalingType, false); } stream.videoTracks.get(0).addRenderer(new VideoRenderer(render)); }
@Override public void onRemoteStreamAdded(MediaStream mediaStream, NBMPeerConnection nbmPeerConnection) { Log.i(TAG, "onRemoteStreamAdded"); // nbmWebRTCPeer.attachRendererToRemoteStream(remoteRender, mediaStream); // runOnUiThread(new Runnable() { // @Override // public void run() { // mCallStatus.setText(""); // } // }); }
@Override public void onRemoteStreamAdded(MediaStream mediaStream, NBMPeerConnection nbmPeerConnection) { Log.i(TAG, "onRemoteStreamAdded"); nbmWebRTCPeer.attachRendererToRemoteStream(remoteRender, mediaStream); runOnUiThread(new Runnable() { @Override public void run() { mCallStatus.setText(""); } }); }
@Override public void onRemoteStream(MediaStream stream) { stream.videoTracks.get(0).setEnabled(true); if(stream.videoTracks.get(0).enabled()) Log.d("JANUSCLIENT", "video tracks enabled"); stream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender)); VideoRendererGui.update(remoteRender, 0, 0, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); VideoRendererGui.update(localRender, 72, 72, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); }
public void run() { Log.d(TAG, "Attaching VideoRenderer to remote stream (" + remoteStream + ")"); // Check if the remote stream has a video track if (remoteStream.videoTracks.size() == 1) { // Get the video track VideoTrack remoteVideoTrack = remoteStream.videoTracks.get(0); // Set video track enabled if we have enabled video rendering remoteVideoTrack.setEnabled(renderVideo); VideoRenderer videoRenderer = remoteVideoRenderers.get(remoteRender); if (videoRenderer != null) { MediaStream mediaStream = remoteVideoMediaStreams.get(videoRenderer); if (mediaStream != null) { VideoTrack videoTrack = remoteVideoTracks.get(mediaStream); if (videoTrack != null) { videoTrack.removeRenderer(videoRenderer); } } } VideoRenderer newVideoRenderer = new VideoRenderer(remoteRender); remoteVideoTrack.addRenderer(newVideoRenderer); remoteVideoRenderers.put(remoteRender, newVideoRenderer); remoteVideoMediaStreams.put(newVideoRenderer, remoteStream); remoteVideoTracks.put(remoteStream, remoteVideoTrack); Log.d(TAG, "Attached."); } }
@Override public void onAddStream(MediaStream mediaStream) { Log.d(TAG,"SE AÑADE UN CLIENTE onAddStream "+mediaStream.label()); // remote streams are displayed from 1 to MAX_PEER (0 is localStream) mListener.onAddRemoteStream(mediaStream, endPoint+1); }
public AndroidMediaStream(MediaStream stream) { this.isLocal = false; this.stream = stream; this.allTracks = new WebRTCMediaTrack[stream.audioTracks.size() + stream.videoTracks.size()]; this.audioTracks = new WebRTCMediaTrack[stream.audioTracks.size()]; for (int i = 0; i < this.audioTracks.length; i++) { audioTracks[i] = new AndroidAudioTrack(stream.audioTracks.get(i), this); allTracks[i] = audioTracks[i]; } this.videoTracks = new WebRTCMediaTrack[stream.videoTracks.size()]; for (int i = 0; i < this.videoTracks.length; i++) { videoTracks[i] = new AndroidVideoTrack(stream.videoTracks.get(i), this); allTracks[audioTracks.length + i] = videoTracks[i]; } }
@Override public void onRemoveStream(final MediaStream stream){ new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (isActive()) { stream.videoTracks.get(0).dispose(); } } }); }
@Override public void onAddStream(final MediaStream stream){ runOnUiThread(new Runnable() { public void run() { abortUnless(stream.audioTracks.size() <= 1 && stream.videoTracks.size() <= 1, "Weird-looking stream: " + stream); if (stream.videoTracks.size() == 1) { stream.videoTracks.get(0).addRenderer( new VideoRenderer(remoteRender)); } } }); }
@Override public void onRemoveStream(final MediaStream stream){ runOnUiThread(new Runnable() { public void run() { stream.videoTracks.get(0).dispose(); } }); }
@Override public void onAddStream(final MediaStream stream) { executor.execute(new Runnable() { @Override public void run() { if (peerConnection == null || isError) { return; } if (stream.audioTracks.size() > 1 || stream.videoTracks.size() > 1) { reportError("Weird-looking stream: " + stream); return; } if (stream.videoTracks.size() == 1) { remoteVideoTrack = stream.videoTracks.get(0); remoteVideoTrack.setEnabled(renderRemoteVideo); if (remoteRenders.size() > 1) { // until we get the backgrounding working let's only handle 1 throw new RuntimeException("Only supporting size 1 remoteRenders"); } else if (remoteRenders.size() == 1) { remoteVideoRenderer = new VideoRenderer(remoteRenders.get(0)); remoteVideoTrack.addRenderer(remoteVideoRenderer); } /* for (VideoRenderer.Callbacks remoteRender : remoteRenders) { remoteVideoTrack.addRenderer(new VideoRenderer(remoteRender)); } */ events.onRemoteVideo(); } } }); }