From 00d1e70a346f542d849253b72b52cf0b638845fd Mon Sep 17 00:00:00 2001 From: ibaker Date: Tue, 9 Jul 2024 07:26:36 -0700 Subject: [PATCH] Rollback of https://github.com/androidx/media/commit/91633e6ae3ca0a41652154f99477dc757981fd88 PiperOrigin-RevId: 650620012 --- RELEASENOTES.md | 13 +++++++++++++ build.gradle | 2 +- constants.gradle | 3 +-- .../java/androidx/media3/demo/main/DemoUtil.java | 4 +++- .../datasource/ByteArrayUploadDataProvider.java | 5 +++-- .../media3/datasource/HttpEngineDataSource.java | 5 +++-- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 584067a1a49..d42f1c92055 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -11,6 +11,15 @@ * Add override for `SimpleBasePlayer.State.Builder.setPlaylist()` to directly specify a `Timeline` and current `Tracks` and `Metadata` instead of building a playlist structure. + * Upgrade `androidx.annotation:annotation` dependency to `1.6.0`. This may + cause `duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations` + and similar errors for non-Kotlin apps that also depend on other libs + like `androidx.appcompat:appcompat`. This is due to + [incomplete version constraints in the Kotlin standard library](https://youtrack.jetbrains.com/issue/KT-55297). + Apps can resolve this by upgrading their + [Kotlin Gradle Plugin](https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin) + to at least version `1.9.20` or using the workaround described in + https://issuetracker.google.com/278545487. * ExoPlayer: * `MediaCodecRenderer.onProcessedStreamChange()` can now be called for every media item. Previously it was not called for the first one. Use @@ -28,6 +37,10 @@ * Extractors: * Allow `Mp4Extractor` and `FragmentedMp4Extractor` to identify H264 samples that are not used as reference by subsequent samples. +* DataSource: + * Update `HttpEngineDataSource` to allow use starting at version S + extension 7 instead of API level 34 + ([#1262](https://github.com/androidx/media/issues/1262)). * Audio: * Video: * Text: diff --git a/build.gradle b/build.gradle index c3243831df0..35eaa58d3f6 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:8.3.2' classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.4' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20' } } allprojects { diff --git a/constants.gradle b/constants.gradle index e18bfbf7881..cb5b6e55925 100644 --- a/constants.gradle +++ b/constants.gradle @@ -38,8 +38,7 @@ project.ext { errorProneVersion = '2.18.0' jsr305Version = '3.0.2' kotlinAnnotationsVersion = '1.9.0' - // Updating this to 1.4.0+ will import Kotlin stdlib [internal ref: b/277891049]. - androidxAnnotationVersion = '1.3.0' + androidxAnnotationVersion = '1.6.0' androidxAnnotationExperimentalVersion = '1.3.1' androidxAppCompatVersion = '1.6.1' androidxCollectionVersion = '1.2.0' diff --git a/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java b/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java index 4713817524d..5d73c58cbb5 100644 --- a/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java +++ b/demos/main/src/main/java/androidx/media3/demo/main/DemoUtil.java @@ -18,6 +18,7 @@ import android.content.Context; import android.net.http.HttpEngine; import android.os.Build; +import android.os.ext.SdkExtensions; import androidx.annotation.OptIn; import androidx.media3.database.DatabaseProvider; import androidx.media3.database.StandaloneDatabaseProvider; @@ -106,7 +107,8 @@ public static synchronized DataSource.Factory getHttpDataSourceFactory(Context c return httpDataSourceFactory; } context = context.getApplicationContext(); - if (Build.VERSION.SDK_INT >= 34) { + if (Build.VERSION.SDK_INT >= 30 + && SdkExtensions.getExtensionVersion(Build.VERSION_CODES.S) >= 7) { HttpEngine httpEngine = new HttpEngine.Builder(context).build(); httpDataSourceFactory = new HttpEngineDataSource.Factory(httpEngine, Executors.newSingleThreadExecutor()); diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/ByteArrayUploadDataProvider.java b/libraries/datasource/src/main/java/androidx/media3/datasource/ByteArrayUploadDataProvider.java index f2f321dd51c..9892906849e 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/ByteArrayUploadDataProvider.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/ByteArrayUploadDataProvider.java @@ -19,12 +19,13 @@ import android.net.http.UploadDataProvider; import android.net.http.UploadDataSink; -import androidx.annotation.RequiresApi; +import android.os.Build; +import androidx.annotation.RequiresExtension; import java.io.IOException; import java.nio.ByteBuffer; /** A {@link UploadDataProvider} implementation that provides data from a {@code byte[]}. */ -@RequiresApi(34) +@RequiresExtension(extension = Build.VERSION_CODES.S, version = 7) /* package */ final class ByteArrayUploadDataProvider extends UploadDataProvider { private final byte[] data; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java index 57879947ebf..9e6c97f032a 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java @@ -26,9 +26,10 @@ import android.net.http.UrlRequest; import android.net.http.UrlRequest.Status; import android.net.http.UrlResponseInfo; +import android.os.Build; import android.text.TextUtils; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; +import androidx.annotation.RequiresExtension; import androidx.annotation.VisibleForTesting; import androidx.media3.common.C; import androidx.media3.common.PlaybackException; @@ -65,7 +66,7 @@ * priority) the {@code dataSpec}, {@link #setRequestProperty} and the default parameters used to * construct the instance. */ -@RequiresApi(34) +@RequiresExtension(extension = Build.VERSION_CODES.S, version = 7) @UnstableApi public final class HttpEngineDataSource extends BaseDataSource implements HttpDataSource {