Skip to content

Commit daa1b64

Browse files
committed
Rely on OpenSSL instead of BoringSSL + Returned rnnoise submodule + Work on tgcalls build
1 parent cec272a commit daa1b64

File tree

12 files changed

+184
-21
lines changed

12 files changed

+184
-21
lines changed

‎.gitmodules

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
path = app/jni/third_party/webrtc
9595
url = https://github.com/ali-fareed/webrtc
9696
shallow = true
97-
[submodule "rnnoise"]
98-
path = app/jni/third_party/rnnoise
97+
[submodule "webrtc_rnnoise"]
98+
path = app/jni/third_party/webrtc_deps/third_party/rnnoise
9999
url = https://github.com/TGX-Android/rnnoise
100100
shallow = true
101101
[submodule "pffft"]
@@ -114,3 +114,9 @@
114114
path = app/jni/third_party/crc32c
115115
url = https://github.com/google/crc32c
116116
shallow = true
117+
[submodule "openssl"]
118+
path = app/jni/third_party/openssl
119+
url = https://github.com/openssl/openssl
120+
[submodule "rnnoise"]
121+
path = app/jni/third_party/rnnoise
122+
url = https://github.com/xiph/rnnoise

‎app/jni/BuildTelegramVoIP.cmake

+9-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,15 @@ target_include_directories(tgvoip PRIVATE
362362
"${TGVOIP_DIR}/webrtc_dsp"
363363
.
364364
)
365+
target_include_directories(tgvoip PUBLIC
366+
"${TGVOIP_DIR}"
367+
)
365368
target_compile_options(tgvoip PRIVATE
366369
-frtti -fexceptions -finline-functions -ffast-math -fno-strict-aliasing -Wno-unknown-pragmas
367370
)
368-
target_link_libraries(tgvoip PUBLIC log OpenSLES opus)
371+
target_link_libraries(tgvoip PUBLIC
372+
log
373+
OpenSLES
374+
opus
375+
ssl
376+
)

‎app/jni/BuildTgCalls.cmake

+85
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,88 @@ set(TGCALLS_DIR "${THIRDPARTY_DIR}/tgcalls")
88
# Source files list:
99
# https://github.com/TelegramMessenger/Telegram-iOS/blob/cb79afd6e87deb03582a0af7bc6a5b3e1479cf51/submodules/TgVoipWebrtc/BUILD
1010

11+
add_library(tgcalls STATIC
12+
"${TGCALLS_DIR}/tgcalls/utils/gzip.cpp"
13+
"${TGCALLS_DIR}/tgcalls/third-party/json11.cpp"
14+
15+
"${TGCALLS_DIR}/tgcalls/FieldTrialsConfig.cpp"
16+
17+
"${TGCALLS_DIR}/tgcalls/ChannelManager.cpp"
18+
"${TGCALLS_DIR}/tgcalls/CodecSelectHelper.cpp"
19+
"${TGCALLS_DIR}/tgcalls/CryptoHelper.cpp"
20+
"${TGCALLS_DIR}/tgcalls/EncryptedConnection.cpp"
21+
"${TGCALLS_DIR}/tgcalls/Instance.cpp"
22+
"${TGCALLS_DIR}/tgcalls/InstanceImpl.cpp"
23+
"${TGCALLS_DIR}/tgcalls/LogSinkImpl.cpp"
24+
"${TGCALLS_DIR}/tgcalls/Manager.cpp"
25+
"${TGCALLS_DIR}/tgcalls/MediaManager.cpp"
26+
"${TGCALLS_DIR}/tgcalls/Message.cpp"
27+
"${TGCALLS_DIR}/tgcalls/NetworkManager.cpp"
28+
"${TGCALLS_DIR}/tgcalls/StaticThreads.cpp"
29+
"${TGCALLS_DIR}/tgcalls/ThreadLocalObject.cpp"
30+
"${TGCALLS_DIR}/tgcalls/VideoCaptureInterface.cpp"
31+
"${TGCALLS_DIR}/tgcalls/VideoCaptureInterfaceImpl.cpp"
32+
"${TGCALLS_DIR}/tgcalls/AudioDeviceHelper.cpp"
33+
"${TGCALLS_DIR}/tgcalls/SctpDataChannelProviderInterfaceImpl.cpp"
34+
"${TGCALLS_DIR}/tgcalls/TurnCustomizerImpl.cpp"
35+
36+
"${TGCALLS_DIR}/tgcalls/legacy/InstanceImplLegacy.cpp"
37+
38+
"${TGCALLS_DIR}/tgcalls/FakeVideoTrackSource.cpp"
39+
"${TGCALLS_DIR}/tgcalls/FakeAudioDeviceModule.cpp"
40+
41+
"${TGCALLS_DIR}/tgcalls/group/VideoStreamingPart.cpp"
42+
"${TGCALLS_DIR}/tgcalls/group/StreamingMediaContext.cpp"
43+
"${TGCALLS_DIR}/tgcalls/group/GroupNetworkManager.cpp"
44+
"${TGCALLS_DIR}/tgcalls/group/GroupJoinPayloadInternal.cpp"
45+
"${TGCALLS_DIR}/tgcalls/group/GroupInstanceCustomImpl.cpp"
46+
"${TGCALLS_DIR}/tgcalls/group/AVIOContextImpl.cpp"
47+
"${TGCALLS_DIR}/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp"
48+
"${TGCALLS_DIR}/tgcalls/group/AudioStreamingPartInternal.cpp"
49+
"${TGCALLS_DIR}/tgcalls/group/AudioStreamingPart.cpp"
50+
51+
"${TGCALLS_DIR}/tgcalls/v2/InstanceV2Impl.cpp"
52+
"${TGCALLS_DIR}/tgcalls/v2/NativeNetworkingImpl.cpp"
53+
"${TGCALLS_DIR}/tgcalls/v2/Signaling.cpp"
54+
"${TGCALLS_DIR}/tgcalls/v2/SignalingEncryption.cpp"
55+
"${TGCALLS_DIR}/tgcalls/v2/ContentNegotiation.cpp"
56+
"${TGCALLS_DIR}/tgcalls/v2/InstanceV2ReferenceImpl.cpp"
57+
"${TGCALLS_DIR}/tgcalls/v2/ExternalSignalingConnection.cpp"
58+
"${TGCALLS_DIR}/tgcalls/v2/ReflectorPort.cpp"
59+
"${TGCALLS_DIR}/tgcalls/v2/ReflectorRelayPortFactory.cpp"
60+
"${TGCALLS_DIR}/tgcalls/v2/SignalingConnection.cpp"
61+
"${TGCALLS_DIR}/tgcalls/v2/SignalingSctpConnection.cpp"
62+
63+
"${TGCALLS_DIR}/tgcalls/v2_4_0_0/InstanceV2_4_0_0Impl.cpp"
64+
"${TGCALLS_DIR}/tgcalls/v2_4_0_0/Signaling_4_0_0.cpp"
65+
66+
"${TGCALLS_DIR}/tgcalls/desktop_capturer/DesktopCaptureSourceManager.cpp"
67+
"${TGCALLS_DIR}/tgcalls/desktop_capturer/DesktopCaptureSourceHelper.cpp"
68+
"${TGCALLS_DIR}/tgcalls/desktop_capturer/DesktopCaptureSource.cpp"
69+
70+
"${TGCALLS_DIR}/tgcalls/platform/android/AndroidContext.cpp"
71+
"${TGCALLS_DIR}/tgcalls/platform/android/AndroidInterface.cpp"
72+
"${TGCALLS_DIR}/tgcalls/platform/android/VideoCameraCapturer.cpp"
73+
"${TGCALLS_DIR}/tgcalls/platform/android/VideoCapturerInterfaceImpl.cpp"
74+
)
75+
76+
target_include_directories(tgcalls PRIVATE
77+
"${TGCALLS_DIR}/tgcalls"
78+
"${CMAKE_HOME_DIRECTORY}"
79+
)
80+
target_include_directories(tgcalls PUBLIC
81+
"${TGCALLS_DIR}"
82+
)
83+
84+
target_compile_options(tgcalls PUBLIC
85+
-Wall -finline-functions -ffast-math -fno-strict-aliasing -O3 -frtti -Wno-unknown-pragmas -funroll-loops -fexceptions -fno-math-errno
86+
)
87+
88+
target_link_libraries(tgcalls PRIVATE
89+
rnnoise
90+
)
91+
92+
target_link_libraries(tgcalls PUBLIC
93+
webrtc
94+
tgvoip
95+
)

‎app/jni/BuildWebRTC.cmake

+7-4
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ set(WEBRTC_DIR "${THIRDPARTY_DIR}/webrtc")
14311431
# "${WEBRTC_DIR}/rtc_base/task_queue_gcd.cc"
14321432

14331433
add_library(webrtc STATIC
1434-
"${THIRDPARTY_DIR}/rnnoise/src/rnn_vad_weights.cc"
1434+
"${THIRDPARTY_DIR}/webrtc_deps/third_party/rnnoise/src/rnn_vad_weights.cc"
14351435

14361436
"${THIRDPARTY_DIR}/pffft/src/fftpack.c"
14371437
"${THIRDPARTY_DIR}/pffft/src/pffft.c"
@@ -2452,7 +2452,6 @@ add_library(webrtc STATIC
24522452
"${WEBRTC_DIR}/modules/audio_processing/aec3/transparent_mode.cc"
24532453
"${WEBRTC_DIR}/modules/audio_processing/agc2/cpu_features.cc"
24542454
"${WEBRTC_DIR}/modules/congestion_controller/goog_cc/inter_arrival_delta.cc"
2455-
"${WEBRTC_DIR}/rtc_base/boringssl_identity.cc"
24562455
"${WEBRTC_DIR}/rtc_base/network_monitor_factory.cc"
24572456
"${WEBRTC_DIR}/rtc_base/openssl_key_pair.cc"
24582457
"${WEBRTC_DIR}/rtc_base/deprecated/recursive_critical_section.cc"
@@ -2472,7 +2471,6 @@ add_library(webrtc STATIC
24722471
"${WEBRTC_DIR}/modules/video_coding/svc/scalability_structure_l2t2_key_shift.cc"
24732472
"${WEBRTC_DIR}/pc/connection_context.cc"
24742473
"${WEBRTC_DIR}/pc/data_channel_utils.cc"
2475-
"${WEBRTC_DIR}/rtc_base/boringssl_certificate.cc"
24762474
"${WEBRTC_DIR}/rtc_base/strings/string_format.cc"
24772475
"${WEBRTC_DIR}/call/adaptation/adaptation_constraint.cc"
24782476
"${WEBRTC_DIR}/modules/audio_processing/optionally_built_submodule_creators.cc"
@@ -2608,6 +2606,10 @@ add_library(webrtc STATIC
26082606
"${WEBRTC_DIR}/api/video_codecs/simulcast_stream.cc"
26092607
)
26102608

2609+
# intentionally removed:
2610+
# "${WEBRTC_DIR}/rtc_base/boringssl_identity.cc" (before network_monitor_factory)
2611+
# "${WEBRTC_DIR}/rtc_base/boringssl_certificate.cc" (before string_format)
2612+
26112613
target_sources(webrtc PRIVATE
26122614
"${WEBRTC_DIR}/rtc_base/system/warn_current_thread_is_deadlocked.cc"
26132615
"${WEBRTC_DIR}/rtc_base/task_queue_libevent.cc"
@@ -2728,6 +2730,7 @@ target_sources(webrtc PRIVATE
27282730
"${THIRDPARTY_DIR}/crc32c/src/crc32c.cc"
27292731
)
27302732
target_include_directories(webrtc PRIVATE
2733+
"${THIRDPARTY_DIR}/webrtc_deps"
27312734
"${THIRDPARTY_DIR}/crc32c/include"
27322735
)
27332736

@@ -2860,7 +2863,7 @@ target_sources(webrtc PRIVATE
28602863
# "${WEBRTC_DIR}/modules/audio_processing/agc2/speech_level_estimator.cc"
28612864
# "${WEBRTC_DIR}/modules/audio_processing/agc2/input_volume_stats_reporter.cc"
28622865

2863-
target_compile_definitions(webrtc PRIVATE
2866+
target_compile_definitions(webrtc PUBLIC
28642867
RTC_DISABLE_TRACE_EVENTS
28652868
WEBRTC_OPUS_SUPPORT_120MS_PTIME=1
28662869
BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0

‎app/jni/CMakeLists.txt

+8-10
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ set(STUB_DIR "${CMAKE_HOME_DIRECTORY}/stub")
1313
set(TDLIB_DIR "${CMAKE_HOME_DIRECTORY}/../../tdlib")
1414
set(UTILS_DIR "${THIRDPARTY_DIR}/jni-utils")
1515

16-
set(SSL_DIR "${THIRDPARTY_DIR}/boringssl")
17-
set(SSL_LIB_PATH "${SSL_DIR}/build/${ANDROID_ABI}/ssl/libssl.a")
18-
set(CRYPTO_LIB_PATH "${SSL_DIR}/build/${ANDROID_ABI}/crypto/libcrypto.a")
16+
set(SSL_DIR "${THIRDPARTY_DIR}/openssl/android_static/${ANDROID_ABI}")
17+
set(SSL_LIB_PATH "${SSL_DIR}/lib/libssl.a")
18+
set(CRYPTO_LIB_PATH "${SSL_DIR}/lib/libcrypto.a")
1919

2020
# Using webp only if building for 32-bit platform
2121
if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "x86")
@@ -106,6 +106,7 @@ set(EXCLUDE_LIBS
106106
libopenh264.a
107107
libabsl.a
108108
libwebrtc.a
109+
libtgcalls.a
109110
)
110111
if (${USE_WEBP})
111112
list(APPEND EXCLUDE_LIBS
@@ -179,6 +180,9 @@ include("${CMAKE_HOME_DIRECTORY}/BuildTgCalls.cmake")
179180
# yuv
180181
include("${CMAKE_HOME_DIRECTORY}/BuildYuv.cmake")
181182

183+
# rnnoise
184+
include("${CMAKE_HOME_DIRECTORY}/BuildRNNoise.cmake")
185+
182186
# vpx
183187
add_library(vpx STATIC IMPORTED)
184188
set_target_properties(vpx PROPERTIES IMPORTED_LOCATION "${VPX_LIB_PATH}")
@@ -281,13 +285,7 @@ target_link_libraries(${NATIVE_LIB}
281285
opus
282286
rlottie
283287
lz4
284-
ssl
285-
crypto
286-
usrsctp
287-
srtp
288-
openh264
289-
absl
290-
webrtc
288+
tgcalls
291289
)
292290
if (${USE_WEBP})
293291
target_link_libraries(${NATIVE_LIB} webpdecoder_static)

‎app/jni/third_party/openssl

Submodule openssl added at 830bf8e

‎app/jni/third_party/rnnoise

‎app/jni/third_party/tgcalls

Submodule rnnoise added at 3b97c79

‎scripts/build-openssl.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
# shellcheck source=set-env.sh
4+
source "$(dirname "$0")"/set-env.sh
5+
6+
build-openssl-impl.sh || (echo "openssl build failed" && exit 1)

‎scripts/private/build-openssl-impl.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
# Credits:
4+
# https://github.com/tdlib/td/blob/master/example/android/build-openssl.sh
5+
6+
OPENSSL_DIR="$THIRDPARTY_LIBRARIES/openssl"
7+
OPENSSL_INSTALL_DIR="$OPENSSL_DIR/android_static"
8+
9+
if [ -e "$OPENSSL_INSTALL_DIR" ] ; then
10+
rm -rf "$OPENSSL_INSTALL_DIR"
11+
fi
12+
13+
mkdir -p $OPENSSL_INSTALL_DIR || exit 1
14+
15+
pushd "$OPENSSL_DIR" > /dev/null
16+
17+
export ANDROID_NDK_ROOT=$ANDROID_NDK # for OpenSSL 3.0
18+
export ANDROID_NDK_HOME=$ANDROID_NDK_ROOT # for OpenSSL 1.1.1
19+
PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$BUILD_PLATFORM/bin:$PATH
20+
21+
if ! clang --help >/dev/null 2>&1 ; then
22+
echo "Error: failed to run clang from Android NDK."
23+
if [[ "$OS_NAME" == "linux" ]] ; then
24+
echo "Prebuilt Android NDK binaries are linked against glibc, so glibc must be installed."
25+
fi
26+
exit 1
27+
fi
28+
29+
ANDROID_API32=16
30+
ANDROID_API64=21
31+
32+
for ABI in arm64-v8a armeabi-v7a x86_64 x86 ; do
33+
if [[ $ABI == "x86" ]] ; then
34+
./Configure android-x86 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API32 || exit 1
35+
elif [[ $ABI == "x86_64" ]] ; then
36+
./Configure android-x86_64 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API64 || exit 1
37+
elif [[ $ABI == "armeabi-v7a" ]] ; then
38+
./Configure android-arm no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API32 -D__ARM_MAX_ARCH__=8 || exit 1
39+
elif [[ $ABI == "arm64-v8a" ]] ; then
40+
./Configure android-arm64 no-shared -U__ANDROID_API__ -D__ANDROID_API__=$ANDROID_API64 || exit 1
41+
fi
42+
43+
sed -i.bak 's/-O3/-O3 -ffunction-sections -fdata-sections/g' Makefile || exit 1
44+
45+
make depend -s || exit 1
46+
make -j4 -s || exit 1
47+
48+
mkdir -p $OPENSSL_INSTALL_DIR/$ABI/lib/ || exit 1
49+
cp libcrypto.a libssl.a $OPENSSL_INSTALL_DIR/$ABI/lib/ || exit 1
50+
cp -r include $OPENSSL_INSTALL_DIR/$ABI/ || exit 1
51+
52+
make distclean || exit 1
53+
done
54+
55+
popd > /dev/null

‎scripts/setup.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ patch-opus-impl.sh
2727
# Patch ExoPlayer sources
2828
patch-exoplayer-impl.sh
2929

30-
# Build boringssl
31-
run-cmake-impl.sh "$THIRDPARTY_LIBRARIES/boringssl"
30+
# Build OpenSSL
31+
build-openssl-impl.sh
3232

3333
# Build and configure libvpx
3434
build-vpx-impl.sh

0 commit comments

Comments
 (0)