一、代理设置
1 | export http_proxy=http://127.0.0.1:8001 |
export ALL_PROXY=socks5://127.0.0.1:1080好像不行。另,没试过export ALL_PROXY=http://127.0.0.1:8001。
二、WebRTC 源码下载
1 | cd /Users/alby/Workspace/OpenSource/webrtc |
三、WebRTC 编译
1 | cd /Users/alby/Workspace/OpenSource/webrtc/webrtc-checkout/src |
注意,
mac_deployment_target="10.11"。尝试用 12.1 等会失败,因为 WebRTC 使用了一些在高版本已经弃用的接口。
四、libmediasoupclient 源码下载
1 | cd /Users/alby/Workspace/OpenSource/webrtc |
五、libmediasoupclient 编译
1 | cd /Users/alby/Workspace/OpenSource/webrtc/libmediasoupclient |
-DCMAKE_OSX_DEPLOYMENT_TARGET="10.11",最好和编译WebRTC时保持一致。
六、mediasoup-broadcaster-demo 编译
1 | cd /Users/alby/Workspace/OpenSource/webrtc |
如有必要:
brew install openssl@1.1
问题
1、libmediasoupclient 相关
在编译 libmediasoupclient 的过程中如果出现与 #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ 行有关的错误,将其改为 #define CATCH_TRAP() asm(".inst 0xd4200000")。见https://github.com/versatica/libmediasoupclient/issues/140。
2、absl 相关
如果在链接时报类似错误:
1 | Undefined symbols for architecture arm64: |
用命令 nm -A libwebrtc.a | grep set_update_rect | c++filt 查看该方法的符号也是存在的:
1 | libwebrtc.a:video_frame.o: 00000000000006c4 T webrtc::VideoFrame::Builder::set_update_rect(absl::optional<webrtc::VideoFrame::UpdateRect> const&) |
但是 libwebrtc 用的是 absl::optional,在应用程序中使用的是 std::optional,需保持一致。
将 webrtc-checkout/src/third_party/abseil-cpp/absl/base/options.h 中 ABSL_OPTION_USE_STD_ANY 、ABSL_OPTION_USE_STD_OPTIONAL ABSL_OPTION_USE_STD_STRING_VIEW 和 ABSL_OPTION_USE_STD_VARIANT 四个宏的值改为从 2 改为 0 再重新编译 webrtc:
1 | // ABSL_OPTION_USE_STD_OPTIONAL |
参考资料
libmediasoupclient v3 Installation
Mac M1 fails to build while building tests