org.webrtc.SurfaceViewRenderer Java Examples
The following examples show how to use
org.webrtc.SurfaceViewRenderer.
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: RCConnection.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 6 votes |
private void initializeVideo(boolean videoEnabled, PercentFrameLayout localRenderLayout, PercentFrameLayout remoteRenderLayout) { if (localRenderLayout == null ||remoteRenderLayout == null) { return; } scalingType = ScalingType.SCALE_ASPECT_FILL; this.localRenderLayout = localRenderLayout; this.remoteRenderLayout = remoteRenderLayout; localRender = (SurfaceViewRenderer)localRenderLayout.getChildAt(0); remoteRender = (SurfaceViewRenderer)remoteRenderLayout.getChildAt(0); localRender.init(peerConnectionClient.getRenderContext(), null); localRender.setZOrderMediaOverlay(true); remoteRender.init(peerConnectionClient.getRenderContext(), null); updateVideoView(VideoViewState.NONE); }
Example #2
Source File: MainActivity.java From janus-gateway-android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); rootView = (LinearLayout) findViewById(R.id.activity_main); mWebSocketChannel = new WebSocketChannel(); mWebSocketChannel.initConnection("ws://xxx:xxx"); mWebSocketChannel.setDelegate(this); createLocalRender(); remoteRender = (SurfaceViewRenderer) findViewById(R.id.remote_video_view); remoteRender.init(rootEglBase.getEglBaseContext(), null); peerConnectionParameters = new PeerConnectionParameters(false, 360, 480, 20, "H264", true, 0, "opus", false, false, false, false, false); peerConnectionClient = PeerConnectionClient.getInstance(); peerConnectionClient.createPeerConnectionFactory(this, peerConnectionParameters, this); }
Example #3
Source File: MainActivity.java From owt-client-android with Apache License 2.0 | 6 votes |
@Override public void onReady(final SurfaceViewRenderer localRenderer, final SurfaceViewRenderer remoteRenderer) { this.localRenderer = localRenderer; this.remoteRenderer = remoteRenderer; localRenderer.init(rootEglBase.getEglBaseContext(), null); remoteRenderer.init(rootEglBase.getEglBaseContext(), null); executor.execute(() -> { if (capturer == null) { boolean vga = settingsFragment == null || settingsFragment.resolutionVGA; boolean isCameraFront = settingsFragment == null || settingsFragment.cameraFront; capturer = OwtVideoCapturer.create(vga ? 640 : 1280, vga ? 480 : 720, 30, true, isCameraFront); localStream = new LocalStream(capturer, new MediaConstraints.AudioTrackConstraints()); } localStream.attach(localRenderer); if (remoteStream != null && !remoteStreamEnded) { remoteStream.attach(remoteRenderer); } }); }
Example #4
Source File: CustomWebSocketListener.java From WebRTCapp with Apache License 2.0 | 6 votes |
private void createVideoView(final RemoteParticipant remoteParticipant) { Handler mainHandler = new Handler(videoConferenceActivity.getMainLooper()); Runnable myRunnable = new Runnable() { @Override public void run() { View rowView = videoConferenceActivity.getLayoutInflater().inflate(R.layout.peer_video, null); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(0, 0, 0, 20); rowView.setLayoutParams(lp); int rowId = View.generateViewId(); rowView.setId(rowId); views_container.addView(rowView); SurfaceViewRenderer videoView = (SurfaceViewRenderer)((ViewGroup)rowView).getChildAt(0); remoteParticipant.setVideoView(videoView); videoView.setMirror(false); EglBase rootEglBase = EglBase.create(); videoView.init(rootEglBase.getEglBaseContext(), null); videoView.setZOrderMediaOverlay(true); View textView = ((ViewGroup)rowView).getChildAt(1); remoteParticipant.setParticipantNameText((TextView) textView); remoteParticipant.setView(rowView); } }; mainHandler.post(myRunnable); }
Example #5
Source File: WebRtcCallService.java From bcm-android with GNU General Public License v3.0 | 6 votes |
private void initializeVideo() { Util.runOnMainSync(() -> { eglBase = EglBase.create(); localRenderer = new SurfaceViewRenderer(WebRtcCallService.this); remoteRenderer = new SurfaceViewRenderer(WebRtcCallService.this); localRenderer.init(eglBase.getEglBaseContext(), null); remoteRenderer.init(eglBase.getEglBaseContext(), null); VideoEncoderFactory encoderFactory = new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true); VideoDecoderFactory decoderFactory = new DefaultVideoDecoderFactory(eglBase.getEglBaseContext()); peerConnectionFactory = PeerConnectionFactory.builder() .setOptions(new PeerConnectionFactoryOptions()) .setVideoEncoderFactory(encoderFactory) .setVideoDecoderFactory(decoderFactory) .createPeerConnectionFactory(); }); }
Example #6
Source File: WebRtcViewModel.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public WebRtcViewModel(@NonNull State state, boolean videoCall, @Nullable Recipient recipient, @Nullable IdentityKey identityKey, @NonNull CameraState localCameraState, @Nullable SurfaceViewRenderer localRenderer, @Nullable SurfaceViewRenderer remoteRenderer, boolean remoteVideoEnabled, boolean isBluetoothAvailable, boolean isMicrophoneEnabled) { this.state = state; this.videoCall = videoCall; this.recipient = recipient; this.localCameraState = localCameraState; this.localRenderer = localRenderer; this.remoteRenderer = remoteRenderer; this.identityKey = identityKey; this.remoteVideoEnabled = remoteVideoEnabled; this.isBluetoothAvailable = isBluetoothAvailable; this.isMicrophoneEnabled = isMicrophoneEnabled; }
Example #7
Source File: WebRtcViewModel.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public WebRtcViewModel(@NonNull State state, boolean videoCall, @Nullable Recipient recipient, @NonNull CameraState localCameraState, @Nullable SurfaceViewRenderer localRenderer, @Nullable SurfaceViewRenderer remoteRenderer, boolean remoteVideoEnabled, boolean isBluetoothAvailable, boolean isMicrophoneEnabled) { this(state, videoCall, recipient, null, localCameraState, localRenderer, remoteRenderer, remoteVideoEnabled, isBluetoothAvailable, isMicrophoneEnabled); }
Example #8
Source File: Peer.java From webrtc_android with MIT License | 6 votes |
public void createRender(EglBase mRootEglBase, Context context, boolean isOverlay) { renderer = new SurfaceViewRenderer(context); renderer.init(mRootEglBase.getEglBaseContext(), new RendererCommon.RendererEvents() { @Override public void onFirstFrameRendered() { Log.d(TAG, "createRender onFirstFrameRendered"); } @Override public void onFrameResolutionChanged(int videoWidth, int videoHeight, int rotation) { Log.d(TAG, "createRender onFrameResolutionChanged"); } }); renderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL); renderer.setMirror(true); renderer.setZOrderMediaOverlay(isOverlay); sink = new ProxyVideoSink(); sink.setTarget(renderer); if (_remoteStream != null && _remoteStream.videoTracks.size() > 0) { _remoteStream.videoTracks.get(0).addSink(sink); } }
Example #9
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 #10
Source File: RtpSessionActivity.java From Conversations with GNU General Public License v3.0 | 5 votes |
private void ensureSurfaceViewRendererIsSetup(final SurfaceViewRenderer surfaceViewRenderer) { surfaceViewRenderer.setVisibility(View.VISIBLE); try { surfaceViewRenderer.init(requireRtpConnection().getEglBaseContext(), null); } catch (IllegalStateException e) { Log.d(Config.LOGTAG, "SurfaceViewRenderer was already initialized"); } surfaceViewRenderer.setEnableHardwareScaler(true); }
Example #11
Source File: RtpSessionActivity.java From Conversations with GNU General Public License v3.0 | 5 votes |
private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) { try { videoTrack.addSink(surfaceViewRenderer); } catch (final IllegalStateException e) { Log.e(Config.LOGTAG, "possible race condition on trying to display video track. ignoring", e); } }
Example #12
Source File: RtpSessionActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private void ensureSurfaceViewRendererIsSetup(final SurfaceViewRenderer surfaceViewRenderer) { surfaceViewRenderer.setVisibility(View.VISIBLE); try { surfaceViewRenderer.init(requireRtpConnection().getEglBaseContext(), null); } catch (IllegalStateException e) { Log.d(Config.LOGTAG, "SurfaceViewRenderer was already initialized"); } surfaceViewRenderer.setEnableHardwareScaler(true); }
Example #13
Source File: RtpSessionActivity.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) { try { videoTrack.addSink(surfaceViewRenderer); } catch (final IllegalStateException e) { Log.e(Config.LOGTAG, "possible race condition on trying to display video track. ignoring", e); } }
Example #14
Source File: WebRTCEngine.java From webrtc_android with MIT License | 5 votes |
@Override public View startPreview(boolean isOverlay) { localRenderer = new SurfaceViewRenderer(mContext); localRenderer.init(mRootEglBase.getEglBaseContext(), null); localRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT); localRenderer.setMirror(true); localRenderer.setZOrderMediaOverlay(isOverlay); localSink = new ProxyVideoSink(); localSink.setTarget(localRenderer); if (_localStream.videoTracks.size() > 0) { _localStream.videoTracks.get(0).addSink(localSink); } return localRenderer; }
Example #15
Source File: PeerVideoActivity.java From nubo-test with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_chat); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mHandler = new Handler(); masterView = (SurfaceViewRenderer) findViewById(R.id.gl_surface); localView = (SurfaceViewRenderer) findViewById(R.id.gl_surface_local); this.mCallStatus = (TextView) findViewById(R.id.call_status); callState = CallState.IDLE; MainActivity.getKurentoRoomAPIInstance().addObserver(this); }
Example #16
Source File: RTCCall.java From meshenger-android with GNU General Public License v3.0 | 4 votes |
public void setRemoteRenderer(SurfaceViewRenderer remoteRenderer) { this.remoteRenderer = remoteRenderer; }
Example #17
Source File: VideoActivity.java From VideoCRE with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_video); VideoConfig config = VideoConfig.builder() .previewWidth(1280) .previewHeight(720) .outputWidth(448) .outputHeight(800) .fps(30) .outputBitrate(800) .build(); VideoConfig hdConfig = VideoConfig.builder() .previewWidth(1280) .previewHeight(720) .outputWidth(720) .outputHeight(1280) .fps(30) .outputBitrate(2000) .build(); VideoCapturer capturer = createVideoCapturer(); mVideoView = (SurfaceViewRenderer) findViewById(R.id.mVideoView1); try { String filename = "video_source_record_" + System.currentTimeMillis(); mMp4Recorder = new Mp4Recorder( new File(Environment.getExternalStorageDirectory(), filename + ".mp4")); mHdMp4Recorder = new Mp4Recorder( new File(Environment.getExternalStorageDirectory(), filename + "-hd.mp4")); } catch (IOException e) { e.printStackTrace(); Toast.makeText(this, "start Mp4Recorder fail!", Toast.LENGTH_SHORT).show(); finish(); return; } mHwAvcEncoder = new HwAvcEncoder(config, mMp4Recorder); mHdHwAvcEncoder = new HwAvcEncoder(hdConfig, mHdMp4Recorder); mVideoSink = new VideoSink(mVideoView, mHwAvcEncoder, mHdHwAvcEncoder); mVideoSource = new VideoSource(getApplicationContext(), config, capturer, mVideoSink); mVideoView.init(mVideoSource.getRootEglBase().getEglBaseContext(), null); mHwAvcEncoder.start(mVideoSource.getRootEglBase()); mHdHwAvcEncoder.start(mVideoSource.getRootEglBase()); initView(); }
Example #18
Source File: MainActivity.java From janus-gateway-android with MIT License | 4 votes |
private void createLocalRender() { localRender = (SurfaceViewRenderer) findViewById(R.id.local_video_view); rootEglBase = EglBase.create(); localRender.init(rootEglBase.getEglBaseContext(), null); localRender.setEnableHardwareScaler(true); }
Example #19
Source File: RTCCall.java From Meshenger with GNU General Public License v3.0 | 4 votes |
public void setRemoteRenderer(SurfaceViewRenderer remoteRenderer) { this.remoteRenderer = remoteRenderer; }
Example #20
Source File: MainService.java From Meshenger with GNU General Public License v3.0 | 4 votes |
RTCCall startCall(Contact contact, String identifier, String username, RTCCall.OnStateChangeListener listener, SurfaceViewRenderer renderer) { return RTCCall.startCall(contact, username, identifier, listener, MainService.this); }
Example #21
Source File: MainActivity.java From owt-client-android with Apache License 2.0 | 4 votes |
@Override public void onRenderer(SurfaceViewRenderer localRenderer, SurfaceViewRenderer remoteRenderer) { this.localRenderer = localRenderer; this.remoteRenderer = remoteRenderer; }
Example #22
Source File: RemoteParticipant.java From WebRTCapp with Apache License 2.0 | 4 votes |
public void setVideoView(SurfaceViewRenderer videoView) { this.videoView = videoView; }
Example #23
Source File: RemoteParticipant.java From WebRTCapp with Apache License 2.0 | 4 votes |
public SurfaceViewRenderer getVideoView() { return videoView; }
Example #24
Source File: PeersManager.java From WebRTCapp with Apache License 2.0 | 4 votes |
public PeersManager(VideoConferenceActivity activity, LinearLayout views_container, SurfaceViewRenderer localVideoView) { this.views_container = views_container; this.localVideoView = localVideoView; this.activity = activity; }
Example #25
Source File: WebRtcViewModel.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public @Nullable SurfaceViewRenderer getRemoteRenderer() { return remoteRenderer; }
Example #26
Source File: WebRtcViewModel.java From bcm-android with GNU General Public License v3.0 | 4 votes |
public @Nullable SurfaceViewRenderer getLocalRenderer() { return localRenderer; }
Example #27
Source File: VideoFragment.java From owt-client-android with Apache License 2.0 | votes |
void onRenderer(SurfaceViewRenderer localRenderer, SurfaceViewRenderer remoteRenderer);
Example #28
Source File: CallFragment.java From owt-client-android with Apache License 2.0 | votes |
void onReady(SurfaceViewRenderer localRenderer, SurfaceViewRenderer remoteRenderer);