Skip to content

Commit c3fee17

Browse files
committed
Optimize memory usage + Migrate from ExoPlayer to androidx:media3 + Upgrade FFmpeg to 6.0 + Memory optimizations
1 parent 3427d34 commit c3fee17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+450
-419
lines changed

‎.gitmodules

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
path = app/jni/third_party/ffmpeg
1717
url = https://github.com/FFmpeg/FFmpeg
1818
shallow = true
19-
branch = release/4.4
19+
branch = release/6.0
2020
[submodule "lz4"]
2121
path = app/jni/third_party/lz4
2222
url = https://github.com/lz4/lz4
2323
shallow = true
24-
[submodule "ExoPlayer"]
25-
path = thirdparty/ExoPlayer
26-
url = https://github.com/google/ExoPlayer
24+
[submodule "androidx-media"]
25+
path = thirdparty/androidx-media
26+
url = https://github.com/androidx/media
2727
shallow = true
28-
branch = release-v2
28+
branch = release
2929
[submodule "flac"]
3030
path = app/jni/third_party/flac
3131
url = https://github.com/xiph/flac

‎app/build.gradle.kts

+9-7
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ android {
7777
"./jni/third_party/webrtc/sdk/android/src/java",
7878
"../thirdparty/WebRTC/src/java"
7979
)
80-
Config.EXOPLAYER_EXTENSIONS.forEach { module ->
81-
java.srcDirs("../thirdparty/ExoPlayer/extensions/${module}/src/main/java")
80+
Config.ANDROIDX_MEDIA_EXTENSIONS.forEach { extension ->
81+
java.srcDirs("../thirdparty/androidx-media/libraries/${extension}/src/main/java")
8282
}
8383
}
8484

@@ -89,10 +89,12 @@ android {
8989

9090
buildTypes {
9191
getByName("release") {
92-
Config.EXOPLAYER_EXTENSIONS.forEach { module ->
93-
val proguardFile = file("../thirdparty/ExoPlayer/extensions/${module}/proguard-rules.txt")
92+
Config.ANDROIDX_MEDIA_EXTENSIONS.forEach { extension ->
93+
val proguardFile = file(
94+
"../thirdparty/androidx-media/libraries/${extension}/proguard-rules.txt"
95+
)
9496
if (proguardFile.exists()) {
95-
project.logger.lifecycle("Applying thirdparty/ExoPlayer/extensions/${module}/proguard-rules.pro")
97+
project.logger.lifecycle("Applying ${proguardFile.path}")
9698
proguardFile(proguardFile)
9799
}
98100
}
@@ -224,8 +226,8 @@ dependencies {
224226
implementation("com.google.firebase:firebase-appcheck-safetynet:16.1.2")
225227
// Play In-App Updates: https://developer.android.com/reference/com/google/android/play/core/release-notes-in_app_updates
226228
implementation("com.google.android.play:app-update:2.1.0")
227-
// ExoPlayer: https://github.com/google/ExoPlayer/blob/release-v2/RELEASENOTES.md
228-
implementation("com.google.android.exoplayer:exoplayer-core:2.19.1")
229+
// AndroidX/media: https://github.com/androidx/media/blob/release/RELEASENOTES.md
230+
implementation("androidx.media3:media3-exoplayer:1.2.1")
229231
// 17.x version requires minSdk 19 or higher
230232
implementation("com.google.mlkit:language-id:16.1.1")
231233
// The Checker Framework: https://checkerframework.org/CHANGELOG.md

‎app/jni/BuildFlac.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# flac
22

33
set(FLAC_DIR "${THIRDPARTY_DIR}/flac")
4-
set(EXO_FLAC_DIR "${CMAKE_HOME_DIRECTORY}/../../thirdparty/ExoPlayer/extensions/flac/src/main/jni")
4+
set(ANDROIDX_MEDIA_FLAC_DIR "${CMAKE_HOME_DIRECTORY}/../../thirdparty/androidx-media/libraries/decoder_flac/src/main/jni")
55

6-
ReadVariables("${EXO_FLAC_DIR}/flac_sources.mk")
6+
ReadVariables("${ANDROIDX_MEDIA_FLAC_DIR}/flac_sources.mk")
77
list(FILTER FLAC_SOURCES INCLUDE REGEX "^flac/.+$")
88
Transform(FLAC_SOURCES "^flac/" "${FLAC_DIR}/")
99

‎app/jni/CMakeLists.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,17 @@ add_library(${NATIVE_LIB} SHARED
210210
gif.cpp
211211
views.c
212212

213-
"${THIRDPARTY_DIR}/exoplayer/opus_jni.cc"
214-
"${THIRDPARTY_DIR}/exoplayer/flac_jni.cc"
215-
"${THIRDPARTY_DIR}/exoplayer/flac_parser.cc"
216-
"${THIRDPARTY_DIR}/exoplayer/ffmpeg_jni.cc"
217-
"${THIRDPARTY_DIR}/exoplayer/vpx_jni.cc"
213+
"${THIRDPARTY_DIR}/androidx-media/opus_jni.cc"
214+
"${THIRDPARTY_DIR}/androidx-media/flac_jni.cc"
215+
"${THIRDPARTY_DIR}/androidx-media/flac_parser.cc"
216+
"${THIRDPARTY_DIR}/androidx-media/ffmpeg_jni.cc"
217+
"${THIRDPARTY_DIR}/androidx-media/vpx_jni.cc"
218218

219219
bridge.cpp
220220
)
221221
target_include_directories(${NATIVE_LIB} PRIVATE
222222
"${THIRDPARTY_DIR}/telegram_intro"
223-
"${THIRDPARTY_DIR}/exoplayer"
223+
"${THIRDPARTY_DIR}/androidx-media"
224224

225225
"${THIRDPARTY_DIR}"
226226
.
@@ -247,7 +247,7 @@ target_compile_options(${NATIVE_LIB} PUBLIC
247247
-fno-rtti
248248
)
249249
# TODO: remove -Wno-macro-redefined -Wno-unused-variable
250-
# only "${THIRDPARTY_DIR}/exoplayer/ffmpeg_jni.cc" needs them.
250+
# only "${THIRDPARTY_DIR}/androidx-media/ffmpeg_jni.cc" needs them.
251251

252252
# == Linking dependencies ==
253253

‎app/jni/cmake/ReadVariables.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ if(POLICY CMP0007)
88
endif()
99

1010
function(ReadVariables MKFile)
11+
if(NOT EXISTS "${MKFile}")
12+
message(FATAL_ERROR "File does not exist: ${MKFile}")
13+
endif()
1114
file(READ "${MKFile}" FileContents)
1215
string(REGEX REPLACE "\\\\\n *" " " FileContents ${FileContents})
1316
string(REGEX REPLACE "#[^\n]*" "" FileContents ${FileContents})

0 commit comments

Comments
 (0)