行业网站推广外包,天翼云主机 网站服务器,如何建设好网站,国外做测评的网站EglBase是什么#xff1f; 它提供了一个接口#xff0c;用于在Android平台上创建和管理EGL#xff08;嵌入式系统图形库#xff09;上下文#xff0c;以便在WebRTC中进行图像和视频的处理和渲染。 Capturer, Source, Track, Sink分别是什么#xff1f; Capturer#xff…EglBase是什么 它提供了一个接口用于在Android平台上创建和管理EGL嵌入式系统图形库上下文以便在WebRTC中进行图像和视频的处理和渲染。 Capturer, Source, Track, Sink分别是什么 Capturer采集器是指用于采集音频或视频数据的设备或软件。它可以是麦克风、摄像头或其他采集设备。Source源是指从采集器获取的原始音频或视频数据。它是数据的起点并可能包含噪音、干扰或其他不必要的信息。Track跟踪器是指对源数据进行处理和分析的组件。它可以包括音频或视频的编码、滤波、分割、特征提取等算法和技术。Sink接收器是指从跟踪器输出的经过处理的音频或视频数据的目标或目的地。它可以是扬声器、显示器或其他接收设备。 activity_rtc.xml
?xml version1.0 encodingutf-8?
androidx.constraintlayout.widget.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingdimen/dp_20org.webrtc.SurfaceViewRendererandroid:idid/localViewandroid:layout_widthmatch_parentandroid:layout_height0dpapp:layout_constraintHeight_percent0.5app:layout_constraintLeft_toLeftOfparentapp:layout_constraintTop_toTopOfparent //androidx.constraintlayout.widget.ConstraintLayoutRtcActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;import androidx.annotation.Nullable;import org.webrtc.Camera1Enumerator;
import org.webrtc.EglBase;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.SurfaceViewRenderer;
import org.webrtc.VideoCapturer;
import org.webrtc.VideoSource;
import org.webrtc.VideoTrack;public class RtcActivity extends Activity {private static final String TAG RtcRemoteActivity;Overrideprotected void onCreate(Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_rtc);// factory static initPeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(this).createInitializationOptions());PeerConnectionFactory.Options options new PeerConnectionFactory.Options();// factory createPeerConnectionFactory peerConnectionFactory PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory();// create videoCapturerCamera1Enumerator camera1Enumerator new Camera1Enumerator(false);// false输出到surfaceString[] deviceNames camera1Enumerator.getDeviceNames();VideoCapturer videoCapturer null;for (String deviceName : deviceNames) {if (camera1Enumerator.isFrontFacing(deviceName)) {VideoCapturer capturer camera1Enumerator.createCapturer(deviceName, null);if (capturer ! null) {videoCapturer capturer;break;}Log.e(TAG, onCreate: create capturer fail);return;}}if (videoCapturer null) {return;}// create videoSourceVideoSource videoSource peerConnectionFactory.createVideoSource(videoCapturer.isScreencast());// init videoCapturerEglBase.Context eglBaseContext EglBase.create().getEglBaseContext();SurfaceTextureHelper surfaceTextureHelper SurfaceTextureHelper.create(surfaceTexture, eglBaseContext);videoCapturer.initialize(surfaceTextureHelper, this, videoSource.getCapturerObserver());videoCapturer.startCapture(480, 640, 30);// width, height, frame// create videoTrackVideoTrack videoTrack peerConnectionFactory.createVideoTrack(videoTrack-1, videoSource);// get show viewSurfaceViewRenderer localView findViewById(R.id.localView);localView.setMirror(true);// 镜像localView.init(eglBaseContext, null);// link track to view so that data show in viewvideoTrack.addSink(localView);}
}