gpt4 book ai didi

Android WebRtc 本地视频流不显示在棉花糖上,但适用于 Lollipop

转载 作者:搜寻专家 更新时间:2023-11-01 08:32:29 27 4
gpt4 key购买 nike

添加的库:

libjingle_peerconnection.jar(版本:1.7.0_101)libjingle_peerconnection_so.so

渐变依赖:

fi.vtt.nubomedia:utilities-android:1.0.1@aar

在 Lenovo K3 Note( Android 6 Marsh Mallow) 上测试

Log:
================================================================================
09-15 15:36:10.585 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/mpeg-L2

09-15 15:36:10.590 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/x-adpcm-ms

09-15 15:36:10.595 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima

09-15 15:36:10.605 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/ape

09-15 15:36:10.607 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/alac

09-15 15:36:10.609 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/ac3

09-15 15:36:10.611 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/eac3

09-15 15:36:10.614 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/eac3-joc

09-15 15:36:10.618 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/x-adpcm-ms

09-15 15:36:10.619 4103-4103/com.caprusit.capv W/AudioCapabilities: Unsupported mime audio/x-adpcm-dvi-ima

09-15 15:36:10.631 4103-4103/com.caprusit.capv W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es

09-15 15:36:10.643 4103-4103/com.caprusit.capv W/VideoCapabilities: Unsupported mime video/x-ms-wmv

09-15 15:36:10.645 4103-4103/com.caprusit.capv W/VideoCapabilities: Unsupported mime video/divx

09-15 15:36:10.647 4103-4103/com.caprusit.capv W/VideoCapabilities: Unsupported mime video/divx3

09-15 15:36:10.649 4103-4103/com.caprusit.capv W/VideoCapabilities: Unsupported mime video/xvid

09-15 15:36:10.652 4103-4103/com.caprusit.capv W/VideoCapabilities: Unsupported mime video/flv1

09-15 15:36:10.800 4103-4712/com.caprusit.capv W/org.webrtc.Logging: WebRtcAudioManager: Invalid audio mode: MODE_NORMAL

09-15 15:36:10.873 4103-4719/com.caprusit.capv W/org.webrtc.Logging: WebRtcAudioManager: Invalid audio mode: MODE_NORMAL

09-15 15:36:11.224 4103-4702/com.caprusit.capv W/libEGL: [ANDROID_RECORDABLE] format: 2

09-15 15:36:11.250 4103-4747/com.caprusit.capv W/libEGL: [ANDROID_RECORDABLE] format: 2

09-15 15:36:11.889 4103-4702/com.caprusit.capv E/AndroidRuntime: FATAL EXCEPTION: GLThread 124856

Process: com.caprusit.capv, PID: 4103
java.lang.RuntimeException: compileShader: GLES20 error: 1282

at org.webrtc.GlUtil.checkNoGLES2Error(GlUtil.java:29)

at org.webrtc.GlShader.compileShader(GlShader.java:37)

at org.webrtc.GlShader.<init>(GlShader.java:44)

at org.webrtc.GlRectDrawer$Shader.<init>(GlRectDrawer.java:104)

at org.webrtc.GlRectDrawer.prepareShader(GlRectDrawer.java:176)

at org.webrtc.GlRectDrawer.drawRgb(GlRectDrawer.java:135)

at com.caprusit.capv.CustomVideoRenderGui$YuvImageRenderer.draw(CustomVideoRenderGui.java:453)

at com.caprusit.capv.CustomVideoRenderGui$YuvImageRenderer.access$700(CustomVideoRenderGui.java:320)


at com.caprusit.capv.CustomVideoRenderGui.onDrawFrame(CustomVideoRenderGui.java:314)

at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1590)

at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)

09-15 15:36:12.621 4103-4110/com.caprusit.capv W/art: Suspending all threads took: 89.404ms

09-15 15:36:13.765 4103-4103/com.caprusit.capv E/libEGL: call to OpenGL ES API with no current context (logged once per thread)

使用以下代码设置视频和音频轨道:

public void setCamera() {

localMS = factory.createLocalMediaStream("ARDAMS");

if (pcParams.videoCallEnabled) {

MediaConstraints videoConstraints = new MediaConstraints();
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxHeight", Integer.toString(pcParams.videoHeight)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxWidth", Integer.toString(pcParams.videoWidth)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("maxFrameRate", Integer.toString(pcParams.videoFps)));
videoConstraints.mandatory.add(new MediaConstraints.KeyValuePair("minFrameRate", Integer.toString(pcParams.videoFps)));

getVideoCapturer();
videoSource = factory.createVideoSource(videoCapturer, videoConstraints);
videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource);
localMS.addTrack(videoTrack);

}

audioSource = factory.createAudioSource(new MediaConstraints());
audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource);
localMS.addTrack(audioTrack);

mListener.onLocalStream(localMS, true);


}

使用以下代码检索 VideoCapturer:

private void createCapturer(CameraEnumerator enumerator) {
final String[] deviceNames = enumerator.getDeviceNames();
Logging.d(TAG, "Looking for front facing cameras.");

for (String deviceName : deviceNames) {
if (enumerator.isFrontFacing(deviceName)) {
Logging.d(TAG, "Creating front facing camera capturer.");
videoCapturer = enumerator.createCapturer(deviceName, null);

if (videoCapturer != null) {

System.out.println("deviceName = " + deviceName);
return;

}
}
}

// Front facing camera not found, try something else
Logging.d(TAG, "Looking for other cameras.");
for (String deviceName : deviceNames) {
if (!enumerator.isFrontFacing(deviceName)) {
Logging.d(TAG, "Creating other camera capturer.");
videoCapturer = enumerator.createCapturer(deviceName, null);

if (videoCapturer != null) {
return;
}
}
}
}

使用以下代码更新自定义的 VideoRenderGui:

                localStream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender));

localVideoRenderGui.update(localRender,
LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING,
LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING,
scalingType, true);

最佳答案

在调用 PeerConnectionFactory.createVideoSource 之前,我们已将适当的 EGL 上下文传递给 PeerConnectionFactory.setVideoHwAccelerationOptions

下面是代码。

    factory.setVideoHwAccelerationOptions(rootEglBase.getEglBaseContext(), rootEglBase.getEglBaseContext());
localMS = factory.createLocalMediaStream("ARDAMS");

if (pcParams.videoCallEnabled) {

getVideoCapturer();

videoSource = factory.createVideoSource(videoCapturer);
videoCapturer.startCapture(pcParams.videoWidth, pcParams.videoHeight, pcParams.videoFps);
videoTrack = factory.createVideoTrack("ARDAMSv0", videoSource);
videoTrack.setEnabled(true);

localMS.addTrack(videoTrack);

}

audioSource = factory.createAudioSource(new MediaConstraints());
audioTrack = factory.createAudioTrack("ARDAMSa0", audioSource);
localMS.addTrack(audioTrack);

mListener.onLocalStream(localMS, true);

Eglcontext 是在创建 SurfaceViewRenderer 的 Activity 上创建的。并将其作为参数传递给 setVideoHwAccelerationOptions 方法。

下行显示了如何创建 EGL 上下文

    rootEglBase = EglBase.create(); 

详情请引用以下链接: https://github.com/njovy/AppRTCDemo

关于Android WebRtc 本地视频流不显示在棉花糖上,但适用于 Lollipop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39528908/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com