当前位置: 首页 > news >正文

webrtc用clang编译支持h264,支持msvc调用库

webrtc遇到困扰:

  • 如果msvc编译,ffmpeg编译失败,需要替换ffmpeg库。
  • 如果用clang编译,vs或qt调用dll又存在崩溃。
    经过反复尝试找到解决方法:

一、编译

1、编译参数

//我得环境配置
set DEPOT_TOOLS_UPDATE=0
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set GYP_MSVS_VERSION=2022
set GYP_MSVS_OVERRIDE_PATH =C:\Program Files (x86)\Microsoft Visual Studio 14.0
set GYP_GENERATORS=msvs-ninja,ninja//x86 release
gn gen out\x86_release_clang --ide=vs2022 --args="use_rtti=true is_debug=false target_cpu=\"x86\" is_component_ffmpeg=true ffmpeg_branding=\"Chrome\" proprietary_codecs=true  rtc_use_h264=true  gtest_enable_absl_printers=false libyuv_include_tests=false  rtc_enable_protobuf=false treat_warnings_as_errors=false use_custom_libcxx=false"//x86 debug
gn gen out\x86_debug_clang --ide=vs2022 --args="use_rtti=true is_debug=true target_cpu=\"x86\" is_component_ffmpeg=true ffmpeg_branding=\"Chrome\" proprietary_codecs=true  rtc_use_h264=true  gtest_enable_absl_printers=false libyuv_include_tests=false  rtc_enable_protobuf=false treat_warnings_as_errors=false enable_iterator_debugging=true use_custom_libcxx=false rtc_enable_avx2=false"

生成sln后,在vs内编译。
生成jsoncpp,进入到生成目录内

lib *.obj /out:jsoncpp.lib

2、编译webrtc,生成libwebrtc库。

2、使用

vs2022 创建dll,举例测试apm:
在这里插入图片描述
选llvm,c++17标准
在这里插入图片描述
多线程MTD
在这里插入图片描述
预处理器这一大堆是比较麻烦的,怎么办?
找到 src\out\x86_debug_clang\obj\pc 下面的peer_connection.vcxproj,用记事本打开,复制

<PreprocessorDefinitions>USE_AURA=1;_HAS_NODISCARD;_CRT_NONSTDC_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;CR_CLANG_REVISION=&quot;llvmorg-18-init-4631-gd50b56d1-1&quot;;_HAS_EXCEPTIONS=0;__STD_C;_CRT_RAND_S;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_ATL_NO_OPENGL;_WINDOWS;CERT_CHAIN_PARA_HAS_EXTRA_FIELDS;PSAPI_VERSION=2;WIN32;_SECURE_ATL;WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WIN32_LEAN_AND_MEAN;NOMINMAX;_UNICODE;UNICODE;NTDDI_VERSION=NTDDI_WIN10_NI;_WIN32_WINNT=0x0A00;WINVER=0x0A00;_DEBUG;DYNAMIC_ANNOTATIONS_ENABLED=1;WEBRTC_ENABLE_PROTOBUF=0;WEBRTC_STRICT_FIELD_TRIALS=0;WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE;RTC_ENABLE_VP9;RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY;WEBRTC_HAVE_SCTP;WEBRTC_USE_H264;WEBRTC_LIBRARY_IMPL;RTC_ENABLE_WIN_WGC;WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1;WEBRTC_WIN;ABSL_ALLOCATOR_NOTHROW=1;_ENABLE_EXTENDED_ALIGNED_STORAGE;LIBYUV_DISABLE_NEON;%(PreprocessorDefinitions)</PreprocessorDefinitions>

在这里插入图片描述
这个是连接器输入,

  • 比较重要的对clang的附加选项限制
    在这里插入图片描述
    这个找到 src\out\x86_debug_clang\obj\pc 下面的peer_connection.vcxproj
      <AdditionalOptions>-Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wshadow -fno-delete-null-pointer-checks -fno-ident -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 /clang:-ffp-contract=off -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase -ffile-reproducible /Zc:sizedDealloc- /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1934 -m32 -msse3 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes /std:c11 -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare /std:c++17 -Wno-trigraphs -ftrivial-auto-var-init=pattern /Ob0 /GF /Z7 -gno-codeview-command-line -gcodeview-ghash -Xclang -fuse-ctor-homing /guard:cf,nochecks -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -Wno-shadow -Wctad-maybe-unsupported -Wc++11-narrowing -Wundef -Wunused-lambda-capture %(AdditionalOptions)</AdditionalOptions>

在这里面封装好的库,就可以在msvc里调用了。

如果还有问题,可能是llvm的版本有问题,需要在dll工程的同目录下创建Directory.build.props 文件,记事本打开编辑

<Project><PropertyGroup><LLVMInstallDir>G:\webrtc20230919\src\third_party\llvm-build\Release+Asserts</LLVMInstallDir><LLVMToolsVersion>18</LLVMToolsVersion></PropertyGroup>
</Project>

这里是指定llvm应用版本,制定的和webrtc用同一个。

http://www.lryc.cn/news/188901.html

相关文章:

  • 迁移学习是什么?
  • 哈希的应用--位图和布隆过滤器
  • mac M2芯片在使用Android studio 编译问题bad cpu type in executable android
  • M4Singer ubuntu 22.04 4060ti16g ModuleNotFoundError: No module named ‘gradio‘
  • postman 密码rsa加密登录-2加密密码
  • 如何去图片水印?这些方法解决你的问题
  • Qt通过正则表达式筛选出字符串中的手机号
  • 【Pytorch】深度学习之数据读取
  • Maven教程
  • 一篇带你看懂异步:promise、async await
  • RocketMQ快速实战以及集群架构详解
  • 京东运营数据分析:2023年8月京东饮料行业品牌销售排行榜
  • ES6之函数的扩展二
  • Ubuntu-Ports更新源 ARM64更新源
  • 渗透测试怎么入门?(超详细解读)
  • MS31804四通道低边驱动器可pin对pin兼容DRV8804
  • Fastadmin 子级菜单展开合并,分类父级归纳
  • Idea创建springboot工程的时候,发现pom文件没有带<parent>标签
  • element树形控件编辑节点组装节点
  • 【算法-动态规划】斐波那契第 n 项
  • Linux系统运行级别详解,切换、配置和常见服务
  • 企业需要ERP系统的八大理由,最后一个尤其重要
  • Java-Atomic原子操作类详解及源码分析,Java原子操作类进阶,LongAdder源码分析
  • 算法通过村第十二关-字符串|黄金笔记|冲刺难题
  • 3ds Max渲染太慢?创意云“一键云渲染”提升3ds Max渲染体验
  • 记录一次公益SRC的常见的cookie注入漏洞(适合初学者)
  • [ACTF2020 新生赛]Exec1
  • DeepFace【部署 03】轻量级人脸识别和面部属性分析框架deepface在Linux环境下服务部署(conda虚拟环境+docker)
  • vuex的求和案例和mapstate,mapmutations,mapgetters
  • Docker 网络访问原理解密