From d11981fa6f73b7304ca4ba0dcc1ad051257a4323 Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Thu, 26 Dec 2024 22:34:52 +0000 Subject: [PATCH 1/2] Add video factories to libwebrtc server. --- libwebrtc/CMakeLists.txt | 13 +++++++------ libwebrtc/Dockerfile | 1 + libwebrtc/Dockerfile-Builder | 3 +-- libwebrtc/PcFactory.cpp | 14 ++++++++------ libwebrtc/README.md | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libwebrtc/CMakeLists.txt b/libwebrtc/CMakeLists.txt index 4672154..3ea8703 100755 --- a/libwebrtc/CMakeLists.txt +++ b/libwebrtc/CMakeLists.txt @@ -5,6 +5,7 @@ set(CMAKE_CXX_COMPILER clang++) set(CMAKE_LINKER ld.lld) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti") project(libwebrtc-webrtc-echo VERSION 1.0) @@ -17,7 +18,8 @@ target_sources(libwebrtc-webrtc-echo PRIVATE add_definitions(-D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS -D_LIBCPP_DEBUG=0 -DWEBRTC_LINUX -DWEBRTC_POSIX -DUSE_AURA=1 -D_HAS_EXCEPTIONS=0 -D_SILENCE_ALL_CXX20_DEPRECATION_WARNINGS) -SET(CMAKE_CXX_FLAGS "-fstack-protector -funwind-tables -fPIC -O0 -g2 -std=c++20") +# SET(CMAKE_CXX_FLAGS "-fstack-protector -funwind-tables -fPIC -O0 -g2 -std=c++20") +set(CMAKE_CXX_FLAGS "-fstack-protector -funwind-tables -fPIC -frtti -std=c++20") target_include_directories(libwebrtc-webrtc-echo PRIVATE /src/webrtc-checkout/src @@ -25,13 +27,12 @@ target_include_directories(libwebrtc-webrtc-echo PRIVATE SET(CMAKE_EXE_LINKER_FLAGS "-z noexecstack -z relro -z now -pie") -link_directories( - /src/webrtc-checkout/src/out/Default) +#link_directories( /src/webrtc-checkout/src/out/Default/obj) target_link_libraries(libwebrtc-webrtc-echo - -L/src/webrtc-checkout/src/out/Default - event # Important that "event" precedes "webrtc-full" as the webrtc library contains duplicate, but older, symbols. - webrtc-full # This will link to libwebrtc-full.a + -L/src/webrtc-checkout/src/out/Default/obj + event + webrtc # This will link to libwebrtc.a from the Builder image. dl pthread X11 diff --git a/libwebrtc/Dockerfile b/libwebrtc/Dockerfile index df040eb..3642a18 100644 --- a/libwebrtc/Dockerfile +++ b/libwebrtc/Dockerfile @@ -7,6 +7,7 @@ RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y \ RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 +RUN update-alternatives --install /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-18 100 RUN update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-18 100 COPY --from=builder /src/webrtc-checkout/src /src/webrtc-checkout/src diff --git a/libwebrtc/Dockerfile-Builder b/libwebrtc/Dockerfile-Builder index 585e381..975a010 100644 --- a/libwebrtc/Dockerfile-Builder +++ b/libwebrtc/Dockerfile-Builder @@ -25,6 +25,5 @@ RUN git fetch --all RUN git checkout remotes/branch-heads/6834 -b m132 # 6834 == m132, see https://chromiumdash.appspot.com/branches. RUN gclient sync RUN build/install-build-deps.sh -RUN gn gen out/Default --args='is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false' +RUN gn gen out/Default --args='is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false use_rtti=true' RUN autoninja -C out/Default -RUN ar crs out/Default/libwebrtc-full.a $(find out/Default/obj -name *\.o) \ No newline at end of file diff --git a/libwebrtc/PcFactory.cpp b/libwebrtc/PcFactory.cpp index 80d7b43..ab63fa8 100755 --- a/libwebrtc/PcFactory.cpp +++ b/libwebrtc/PcFactory.cpp @@ -32,13 +32,15 @@ #include #include #include -#include -#include -#include -#include #include #include "api/enable_media.h" #include "fake_audio_capture_module.h" +#include +#include +#include +#include +#include +#include #include #include @@ -65,8 +67,8 @@ PcFactory::PcFactory() : _pcf_deps.event_log_factory = std::make_unique(_pcf_deps.task_queue_factory.get()); _pcf_deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); _pcf_deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); - //_pcf_deps.video_encoder_factory = webrtc::CreateBuiltinVideoEncoderFactory(); // Missing symbol in m132 build (tried everything). - //_pcf_deps.video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory(); // Missing symbol in m132 build (tried everything). + _pcf_deps.video_encoder_factory = std::make_unique>(); + _pcf_deps.video_decoder_factory = std::make_unique>(); _pcf_deps.adm = rtc::scoped_refptr(FakeAudioCaptureModule::Create()); _pcf_deps.audio_processing = apm; // Gets moved in EnableMedia. diff --git a/libwebrtc/README.md b/libwebrtc/README.md index 05a3f3b..e6436e0 100755 --- a/libwebrtc/README.md +++ b/libwebrtc/README.md @@ -70,7 +70,7 @@ c:\dev\webrtc-checkout\src> rmdir /q /s out\Default # Setting use_custom_libcxx=false is critical. If it is true, the build uses the libc++ standard library from the third-party source tree, # making it incompatible when linking with Visual Studio. By setting it to false, the MSVC standard library will be used (e.g msvcp140.dll), # ensuring that Visual Studio can properly resolve all the required symbols. -c:\dev\webrtc-checkout\src> gn gen out/Default --args="is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false" +c:\dev\webrtc-checkout\src> gn gen out/Default --args="is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false use_rtti=true" c:\dev\webrtc-checkout\src> autoninja -C out/Default # DON'T use "ninja all -C out/Default", as listed on the build instructions site, it attempts to build everything in the out/Default directory rather than just libwebrtc. # The resultant webrtc.lib should be in out/Default/obj. # Note as an added bonus vcpkg installed binaries that are build the the standard msbuild toolcahin, e.g. cl and ld, are compatible with the clang and lld-ld linker. From 79bd29e757b9bb907592443a52725f23c2ff4f2f Mon Sep 17 00:00:00 2001 From: Aaron Clauson Date: Thu, 26 Dec 2024 22:35:32 +0000 Subject: [PATCH 2/2] Add all in one docker file for testing. --- libwebrtc/Dockerfile-AllInOne | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libwebrtc/Dockerfile-AllInOne diff --git a/libwebrtc/Dockerfile-AllInOne b/libwebrtc/Dockerfile-AllInOne new file mode 100644 index 0000000..316c623 --- /dev/null +++ b/libwebrtc/Dockerfile-AllInOne @@ -0,0 +1,40 @@ +FROM ubuntu:20.04 + +# Install packages for libwebrtc build and app dependencies. +ENV DEBIAN_FRONTEND=noninteractive +RUN echo "tzdata tzdata/Areas select Europe" | debconf-set-selections && \ + echo "tzdata tzdata/Zones/Europe select Dublin" | debconf-set-selections +RUN apt update && apt install -y tzdata +RUN echo "keyboard-configuration keyboard-configuration/layoutcode string us" | debconf-set-selections && \ + echo "keyboard-configuration keyboard-configuration/modelcode string pc105" | debconf-set-selections +RUN apt update && apt install -y keyboard-configuration +RUN apt update && apt install -y curl git lsb-release python3 python-is-python3 sudo wget xz-utils file +RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y \ + build-essential cmake libglib2.0-dev libx11-dev libevent-dev clang-18 lld-18 + +# Install depot_tools +WORKDIR /src + +# https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/development/prerequisite-sw/index.md +RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth 1 depot_tools +ENV PATH="/src/depot_tools:${PATH}" + +# See the README.md file in the same directory as this docker build file for more explanations and links. +WORKDIR /src/webrtc-checkout +RUN fetch --nohooks webrtc +WORKDIR /src/webrtc-checkout/src +RUN git fetch --all +RUN git checkout remotes/branch-heads/6834 -b m132 # 6834 == m132, see https://chromiumdash.appspot.com/branches. +RUN gclient sync +RUN build/install-build-deps.sh + +WORKDIR /src/libwebrtc-webrtc-echo +COPY ["CMakeLists.txt", "fake_audio_capture_module.*", "HttpSimpleServer.*", "json.hpp", "libwebrtc-webrtc-echo.cpp", "PcFactory.*", "PcObserver.*", "./"] + +WORKDIR /src + +RUN gn gen out/Default --args='is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false use_rtti=true' +RUN autoninja -C out/Default + +WORKDIR /src/libwebrtc-webrtc-echo/build +RUN cmake .. && make VERBOSE=1 && cp libwebrtc-webrtc-echo / \ No newline at end of file