Skip to content

Commit

Permalink
Migrate to AndroidX Media3
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Dec 23, 2023
1 parent ee5bdf9 commit d52bf9d
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/extension-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/extension-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion ExoPlayer
Submodule ExoPlayer deleted from 5d4b70
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
}

allprojects {
group = "org.jellyfin.exoplayer"
group = "org.jellyfin.media3"
version = createVersion()

repositories {
Expand Down
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
1 change: 1 addition & 0 deletions media
Submodule media added at f6fe90
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
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)
}

// 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) {
Expand All @@ -33,15 +54,15 @@ afterEvaluate {
// Specify release artifacts and apply POM
publishing.publications.create<MavenPublication>("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 {
Expand Down
12 changes: 4 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit d52bf9d

Please sign in to comment.