Recently, I need to sort out the original project, modify and improve functions, and extract and use functions. The module WebRtc has been assigned to me. First of all, WebRtc is a third-party SDK for multi-purpose video browsing. If you are interested, you can learn about it

  1. No static method create()Lorg/ WebRtc /EglBase

Gradle version should not be too high around 3.4.1

  1. The WebRtc point-to-point local video is not displayed

    Using multiple EglBases results in inconsistent objects

    For example, global and local variables are used in the same place

        -- EglBase eglBase = null;
	-- eglBase = EglBase.create();

	-- final EglBase eglBase = EglBase.create();
Copy the code

Remove local variables

  1. WebRtc Video encoding and sharpness The sharpness of the encoding is related to the video width and high (resolution) video transmission bit rate

    Video size resolution bit rate 480P 720 X 480 1800kbps 720P 1280 X 720 3500kbps 1080P 1920 X 1080 8500kbpsCopy the code

Depending on hardware and network support, the higher the bit rate, the clearer the network bandwidth

If the bit rate is too high, the video will be stuck, unclear and Mosaic during the call, because the hardware we tested is not as good as the CPU of the mobile phone. When setting 720P, 3500 is too high and 2000 is too fuzzy, and the compromise value is 3k, which needs to be obtained through the testCopy the code
Pseudo code: RtpParameters parameters. = localVideoSender getParameters ();for (RtpParameters.Encoding encoding : parameters.encodings) {
                // Null value means no limit.
          encoding.maxBitrateBps = maxBitrateKbps == null ? null : maxBitrateKbps * BPS_IN_KBPS;
        }
Copy the code
  1. WebRtc video echo suppression and sound gain

        / / pseudo code
     AudioDeviceModule createJavaAudioDevice(a) {
    return builder(appContext)
                .setSamplesReadyCallback(saveRecordedAudioToFile)
                .setUseHardwareAcousticEchoCanceler(false) \ \falseTurn on echo suppressiontrueDon't open. SetUseHardwareNoiseSuppressor (false) \ \falseTurn on sound gaintrueDon't open. CreateAudioDeviceModule (); } ` ` `Copy the code
  2. The difference between WebRtc sound gain (software) and AudioManager is that AudioManager calls the volume level of the local hardware. If the volume is raised to the highest level, it cannot increase the volume. Software sound gain can call the gain level int 0-10 on this basis Private class PCObserver implements Observer {private class PCObserver implements Observer {

    @override public void onAddStream(final MediaStream stream) {log. e("-->"," +peerConnectionParameters.voiceGainLevel); stream.audioTracks.get(0).setVolume(1); }Copy the code

    }

  3. View stacking problem solving and processing

    First question about the android 7 view laminated Should be a version of the function Call the setZOrderMediaOverlay (true);

    view.setZOrderOnTop(true);

    / / it doesn’t work

    The problem of changing the layout to relative layout layering has not been solved

    view.bringToFront();

    Use this to place the specified view at the top level