【发布时间】:2020-04-10 09:14:10
【问题描述】:
在 Android 中实现 WebRTC 时遇到此问题:
原因:java.lang.RuntimeException:CameraCapturer 必须在调用 startCapture 之前进行初始化。
build.gradle(:app)
dependencies {
......
implementation 'org.webrtc:google-webrtc:1.0.+'
......
}
// 导致问题的块:
private void getVideoSource() {
// isScreenCast = false
videoSource = peerConnectionFactory.createVideoSource(false);
surfaceTextureHelper = SurfaceTextureHelper.create(Thread.currentThread().getName(), rootEglBase.getEglBaseContext());
VideoCapturer videoCapturer = createCameraCapturer(new Camera1Enumerator(false));
localVideoTrack = peerConnectionFactory.createVideoTrack("200", videoSource);
localVideoTrack.addSink(local_renderer);
if(videoCapturer != null)
videoCapturer.startCapture(1000,1000,30); // <- Here is the Exception
}
CameraCapturer 已弃用。 Camera1Capturer 现在可用。
【问题讨论】:
标签: java android webrtc webrtc-android