本文主要是介绍mediasoup源码(一)编译及部署,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
基本介绍
mediasoup是一个sfu架构的流媒体服务器,读者可以根据需要选择不同的编译方式。如果只需要学习c++流媒体传输部分,则选择mediasoup,如果需要学习mediasoup整个demo,并做演示,则可以选择mediasoup-demo,如果只需要学习mediasoup客户端部分,则选择mediasoup-client
前置要求
1.选择linux环境,centos或者ubuntu
2.nodejs版本大于18.0
安装 gulp:
sudo npm install -g gulp-cli
安装 build-essential:
sudo apt install build-essential
编译
①仅编译mediasoup
//下载mediasoup源码
git clone https://github.com/versatica/mediasoup.git
//跳转到编译路径
cd mediasoup/worker
//编译
执行make命令
编译后生成的可执行文件路径为
e/mediasoup/worker/out/Release/mediasoup-worker
②编译mediasoup-demo
1.下载源码
git clone https://github.com/versatica/mediasoup-demo.git
2.下载相关依赖
cd mediasoup-demo/server
执行npm install -g gulp-cli
cd mediasoup-demp/client
执行npm install -g gulp-cli
服务依赖项如下
{"name": "mediasoup-demo-server","version": "3.0.0","private": true,"description": "mediasoup demo server","author": "Iñaki Baz Castillo <ibc@aliax.net>","license": "All Rights Reserved","main": "lib/index.js","scripts": {"generate-dev-certificate": "mkcert -install --key-file certs/server.key --cert-file certs/server.crt mediasoup-demo.dev \"*.mediasoup-demo.dev\" localhost 127.0.0.1 ::1","lint": "eslint -c .eslintrc.js server.js lib connect.js","start": "DEBUG=${DEBUG:='*mediasoup* *INFO* *WARN* *ERROR*'} INTERACTIVE=${INTERACTIVE:='true'} node server.js","connect": "node connect.js"},"dependencies": {"@sitespeed.io/throttle": "^3.1.1","awaitqueue": "^2.3.3","body-parser": "^1.19.0","colors": "^1.4.0","debug": "^4.3.1","express": "^4.17.1","mediasoup": "github:versatica/mediasoup#v3","pidusage": "^2.0.21","protoo-server": "^4.0.5","rtp.js": "^0.11.4"},"devDependencies": {"eslint": "^6.8.0","gulp": "^4.0.2","gulp-eslint": "^6.0.0","gulp-plumber": "^1.2.1"}
}
客户端依赖如下
{"name": "mediasoup-demo-app","version": "3.0.0","private": true,"description": "mediasoup demo app","author": "Iñaki Baz Castillo <ibc@aliax.net>","license": "All Rights Reserved","main": "lib/index.jsx","scripts": {"lint": "eslint -c .eslintrc.js --ext .js,.jsx gulpfile.js lib","start": "gulp live"},"dependencies": {"@babel/runtime": "^7.8.4","bowser": "^2.11.0","classnames": "^2.2.6","clipboard-copy": "^3.1.0","debug": "^4.3.1","domready": "^1.0.8","face-api.js": "^0.21.0","hark": "^1.2.3","js-cookie": "^2.2.1","mediasoup-client": "github:versatica/mediasoup-client#v3","pokemon": "^2.0.2","prop-types": "^15.7.2","protoo-client": "^4.0.5","random-string": "^0.2.0","react": "^16.12.0","react-dom": "^16.12.0","react-draggable": "^3.3.2","react-dropzone": "^10.2.1","react-redux": "^7.2.0","react-spinner": "^0.2.7","react-tooltip": "^3.11.1","react-transition-group": "^4.3.0","redux": "^4.0.5","redux-logger": "^3.0.6","redux-thunk": "^2.3.0","riek": "^1.1.0","url-parse": "^1.4.7"},"devDependencies": {"@babel/core": "^7.8.4","@babel/plugin-proposal-object-rest-spread": "^7.8.3","@babel/plugin-transform-runtime": "^7.8.3","@babel/preset-env": "^7.8.4","@babel/preset-react": "^7.8.3","babel-plugin-jsx-control-statements": "^4.0.0","babelify": "^10.0.0","browser-sync": "^2.26.7","browserify": "^16.5.0","del": "^5.1.0","envify": "^4.1.0","eslint": "^6.8.0","eslint-plugin-import": "^2.20.1","eslint-plugin-jsx-control-statements": "^2.2.1","eslint-plugin-react": "^7.18.3","gulp": "^4.0.2","gulp-css-base64": "^1.3.4","gulp-eslint": "^6.0.0","gulp-header": "^2.0.9","gulp-if": "^3.0.0","gulp-plumber": "^1.2.1","gulp-rename": "^1.4.0","gulp-stylus": "^2.7.0","gulp-touch-cmd": "0.0.1","gulp-uglify-es": "^3.0.0","gulp-util": "^3.0.8","mkdirp": "^0.5.1","ncp": "^2.0.0","nib": "^1.1.2","supports-color": "^7.1.0","vinyl-buffer": "^1.0.1","vinyl-source-stream": "^2.0.0","watchify": "^3.11.1"}
}
启动服务
启动服务之前先生成证书,修改配置文件
在 mediasoup-demo/server下创建cert目录,然后通过openssl生成自签名证书
openssl genrsa -out privkey.pem 2048
openssl req -new -key privkey.pem -out csr.pem
openssl x509 -req -in csr.pem -signkey privkey.pem -out fullchain.pem
修改配置文件
将config.example.js改名为config.js
cp config.example.js config.js
修改MEDIASOUP_ANNOUNCED_IP为服务器主机对应的IP
启动服务
MEDIASOUP_ANNOUNCED_IP=主机对应的IP地址 npm start
启动客户端
cd mediasoup-demo/app
npm start
其他方式部署mediasoup
参考李超老师提供的mediasoup-demo编译
这篇关于mediasoup源码(一)编译及部署的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!