• 【网络通信 -- WebRTC】项目实战记录 -- mediasoup android 适配 webrtc m94


    【网络通信 -- WebRTC】项目实战记录 -- mediasoup android 适配 webrtc m94

    【1】下载并配置 depot_tools

    1. 下载 depot_tools
    2. git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    3. 编辑 ~/.bashrc 将 depot_tools 添加到路径中
    4. vim ~/.bashrc
    5. export PATH=$PATH:/(path to depot_tools)/depot_tools
    6. source ~/.bashrc
    7. 检查 depot_tools 是否安装配置成功
    8. which gn
    9. which gclient

    【2】获取 WebRTC 源码

    1. 获取 Android WebRTC 代码
    2. fetch --nohooks webrtc_android
    3. 若其中发生中断则执行如下命令继续
    4. gclient sync
    5. 切换到 m94 分支并同步
    6. cd src
    7. git checkout -b m94 branch-heads/4606
    8. cd ..
    9. gclient sync --nohooks
    10. gclient runhooks
    11. 下载安装相关依赖
    12. cd src
    13. ./build/install-build-deps.sh
    14. ./build/install-build-deps-android.sh

    【3】编译 WebRTC

    1. 编译 AAR
    2. 编译 libwebrtc.a 和 libwebrtc.jar
    3. 默认不会编译 webrtc 模块,在 /tools_webrtc/android/build_aar.py 文件中加入 ':webrtc',如下
    4. TARGETS = [
    5. ':webrtc',
    6. 'sdk/android:libwebrtc',
    7. 'sdk/android:libjingle_peerconnection_so',
    8. ]
    9. --------------------------------------------------
    10. 开启 h264
    11. 修改 tools_webrtc/libs/generate_licenses.py 如下,添加 LICENSE
    12. 'g722': ['modules/third_party/g722/LICENSE'],
    13. 'fft4g': ['common_audio/third_party/fft4g/LICENSE'],
    14. 'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
    15. + 'openh264':['third_party/openh264/src/LICENSE'],
    16. + 'ffmpeg':['third_party/ffmpeg/LICENSE.md'],
    17. # TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
    18. --------------------------------------------------
    19. 执行编译命令
    20. ./tools_webrtc/android/build_aar.py --extra-gn-args 'is_debug=false is_component_build=false is_clang=true rtc_include_tests=false rtc_use_h264=true rtc_enable_protobuf=false use_rtti=true use_custom_libcxx=false' --build-dir ./out/release-build/m94/
    21. --------------------------------------------------
    22. 编译结果输出路径
    23. out/release-build/m94/armeabi-v7a/obj/libwebrtc.a
    24. out/release-build/m94/armeabi-v7a/lib.java/sdk/android/libwebrtc.jar

    【4】保存 Webrtc Android 相关头文件与库

    1. #!/bin/bash
    2. cd ./src
    3. mkdir -p ../m94/
    4. mkdir -p ../m94/include/third_party/
    5. cp -r api/ ../m94/include/
    6. cp -r audio/ ../m94/include/
    7. cp -r base/ ../m94/include/
    8. cp -r build_overrides/ ../m94/include/
    9. cp -r call/ ../m94/include/
    10. cp -r common_audio/ ../m94/include/
    11. cp -r common_video/ ../m94/include/
    12. cp -r logging/ ../m94/include/
    13. cp -r media/ ../m94/include/
    14. cp -r modules/ ../m94/include/
    15. cp -r p2p/ ../m94/include/
    16. cp -r pc/ ../m94/include/
    17. cp -r rtc_base/ ../m94/include/
    18. cp -r rtc_tools/ ../m94/include/
    19. cp -r sdk/ ../m94/include/
    20. cp -r stats/ ../m94/include/
    21. cp -r style-guide/ ../m94/include/
    22. cp -r system_wrappers/ ../m94/include/
    23. cp -r test/ ../m94/include/
    24. cp -r third_party/abseil-cpp/ ../m94/include/third_party/
    25. cp -r tools_webrtc/ ../m94/include/
    26. cp -r video/ ../m94/include/
    27. cp .clang-format ../m94/include/
    28. cp .git-blame-ignore-revs ../m94/include/
    29. cp .gitignore ../m94/include/
    30. cp .vpython ../m94/include/
    31. cp abseil-in-webrtc.md ../m94/include/
    32. cp AUTHORS ../m94/include/
    33. cp BUILD.gn ../m94/include/
    34. cp codereview.settings ../m94/include/
    35. cp CODE_OF_CONDUCT.md ../m94/include/
    36. cp common_types.h ../m94/include/
    37. cp DEPS ../m94/include/
    38. cp ENG_REVIEW_OWNERS ../m94/include/
    39. cp LICENSE ../m94/include/
    40. cp license_template.txt ../m94/include/
    41. cp native-api.md ../m94/include/
    42. cp OWNERS ../m94/include/
    43. cp PATENTS ../m94/include/
    44. cp PRESUBMIT.py ../m94/include/
    45. cp presubmit_test.py ../m94/include/
    46. cp presubmit_test_mocks.py ../m94/include/
    47. cp pylintrc ../m94/include/
    48. cp README.chromium ../m94/include/
    49. cp README.md ../m94/include/
    50. cp style-guide.md ../m94/include/
    51. cp WATCHLISTS ../m94/include/
    52. cp webrtc.gni ../m94/include/
    53. cp whitespace.txt ../m94/include/
    54. mkdir -p ../m94/lib/arm64-v8a/obj/
    55. mkdir -p ../m94/lib/arm64-v8a/lib.java/sdk/android/
    56. cp out/release-build/m94/arm64-v8a/obj/libwebrtc.a ../m94/lib/arm64-v8a/obj/
    57. cp -r out/release-build/m94/arm64-v8a/lib.java/sdk/android/ ../m94/lib/arm64-v8a/lib.java/sdk/android/
    58. mkdir -p ../m94/lib/armeabi-v7a/obj/
    59. mkdir -p ../m94/lib/armeabi-v7a/lib.java/sdk/android/
    60. cp out/release-build/m94/armeabi-v7a/obj/libwebrtc.a ../m94/lib/armeabi-v7a/obj/
    61. cp -r out/release-build/m94/armeabi-v7a/lib.java/sdk/android/ ../m94/lib/armeabi-v7a/lib.java/sdk/android/
    62. mkdir -p ../m94/lib/x86/obj/
    63. mkdir -p ../m94/lib/x86/lib.java/sdk/android/
    64. cp out/release-build/m94/x86/obj/libwebrtc.a ../m94/lib/x86/obj/
    65. cp -r out/release-build/m94/x86/lib.java/sdk/android/ ../m94/lib/x86/lib.java/sdk/android/
    66. mkdir -p ../m94/lib/x86_64/obj/
    67. mkdir -p ../m94/lib/x86_64/lib.java/sdk/android/
    68. cp out/release-build/m94/x86_64/obj/libwebrtc.a ../m94/lib/x86_64/obj/
    69. cp -r out/release-build/m94/x86_64/lib.java/sdk/android/ ../m94/lib/x86_64/lib.java/sdk/android/
    70. cp libwebrtc.aar ../m94/lib/

    【5】适配 MediaSoup Android Client Lib

    1. 下载 mediasoup-client-android
    2. git clone https://github.com/haiyangwu/mediasoup-client-android.git
    3. 将编译好的 webrtc m94 android 库的头文件与库文件拷贝到项目对应的 deps/webrtc 目录下
    4. 下载 mediasoup-demo-android
    5. git clone https://github.com/haiyangwu/mediasoup-demo-android.git
    6. settings.gradle 中配置 mediasoup-client-android 项目路径
    7. build.gradle(:app) 中引用 mediasoup-client-android
    8. 即可编译 mediaoup-android APK

    参考致谢

    本博客为博主的学习实践总结,并参考了众多博主的博文,在此表示感谢,博主若有不足之处,请批评指正。

    【1】二 Ubuntu下编译WebRtc-Android

    【2】webrtc Android最新源码及编译

    【3】webrtc 103 android编译问题

    【4】安卓 Mediasoup V3 基于webrtc 分支m84 的编译

    【5】基于WebRTC m94 android版本编译 mediasoup-client-android

  • 相关阅读:
    List接口
    LM-INFINITE: SIMPLE ON-THE-FLY LENGTH GENERALIZATION FOR LARGE LANGUAGE MODELS
    用浏览器进行web应用测试,你会怎么做?
    windows qemu安装飞腾Aarch64 操作系统 亲测
    基于 Docker 构建轻量级 CI 系统:Gitea 与 Woodpecker CI 集成
    带你学会指针进阶
    测试用例设计方法-异常测试
    一文看懂一体成型贴片电感感值怎么测量gujing
    Linux系统conda虚拟环境离线迁移移植
    一种基于动态代理的通用研发提效解决方案
  • 原文地址:https://blog.csdn.net/qq_27788177/article/details/131494184