Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libwebrtc video #54

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions libwebrtc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -17,21 +18,21 @@ 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
/src/webrtc-checkout/src/third_party/abseil-cpp)

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
Expand Down
1 change: 1 addition & 0 deletions libwebrtc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions libwebrtc/Dockerfile-AllInOne
Original file line number Diff line number Diff line change
@@ -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 /
3 changes: 1 addition & 2 deletions libwebrtc/Dockerfile-Builder
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 8 additions & 6 deletions libwebrtc/PcFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
#include <api/peer_connection_interface.h>
#include <api/rtc_event_log/rtc_event_log_factory.h>
#include <api/task_queue/default_task_queue_factory.h>
#include <api/video_codecs/builtin_video_decoder_factory.h>
#include <api/video_codecs/builtin_video_encoder_factory.h>
#include <api/video_codecs/video_decoder_factory.h>
#include <api/video_codecs/video_encoder_factory.h>
#include <media/engine/webrtc_media_engine.h>
#include "api/enable_media.h"
#include "fake_audio_capture_module.h"
#include <api/video_codecs/video_decoder_factory_template.h>
#include <api/video_codecs/video_encoder_factory_template.h>
#include <api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h>
#include <api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h>
#include <api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h>
#include <api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h>

#include <iostream>
#include <sstream>
Expand All @@ -65,8 +67,8 @@ PcFactory::PcFactory() :
_pcf_deps.event_log_factory = std::make_unique<webrtc::RtcEventLogFactory>(_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<webrtc::VideoEncoderFactoryTemplate<webrtc::LibvpxVp8EncoderTemplateAdapter>>();
_pcf_deps.video_decoder_factory = std::make_unique<webrtc::VideoDecoderFactoryTemplate<webrtc::LibvpxVp8DecoderTemplateAdapter>>();
_pcf_deps.adm = rtc::scoped_refptr<webrtc::AudioDeviceModule>(FakeAudioCaptureModule::Create());
_pcf_deps.audio_processing = apm; // Gets moved in EnableMedia.

Expand Down
2 changes: 1 addition & 1 deletion libwebrtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading