From d52bf9da819d7a3cbf78038ccd140910966a9e35 Mon Sep 17 00:00:00 2001 From: Maxr1998 Date: Sat, 23 Dec 2023 22:16:11 +0100 Subject: [PATCH] Migrate to AndroidX Media3 --- .github/workflows/extension-build.yaml | 2 +- .github/workflows/extension-publish.yaml | 2 +- .gitmodules | 8 ++-- ExoPlayer | 1 - build.gradle.kts | 2 +- build.sh | 10 ++--- media | 1 + .../build.gradle.kts | 39 ++++++++++++++----- settings.gradle.kts | 12 ++---- 9 files changed, 47 insertions(+), 30 deletions(-) delete mode 160000 ExoPlayer create mode 160000 media rename {exoplayer-ffmpeg-extension => media3-ffmpeg-decoder}/build.gradle.kts (67%) diff --git a/.github/workflows/extension-build.yaml b/.github/workflows/extension-build.yaml index 4d729b8..d65303e 100644 --- a/.github/workflows/extension-build.yaml +++ b/.github/workflows/extension-build.yaml @@ -35,4 +35,4 @@ jobs: - name: Build ffmpeg run: ./build.sh - name: Build extension and publish library locally - run: ./gradlew :exoplayer-ffmpeg-extension:publishToMavenLocal + run: ./gradlew :media3-ffmpeg-decoder:publishToMavenLocal diff --git a/.github/workflows/extension-publish.yaml b/.github/workflows/extension-publish.yaml index e3d4d22..b35d51c 100644 --- a/.github/workflows/extension-publish.yaml +++ b/.github/workflows/extension-publish.yaml @@ -41,7 +41,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: echo "JELLYFIN_VERSION=$(echo ${GITHUB_REF#refs/tags/v} | tr / -)" >> $GITHUB_ENV - name: Build extension and publish library - run: ./gradlew :exoplayer-ffmpeg-extension:publish closeAndReleaseSonatypeStagingRepository + run: ./gradlew :media3-ffmpeg-decoder:publish closeAndReleaseSonatypeStagingRepository env: SIGNING_KEY: ${{ secrets.SIGNING_KEY }} OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/.gitmodules b/.gitmodules index 7af56f0..cf1abbf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ -[submodule "ExoPlayer"] - path = ExoPlayer - url = https://github.com/google/ExoPlayer.git - branch = release-v2 +[submodule "media"] + path = media + url = https://github.com/androidx/media.git + branch = release [submodule "ffmpeg"] path = ffmpeg url = https://git.ffmpeg.org/ffmpeg.git diff --git a/ExoPlayer b/ExoPlayer deleted file mode 160000 index 5d4b706..0000000 --- a/ExoPlayer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5d4b70666f26273fbd4c3f6dccb18ccd91093d83 diff --git a/build.gradle.kts b/build.gradle.kts index 7d7d134..8eea79a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ buildscript { } allprojects { - group = "org.jellyfin.exoplayer" + group = "org.jellyfin.media3" version = createVersion() repositories { diff --git a/build.sh b/build.sh index c3f5adc..7493960 100755 --- a/build.sh +++ b/build.sh @@ -6,14 +6,14 @@ export ANDROID_NDK_PATH=$ANDROID_HOME/ndk/21.4.7075529 [[ -z "$ANDROID_NDK_PATH" ]] && echo "No NDK found, quitting…" && exit 1 # Setup environment -export EXOPLAYER_ROOT="${PWD}/ExoPlayer" -export FFMPEG_EXT_PATH="${EXOPLAYER_ROOT}/extensions/ffmpeg/src/main" +export ANDROIDX_MEDIA_ROOT="${PWD}/media" +export FFMPEG_MOD_PATH="${ANDROIDX_MEDIA_ROOT}/libraries/decoder_ffmpeg/src/main" export FFMPEG_PATH="${PWD}/ffmpeg" export ENABLED_DECODERS=(flac alac pcm_mulaw pcm_alaw mp3 aac ac3 eac3 dca mlp truehd) # Create softlink to ffmpeg -ln -sf "${FFMPEG_PATH}" "${FFMPEG_EXT_PATH}/jni/ffmpeg" +ln -sf "${FFMPEG_PATH}" "${FFMPEG_MOD_PATH}/jni/ffmpeg" # Start build -cd "${FFMPEG_EXT_PATH}/jni" -./build_ffmpeg.sh "${FFMPEG_EXT_PATH}" "${ANDROID_NDK_PATH}" "linux-x86_64" "${ENABLED_DECODERS[@]}" +cd "${FFMPEG_MOD_PATH}/jni" +./build_ffmpeg.sh "${FFMPEG_MOD_PATH}" "${ANDROID_NDK_PATH}" "linux-x86_64" "${ENABLED_DECODERS[@]}" diff --git a/media b/media new file mode 160000 index 0000000..f6fe90f --- /dev/null +++ b/media @@ -0,0 +1 @@ +Subproject commit f6fe90f30ba022c7e04e14a3dc5c28c568a4d1e2 diff --git a/exoplayer-ffmpeg-extension/build.gradle.kts b/media3-ffmpeg-decoder/build.gradle.kts similarity index 67% rename from exoplayer-ffmpeg-extension/build.gradle.kts rename to media3-ffmpeg-decoder/build.gradle.kts index 8ab3e4c..2d328bc 100644 --- a/exoplayer-ffmpeg-extension/build.gradle.kts +++ b/media3-ffmpeg-decoder/build.gradle.kts @@ -1,19 +1,39 @@ import com.android.build.gradle.LibraryExtension +import com.android.build.gradle.api.LibraryVariant +import com.android.build.gradle.tasks.BundleAar plugins { `maven-publish` signing } -val exoplayerProject = project(":exoplayer-extension-ffmpeg") -val android = exoplayerProject.extensions.findByType(LibraryExtension::class.java) +val decoderProject = project(":androidx-media-lib-decoder-ffmpeg") +val androidExtension = decoderProject.extensions.findByType(LibraryExtension::class.java) ?: error("Could not find android extension") -val generateJavadoc by exoplayerProject.tasks.getting(Javadoc::class) -generateJavadoc.isFailOnError = false +@Suppress("deprecation") // libraryVariants exposes deprecated type +val releaseVariant: LibraryVariant = androidExtension.libraryVariants.first { variant -> + variant.name == "release" +} + +val bundleReleaseAar by decoderProject.tasks.getting(BundleAar::class) + +val generateJavadoc by tasks.registering(Javadoc::class) { + group = "publishing" + description = "Generates Javadoc for release sources." + + val javaCompile = releaseVariant.javaCompileProvider.get() + source = javaCompile.source + classpath = javaCompile.classpath + files(androidExtension.bootClasspath) + + setDestinationDir(File(buildDir, "/docs/javadoc")) -val javadocJar by tasks.creating(Jar::class) { + isFailOnError = false +} + +val javadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") + from(generateJavadoc) dependsOn(generateJavadoc) } @@ -21,7 +41,8 @@ val javadocJar by tasks.creating(Jar::class) { // Package sources from ExoPlayer FFmpeg extension project val sourcesJar by tasks.registering(Jar::class) { archiveClassifier.set("sources") - val main = android.sourceSets.getByName("main") + + val main = androidExtension.sourceSets.getByName("main") from(main.java.srcDirs) @Suppress("deprecation") from(main.jni.srcDirs) { @@ -33,15 +54,15 @@ afterEvaluate { // Specify release artifacts and apply POM publishing.publications.create("default") { // Repackage release artifacts of extension - from(exoplayerProject.components["release"]) + artifact(bundleReleaseAar) // Add JavaDocs and sources artifact(javadocJar) artifact(sourcesJar) pom { - name.set("Jellyfin ExoPlayer libraries - $artifactId") - description.set("ExoPlayer FFmpeg extension used in the Jellyfin project") + name.set("Jellyfin AndroidX Media3 libraries - $artifactId") + description.set("AndroidX Media3 FFmpeg decoder used in the Jellyfin project") url.set("https://github.com/jellyfin/jellyfin-exoplayer-ffmpeg-extension") scm { diff --git a/settings.gradle.kts b/settings.gradle.kts index b742fb5..89aab36 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,9 +1,5 @@ -// See https://github.com/google/ExoPlayer/issues/6339 -if (gradle is ExtensionAware) { - val extension = gradle as ExtensionAware - extension.extra["exoplayerRoot"] = file("ExoPlayer").absolutePath - extension.extra["exoplayerModulePrefix"] = "exoplayer-" - apply(from = File(extension.extra["exoplayerRoot"].toString(), "core_settings.gradle")) -} +gradle.extra["androidxMediaModulePrefix"] = "androidx-media-" +val mediaRoot = file("media") +apply(from = File(mediaRoot, "core_settings.gradle")) -include(":exoplayer-ffmpeg-extension") +include(":media3-ffmpeg-decoder")