use of org.webrtc.SurfaceViewRenderer in project talk-android by nextcloud.
the class CallActivity method gotRemoteStream.
private void gotRemoteStream(MediaStream stream, String session) {
removeMediaStream(session);
if (stream.videoTracks.size() == 1) {
VideoTrack videoTrack = stream.videoTracks.get(0);
try {
RelativeLayout relativeLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.surface_renderer, remoteRenderersLayout, false);
relativeLayout.setTag(session);
SurfaceViewRenderer surfaceViewRenderer = relativeLayout.findViewById(R.id.surface_view);
surfaceViewRenderer.setMirror(false);
surfaceViewRenderer.init(rootEglBase.getEglBaseContext(), null);
surfaceViewRenderer.setZOrderMediaOverlay(false);
// disabled because it causes some devices to crash
surfaceViewRenderer.setEnableHardwareScaler(false);
surfaceViewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
surfaceViewRenderer.setOnClickListener(videoOnClickListener);
VideoRenderer remoteRenderer = new VideoRenderer(surfaceViewRenderer);
videoTrack.addRenderer(remoteRenderer);
remoteRenderersLayout.addView(relativeLayout);
gotNick(session, getPeerConnectionWrapperForSessionId(session).getNick());
} catch (Exception e) {
Log.d(TAG, "Failed to create a new video view");
}
}
callControls.setZ(100.0f);
}
use of org.webrtc.SurfaceViewRenderer in project matrix-android-sdk by matrix-org.
the class MXWebRtcView method setMirror.
/**
* Sets the indicator which determines whether this {@code WebRTCView} is to
* mirror the video represented by {@link #videoTrack} during its rendering.
*
* @param mirror If this {@code WebRTCView} is to mirror the video
* represented by {@code videoTrack} during its rendering, {@code true};
* otherwise, {@code false}.
*/
public void setMirror(boolean mirror) {
if (this.mirror != mirror) {
this.mirror = mirror;
SurfaceViewRenderer surfaceViewRenderer = getSurfaceViewRenderer();
surfaceViewRenderer.setMirror(mirror);
// SurfaceViewRenderer takes the value of its mirror property into
// account upon its layout.
requestSurfaceViewRendererLayout();
}
}
use of org.webrtc.SurfaceViewRenderer in project matrix-android-sdk by matrix-org.
the class MXWebRtcView method setScalingType.
private void setScalingType(ScalingType scalingType) {
SurfaceViewRenderer surfaceViewRenderer;
synchronized (layoutSyncRoot) {
if (this.scalingType == scalingType) {
return;
}
this.scalingType = scalingType;
surfaceViewRenderer = getSurfaceViewRenderer();
surfaceViewRenderer.setScalingType(scalingType);
}
// Both this instance ant its SurfaceViewRenderer take the value of
// their scalingType properties into account upon their layouts.
requestSurfaceViewRendererLayout();
}
use of org.webrtc.SurfaceViewRenderer in project matrix-android-sdk by matrix-org.
the class MXWebRtcView method tryAddRendererToVideoTrack.
/**
* Starts rendering {@link #videoTrack} if rendering is not in progress and
* all preconditions for the start of rendering are met.
*/
private void tryAddRendererToVideoTrack() {
if (videoRenderer == null && videoTrack != null && ViewCompat.isAttachedToWindow(this)) {
EglBase.Context sharedContext = EglUtils.getRootEglBaseContext();
if (sharedContext == null) {
// If SurfaceViewRenderer#init() is invoked, it will throw a
// RuntimeException which will very likely kill the application.
Log.e(LOG_TAG, "Failed to render a VideoTrack!");
return;
}
SurfaceViewRenderer surfaceViewRenderer = getSurfaceViewRenderer();
surfaceViewRenderer.init(sharedContext, rendererEvents);
videoRenderer = new VideoRenderer(surfaceViewRenderer);
videoTrack.addRenderer(videoRenderer);
}
}
Aggregations