1

我正在努力在我的系统上集成easyrtc。目前我可以进行音频和视频通话。但过了一段时间后,我可以听到自己的声音,并且有明显的延迟。我用 chrome 签入chrome:webrtc-internals,似乎没有回声消除技术的输入。How can I enable it?谢谢你。如果还有什么需要

我们的集成代码:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page session="true" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html lang="de">
<head>
    <jsp:include page="../common/meta.jsp"/>
    <title>&nbsp;<spring:message code="meta.title.videochat"/></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/easyrtc.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/jquery-ui.css">
</head>
<body class="stream-view">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script>
        if (typeof jQuery == 'undefined') {
            document.write(unescape("%3Cscript src='/resources/js/plugins/jquery-2.1.4.min.js' type='text/javascript'%3E%3C/script%3E"));
        }
    </script>
    <script type="text/javascript" src="https://www.OUR_APP.com:PORT/socket.io/socket.io.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/easyrtc/easyrtc.js?version=${appVersionNumber}"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/easyrtc/easyrtc_rates.js?version=${appVersionNumber}"></script>
  var activeBox = -1;  // nothing selected
    var aspectRatio = 4/3;  // standard definition video aspect ratio
    var maxCALLERS = 5;
    var numVideoOBJS = maxCALLERS;
    var layout;
    var microphone = true;
    var camera = true;

    var getURLParameter = function(name){
        if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
            return decodeURIComponent(name[1]);
    };

    var personal = getURLParameter("p");
    var group = getURLParameter("g");

    easyrtc.setSocketUrl("https://www.OUR_APP.com:PORT");
    easyrtc.dontAddCloseButtons(true);
4

2 回答 2

2

“降噪”和“能听到自己的声音”是不同的东西。

第一个被称为噪声抑制。后者称为 AEC(声学回声消除)。

在 Chrome 中,您可以通过指定 mediaConstraints 来设置它们,但我认为它们默认是打开的:

var mediaConstraints = {
    audio: {
        echoCancellation: { exact: true },
        googEchoCancellation: { exact: true},
        googAutoGainControl: { exact: true},
        googNoiseSuppression: { exact: true},
    }
}

在 Firefox 中,您需要使用“moz”前缀而不是“goog”。

于 2017-07-17T18:41:30.497 回答
0

为了扩展给定的答案,这有助于作为一个起点,但没有解释easyrtc中的实现:

我已经开始讨论关于 open-easyrtc 的拉取请求的问题,但现在我已经通过单行更新破解了我自己的分支:

(请注意,我在这里发布了整个函数,但实际变化很小,如评论所示——查找“START FORK”)

self.getUserMediaConstraints = function() {
        var constraints = {};
        //
        // _presetMediaConstraints allow you to provide your own constraints to be used
        // with initMediaSource.
        //
        if (self._presetMediaConstraints) {
            constraints = self._presetMediaConstraints;
            delete self._presetMediaConstraints;
            return constraints;
        }  else if (!self.videoEnabled) {
            constraints.video = false;
        }
        else {

            // Tested Firefox 49 and MS Edge require minFrameRate and maxFrameRate 
            // instead max,min,ideal that cause GetUserMedia failure.
            // Until confirmed both browser support idea,max and min we need this.
            if (
                adapter && adapter.browserDetails &&
                    (adapter.browserDetails.browser === "firefox" || adapter.browserDetails.browser === "edge")
            ) {
                constraints.video = {};
                if (self._desiredVideoProperties.width) {
                    constraints.video.width = self._desiredVideoProperties.width;
                }
                if (self._desiredVideoProperties.height) {
                    constraints.video.height = self._desiredVideoProperties.height;
                }
                if (self._desiredVideoProperties.frameRate) {
                    constraints.video.frameRate = { 
                        minFrameRate: self._desiredVideoProperties.frameRate,
                        maxFrameRate: self._desiredVideoProperties.frameRate
                    };
                }
                if (self._desiredVideoProperties.videoSrcId) {
                    constraints.video.deviceId = self._desiredVideoProperties.videoSrcId;
                }

            // chrome and opera
            } else { 
                constraints.video = {};
                if (self._desiredVideoProperties.width) {
                     constraints.video.width = { 
                        max: self._desiredVideoProperties.width,
                        min : self._desiredVideoProperties.width,
                        ideal : self._desiredVideoProperties.width 
                     };
                }
                if (self._desiredVideoProperties.height) {
                    constraints.video.height = {
                        max: self._desiredVideoProperties.height,
                        min: self._desiredVideoProperties.height,
                        ideal: self._desiredVideoProperties.height
                    };
                }
                if (self._desiredVideoProperties.frameRate) {
                    constraints.video.frameRate = {
                        max: self._desiredVideoProperties.frameRate,
                        ideal: self._desiredVideoProperties.frameRate
                    };
                }
                if (self._desiredVideoProperties.videoSrcId) {
                    constraints.video.deviceId = self._desiredVideoProperties.videoSrcId;
                }
                // hack for opera
                if (Object.keys(constraints.video).length === 0 ) {
                    constraints.video = true;
                }
            }
        }

        if (!self.audioEnabled) {
            constraints.audio = false;
        }
        else {
            // START FORK FOR ECHO CANCELLATION
            // 
            //
            // see: https://github.com/open-easyrtc/open-easyrtc/issues/47

            // constraints.audio = {};
            constraints.audio = {
                sampleSize: 8,
                echoCancellation: true,
            };
            //
            // END FORK
            //
    
            if (self._desiredAudioProperties.audioSrcId) {
            //    constraints.audio.deviceId = {exact: self._desiredAudioProperties.audioSrcId};
             constraints.audio.deviceId = self._desiredAudioProperties.audioSrcId;
            }
        }
        console.log("CONSTRAINTS", constraints)
        return constraints;
    };

这是修补此问题的短期方法。理想情况下,open-easyrtc 将来会获得一种任意添加此类功能标志的方法。

如果您不打算实现自己的 open-easyrtc 分支,则需要使用self._presetMediaConstraints. 但是,这将排除此函数中的所有逻辑,并排除使用easyrtc.enableAudio等函数,如果我没记错的话,要求您自己做所有这些,或者只是复制/粘贴此代码并让混乱四处飘荡(正如您在此答案中看到的,此代码将来可能会更改,您不会看到这些更新或从这些更新中受益)。从长远来看,这可能是我要走的路,但我为客户工作的时间/预算有限,并且已经有现有的逻辑可以与 easyrtc 中的默认代码路径一起使用,所以我不想开始为自己重写所有这些弄得一团糟。

但是,如果你要走那条路,你会做类似的事情

easyrtc._presetMediaConstraints = {
    audio: {
      sampleSize: 8,
      echoCancellation: true
    }
  }
于 2020-07-31T03:05:47.903 回答