为 webrtc 设置超过 500kb 的 Kurento 媒体服务器的最大带宽

如何解决为 webrtc 设置超过 500kb 的 Kurento 媒体服务器的最大带宽

我在我的 webrtc 项目中使用 Kurento 媒体服务器。 我想提高网络通话的视频质量。

setmaxsend/recbandwith() 不适用于超过 500 kb 的值。

我想更改最大带宽,请告诉我该怎么做。

我需要什么:

  1. 有什么办法可以做到这一点
  2. 我能否找到用于定义带宽的实际变量。
  3. 我想将最大带宽设置为 2000kb。

我的 SDP

v=0\r\n' +
    'o=- 594779498531068541 2 IN IP4 127.0.0.1\r\n' +
    's=-\r\n' +
    't=0 0\r\n' +
    'a=group:BUNDLE 0 1\r\n' +
    'a=msid-semantic: WMS yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1\r\n' +
    'm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\n' +
    'c=IN IP4 0.0.0.0\r\n' +
    'a=rtcp:9 IN IP4 0.0.0.0\r\n' +
    'a=ice-ufrag:nSy7\r\n' +
    'a=ice-pwd:RM/BPZmvUexKN0Sjm+/hCIbz\r\n' +
    'a=ice-options:trickle\r\n' +
    'a=fingerprint:sha-256 46:C6:8C:6A:ED:6C:C0:13:CC:EB:6E:D0:A3:76:12:DA:87:D6:B2:B8:D3:29:F8:CB:D3:FF:FE:96:BF:8F:F3:A6\r\n' +
    'a=setup:actpass\r\n' +
    'a=mid:0\r\n' +
    'a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n' +
    'a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\n' +
    'a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\n' +
    'a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\n' +
    'a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\n' +
    'a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\n' +
    'a=sendrecv\r\n' +
    'a=msid:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1 eb8b778d-91b1-4c0f-b176-3dcc4dff00e0\r\n' +
    'a=rtcp-mux\r\n' +
    'a=rtpmap:111 opus/48000/2\r\n' +
    'a=rtcp-fb:111 transport-cc\r\n' +
    'a=fmtp:111 minptime=10;useinbandfec=1\r\n' +
    'a=rtpmap:103 ISAC/16000\r\n' +
    'a=rtpmap:104 ISAC/32000\r\n' +
    'a=rtpmap:9 G722/8000\r\n' +
    'a=rtpmap:0 PCMU/8000\r\n' +
    'a=rtpmap:8 PCMA/8000\r\n' +
    'a=rtpmap:106 CN/32000\r\n' +
    'a=rtpmap:105 CN/16000\r\n' +
    'a=rtpmap:13 CN/8000\r\n' +
    'a=rtpmap:110 telephone-event/48000\r\n' +
    'a=rtpmap:112 telephone-event/32000\r\n' +
    'a=rtpmap:113 telephone-event/16000\r\n' +
    'a=rtpmap:126 telephone-event/8000\r\n' +
    'a=ssrc:3075742303 cname:XuMK8Lp2rvft5uMI\r\n' +
    'a=ssrc:3075742303 msid:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1 eb8b778d-91b1-4c0f-b176-3dcc4dff00e0\r\n' +
    'a=ssrc:3075742303 mslabel:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1\r\n' +
    'a=ssrc:3075742303 label:eb8b778d-91b1-4c0f-b176-3dcc4dff00e0\r\n' +
    'm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 124 119 123 118 114 115 116\r\n' +
    'c=IN IP4 0.0.0.0\r\n' +
    'a=rtcp:9 IN IP4 0.0.0.0\r\n' +
    'a=ice-ufrag:nSy7\r\n' +
    'a=ice-pwd:RM/BPZmvUexKN0Sjm+/hCIbz\r\n' +
    'a=ice-options:trickle\r\n' +
    'a=fingerprint:sha-256 46:C6:8C:6A:ED:6C:C0:13:CC:EB:6E:D0:A3:76:12:DA:87:D6:B2:B8:D3:29:F8:CB:D3:FF:FE:96:BF:8F:F3:A6\r\n' +
    'a=setup:actpass\r\n' +
    'a=mid:1\r\n' +
    'a=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\n' +
    'a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\n' +
    'a=extmap:13 urn:3gpp:video-orientation\r\n' +
    'a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\n' +
    'a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\n' +
    'a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\n' +
    'a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\n' +
    'a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\n' +
    'a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\n' +
    'a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\n' +
    'a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\n' +
    'a=sendrecv\r\n' +
    'a=msid:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1 a0a25d11-697e-4b2d-bf43-60c9e59291d6\r\n' +
    'a=rtcp-mux\r\n' +
    'a=rtcp-rsize\r\n' +
    'a=rtpmap:96 VP8/90000\r\n' +
    'a=rtcp-fb:96 goog-remb\r\n' +
    'a=rtcp-fb:96 transport-cc\r\n' +
    'a=rtcp-fb:96 ccm fir\r\n' +
    'a=rtcp-fb:96 nack\r\n' +
    'a=rtcp-fb:96 nack pli\r\n' +
    'a=rtpmap:97 rtx/90000\r\n' +
    'a=fmtp:97 apt=96\r\n' +
    'a=rtpmap:98 VP9/90000\r\n' +
    'a=rtcp-fb:98 goog-remb\r\n' +
    'a=rtcp-fb:98 transport-cc\r\n' +
    'a=rtcp-fb:98 ccm fir\r\n' +
    'a=rtcp-fb:98 nack\r\n' +
    'a=rtcp-fb:98 nack pli\r\n' +
    'a=fmtp:98 profile-id=0\r\n' +
    'a=rtpmap:99 rtx/90000\r\n' +
    'a=fmtp:99 apt=98\r\n' +
    'a=rtpmap:100 VP9/90000\r\n' +
    'a=rtcp-fb:100 goog-remb\r\n' +
    'a=rtcp-fb:100 transport-cc\r\n' +
    'a=rtcp-fb:100 ccm fir\r\n' +
    'a=rtcp-fb:100 nack\r\n' +
    'a=rtcp-fb:100 nack pli\r\n' +
    'a=fmtp:100 profile-id=2\r\n' +
    'a=rtpmap:101 rtx/90000\r\n' +
    'a=fmtp:101 apt=100\r\n' +
    'a=rtpmap:102 H264/90000\r\n' +
    'a=rtcp-fb:102 goog-remb\r\n' +
    'a=rtcp-fb:102 transport-cc\r\n' +
    'a=rtcp-fb:102 ccm fir\r\n' +
    'a=rtcp-fb:102 nack\r\n' +
    'a=rtcp-fb:102 nack pli\r\n' +
    'a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\n' +
    'a=rtpmap:121 rtx/90000\r\n' +
    'a=fmtp:121 apt=102\r\n' +
    'a=rtpmap:127 H264/90000\r\n' +
    'a=rtcp-fb:127 goog-remb\r\n' +
    'a=rtcp-fb:127 transport-cc\r\n' +
    'a=rtcp-fb:127 ccm fir\r\n' +
    'a=rtcp-fb:127 nack\r\n' +
    'a=rtcp-fb:127 nack pli\r\n' +
    'a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\n' +
    'a=rtpmap:120 rtx/90000\r\n' +
    'a=fmtp:120 apt=127\r\n' +
    'a=rtpmap:125 H264/90000\r\n' +
    'a=rtcp-fb:125 goog-remb\r\n' +
    'a=rtcp-fb:125 transport-cc\r\n' +
    'a=rtcp-fb:125 ccm fir\r\n' +
    'a=rtcp-fb:125 nack\r\n' +
    'a=rtcp-fb:125 nack pli\r\n' +
    'a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\n' +
    'a=rtpmap:107 rtx/90000\r\n' +
    'a=fmtp:107 apt=125\r\n' +
    'a=rtpmap:108 H264/90000\r\n' +
    'a=rtcp-fb:108 goog-remb\r\n' +
    'a=rtcp-fb:108 transport-cc\r\n' +
    'a=rtcp-fb:108 ccm fir\r\n' +
    'a=rtcp-fb:108 nack\r\n' +
    'a=rtcp-fb:108 nack pli\r\n' +
    'a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\n' +
    'a=rtpmap:109 rtx/90000\r\n' +
    'a=fmtp:109 apt=108\r\n' +
    'a=rtpmap:124 H264/90000\r\n' +
    'a=rtcp-fb:124 goog-remb\r\n' +
    'a=rtcp-fb:124 transport-cc\r\n' +
    'a=rtcp-fb:124 ccm fir\r\n' +
    'a=rtcp-fb:124 nack\r\n' +
    'a=rtcp-fb:124 nack pli\r\n' +
    'a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f\r\n' +
    'a=rtpmap:119 rtx/90000\r\n' +
    'a=fmtp:119 apt=124\r\n' +
    'a=rtpmap:123 H264/90000\r\n' +
    'a=rtcp-fb:123 goog-remb\r\n' +
    'a=rtcp-fb:123 transport-cc\r\n' +
    'a=rtcp-fb:123 ccm fir\r\n' +
    'a=rtcp-fb:123 nack\r\n' +
    'a=rtcp-fb:123 nack pli\r\n' +
    'a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\n' +
    'a=rtpmap:118 rtx/90000\r\n' +
    'a=fmtp:118 apt=123\r\n' +
    'a=rtpmap:114 red/90000\r\n' +
    'a=rtpmap:115 rtx/90000\r\n' +
    'a=fmtp:115 apt=114\r\n' +
    'a=rtpmap:116 ulpfec/90000\r\n' +
    'a=ssrc-group:FID 860428813 4198649496\r\n' +
    'a=ssrc:860428813 cname:XuMK8Lp2rvft5uMI\r\n' +
    'a=ssrc:860428813 msid:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1 a0a25d11-697e-4b2d-bf43-60c9e59291d6\r\n' +
    'a=ssrc:860428813 mslabel:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1\r\n' +
    'a=ssrc:860428813 label:a0a25d11-697e-4b2d-bf43-60c9e59291d6\r\n' +
    'a=ssrc:4198649496 cname:XuMK8Lp2rvft5uMI\r\n' +
    'a=ssrc:4198649496 msid:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1 a0a25d11-697e-4b2d-bf43-60c9e59291d6\r\n' +
    'a=ssrc:4198649496 mslabel:yLSrYTOKMcyDlIv8Sqhr5RW0DNPgo984JnC1\r\n' +
    'a=ssrc:4198649496 label:a0a25d11-697e-4b2d-bf43-60c9e59291d6\r\n'

生成此 sdp 的代码

        return new Promise((resolve,reject) => {

            webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options,function(
                error) {
                if (error) {
                    reject(error)
                    console.error(error);
                    setCallState(NO_CALL);
                }

                this.generateOffer(function(error,offerSdp) {
                    if (error) {
                        console.error(error);
                        setCallState(NO_CALL);
                    }
                    console.log(offerSdp)
                    var message = {
                        id: 'call',from: LOCAL_USER_ID,name: userObject.firstName + " " + userObject.lastName,to: id,sdpOffer: offerSdp
                    };

                    socket.emit('message',message)
                });
            });

        })
    }

我的整个调用方法也许有帮助

    async function kurentoCall(id) {
        if (typeof AdapterJS !== 'undefined' && AdapterJS.webrtcDetectedBrowser === 'IE' && AdapterJS.webrtcDetectedVersion >= 9) {
            await navigator.getUserMedia(constraints,function(stream) {
                local_video_stream = stream;
            },(err) => console.log(err));
        } else {
            await navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
                console.log("video stream acquired")
                local_video_stream = stream;
            }).catch((err) => console.log(err));
        }

        if (!local_video_stream) {
            console.log(local_video_stream)
            console.log("No stream")
            return;
        }
        var options = {
            localVideo: videoInput,remoteVideo: videoOutput,videoStream: local_video_stream,onicecandidate: onIceCandidate
        }
        return new Promise((resolve,message)
                });
            });

        })
    }

解决方法

我在创建答案时更改了 SDP 带宽属性:

function changeSDP( offer ) {
    let audioBandwidth = 2000
    let videoBandwidth = 2000
    // splitting the sdp every line
    let sdp = offer.split('\r\n');
    let new_sdp = '';
    let position = null;
    
    sdp = sdp.slice(0,-1);
    // looping over every line to identify where the bandwidth lines are
    for(let i = 0; i < sdp.length; i++) { 
        if(sdp[i].match('b=AS:')) {
            position = i;
        }
    }
    if(position) {
        sdp.splice(position,1);
    }
    // looping over the truncated sdp to replace the bandwidth attributes
    for(let i = 0; i < sdp.length; i++) {
        // matching video bandwidth
        if(sdp[i].match('m=video')) {
            new_sdp += sdp[i] + '\r\n' + 'b=AS:' + videoBandwidth + '\r\n';
        } else {
            if(sdp[i].match('m=audio')) {
                // current line is the audio bandwidth line,replace it
                new_sdp += sdp[i] + '\r\n' + 'b=AS:' + audioBandwidth + '\r\n';
            }
            else {
                // the sdp doesn't need to be changed,use the old sdp
                new_sdp += sdp[i] + '\r\n';
            }
        }
    }
    // return the old sdp
    return new_sdp;
}

ChangeSDP 获取答案的 sdp 并强制 SDP 使用给定的参数。

这是一个如何使用它的(不完整的)示例:

answer = await pc.createAnswer();
answer.sdp = changeSDP( oldSDP )
await pc.setLocalDescription( answer );

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res