Android WebRtc Local Video Stream is not displayin

2019-07-13 10:48发布

Added Libraries:

libjingle_peerconnection.jar (Version :1.7.0_101) libjingle_peerconnection_so.so

GRADLE DEPENDENCY:

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

Tested on 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)

Using below code to set video and audio track:

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);


}

Using Below code to retrieve 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;
            }
        }
    }
}

Using below Code to Update Customized 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);

1条回答
家丑人穷心不美
2楼-- · 2019-07-13 11:20

We have pass proper EGL context to PeerConnectionFactory.setVideoHwAccelerationOptions before calling PeerConnectionFactory.createVideoSource

Below is code for that.

    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 is created on the activity where your SurfaceViewRenderer is created. and it is passed as an argument to setVideoHwAccelerationOptions method.

below line shows how to create an EGL context

    rootEglBase = EglBase.create(); 

Please refer to below link for details: https://github.com/njovy/AppRTCDemo

查看更多
登录 后发表回答