Java Code Examples for org.webrtc.VideoCapturer#startCapture()
The following examples show how to use
org.webrtc.VideoCapturer#startCapture() .
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: MainActivity.java From webrtc-android-tutorial with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // create PeerConnectionFactory PeerConnectionFactory.InitializationOptions initializationOptions = PeerConnectionFactory.InitializationOptions.builder(this).createInitializationOptions(); PeerConnectionFactory.initialize(initializationOptions); PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder().createPeerConnectionFactory(); // create AudioSource AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("101", audioSource); EglBase.Context eglBaseContext = EglBase.create().getEglBaseContext(); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext); // create VideoCapturer VideoCapturer videoCapturer = createCameraCapturer(); VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast()); videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver()); videoCapturer.startCapture(480, 640, 30); SurfaceViewRenderer localView = findViewById(R.id.localView); localView.setMirror(true); localView.init(eglBaseContext, null); // create VideoTrack VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("100", videoSource); // display in localView videoTrack.addSink(localView); }
Example 2
Source File: PeerConnectionClient.java From sample-videoRTC with Apache License 2.0 | 5 votes |
private VideoTrack createVideoTrack(VideoCapturer capturer) { videoSource = factory.createVideoSource(capturer); capturer.startCapture(videoWidth, videoHeight, videoFps); localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); localVideoTrack.setEnabled(renderVideo); localVideoTrack.addSink(localRender); return localVideoTrack; }
Example 3
Source File: PeerConnectionClient.java From janus-gateway-android with MIT License | 5 votes |
private VideoTrack createVideoTrack(VideoCapturer capturer) { videoSource = factory.createVideoSource(capturer); capturer.startCapture(videoWidth, videoHeight, videoFps); localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); localVideoTrack.setEnabled(renderVideo); localVideoTrack.addRenderer(new VideoRenderer(localRender)); return localVideoTrack; }
Example 4
Source File: PeerConnectionClient.java From voip_android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private VideoTrack createVideoTrack(VideoCapturer capturer) { surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", rootEglBase.getEglBaseContext()); videoSource = factory.createVideoSource(capturer.isScreencast()); capturer.initialize(surfaceTextureHelper, appContext, videoSource.getCapturerObserver()); capturer.startCapture(videoWidth, videoHeight, videoFps); localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); localVideoTrack.setEnabled(renderVideo); localVideoTrack.addSink(localRender); return localVideoTrack; }
Example 5
Source File: PeerConnectionClient.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 5 votes |
private VideoTrack createVideoTrack(VideoCapturer capturer) { videoSource = factory.createVideoSource(capturer); capturer.startCapture(videoWidth, videoHeight, videoFps); localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); localVideoTrack.setEnabled(renderLocalVideo); localVideoTrack.addSink(localRender); return localVideoTrack; }
Example 6
Source File: MainActivity.java From webrtc-android-tutorial with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EglBase.Context eglBaseContext = EglBase.create().getEglBaseContext(); // create PeerConnectionFactory PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions .builder(this) .createInitializationOptions()); PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(eglBaseContext, true, true); DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(eglBaseContext); peerConnectionFactory = PeerConnectionFactory.builder() .setOptions(options) .setVideoEncoderFactory(defaultVideoEncoderFactory) .setVideoDecoderFactory(defaultVideoDecoderFactory) .createPeerConnectionFactory(); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext); // create VideoCapturer VideoCapturer videoCapturer = createCameraCapturer(true); VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast()); videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver()); videoCapturer.startCapture(480, 640, 30); localView = findViewById(R.id.localView); localView.setMirror(true); localView.init(eglBaseContext, null); // create VideoTrack VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("100", videoSource); // // display in localView // videoTrack.addSink(localView); SurfaceTextureHelper remoteSurfaceTextureHelper = SurfaceTextureHelper.create("RemoteCaptureThread", eglBaseContext); // create VideoCapturer VideoCapturer remoteVideoCapturer = createCameraCapturer(false); VideoSource remoteVideoSource = peerConnectionFactory.createVideoSource(remoteVideoCapturer.isScreencast()); remoteVideoCapturer.initialize(remoteSurfaceTextureHelper, getApplicationContext(), remoteVideoSource.getCapturerObserver()); remoteVideoCapturer.startCapture(480, 640, 30); remoteView = findViewById(R.id.remoteView); remoteView.setMirror(false); remoteView.init(eglBaseContext, null); // create VideoTrack VideoTrack remoteVideoTrack = peerConnectionFactory.createVideoTrack("102", remoteVideoSource); // // display in remoteView // remoteVideoTrack.addSink(remoteView); mediaStreamLocal = peerConnectionFactory.createLocalMediaStream("mediaStreamLocal"); mediaStreamLocal.addTrack(videoTrack); mediaStreamRemote = peerConnectionFactory.createLocalMediaStream("mediaStreamRemote"); mediaStreamRemote.addTrack(remoteVideoTrack); call(mediaStreamLocal, mediaStreamRemote); }
Example 7
Source File: MainActivity.java From webrtc-android-tutorial with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EglBase.Context eglBaseContext = EglBase.create().getEglBaseContext(); // create PeerConnectionFactory PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions .builder(this) .createInitializationOptions()); PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(eglBaseContext, true, true); DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(eglBaseContext); peerConnectionFactory = PeerConnectionFactory.builder() .setOptions(options) .setVideoEncoderFactory(defaultVideoEncoderFactory) .setVideoDecoderFactory(defaultVideoDecoderFactory) .createPeerConnectionFactory(); SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", eglBaseContext); // create VideoCapturer VideoCapturer videoCapturer = createCameraCapturer(true); VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast()); videoCapturer.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver()); videoCapturer.startCapture(480, 640, 30); localView = findViewById(R.id.localView); localView.setMirror(true); localView.init(eglBaseContext, null); // create VideoTrack VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("100", videoSource); // // display in localView videoTrack.addSink(localView); remoteView = findViewById(R.id.remoteView); remoteView.setMirror(false); remoteView.init(eglBaseContext, null); AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); AudioTrack audioTrack = peerConnectionFactory.createAudioTrack("101", audioSource); mediaStream = peerConnectionFactory.createLocalMediaStream("mediaStream"); mediaStream.addTrack(videoTrack); mediaStream.addTrack(audioTrack); SignalingClient.get().setCallback(this); call(); }