From 5e35d3d8155253b924ef99eae48c4f76b311ac49 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 17 Dec 2020 16:27:06 +0400 Subject: [PATCH] Additional updates for sim_arm64 --- WORKSPACE | 4 +- submodules/TgVoip/BUILD | 51 ++---------------- .../Sources/OngoingCallThreadLocalContext.mm | 52 +++++++------------ submodules/TgVoip/libtgvoip | 2 +- third-party/mozjpeg/BUILD | 2 +- third-party/yasm/BUILD | 4 +- 6 files changed, 29 insertions(+), 86 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index e332c39203..a270359be7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -53,6 +53,6 @@ bazel_skylib_workspace() http_file( name = "cmake_tar_gz", - urls = ["https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Darwin-x86_64.tar.gz"], - sha256 = "9d27049660474cf134ab46fa0e0db771b263313fcb8ba82ee8b2d1a1a62f8f20", + urls = ["https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2-macos-universal.tar.gz"], + sha256 = "50afa2cb66bea6a0314ef28034f3ff1647325e30cf5940f97906a56fd9640bd8", ) diff --git a/submodules/TgVoip/BUILD b/submodules/TgVoip/BUILD index f6ea79ffa5..4f6632ff94 100644 --- a/submodules/TgVoip/BUILD +++ b/submodules/TgVoip/BUILD @@ -7,6 +7,7 @@ copts_arm = [ "-DWEBRTC_NS_FLOAT", "-DWEBRTC_IOS", "-DWEBRTC_HAS_NEON", + "-DTGVOIP_NO_DSP", ] copts_x86 = [ @@ -14,52 +15,11 @@ copts_x86 = [ "-DWEBRTC_APM_DEBUG_DUMP=0", "-DWEBRTC_POSIX", "-DTGVOIP_HAVE_TGLOG", + "-DTGVOIP_NO_DSP", "-DWEBRTC_NS_FLOAT", "-DWEBRTC_IOS", ] -replace_symbols = [ - "WebRtcAgc_Process", - "rtc_FatalMessage", - "WebRtcAgc_UpdateAgcThresholds", - "WebRtcAgc_Init", - "WebRtcAgc_GetAddFarendError", - "WebRtcAgc_ZeroCtrl", - "WebRtcAgc_SaturationCtrl", - "WebRtcAgc_SpeakerInactiveCtrl", - "WebRtcAgc_ProcessAnalog", - "WebRtcAgc_set_config", - "WebRtcAgc_get_config", - "WebRtcAgc_ExpCurve", - "WebRtcAgc_Create", - "WebRtcAgc_Free", - "WebRtcAgc_AddFarend", - "WebRtcAgc_VirtualMic", - "WebRtcAgc_AddMic", - "WebRtcAgc_InitDigital", - "WebRtcAgc_AddFarendToDigital", - "WebRtcAgc_CalculateGainTable", - "WebRtcAgc_InitVad", - "WebRtcAgc_ProcessVad", - "TimeDiff", - "TimeAfter", - "TimeMicros", - "TimeUTCMicros", - "SystemTimeNanos", - "TimeNanos", - "SystemTimeMillis", - "TimeMillis", - "TimeUTCMillis", - "GetClockForTesting", - "TimestampWrapAroundHandler", - "Time32", - "TmToSeconds", - "TimeDiff32", - "TimestampWrapAroundHandler", - "g_clock", - "SetClockForTesting", -] - objc_library( name = "TgVoip", enable_modules = True, @@ -77,9 +37,6 @@ objc_library( "libtgvoip/os/darwin/*.mm", "libtgvoip/os/darwin/*.cpp", "libtgvoip/os/posix/*.cpp", - "libtgvoip/webrtc_dsp/**/*.c", - "libtgvoip/webrtc_dsp/**/*.cc", - "libtgvoip/webrtc_dsp/**/*.cpp", ], exclude = ["libtgvoip/os/darwin/*OSX*"]), hdrs = glob([ "PublicHeaders/**/*.h", @@ -87,12 +44,12 @@ objc_library( copts = [ "-I{}/PublicHeaders/TgVoip".format(package_name()), "-I{}/libtgvoip".format(package_name()), - "-I{}/libtgvoip/webrtc_dsp".format(package_name()), + "-I{}/third-party/webrtc/webrtc-ios/src".format(package_name()), "-Isubmodules/Opus/Public/opus", "-DTGVOIP_USE_INSTALLED_OPUS", "-Drtc=rtc1", "-Dwebrtc=webrtc1", - ] + ["-D{symbol}={symbol}1".format(symbol=symbol) for symbol in replace_symbols] + select({ + ] + select({ "@build_bazel_rules_apple//apple:ios_armv7": copts_arm, "@build_bazel_rules_apple//apple:ios_arm64": copts_arm, "//build-system:ios_sim_arm64": copts_arm, diff --git a/submodules/TgVoip/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoip/Sources/OngoingCallThreadLocalContext.mm index 7479f6cec8..ce673b433c 100644 --- a/submodules/TgVoip/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoip/Sources/OngoingCallThreadLocalContext.mm @@ -127,7 +127,7 @@ static void withContext(int32_t contextId, void (^f)(OngoingCallThreadLocalConte NSTimeInterval _callConnectTimeout; NSTimeInterval _callPacketTimeout; - TgVoip *_tgVoip; + std::unique_ptr _tgVoip; OngoingCallState _state; int32_t _signalBars; @@ -262,45 +262,32 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; endpoints.push_back(endpoint); } - TgVoipConfig config = { - .initializationTimeout = _callConnectTimeout, - .receiveTimeout = _callPacketTimeout, - .dataSaving = callControllerDataSavingForType(dataSaving), - .enableP2P = static_cast(allowP2P), - .enableAEC = false, - .enableNS = true, - .enableAGC = true, - .enableCallUpgrade = false, - .logPath = logPath.length == 0 ? "" : std::string(logPath.UTF8String), - .maxApiLayer = [OngoingCallThreadLocalContext maxLayer] - }; + TgVoipConfig config; + config.initializationTimeout = _callConnectTimeout; + config.receiveTimeout = _callPacketTimeout; + config.dataSaving = callControllerDataSavingForType(dataSaving); + config.enableP2P = static_cast(allowP2P); + config.enableAEC = false; + config.enableNS = true; + config.enableAGC = true; + config.enableVolumeControl = false; + config.enableCallUpgrade = false; + config.logPath = logPath.length == 0 ? "" : std::string(logPath.UTF8String); + config.maxApiLayer = [OngoingCallThreadLocalContext maxLayer]; std::vector encryptionKeyValue; encryptionKeyValue.resize(key.length); memcpy(encryptionKeyValue.data(), key.bytes, key.length); - TgVoipEncryptionKey encryptionKey = { - .value = encryptionKeyValue, - .isOutgoing = isOutgoing, - }; - - /* - TgVoipConfig const &config, - TgVoipPersistentState const &persistentState, - std::vector const &endpoints, - std::unique_ptr const &proxy, - TgVoipNetworkType initialNetworkType, - TgVoipEncryptionKey const &encryptionKey - #ifdef TGVOIP_USE_CUSTOM_CRYPTO - , - TgVoipCrypto const &crypto - */ + TgVoipEncryptionKey encryptionKey; + encryptionKey.value = encryptionKeyValue; + encryptionKey.isOutgoing = isOutgoing; _tgVoip = TgVoip::makeInstance( config, { derivedStateValue }, endpoints, - proxyValue, + proxyValue.get(), callControllerNetworkTypeForType(networkType), encryptionKey, crypto @@ -341,8 +328,7 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; NSString *debugLog = [NSString stringWithUTF8String:finalState.debugLog.c_str()]; _lastDerivedState = [[NSData alloc] initWithBytes:finalState.persistentState.value.data() length:finalState.persistentState.value.size()]; - delete _tgVoip; - _tgVoip = NULL; + _tgVoip.reset(); if (completion) { completion(debugLog, finalState.trafficStats.bytesSentWifi, finalState.trafficStats.bytesReceivedWifi, finalState.trafficStats.bytesSentMobile, finalState.trafficStats.bytesReceivedMobile); @@ -381,7 +367,7 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; - (void)controllerStateChanged:(TgVoipState)state { OngoingCallState callState = OngoingCallStateInitializing; switch (state) { - case TgVoipState::Estabilished: + case TgVoipState::Established: callState = OngoingCallStateConnected; break; case TgVoipState::Failed: diff --git a/submodules/TgVoip/libtgvoip b/submodules/TgVoip/libtgvoip index dc4e9ec482..37d98e984f 160000 --- a/submodules/TgVoip/libtgvoip +++ b/submodules/TgVoip/libtgvoip @@ -1 +1 @@ -Subproject commit dc4e9ec48207388e41db1c2ef1cccf9899d9765f +Subproject commit 37d98e984fd6fa389262307db826d52ab86c8241 diff --git a/third-party/mozjpeg/BUILD b/third-party/mozjpeg/BUILD index d1243ec750..ce7752f959 100644 --- a/third-party/mozjpeg/BUILD +++ b/third-party/mozjpeg/BUILD @@ -57,7 +57,7 @@ genrule( mkdir -p "$$BUILD_DIR/Public/mozjpeg" - PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" sh $$BUILD_DIR/build-mozjpeg-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/mozjpeg" "$$BUILD_DIR" + PATH="$$PATH:$$CMAKE_DIR/cmake-3.19.2-macos-universal/CMake.app/Contents/bin" sh $$BUILD_DIR/build-mozjpeg-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/mozjpeg" "$$BUILD_DIR" """ + "\n".join([ "cp -f \"$$BUILD_DIR/mozjpeg/{}\" \"$(location Public/mozjpeg/{})\"".format(header, header) for header in headers diff --git a/third-party/yasm/BUILD b/third-party/yasm/BUILD index 1970b6b67c..3d1ee6a815 100644 --- a/third-party/yasm/BUILD +++ b/third-party/yasm/BUILD @@ -23,8 +23,8 @@ set -x pushd "$$BUILD_DIR/yasm-1.3.0" mkdir build cd build - PATH="$$PATH:$$CMAKE_DIR/cmake-3.18.4-Darwin-x86_64/CMake.app/Contents/bin" arch -x86_64 cmake .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF - arch -x86_64 make -j $$core_count + PATH="$$PATH:$$CMAKE_DIR/cmake-3.19.2-macos-universal/CMake.app/Contents/bin" cmake .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF + make -j $$core_count popd tar -cf "$(location yasm.tar)" -C "$$BUILD_DIR/yasm-1.3.0/build" .