Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Nov 21, 2024
2 parents 39b4cf6 + fb2e545 commit c94099b
Show file tree
Hide file tree
Showing 263 changed files with 18,181 additions and 3,844 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
[submodule "TMessagesProj/jni/ffmpeg"]
path = TMessagesProj/jni/ffmpeg
url = https://github.com/FFmpeg/FFmpeg
[submodule "TMessagesProj/jni/dav1d"]
path = TMessagesProj/jni/dav1d
url = https://github.com/videolan/dav1d
2 changes: 1 addition & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
}

def verName = APP_VERSION_NAME
def verCode = 1198
def verCode = 1199


def officialVer = APP_VERSION_NAME
Expand Down
4 changes: 4 additions & 0 deletions TMessagesProj/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libavresample.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libavutil.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/build/${ANDROID_ABI}/lib/libswresample.a,
${CMAKE_HOME_DIRECTORY}/libvpx/build/${ANDROID_ABI}/lib/libvpx.a,
${CMAKE_HOME_DIRECTORY}/dav1d/build/${ANDROID_ABI}/lib/libdav1d.a,
${CMAKE_HOME_DIRECTORY}/boringssl/build/${ANDROID_ABI}/ssl/libssl.a,
${CMAKE_HOME_DIRECTORY}/boringssl/build/${ANDROID_ABI}/crypto/libcrypto.a")

Expand Down Expand Up @@ -58,6 +59,8 @@ set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/b
add_library(libvpx STATIC IMPORTED)
set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/libvpx/build/${ANDROID_ABI}/lib/libvpx.a)

add_library(libdav1d STATIC IMPORTED)
set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/dav1d/build/${ANDROID_ABI}/lib/libdav1d.a)

#tgnet
#add_library(mozjpeg STATIC
Expand Down Expand Up @@ -654,6 +657,7 @@ target_link_libraries(${NATIVE_LIB}
avresample
swresample
libvpx
libdav1d
avutil
ssl
crypto
Expand Down
5 changes: 5 additions & 0 deletions TMessagesProj/jni/TgNetWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ jint getCurrentTime(JNIEnv *env, jclass c, jint instanceNum) {
return ConnectionsManager::getInstance(instanceNum).getCurrentTime();
}

jint getCurrentPingTime(JNIEnv *env, jclass c, jint instanceNum) {
return ConnectionsManager::getInstance(instanceNum).getCurrentPingTime();
}

jint getCurrentDatacenterId(JNIEnv *env, jclass c, jint instanceNum) {
return ConnectionsManager::getInstance(instanceNum).getCurrentDatacenterId();
}
Expand Down Expand Up @@ -560,6 +564,7 @@ static const char *ConnectionsManagerClassPathName = "org/telegram/tgnet/Connect
static JNINativeMethod ConnectionsManagerMethods[] = {
{"native_getCurrentTimeMillis", "(I)J", (void *) getCurrentTimeMillis},
{"native_getCurrentTime", "(I)I", (void *) getCurrentTime},
{"native_getCurrentPingTime", "(I)I", (void *) getCurrentPingTime},
{"native_getCurrentDatacenterId", "(I)I", (void *) getCurrentDatacenterId},
{"native_isTestBackend", "(I)I", (void *) isTestBackend},
{"native_getTimeDifference", "(I)I", (void *) getTimeDifference},
Expand Down
165 changes: 165 additions & 0 deletions TMessagesProj/jni/build_dav1d_clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/bin/bash
set -e
function build_one {
echo "Building ${ARCH}..."

PREBUILT=${NDK}/toolchains/${PREBUILT_ARCH}-${VERSION}/prebuilt/${BUILD_PLATFORM}
PLATFORM=${NDK}/platforms/android-${ANDROID_API}/arch-${ARCH}

TOOLS_PREFIX="${LLVM_BIN}/${ARCH_NAME}-linux-${BIN_MIDDLE}-"

export LD=${TOOLS_PREFIX}ld
export AR=${TOOLS_PREFIX}ar
export STRIP=${TOOLS_PREFIX}strip
export RANLIB=${TOOLS_PREFIX}ranlib
export NM=${TOOLS_PREFIX}nm

export CC_PREFIX="${LLVM_BIN}/${CLANG_PREFIX}-linux-${BIN_MIDDLE}${ANDROID_API}-"

export CC=${CC_PREFIX}clang
export CXX=${CC_PREFIX}clang++
export AS=${CC_PREFIX}clang++
export CROSS_PREFIX=${PREBUILT}/bin/${ARCH_NAME}-linux-${BIN_MIDDLE}-


export CFLAGS="-DANDROID -fpic -fpie ${OPTIMIZE_CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS} -std=c++11"
export ASFLAGS="-D__ANDROID__"
export LDFLAGS="-L${PLATFORM}/usr/lib"

meson setup builddir-${ARCH} \
--prefix "$PREFIX" \
--libdir="lib" \
--includedir="include" \
--buildtype=release -Denable_tests=false -Denable_tools=false -Ddefault_library=static \
--cross-file <(echo "
[binaries]
c = '${CC}'
ar = '${AR}'
[host_machine]
system = '${BIN_MIDDLE}'
cpu_family = '${PREBUILT_ARCH}'
cpu = '${CPU}'
endian = 'little'
")
cd builddir-${ARCH}
meson compile && meson install
cd ..
# ninja -C builddir-${ARCH}
# ninja -C builddir-${ARCH} install
}

function setCurrentPlatform {

CURRENT_PLATFORM="$(uname -s)"
case "${CURRENT_PLATFORM}" in
Darwin*)
BUILD_PLATFORM=darwin-x86_64
COMPILATION_PROC_COUNT=`sysctl -n hw.physicalcpu`
;;
Linux*)
BUILD_PLATFORM=linux-x86_64
COMPILATION_PROC_COUNT=$(nproc)
;;
*)
echo -e "\033[33mWarning! Unknown platform ${CURRENT_PLATFORM}! falling back to linux-x86_64\033[0m"
BUILD_PLATFORM=linux-x86_64
COMPILATION_PROC_COUNT=1
;;
esac

echo "Build platform: ${BUILD_PLATFORM}"
echo "Parallel jobs: ${COMPILATION_PROC_COUNT}"

}

function checkPreRequisites {

if ! [ -d "dav1d" ] || ! [ "$(ls -A dav1d)" ]; then
echo -e "\033[31mFailed! Submodule 'dav1d' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule init && git submodule update'\033[0m"
exit
fi

if [ -z "$NDK" -a "$NDK" == "" ]; then
echo -e "\033[31mFailed! NDK is empty. Run 'export NDK=[PATH_TO_NDK]'\033[0m"
exit
fi
}

setCurrentPlatform
checkPreRequisites

cd dav1d

## common
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
LLVM_BIN="${LLVM_PREFIX}/bin"
PREFIX_D=$(realpath .)
VERSION="4.9"
ANDROID_API=21

function build {
for arg in "$@"; do
case "${arg}" in
x86_64)
ANDROID_API=21
ARCH=x86_64
ARCH_NAME=x86_64
PREBUILT_ARCH=x86_64
CLANG_PREFIX=x86_64
BIN_MIDDLE=android
CPU=x86_64
CPU_NAME=x86_64
PREFIX=${PREFIX_D}/build/$CPU
build_one
;;
x86)
ANDROID_API=21
ARCH=x86
ARCH_NAME=i686
PREBUILT_ARCH=x86
CLANG_PREFIX=i686
BIN_MIDDLE=android
CPU=i686
CPU_NAME=i686
PREFIX=${PREFIX_D}/build/x86
build_one
;;
arm64)
ANDROID_API=21
ARCH=arm64
ARCH_NAME=aarch64
PREBUILT_ARCH=aarch64
CLANG_PREFIX=aarch64
BIN_MIDDLE=android
CPU=arm64-v8a
CPU_NAME=arm64
PREFIX=${PREFIX_D}/build/$CPU
build_one
;;
arm)
ANDROID_API=21
ARCH=arm
ARCH_NAME=arm
PREBUILT_ARCH=arm
CLANG_PREFIX=armv7a
BIN_MIDDLE=androideabi
CPU=armeabi-v7a
CPU_NAME=armv7
PREFIX=${PREFIX_D}/build/$CPU
build_one
;;
*)
;;
esac
done
}

if (( $# == 0 )); then
build arm arm64
else
build $@
fi
21 changes: 16 additions & 5 deletions TMessagesProj/jni/build_ffmpeg_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ function build_one {
CXX=${CC_PREFIX}clang++
CROSS_PREFIX=${PREBUILT}/bin/${ARCH_NAME}-linux-${BIN_MIDDLE}-

INCLUDES=" -I./${LIBVPXPREFIX}/include"
LIBS=" -L./${LIBVPXPREFIX}/lib"
INCLUDES=" -I./${LIBVPXPREFIX}/include -I${LIBDAV1DPREFIX}/include"
LIBS=" -L./${LIBVPXPREFIX}/lib -L${LIBDAV1DPREFIX}/lib"

echo "Cleaning..."
rm -f config.h
make clean || true

echo "Configuring..."

./configure \
PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${LIBDAV1DPREFIX}/lib/pkgconfig ./configure \
--nm=${NM} \
--ar=${AR} \
--strip=${STRIP} \
Expand All @@ -40,6 +40,8 @@ function build_one {
--enable-cross-compile \
--x86asmexe=$NDK/prebuilt/${BUILD_PLATFORM}/bin/yasm \
--prefix=$PREFIX \
--pkg-config="pkg-config" \
--pkg-config-flags="--static" \
--enable-pic \
--disable-shared \
--enable-static \
Expand Down Expand Up @@ -79,6 +81,10 @@ function build_one {
--enable-muxer=matroska \
--enable-bsf=vp9_superframe \
--enable-bsf=vp9_raw_reorder \
\
--enable-libdav1d \
--enable-decoder=libdav1d \
--enable-decoder=av1 \
--enable-runtime-cpudetect \
--enable-pthreads \
--enable-avresample \
Expand Down Expand Up @@ -157,6 +163,7 @@ cd ffmpeg
## common
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
LLVM_BIN="${LLVM_PREFIX}/bin"
PREFIX_D=$(realpath ..)
VERSION="4.9"

function build {
Expand All @@ -174,6 +181,7 @@ function build {
CPU=x86_64
PREFIX=./build/$CPU
LIBVPXPREFIX=../libvpx/build/x86_64
LIBDAV1DPREFIX=$PREFIX_D/dav1d/build/x86_64
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
build_one
;;
Expand All @@ -190,11 +198,12 @@ function build {
OPTIMIZE_CFLAGS=
PREFIX=./build/$CPU
LIBVPXPREFIX=../libvpx/build/arm64-v8a
LIBDAV1DPREFIX=$PREFIX_D/dav1d/build/arm64-v8a
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --enable-optimizations"
build_one
;;
arm)
ANDROID_API=16
ANDROID_API=21

ARCH=arm
ARCH_NAME=arm
Expand All @@ -206,11 +215,12 @@ function build {
OPTIMIZE_CFLAGS="-marm -march=$CPU"
PREFIX=./build/armeabi-v7a
LIBVPXPREFIX=../libvpx/build/armeabi-v7a
LIBDAV1DPREFIX=$PREFIX_D/dav1d/build/armeabi-v7a
ADDITIONAL_CONFIGURE_FLAG="--enable-neon"
build_one
;;
x86)
ANDROID_API=16
ANDROID_API=21

ARCH=x86
ARCH_NAME=i686
Expand All @@ -222,6 +232,7 @@ function build {
OPTIMIZE_CFLAGS="-march=$CPU"
PREFIX=./build/x86
LIBVPXPREFIX=../libvpx/build/x86
LIBDAV1DPREFIX=$PREFIX_D/dav1d/build/x86
ADDITIONAL_CONFIGURE_FLAG="--disable-x86asm --disable-inline-asm --disable-asm"
build_one
;;
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/dav1d
Submodule dav1d added at 30c3dd
Loading

0 comments on commit c94099b

Please sign in to comment.