Java Code Examples for org.webrtc.PeerConnection#RTCConfiguration
The following examples show how to use
org.webrtc.PeerConnection#RTCConfiguration .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebRtcClient.java From imsdk-android with MIT License | 6 votes |
public Peer(EglBase.Context context) { PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); if(pcParams.videoCallEnabled) { factory.setVideoHwAccelerationOptions(context, context); } // rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.ALL; rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.RELAY; //禁用TCP, turn服务器ice协议使用UDP rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.ENABLED; rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.NEGOTIATE; rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; // Use ECDSA encryption. rtcConfig.keyType = PeerConnection.KeyType.ECDSA; this.pc = factory.createPeerConnection(rtcConfig, pcConstraints, this); pc.addStream(localMS); if(mListener != null) mListener.onStatusChanged(WebRTCStatus.CONNECTING); }
Example 2
Source File: PeerConnectionChannel.java From owt-client-android with Apache License 2.0 | 6 votes |
protected PeerConnectionChannel(String key, PeerConnection.RTCConfiguration configuration, boolean receiveVideo, boolean receiveAudio, PeerConnectionChannelObserver observer) { this.key = key; this.observer = observer; videoRtpSenders = new ConcurrentHashMap<>(); audioRtpSenders = new ConcurrentHashMap<>(); queuedRemoteCandidates = new LinkedList<>(); queuedMessage = new ArrayList<>(); sdpConstraints = new MediaConstraints(); sdpConstraints.mandatory.add( new KeyValuePair("OfferToReceiveAudio", String.valueOf(receiveAudio))); sdpConstraints.mandatory.add( new KeyValuePair("OfferToReceiveVideo", String.valueOf(receiveVideo))); peerConnection = PCFactoryProxy.instance().createPeerConnection(configuration, this); RCHECK(peerConnection); signalingState = peerConnection.signalingState(); }
Example 3
Source File: PeerConnectionClient.java From janus-gateway-android with MIT License | 6 votes |
private PeerConnection createPeerConnection(BigInteger handleId, boolean type) { Log.d(TAG, "Create peer connection."); PeerConnection.IceServer iceServer = new PeerConnection.IceServer("turn:xxx.xxx.xx.xx:xxx", "ling", "ling1234"); List<PeerConnection.IceServer> iceServers = new ArrayList<>(); iceServers.add(iceServer); PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.RELAY; PCObserver pcObserver = new PCObserver(); SDPObserver sdpObserver = new SDPObserver(); PeerConnection peerConnection = factory.createPeerConnection(rtcConfig, pcConstraints, pcObserver); JanusConnection janusConnection = new JanusConnection(); janusConnection.handleId = handleId; janusConnection.sdpObserver = sdpObserver; janusConnection.peerConnection = peerConnection; janusConnection.type = type; peerConnectionMap.put(handleId, janusConnection); pcObserver.setConnection(janusConnection); sdpObserver.setConnection(janusConnection); Log.d(TAG, "Peer connection created."); return peerConnection; }
Example 4
Source File: CallActivity.java From RTCStartupDemo with GNU General Public License v3.0 | 5 votes |
public PeerConnection createPeerConnection() { Log.i(TAG, "Create PeerConnection ..."); PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(new ArrayList<>()); PeerConnection connection = mPeerConnectionFactory.createPeerConnection(configuration, mPeerConnectionObserver); if (connection == null) { Log.e(TAG, "Failed to createPeerConnection !"); return null; } connection.addTrack(mVideoTrack); connection.addTrack(mAudioTrack); return connection; }
Example 5
Source File: MainActivity.java From owt-client-android with Apache License 2.0 | 5 votes |
private void initConferenceClient() { rootEglBase = EglBase.create(); if (!contextHasInitialized) { ContextInitialization.create() .setApplicationContext(this) .addIgnoreNetworkType(ContextInitialization.NetworkType.LOOPBACK) .setVideoHardwareAccelerationOptions( rootEglBase.getEglBaseContext(), rootEglBase.getEglBaseContext()) .initialize(); contextHasInitialized = true; } PeerConnection.IceServer iceServer = PeerConnection.IceServer.builder( "turn:example.com?transport=tcp").setUsername("userName").setPassword( "passward").createIceServer(); List<PeerConnection.IceServer> iceServers = new ArrayList<>(); iceServers.add(iceServer); PeerConnection.RTCConfiguration rtcConfiguration = new PeerConnection.RTCConfiguration( iceServers); HttpUtils.setUpINSECURESSLContext(); rtcConfiguration.continualGatheringPolicy = GATHER_CONTINUALLY; ConferenceClientConfiguration configuration = ConferenceClientConfiguration.builder() .setHostnameVerifier(HttpUtils.hostnameVerifier) .setSSLContext(HttpUtils.sslContext) .setRTCConfiguration(rtcConfiguration) .build(); conferenceClient = new ConferenceClient(configuration); conferenceClient.addObserver(this); }
Example 6
Source File: P2PClientConfiguration.java From owt-client-android with Apache License 2.0 | 5 votes |
private P2PClientConfiguration(PeerConnection.RTCConfiguration rtcConfiguration, List<AudioEncodingParameters> audioEncodings, List<VideoEncodingParameters> videoEncodings) { super(rtcConfiguration); this.audioEncodings = audioEncodings; this.videoEncodings = videoEncodings; }
Example 7
Source File: PeerConnectionResourceManager.java From webrtcpeer-android with Apache License 2.0 | 5 votes |
NBMPeerConnection createPeerConnection( SignalingParameters signalingParameters, MediaConstraints pcConstraints, String connectionId) { Log.d(TAG, "Create peer connection."); Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); // TCP candidates are only useful when connecting to a server that supports ICE-TCP. PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(signalingParameters.iceServers); rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE; rtcConfig.keyType = PeerConnection.KeyType.ECDSA; //rtcConfig.iceServers IceServer NBMPeerConnection connectionWrapper = new NBMPeerConnection(connectionId, preferIsac, videoCallEnabled, preferH264, executor, peerConnectionParameters); PeerConnection peerConnection = factory.createPeerConnection(rtcConfig, pcConstraints, connectionWrapper); connectionWrapper.setPc(peerConnection); connections.put(connectionId, connectionWrapper); // Set default WebRTC tracing and INFO libjingle logging. // NOTE: this _must_ happen while |factory| is alive! Logging.enableTracing("logcat:", EnumSet.of(Logging.TraceLevel.TRACE_DEFAULT), Logging.Severity.LS_INFO); Log.d(TAG, "Peer connection created."); return connectionWrapper; }
Example 8
Source File: WebRTC.java From iGap-Android with GNU Affero General Public License v3.0 | 5 votes |
PeerConnection peerConnectionInstance() { if (peerConnection == null) { List<PeerConnection.IceServer> iceServers = new ArrayList<>(); Realm realm = Realm.getDefaultInstance(); RealmCallConfig realmCallConfig = realm.where(RealmCallConfig.class).findFirst(); for (RealmIceServer ice : realmCallConfig.getIceServer()) { iceServers.add(new PeerConnection.IceServer(ice.getUrl(), ice.getUsername(), ice.getCredential())); } realm.close(); PeerConnection.RTCConfiguration configuration = new PeerConnection.RTCConfiguration(iceServers); configuration.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; configuration.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE; configuration.iceTransportsType = PeerConnection.IceTransportsType.RELAY; PeerConnection.Observer observer = new PeerConnectionObserver(); MediaConstraints mediaConstraints = mediaConstraintsGetInstance(); peerConnection = peerConnectionFactoryInstance().createPeerConnection(iceServers, mediaConstraints, observer); mediaStream = peerConnectionFactoryInstance().createLocalMediaStream("ARDAMS"); addAudioTrack(mediaStream); addVideoTrack(mediaStream); peerConnection.addStream(mediaStream); } return peerConnection; }
Example 9
Source File: ConferenceClientConfiguration.java From owt-client-android with Apache License 2.0 | 4 votes |
private ConferenceClientConfiguration(PeerConnection.RTCConfiguration configuration) { super(configuration); }
Example 10
Source File: WebRTCWrapper.java From Conversations with GNU General Public License v3.0 | 4 votes |
synchronized void initializePeerConnection(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws InitializationException { Preconditions.checkState(this.eglBase != null); Preconditions.checkNotNull(media); Preconditions.checkArgument(media.size() > 0, "media can not be empty when initializing peer connection"); final boolean setUseHardwareAcousticEchoCanceler = WebRtcAudioEffects.canUseAcousticEchoCanceler() && !HARDWARE_AEC_BLACKLIST.contains(Build.MODEL); Log.d(Config.LOGTAG, String.format("setUseHardwareAcousticEchoCanceler(%s) model=%s", setUseHardwareAcousticEchoCanceler, Build.MODEL)); PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder() .setVideoDecoderFactory(new DefaultVideoDecoderFactory(eglBase.getEglBaseContext())) .setVideoEncoderFactory(new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true)) .setAudioDeviceModule(JavaAudioDeviceModule.builder(context) .setUseHardwareAcousticEchoCanceler(setUseHardwareAcousticEchoCanceler) .createAudioDeviceModule() ) .createPeerConnectionFactory(); final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); final Optional<CapturerChoice> optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); if (optionalCapturerChoice.isPresent()) { this.capturerChoice = optionalCapturerChoice.get(); final CameraVideoCapturer capturer = this.capturerChoice.cameraVideoCapturer; final VideoSource videoSource = peerConnectionFactory.createVideoSource(false); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext()); capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver()); Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate())); capturer.startCapture(capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate()); this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource); stream.addTrack(this.localVideoTrack); } if (media.contains(Media.AUDIO)) { //set up audio track final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); this.localAudioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource); stream.addTrack(this.localAudioTrack); } final PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver); if (peerConnection == null) { throw new InitializationException("Unable to create PeerConnection"); } peerConnection.addStream(stream); peerConnection.setAudioPlayout(true); peerConnection.setAudioRecording(true); this.peerConnection = peerConnection; }
Example 11
Source File: WebRTCWrapper.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
synchronized void initializePeerConnection(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws InitializationException { Preconditions.checkState(this.eglBase != null); Preconditions.checkNotNull(media); Preconditions.checkArgument(media.size() > 0, "media can not be empty when initializing peer connection"); final boolean setUseHardwareAcousticEchoCanceler = WebRtcAudioEffects.canUseAcousticEchoCanceler() && !HARDWARE_AEC_BLACKLIST.contains(Build.MODEL); Log.d(Config.LOGTAG, String.format("setUseHardwareAcousticEchoCanceler(%s) model=%s", setUseHardwareAcousticEchoCanceler, Build.MODEL)); PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder() .setVideoDecoderFactory(new DefaultVideoDecoderFactory(eglBase.getEglBaseContext())) .setVideoEncoderFactory(new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true)) .setAudioDeviceModule(JavaAudioDeviceModule.builder(context) .setUseHardwareAcousticEchoCanceler(setUseHardwareAcousticEchoCanceler) .createAudioDeviceModule() ) .createPeerConnectionFactory(); final MediaStream stream = peerConnectionFactory.createLocalMediaStream("my-media-stream"); final Optional<CapturerChoice> optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent(); if (optionalCapturerChoice.isPresent()) { this.capturerChoice = optionalCapturerChoice.get(); final CameraVideoCapturer capturer = this.capturerChoice.cameraVideoCapturer; final VideoSource videoSource = peerConnectionFactory.createVideoSource(false); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext()); capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver()); Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate())); capturer.startCapture(capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate()); this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource); stream.addTrack(this.localVideoTrack); } if (media.contains(Media.AUDIO)) { //set up audio track final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); this.localAudioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource); stream.addTrack(this.localAudioTrack); } final PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers); rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY; final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver); if (peerConnection == null) { throw new InitializationException("Unable to create PeerConnection"); } peerConnection.addStream(stream); peerConnection.setAudioPlayout(true); peerConnection.setAudioRecording(true); this.peerConnection = peerConnection; }
Example 12
Source File: PeerConnectionClient.java From Yahala-Messenger with MIT License | 4 votes |
private void createPeerConnectionInternal(EGLContext renderEGLContext) { if (factory == null || isError) { Log.e(TAG, "Peerconnection factory is not created"); return; } Log.d(TAG, "Create peer connection."); Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); if (videoConstraints != null) { Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); } queuedRemoteCandidates = new LinkedList<IceCandidate>(); if (videoCallEnabled) { Log.d(TAG, "EGLContext: " + renderEGLContext); factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext); } PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(signalingParameters.iceServers); // TCP candidates are only useful when connecting to a server that supports // ICE-TCP. rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE; // Use ECDSA encryption. rtcConfig.keyType = PeerConnection.KeyType.ECDSA; peerConnection = factory.createPeerConnection( rtcConfig, pcConstraints, pcObserver); isInitiator = false; // Set default WebRTC tracing and INFO libjingle logging. // NOTE: this _must_ happen while |factory| is alive! Logging.enableTracing( "logcat:", EnumSet.of(Logging.TraceLevel.TRACE_DEFAULT), Logging.Severity.LS_INFO); mediaStream = factory.createLocalMediaStream("ARDAMS"); if (videoCallEnabled) { String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); String frontCameraDeviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice(); if (numberOfCameras > 1 && frontCameraDeviceName != null) { cameraDeviceName = frontCameraDeviceName; } Log.d(TAG, "Opening camera: " + cameraDeviceName); videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, peerConnectionParameters.captureToTexture ? renderEGLContext : null); if (videoCapturer == null) { reportError("Failed to open camera"); return; } mediaStream.addTrack(createVideoTrack(videoCapturer)); } mediaStream.addTrack(factory.createAudioTrack( AUDIO_TRACK_ID, factory.createAudioSource(audioConstraints))); peerConnection.addStream(mediaStream); Log.d(TAG, "Peer connection created."); }
Example 13
Source File: ConferencePeerConnectionChannel.java From owt-client-android with Apache License 2.0 | 4 votes |
ConferencePeerConnectionChannel(String key, PeerConnection.RTCConfiguration configuration, boolean receiveVideo, boolean receiveAudio, PeerConnectionChannelObserver observer) { super(key, configuration, receiveVideo, receiveAudio, observer); queuedLocalCandidates = new LinkedList<>(); }
Example 14
Source File: Peer.java From webrtc_android with MIT License | 4 votes |
public PeerConnection createPeerConnection() { PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(mIceLis); return mFactory.createPeerConnection(rtcConfig, this); }
Example 15
Source File: PeerConnectionWrapper.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public PeerConnectionWrapper(@NonNull Context context, @NonNull PeerConnectionFactory factory, @NonNull PeerConnection.Observer observer, @NonNull VideoSink localRenderer, @NonNull List<PeerConnection.IceServer> turnServers, @NonNull CameraEventListener cameraEventListener, @NonNull EglBase eglBase, boolean hideIp) { List<PeerConnection.IceServer> iceServers = new LinkedList<>(); iceServers.add(STUN_SERVER); iceServers.addAll(turnServers); this.iceServers = iceServers; 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.peerConnection.setAudioPlayout(false); this.peerConnection.setAudioRecording(false); this.mediaStream = factory.createLocalMediaStream("ARDAMS"); this.audioSource = factory.createAudioSource(audioConstraints); this.audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource); this.audioTrack.setEnabled(false); mediaStream.addTrack(audioTrack); this.camera = new Camera(context, cameraEventListener); if (camera.capturer != null) { this.videoSource = factory.createVideoSource(false); this.videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource); camera.capturer.initialize(SurfaceTextureHelper.create("WebRTC-SurfaceTextureHelper", eglBase.getEglBaseContext()), context, videoSource.getCapturerObserver()); this.videoTrack.addSink(localRenderer); this.videoTrack.setEnabled(false); mediaStream.addTrack(videoTrack); } else { this.videoSource = null; this.videoTrack = null; } this.peerConnection.addStream(mediaStream); }
Example 16
Source File: ConferenceClientConfiguration.java From owt-client-android with Apache License 2.0 | 2 votes |
/** * Set up the RTCConfiguration for the underlying WebRTC PeerConnection * * @param rtcConfiguration RTCConfiguration to be set. * @return Builder */ public Builder setRTCConfiguration(PeerConnection.RTCConfiguration rtcConfiguration) { this.rtcConfiguration = rtcConfiguration; return this; }
Example 17
Source File: P2PClientConfiguration.java From owt-client-android with Apache License 2.0 | 2 votes |
/** * Set up the RTCConfiguration for the underlying WebRTC PeerConnection * * @param rtcConfiguration RTCConfiguration to be set. * @return Builder */ public Builder setRTCConfiguration(PeerConnection.RTCConfiguration rtcConfiguration) { this.rtcConfiguration = rtcConfiguration; return this; }