Skip to content

Commit 381f8ed

Browse files
committed
chore: upgrade libwebrtc M85 (#177)
* wip * wip * fixed build error * add webrtcd.lib for debug * fixed cmake to build for debug * debug build on macos * create static library for debug build on Linux * upgrade libwebrtc version M85 * change webrtc version * fixed library build error * fixed build error * fixed build error * fixed error
1 parent 988a3f8 commit 381f8ed

19 files changed

+766
-91
lines changed

.yamato/meta/environments.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ upm:
22
registry_url: https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
33
package_version: stable
44
webrtc_version:
5-
name: M84
5+
name: M85

BuildScripts~/ReplaceText.ps1

-1
This file was deleted.

BuildScripts~/build_libwebrtc_linux.sh

+36-14
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,57 @@ then
55
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
66
fi
77

8+
export COMMAND_DIR=$(cd $(dirname $0); pwd)
89
export PATH="$(pwd)/depot_tools:$PATH"
9-
export WEBRTC_VERSION=4147
10+
export WEBRTC_VERSION=4183
1011
export OUTPUT_DIR="$(pwd)/out"
1112
export ARTIFACTS_DIR="$(pwd)/artifacts"
1213

13-
fetch webrtc
14+
if [ ! -e "$(pwd)/src" ]
15+
then
16+
fetch webrtc
17+
cd src
18+
git config --system core.longpaths true
19+
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
20+
cd ..
21+
gclient sync -f
22+
fi
1423

15-
cd src
16-
git config --system core.longpaths true
17-
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
18-
cd ..
24+
# add jsoncpp
25+
patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
1926

20-
gclient sync -f
27+
mkdir -p "$ARTIFACTS_DIR/lib"
2128

22-
# add jsoncpp
23-
patch "src/BUILD.gn" < "BuildScripts~/add_jsoncpp.patch"
29+
# generate ninja files for release
30+
gn gen "$OUTPUT_DIR" --root="src" \
31+
--args="is_debug=false target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
2432

25-
gn gen "$OUTPUT_DIR" --root="src" --args="is_debug=false target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
33+
# build static library for release
34+
ninja -C "$OUTPUT_DIR" webrtc
2635

36+
# cppy static library for release
37+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtc.a"
38+
39+
# generate ninja files for debug
40+
gn gen "$OUTPUT_DIR" --root="src" \
41+
--args="is_debug=true target_os=\"linux\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
42+
43+
# build static library for debug
2744
ninja -C "$OUTPUT_DIR" webrtc
2845

29-
python ./src/tools_webrtc/libs/generate_licenses.py --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
46+
# cppy static library for debug
47+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtcd.a"
48+
49+
# fix error when generate license
50+
patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \
51+
"$COMMAND_DIR/patches/generate_licenses.patch"
52+
53+
python "./src/tools_webrtc/libs/generate_licenses.py" \
54+
--target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
3055

3156
cd src
3257
find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
3358

34-
mkdir -p "$ARTIFACTS_DIR/lib"
35-
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib"
36-
3759
cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
3860

3961
# create zip

BuildScripts~/build_libwebrtc_macos.sh

+36-14
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,57 @@ then
55
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
66
fi
77

8+
export COMMAND_DIR=$(cd $(dirname $0); pwd)
89
export PATH="$(pwd)/depot_tools:$PATH"
9-
export WEBRTC_VERSION=4147
10+
export WEBRTC_VERSION=4183
1011
export OUTPUT_DIR="$(pwd)/out"
1112
export ARTIFACTS_DIR="$(pwd)/artifacts"
1213

13-
fetch webrtc
14+
if [ ! -e "$(pwd)/src" ]
15+
then
16+
fetch webrtc
17+
cd src
18+
git config --system core.longpaths true
19+
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
20+
cd ..
21+
gclient sync -f
22+
fi
1423

15-
cd src
16-
git config --system core.longpaths true
17-
git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
18-
cd ..
24+
# add jsoncpp
25+
patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
1926

20-
gclient sync -f
27+
mkdir -p "$ARTIFACTS_DIR/lib"
2128

22-
# add jsoncpp
23-
patch "src/BUILD.gn" < "BuildScripts~/add_jsoncpp.patch"
29+
# generate ninja files for release
30+
gn gen "$OUTPUT_DIR" --root="src" \
31+
--args="is_debug=false target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
2432

25-
gn gen "$OUTPUT_DIR" --root="src" --args="is_debug=false target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
33+
# build static library for release
34+
ninja -C "$OUTPUT_DIR" webrtc
2635

36+
# cppy static library for release
37+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtc.a"
38+
39+
# generate ninja files for debug
40+
gn gen "$OUTPUT_DIR" --root="src" \
41+
--args="is_debug=true target_os=\"mac\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false"
42+
43+
# build static library for debug
2744
ninja -C "$OUTPUT_DIR" webrtc
2845

29-
python ./src/tools_webrtc/libs/generate_licenses.py --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
46+
# cppy static library for debug
47+
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/libwebrtcd.a"
48+
49+
# fix error when generate license
50+
patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \
51+
"$COMMAND_DIR/patches/generate_licenses.patch"
52+
53+
python "./src/tools_webrtc/libs/generate_licenses.py" \
54+
--target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
3055

3156
cd src
3257
find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
3358

34-
mkdir -p "$ARTIFACTS_DIR/lib"
35-
cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib"
36-
3759
cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
3860

3961
# create zip

BuildScripts~/build_libwebrtc_win.cmd

+45-31
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,76 @@
11
@echo off
22

33
if not exist depot_tools (
4-
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
4+
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
55
)
66

7+
set COMMAND_DIR=%~dp0
78
set PATH=%cd%\depot_tools;%PATH%
8-
set WEBRTC_VERSION=4147
9+
set WEBRTC_VERSION=4183
910
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
1011
set CPPFLAGS=/WX-
1112
set GYP_GENERATORS=ninja,msvs-ninja
1213
set GYP_MSVS_VERSION=2017
1314
set OUTPUT_DIR=out
1415
set ARTIFACTS_DIR=%cd%\artifacts
16+
set PYPI_URL=https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
1517
set vs2017_install=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
1618

17-
cmd /k fetch.bat webrtc
19+
if not exist src (
20+
call fetch.bat webrtc
21+
cd src
22+
call git.bat config --system core.longpaths true
23+
call git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION%
24+
cd ..
25+
call gclient.bat sync -f
26+
)
1827

19-
cd src
20-
cmd /k git.bat config --system core.longpaths true
21-
cmd /k git.bat checkout refs/remotes/branch-heads/%WEBRTC_VERSION%
22-
cd ..
28+
rem add jsoncpp
29+
patch -N "src\BUILD.gn" < "%COMMAND_DIR%\patches\add_jsoncpp.patch"
2330

24-
cmd /k gclient.bat sync -f
31+
rem install pywin32
32+
call "%cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe" ^
33+
-m pip install pywin32 --index-url "%PYPI_URL%" --upgrade
2534

26-
REM add jsoncpp
27-
patch "src\BUILD.gn" < "BuildScripts~\add_jsoncpp.patch"
35+
rem generate ninja for release
36+
call gn.bat gen %OUTPUT_DIR% --root="src" ^
37+
--args="is_debug=false is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
2838

29-
REM install pywin32
30-
cmd /k %cd%\depot_tools\bootstrap-3_8_0_chromium_8_bin\python\bin\python.exe -m pip install pywin32 --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
39+
rem build
40+
ninja.exe -C %OUTPUT_DIR%
3141

32-
cmd /k gn.bat gen %OUTPUT_DIR% --root="src" --args="is_debug=false is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
42+
mkdir "%ARTIFACTS_DIR%\lib"
3343

34-
REM add json.obj in link list of webrtc.ninja
35-
powershell -File ".\BuildScripts~\ReplaceText.ps1" "%OUTPUT_DIR%\obj\webrtc.ninja" "obj/rtc_base/rtc_base/crc32.obj" "obj/rtc_base/rtc_base/crc32.obj obj/rtc_base/rtc_json/json.obj"
36-
type "%OUTPUT_DIR%\obj\webrtc.ninja"
44+
rem copy static library for release build
45+
copy "%OUTPUT_DIR%\obj\webrtc.lib" "%ARTIFACTS_DIR%\lib\webrtc.lib"
3746

38-
REM update LIB_TO_LICENSES_DICT in generate_licenses.py
39-
powershell -File ".\BuildScripts~\ReplaceText.ps1" "src\tools_webrtc\libs\generate_licenses.py" "'ow2_asm': []," "'ow2_asm': [], 'winsdk_samples': [], 'googletest': ['third_party/googletest/src/LICENSE'], 'nasm': ['third_party/nasm/LICENSE'], "
40-
type "src\tools_webrtc\libs\generate_licenses.py"
47+
rem generate ninja for debug build
48+
call gn.bat gen %OUTPUT_DIR% --root="src" ^
49+
--args="is_debug=true is_clang=false target_cpu=\"x64\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false"
4150

51+
rem build
4252
ninja.exe -C %OUTPUT_DIR%
4353

44-
REM generate license
45-
call python.bat .\src\tools_webrtc\libs\generate_licenses.py --target //:default %OUTPUT_DIR% %OUTPUT_DIR%
54+
rem copy static library for debug build
55+
copy "%OUTPUT_DIR%\obj\webrtc.lib" "%ARTIFACTS_DIR%\lib\webrtcd.lib"
56+
57+
rem fix error when generate license
58+
patch -N "%cd%\src\tools_webrtc\libs\generate_licenses.py" < ^
59+
"%COMMAND_DIR%\patches\generate_licenses.patch"
4660

47-
REM unescape license
48-
powershell -File .\Unescape.ps1 %OUTPUT_DIR%\LICENSE.md
61+
rem generate license
62+
call python.bat "%cd%\src\tools_webrtc\libs\generate_licenses.py" ^
63+
--target //:default %OUTPUT_DIR% %OUTPUT_DIR%
4964

50-
REM copy header
51-
xcopy src\*.h %ARTIFACTS_DIR%\include /C /S /I /F /H
65+
rem unescape license
66+
powershell -File "%COMMAND_DIR%\Unescape.ps1" "%OUTPUT_DIR%\LICENSE.md"
5267

53-
REM copy lib
54-
mkdir %ARTIFACTS_DIR%\lib
55-
for %%G in (webrtc.lib audio_decoder_opus.lib webrtc_opus.lib) do forfiles /P "%cd%\%OUTPUT_DIR%" /S /M %%G /C "cmd /c copy @path %ARTIFACTS_DIR%\lib"
68+
rem copy header
69+
xcopy src\*.h "%ARTIFACTS_DIR%\include" /C /S /I /F /H
5670

57-
REM copy license
58-
copy %OUTPUT_DIR%\LICENSE.md %ARTIFACTS_DIR%
71+
rem copy license
72+
copy "%OUTPUT_DIR%\LICENSE.md" "%ARTIFACTS_DIR%"
5973

60-
REM create zip
74+
rem create zip
6175
cd %ARTIFACTS_DIR%
6276
7z a -tzip webrtc-win.zip *

BuildScripts~/build_plugin.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-win.zip
3+
set LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-win.zip
44
set SOLUTION_DIR=%cd%\Plugin~
55

66
echo -------------------

BuildScripts~/build_plugin.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-linux.zip
3+
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-linux.zip
44
export SOLUTION_DIR=$(pwd)/Plugin~
55

66
# Download LibWebRTC

BuildScripts~/build_plugin_mac.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M84/webrtc-mac.zip
3+
export LIBWEBRTC_DOWNLOAD_URL=https://github.com/Unity-Technologies/com.unity.webrtc/releases/download/M85/webrtc-mac.zip
44
export SOLUTION_DIR=$(pwd)/Plugin~
55

66
# Install cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- ./src/tools_webrtc/libs/generate_licenses.py 2020-08-08 11:02:57.064616700 +0900
2+
+++ ./src/tools_webrtc/libs/generate_licenses.py.edited 2020-08-29 10:58:18.826417100 +0900
3+
@@ -70,6 +70,7 @@ LIB_TO_LICENSES_DICT = {
4+
'g722': ['modules/third_party/g722/LICENSE'],
5+
'ooura': ['common_audio/third_party/ooura/LICENSE'],
6+
'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
7+
+ 'catapult': ['third_party/catapult/LICENSE'],
8+
9+
# TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
10+
# For some reason it is listed as so in _GetThirdPartyLibraries.

Editor/PeerStatsView.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ private VisualElement CreateDataChannelView(string id)
482482
container.Add(new Label($"{nameof(dataChannelStats.Timestamp)}: {dataChannelStats.Timestamp}"));
483483
container.Add(new Label($"{nameof(dataChannelStats.label)}: {dataChannelStats.label}"));
484484
container.Add(new Label($"{nameof(dataChannelStats.protocol)}: {dataChannelStats.protocol}"));
485-
container.Add(new Label($"{nameof(dataChannelStats.datachannelid)}: {dataChannelStats.datachannelid}"));
485+
container.Add(new Label($"{nameof(dataChannelStats.dataChannelIdentifier)}: {dataChannelStats.dataChannelIdentifier}"));
486486
container.Add(new Label($"{nameof(dataChannelStats.state)}: {dataChannelStats.state}"));
487487
container.Add(new Label($"{nameof(dataChannelStats.messagesSent)}: {dataChannelStats.messagesSent}"));
488488
container.Add(new Label($"{nameof(dataChannelStats.bytesSent)}: {dataChannelStats.bytesSent}"));

Plugin~/CMakeLists.txt

+14-6
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@ project(webrtc)
66
set(CMAKE_VERBOSE_MAKEFILE ON)
77
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -O0 -D_DEBUG")
88

9+
if(MSVC)
10+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /Zi")
11+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /Zi -D_ITERATOR_DEBUG_LEVEL=0")
12+
else()
13+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_DEBUG=1")
14+
endif()
15+
916
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
1017
find_package(Threads REQUIRED)
1118

12-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
19+
list(APPEND CMAKE_MODULE_PATH
20+
"${CMAKE_SOURCE_DIR}/cmake"
21+
)
22+
1323
find_package(WebRTC REQUIRED)
14-
if(MSVC)
15-
find_package(CUDA REQUIRED)
16-
find_package(Vulkan REQUIRED)
17-
elseif(APPLE)
24+
25+
if(APPLE)
1826
find_package(Framework REQUIRED)
19-
elseif(UNIX)
27+
else()
2028
find_package(CUDA REQUIRED)
2129
find_package(Vulkan REQUIRED)
2230
endif()

Plugin~/WebRTCPlugin/CMakeLists.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if(MSVC)
3737
list (APPEND sources ${append_source})
3838
elseif(APPLE)
3939
file(GLOB append_source
40+
../libcxx/debug.cpp
4041
GraphicsDevice/Metal/*.h
4142
GraphicsDevice/Metal/*.mm
4243
Codec/SoftwareCodec/*.h
@@ -88,10 +89,10 @@ endif()
8889

8990
if(MSVC)
9091
# Use precompiled header
91-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yu /Yupch.h")
92-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT /Zi")
93-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MT /Zi")
94-
set(PROJECT_BINARY_DIR "${CMAKE_SOURCE_DIR}/../Runtime/Plugins/x86_64")
92+
set(CMAKE_CXX_FLAGS
93+
"${CMAKE_CXX_FLAGS} /Yu /Yupch.h")
94+
set(PROJECT_BINARY_DIR
95+
"${CMAKE_SOURCE_DIR}/../Runtime/Plugins/x86_64")
9596

9697
target_compile_definitions(webrtc
9798
PRIVATE
@@ -100,7 +101,7 @@ if(MSVC)
100101
)
101102
target_link_libraries(webrtc
102103
PRIVATE
103-
${WEBRTC_LIBRARIES}
104+
${WEBRTC_LIBRARY}
104105
${Vulkan_LIBRARY}
105106
${CUDA_CUDA_LIBRARY}
106107
d3d11
@@ -152,7 +153,7 @@ elseif(APPLE)
152153
)
153154
target_link_libraries(webrtc
154155
PRIVATE
155-
${WEBRTC_LIBRARIES}
156+
${WEBRTC_LIBRARY}
156157
${OPENGL_LIBRARIES}
157158
${FRAMEWORK_LIBS}
158159
)
@@ -175,7 +176,7 @@ elseif(UNIX)
175176
)
176177
target_link_libraries(webrtc
177178
PRIVATE
178-
${WEBRTC_LIBRARIES}
179+
${WEBRTC_LIBRARY}
179180
${OPENGL_opengl_LIBRARY}
180181
${Vulkan_LIBRARY}
181182
cuda

0 commit comments

Comments
 (0)