From 5d538ee4e66d85c71f532c3963c649ffc14caed1 Mon Sep 17 00:00:00 2001 From: Artem Umerov Date: Mon, 10 Apr 2023 22:26:28 +0300 Subject: [PATCH] 20 20 --- app_fenrir/build.gradle | 4 +- .../fenrir/db/model/entity/DialogDboEntity.kt | 5 + .../fenrir/domain/impl/MessagesRepository.kt | 4 +- .../fragment/accounts/AccountsPresenter.kt | 55 +++++++- .../messages/dialogs/DialogsFragment.kt | 2 +- .../messages/dialogs/DialogsPresenter.kt | 9 ++ .../dev/ragnarok/fenrir/media/exo/ExoUtil.kt | 2 +- .../fenrir/media/exo/OkHttpDataSource.kt | 76 ++++++----- .../media/music/MusicPlaybackService.kt | 26 ++-- .../fenrir/media/story/ExoStoryPlayer.kt | 13 +- .../fenrir/media/video/ExoVideoPlayer.kt | 23 ++-- .../fenrir/media/voice/ExoVoicePlayer.kt | 19 +-- .../media/voice/ExoVoicePlayerSensored.kt | 19 +-- .../kotlin/dev/ragnarok/fenrir/util/Utils.kt | 2 +- .../src/main/res/layout/item_short_link.xml | 128 ++++++++---------- app_filegallery/build.gradle | 2 +- .../ragnarok/filegallery/media/exo/ExoUtil.kt | 2 +- .../filegallery/media/exo/OkHttpDataSource.kt | 74 +++++----- .../media/music/MusicPlaybackService.kt | 23 ++-- .../filegallery/media/video/ExoVideoPlayer.kt | 21 +-- .../dev/ragnarok/filegallery/util/Utils.kt | 3 +- build.gradle | 14 +- libfenrir/build.gradle | 2 +- libfenrir/src/main/jni/CMakeLists.txt | 1 + .../animation/libyuv/include/libyuv/cpu_id.h | 7 + .../jni/animation/libyuv/include/libyuv/row.h | 9 ++ .../animation/libyuv/include/libyuv/version.h | 2 +- .../animation/libyuv/source/convert_argb.cc | 10 ++ .../jni/animation/libyuv/source/cpu_id.cc | 61 +++++++++ .../libyuv/source/planar_functions.cc | 5 + .../jni/animation/libyuv/source/row_any.cc | 2 +- .../jni/animation/libyuv/source/row_rvv.cc | 75 ++++++++++ .../main/jni/animation/libyuv/source/scale.cc | 2 + .../jni/animation/libyuv/source/scale_uv.cc | 24 ++-- .../src/main/jni/audio/ffmpeg/ffmpeg_jni.cpp | 29 ++-- libfenrir/src/main/jni/audio/opus/opus_jni.cc | 36 +++-- .../compress/zstd/compress/zstd_compress.c | 34 +++-- .../zstd/decompress/zstd_decompress.c | 78 +++++------ .../rlottie/src/lottie/rapidjson/allocators.h | 2 +- .../src/lib/sw_engine/tvgSwRenderer.cpp | 14 +- .../thorvg/src/lib/sw_engine/tvgSwStroke.cpp | 11 +- .../main/jni/thorvg/src/lib/tvgAccessor.cpp | 11 +- .../jni/thorvg/src/lib/tvgIteratorAccessor.h | 2 +- .../main/jni/thorvg/src/lib/tvgSaveModule.h | 2 +- .../src/main/jni/thorvg/src/lib/tvgShape.cpp | 1 + .../jni/thorvg/src/lib/tvgTaskScheduler.cpp | 7 +- .../jni/thorvg/src/lib/tvgTaskScheduler.h | 33 +++-- .../src/loaders/svg/tvgSvgSceneBuilder.cpp | 4 +- .../decoder}/ffmpeg/FfmpegAudioDecoder.kt | 25 ++-- .../decoder}/ffmpeg/FfmpegAudioRenderer.kt | 31 +++-- .../decoder}/ffmpeg/FfmpegDecoderException.kt | 6 +- .../media3/decoder}/ffmpeg/FfmpegLibrary.kt | 14 +- .../decoder}/opus/LibopusAudioRenderer.kt | 24 ++-- .../media3/decoder}/opus/OpusDecoder.kt | 16 ++- .../decoder}/opus/OpusDecoderException.kt | 6 +- .../media3/decoder}/opus/OpusLibrary.kt | 15 +- 56 files changed, 712 insertions(+), 415 deletions(-) create mode 100644 libfenrir/src/main/jni/animation/libyuv/source/row_rvv.cc rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/ffmpeg/FfmpegAudioDecoder.kt (93%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/ffmpeg/FfmpegAudioRenderer.kt (86%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/ffmpeg/FfmpegDecoderException.kt (86%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/ffmpeg/FfmpegLibrary.kt (90%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/opus/LibopusAudioRenderer.kt (88%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/opus/OpusDecoder.kt (96%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/opus/OpusDecoderException.kt (86%) rename libfenrir/src/main/kotlin/{com/google/android/exoplayer2/ext => androidx/media3/decoder}/opus/OpusLibrary.kt (83%) diff --git a/app_fenrir/build.gradle b/app_fenrir/build.gradle index a0c9d77d8..3f3ed6686 100644 --- a/app_fenrir/build.gradle +++ b/app_fenrir/build.gradle @@ -148,11 +148,11 @@ dependencies { implementation("com.squareup.okhttp3:okhttp-android:$okhttpLibraryVersion") //implementation("com.squareup.okhttp3:logging-interceptor:$okhttpLibraryVersion") implementation("com.squareup.okio:okio:$okioVersion") - implementation("com.google.android.exoplayer:exoplayer-core:$exoLibraryVersion") - implementation("com.google.android.exoplayer:exoplayer-hls:$exoLibraryVersion") implementation("androidx.constraintlayout:constraintlayout:$constraintlayoutVersion") implementation("androidx.biometric:biometric-ktx:$biometricVersion") implementation("androidx.media:media:$mediaVersion") + implementation("androidx.media3:media3-exoplayer:$media3Version") + implementation("androidx.media3:media3-exoplayer-hls:$media3Version") implementation("androidx.coordinatorlayout:coordinatorlayout:$coordinatorlayoutVersion") implementation("androidx.activity:activity-ktx:$activityVersion") implementation("androidx.fragment:fragment-ktx:$fragmentVersion") diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/model/entity/DialogDboEntity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/model/entity/DialogDboEntity.kt index 6813b25c8..6b1aa9133 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/model/entity/DialogDboEntity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/db/model/entity/DialogDboEntity.kt @@ -1,5 +1,10 @@ package dev.ragnarok.fenrir.db.model.entity +import androidx.annotation.Keep +import kotlinx.serialization.Serializable + +@Keep +@Serializable class DialogDboEntity(val peerId: Long) : DboEntity() { var title: String? = null private set diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/domain/impl/MessagesRepository.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/domain/impl/MessagesRepository.kt index f6958e493..d1d1b9e70 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/domain/impl/MessagesRepository.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/domain/impl/MessagesRepository.kt @@ -190,7 +190,7 @@ class MessagesRepository( }) } - private fun onUpdloadSuccess(upload: Upload) { + private fun onUploadSuccess(upload: Upload) { val accountId = upload.accountId val messagesId = upload.destination.id compositeDisposable.add(uploadManager[accountId, upload.destination] @@ -1774,7 +1774,7 @@ class MessagesRepository( uploadManager.observeResults() .filter { it.first.destination.method == Method.TO_MESSAGE } .subscribe({ result -> - onUpdloadSuccess( + onUploadSuccess( result.first ) }, ignore()) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsPresenter.kt index 8fac20382..33285787a 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsPresenter.kt @@ -23,6 +23,7 @@ import dev.ragnarok.fenrir.api.model.response.BaseResponse import dev.ragnarok.fenrir.api.rest.HttpException import dev.ragnarok.fenrir.api.util.VKStringUtils import dev.ragnarok.fenrir.db.DBHelper +import dev.ragnarok.fenrir.db.model.entity.DialogDboEntity import dev.ragnarok.fenrir.domain.IAccountsInteractor import dev.ragnarok.fenrir.domain.IOwnersRepository import dev.ragnarok.fenrir.domain.InteractorFactory @@ -37,6 +38,7 @@ import dev.ragnarok.fenrir.model.Account import dev.ragnarok.fenrir.model.IOwnersBundle import dev.ragnarok.fenrir.model.SaveAccount import dev.ragnarok.fenrir.model.User +import dev.ragnarok.fenrir.model.criteria.DialogsCriteria import dev.ragnarok.fenrir.nonNullNoEmpty import dev.ragnarok.fenrir.nonNullNoEmptyOr import dev.ragnarok.fenrir.requireNonNull @@ -53,8 +55,10 @@ import dev.ragnarok.fenrir.util.serializeble.json.JsonObjectBuilder import dev.ragnarok.fenrir.util.serializeble.json.contentOrNull import dev.ragnarok.fenrir.util.serializeble.json.decodeFromStream import dev.ragnarok.fenrir.util.serializeble.json.intOrNull +import dev.ragnarok.fenrir.util.serializeble.json.jsonArray import dev.ragnarok.fenrir.util.serializeble.json.jsonObject import dev.ragnarok.fenrir.util.serializeble.json.jsonPrimitive +import dev.ragnarok.fenrir.util.serializeble.json.long import dev.ragnarok.fenrir.util.serializeble.json.longOrNull import dev.ragnarok.fenrir.util.serializeble.json.put import dev.ragnarok.fenrir.util.serializeble.msgpack.MsgPack @@ -62,6 +66,7 @@ import dev.ragnarok.fenrir.util.toast.CustomToast import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.SingleEmitter import io.reactivex.rxjava3.exceptions.Exceptions +import kotlinx.serialization.builtins.ListSerializer import okhttp3.FormBody import okhttp3.Request import okhttp3.Response @@ -495,6 +500,26 @@ class AccountsPresenter(savedInstanceState: Bundle?) : R.string.need_restart ) } + try { + if (obj.has("conversations_saved")) { + for (i in obj["conversations_saved"]?.asJsonArray.orEmpty()) { + val aid = i.asJsonObject["account_id"]?.jsonPrimitive?.long ?: continue + val dialogsJsonElem = + i.asJsonObject["conversation"]?.jsonArray ?: continue + if (!dialogsJsonElem.isEmpty()) { + Includes.stores.dialogs().insertDialogs( + aid, kJson.decodeFromJsonElement( + ListSerializer( + DialogDboEntity.serializer() + ), dialogsJsonElem + ), true + ).blockingAwait() + } + } + } + } catch (e: Exception) { + e.printStackTrace() + } } view?.customToast?.showToast( R.string.accounts_restored, @@ -533,7 +558,8 @@ class AccountsPresenter(savedInstanceState: Bundle?) : try { val root = JsonObjectBuilder() val arr = JsonArrayBuilder() - for (i in Settings.get().accounts().registered) { + val registered = Settings.get().accounts().registered + for (i in registered) { val temp = JsonObjectBuilder() val owner = Users?.getById(i) temp.put("user_name", owner?.fullName) @@ -560,6 +586,33 @@ class AccountsPresenter(savedInstanceState: Bundle?) : root.put("fenrir_accounts", arr.build()) val settings = SettingsBackup().doBackup() root.put("settings", settings) + + val arrDialogs = JsonArrayBuilder() + for (i in registered) { + if (Utils.isHiddenAccount(i)) { + try { + val dialogs = + Includes.stores.dialogs().getDialogs(DialogsCriteria(i)).blockingGet() + val tmp = JsonObjectBuilder() + tmp.put( + "account_id", i + ) + tmp.put( + "conversation", kJson.encodeToJsonElement( + ListSerializer( + DialogDboEntity.serializer() + ), dialogs + ) + ) + arrDialogs.add( + tmp.build() + ) + } catch (e: Exception) { + e.printStackTrace() + } + } + } + root.put("conversations_saved", arrDialogs.build()) val bytes = Json { prettyPrint = true }.printJsonElement(root.build()).toByteArray( Charsets.UTF_8 ) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsFragment.kt index 155e212b5..0126334c1 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsFragment.kt @@ -203,7 +203,7 @@ class DialogsFragment : BaseMvpFragment(), IDial }) mSwipeRefreshLayout = root.findViewById(R.id.swipeRefreshLayout) mSwipeRefreshLayout?.setOnRefreshListener { - presenter?.fireRefresh() + presenter?.fireRefreshConfirmationHidden() } setupSwipeRefreshLayoutWithCurrentTheme(requireActivity(), mSwipeRefreshLayout) mAdapter = DialogsAdapter(requireActivity(), emptyList()) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsPresenter.kt index 0a8da3162..e9a450d8e 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/dialogs/DialogsPresenter.kt @@ -407,6 +407,15 @@ class DialogsPresenter( requestAtLast() } + fun fireRefreshConfirmationHidden() { + if (isHiddenAccount(accountId)) { + resolveRefreshingView() + view?.askToReload() + } else { + fireRefresh() + } + } + fun fireSearchClick() { assertPositive(dialogsOwnerId) view?.goToSearch(accountId) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/ExoUtil.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/ExoUtil.kt index 7650c89b9..92e8df9a6 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/ExoUtil.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/ExoUtil.kt @@ -1,6 +1,6 @@ package dev.ragnarok.fenrir.media.exo -import com.google.android.exoplayer2.ExoPlayer +import androidx.media3.exoplayer.ExoPlayer object ExoUtil { fun pausePlayer(player: ExoPlayer?) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/OkHttpDataSource.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/OkHttpDataSource.kt index adde1a6d3..08d91bd2a 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/OkHttpDataSource.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/exo/OkHttpDataSource.kt @@ -1,13 +1,17 @@ package dev.ragnarok.fenrir.media.exo import android.net.Uri -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.ExoPlayerLibraryInfo -import com.google.android.exoplayer2.PlaybackException -import com.google.android.exoplayer2.upstream.* -import com.google.android.exoplayer2.upstream.HttpDataSource.* -import com.google.android.exoplayer2.util.Assertions -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.MediaLibraryInfo +import androidx.media3.common.PlaybackException +import androidx.media3.common.util.Assertions +import androidx.media3.common.util.Util +import androidx.media3.datasource.BaseDataSource +import androidx.media3.datasource.DataSourceException +import androidx.media3.datasource.DataSpec +import androidx.media3.datasource.HttpDataSource +import androidx.media3.datasource.HttpUtil +import androidx.media3.datasource.TransferListener import com.google.common.base.Predicate import com.google.common.net.HttpHeaders import com.google.common.util.concurrent.SettableFuture @@ -28,24 +32,25 @@ import java.util.concurrent.ExecutionException * priority) the `dataSpec`, [.setRequestProperty] and the default parameters used to * construct the instance. */ +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class OkHttpDataSource internal constructor( callFactory: OkHttpClient, userAgent: String?, cacheControl: CacheControl?, - defaultRequestProperties: RequestProperties?, + defaultRequestProperties: HttpDataSource.RequestProperties?, contentTypePredicate: Predicate? ) : BaseDataSource( /* isNetwork = */true), HttpDataSource { companion object { init { - ExoPlayerLibraryInfo.registerModule("goog.exo.okhttp") + MediaLibraryInfo.registerModule("media3.datasource.okhttp") } } private val callFactory: OkHttpClient - private val requestProperties: RequestProperties + private val requestProperties: HttpDataSource.RequestProperties private val userAgent: String? private val cacheControl: CacheControl? - private val defaultRequestProperties: RequestProperties? + private val defaultRequestProperties: HttpDataSource.RequestProperties? private val contentTypePredicate: Predicate? private var dataSpec: DataSpec? = null private var response: Response? = null @@ -80,7 +85,7 @@ class OkHttpDataSource internal constructor( requestProperties.clear() } - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) override fun open(dataSpec: DataSpec): Long { this.dataSpec = dataSpec bytesRead = 0 @@ -96,8 +101,8 @@ class OkHttpDataSource internal constructor( responseBody = response?.body ?: return -1 responseByteStream = responseBody.byteStream() } catch (e: IOException) { - throw HttpDataSourceException.createForIOException( - e, dataSpec, HttpDataSourceException.TYPE_OPEN + throw HttpDataSource.HttpDataSourceException.createForIOException( + e, dataSpec, HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } val responseCode = response.code @@ -123,7 +128,7 @@ class OkHttpDataSource internal constructor( closeConnectionQuietly() val cause: IOException? = if (responseCode == 416) DataSourceException(PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE) else null - throw InvalidResponseCodeException( + throw HttpDataSource.InvalidResponseCodeException( responseCode, response.message, cause, headers, dataSpec, errorResponseBody ) } @@ -133,7 +138,7 @@ class OkHttpDataSource internal constructor( val contentType = mediaType?.toString() ?: "" if (contentTypePredicate != null && !contentTypePredicate.apply(contentType)) { closeConnectionQuietly() - throw InvalidContentTypeException(contentType, dataSpec) + throw HttpDataSource.InvalidContentTypeException(contentType, dataSpec) } // If we requested a range starting from a non-zero position and received a 200 rather than a @@ -153,20 +158,20 @@ class OkHttpDataSource internal constructor( transferStarted(dataSpec) try { skipFully(bytesToSkip, dataSpec) - } catch (e: HttpDataSourceException) { + } catch (e: HttpDataSource.HttpDataSourceException) { closeConnectionQuietly() throw e } return bytesToRead } - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) override fun read(buffer: ByteArray, offset: Int, length: Int): Int { return try { readInternal(buffer, offset, length) } catch (e: IOException) { - throw HttpDataSourceException.createForIOException( - e, Util.castNonNull(dataSpec), HttpDataSourceException.TYPE_READ + throw HttpDataSource.HttpDataSourceException.createForIOException( + e, Util.castNonNull(dataSpec), HttpDataSource.HttpDataSourceException.TYPE_READ ) } } @@ -182,16 +187,16 @@ class OkHttpDataSource internal constructor( /** * Establishes a connection. */ - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) private fun makeRequest(dataSpec: DataSpec): Request { val position = dataSpec.position val length = dataSpec.length val url = dataSpec.uri.toString().toHttpUrlOrNull() - ?: throw HttpDataSourceException( + ?: throw HttpDataSource.HttpDataSourceException( "Malformed URL", dataSpec, PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) val builder: Request.Builder = Request.Builder().url(url) if (cacheControl != null) { @@ -259,11 +264,11 @@ class OkHttpDataSource internal constructor( * * @param bytesToSkipLong The number of bytes to skip. * @param dataSpec The [DataSpec]. - * @throws HttpDataSourceException If the thread is interrupted during the operation, or an error + * @throws HttpDataSource.HttpDataSourceException If the thread is interrupted during the operation, or an error * occurs while reading from the source, or if the data ended before skipping the specified * number of bytes. */ - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) private fun skipFully(bytesToSkipLong: Long, dataSpec: DataSpec) { var bytesToSkip = bytesToSkipLong if (bytesToSkip == 0L) { @@ -278,23 +283,23 @@ class OkHttpDataSource internal constructor( throw InterruptedIOException() } if (read == -1) { - throw HttpDataSourceException( + throw HttpDataSource.HttpDataSourceException( dataSpec, PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } bytesToSkip -= read.toLong() bytesTransferred(read) } } catch (e: IOException) { - if (e is HttpDataSourceException) { + if (e is HttpDataSource.HttpDataSourceException) { throw e } else { - throw HttpDataSourceException( + throw HttpDataSource.HttpDataSourceException( dataSpec, PlaybackException.ERROR_CODE_IO_UNSPECIFIED, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } } @@ -349,10 +354,11 @@ class OkHttpDataSource internal constructor( } /** - * [DataSource.Factory] for [OkHttpDataSource] instances. + * [androidx.media3.datasource.DataSource.Factory] for [OkHttpDataSource] instances. */ class Factory(private val callFactory: OkHttpClient) : HttpDataSource.Factory { - private val defaultRequestProperties: RequestProperties = RequestProperties() + private val defaultRequestProperties: HttpDataSource.RequestProperties = + HttpDataSource.RequestProperties() private var userAgent: String? = null private var transferListener: TransferListener? = null private var cacheControl: CacheControl? = null @@ -419,7 +425,7 @@ class OkHttpDataSource internal constructor( * The default is `null`. * * - * See [DataSource.addTransferListener]. + * See [androidx.media3.datasource.DataSource.addTransferListener]. * * @param transferListener The listener that will be used. * @return This factory. @@ -446,6 +452,6 @@ class OkHttpDataSource internal constructor( this.cacheControl = cacheControl this.defaultRequestProperties = defaultRequestProperties this.contentTypePredicate = contentTypePredicate - requestProperties = RequestProperties() + requestProperties = HttpDataSource.RequestProperties() } -} \ No newline at end of file +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/music/MusicPlaybackService.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/music/MusicPlaybackService.kt index 98945a6b8..d6c538eeb 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/music/MusicPlaybackService.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/music/MusicPlaybackService.kt @@ -19,15 +19,21 @@ import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.PlaybackStateCompat import android.util.Log import androidx.media.session.MediaButtonReceiver -import com.google.android.exoplayer2.* -import com.google.android.exoplayer2.DefaultRenderersFactory.* -import com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource -import com.google.android.exoplayer2.source.hls.HlsMediaSource -import com.google.android.exoplayer2.upstream.DefaultDataSource -import com.google.android.exoplayer2.upstream.RawResourceDataSource +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.PlaybackException +import androidx.media3.common.Player +import androidx.media3.common.Player.PlayWhenReadyChangeReason +import androidx.media3.datasource.DefaultDataSource +import androidx.media3.datasource.RawResourceDataSource +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.hls.HlsMediaSource +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import com.squareup.picasso3.BitmapTarget import com.squareup.picasso3.Picasso.LoadedFrom import dev.ragnarok.fenrir.* @@ -47,7 +53,6 @@ import dev.ragnarok.fenrir.util.rxutils.RxUtils import io.reactivex.rxjava3.disposables.CompositeDisposable import java.lang.ref.WeakReference - class MusicPlaybackService : Service() { private val SHUTDOWN = "dev.ragnarok.fenrir.media.music.shutdown" private val mBinder: IBinder = ServiceStub(this) @@ -935,6 +940,7 @@ class MusicPlaybackService : Service() { } } + @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) private class MultiPlayer(service: MusicPlaybackService) { val mService: WeakReference = WeakReference(service) var mCurrentMediaPlayer: ExoPlayer = ExoPlayer.Builder( diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/story/ExoStoryPlayer.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/story/ExoStoryPlayer.kt index a6acfc1f5..a9032c8fe 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/story/ExoStoryPlayer.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/story/ExoStoryPlayer.kt @@ -1,10 +1,10 @@ package dev.ragnarok.fenrir.media.story import android.view.SurfaceHolder -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.Player -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource +import androidx.media3.common.Player +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import dev.ragnarok.fenrir.App.Companion.instance import dev.ragnarok.fenrir.UserAgentTool import dev.ragnarok.fenrir.media.story.IStoryPlayer.IStatus @@ -15,6 +15,7 @@ import dev.ragnarok.fenrir.util.Logger.d import dev.ragnarok.fenrir.util.Utils.getExoPlayerFactory import dev.ragnarok.fenrir.util.Utils.makeMediaItem +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class ExoStoryPlayer( private val url: String, private val proxyConfig: ProxyConfig?, @@ -27,7 +28,7 @@ class ExoStoryPlayer( private set private var playbackSpeed = false private val videoListener: Player.Listener = object : Player.Listener { - override fun onVideoSizeChanged(videoSize: com.google.android.exoplayer2.video.VideoSize) { + override fun onVideoSizeChanged(videoSize: androidx.media3.common.VideoSize) { this@ExoStoryPlayer.videoSize = VideoSize(videoSize.width, videoSize.height) this@ExoStoryPlayer.onVideoSizeChanged() } @@ -179,4 +180,4 @@ class ExoStoryPlayer( internalPlayer?.playbackState } } -} \ No newline at end of file +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/video/ExoVideoPlayer.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/video/ExoVideoPlayer.kt index adbc0ef7f..8e4b1a1ca 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/video/ExoVideoPlayer.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/video/ExoVideoPlayer.kt @@ -2,16 +2,16 @@ package dev.ragnarok.fenrir.media.video import android.content.Context import android.view.SurfaceHolder -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.DefaultRenderersFactory -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.Player -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource -import com.google.android.exoplayer2.source.hls.HlsMediaSource -import com.google.android.exoplayer2.upstream.DefaultDataSource -import com.google.android.exoplayer2.video.VideoSize +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.Player +import androidx.media3.common.VideoSize +import androidx.media3.datasource.DefaultDataSource +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.hls.HlsMediaSource +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import dev.ragnarok.fenrir.UserAgentTool import dev.ragnarok.fenrir.media.exo.ExoUtil.pausePlayer import dev.ragnarok.fenrir.media.exo.ExoUtil.startPlayer @@ -22,6 +22,7 @@ import dev.ragnarok.fenrir.util.Utils.getExoPlayerFactory import dev.ragnarok.fenrir.util.Utils.makeMediaItem import java.lang.ref.WeakReference +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class ExoVideoPlayer( context: Context, url: String, @@ -204,4 +205,4 @@ class ExoVideoPlayer( size == InternalVideoSize.SIZE_HLS || size == InternalVideoSize.SIZE_LIVE ) } -} \ No newline at end of file +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayer.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayer.kt index 466e09350..568f735f3 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayer.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayer.kt @@ -2,14 +2,14 @@ package dev.ragnarok.fenrir.media.voice import android.content.Context import android.os.Build -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.DefaultRenderersFactory -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.PlaybackException -import com.google.android.exoplayer2.Player -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.PlaybackException +import androidx.media3.common.Player +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import dev.ragnarok.fenrir.UserAgentTool import dev.ragnarok.fenrir.media.exo.ExoUtil.pausePlayer import dev.ragnarok.fenrir.media.exo.ExoUtil.startPlayer @@ -26,6 +26,7 @@ import dev.ragnarok.fenrir.util.Utils.firstNonEmptyString import dev.ragnarok.fenrir.util.Utils.getExoPlayerFactory import dev.ragnarok.fenrir.util.Utils.makeMediaItem +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class ExoVoicePlayer(context: Context, config: ProxyConfig?) : IVoicePlayer { private val app: Context = context.applicationContext private val proxyConfig: ProxyConfig? = config @@ -186,4 +187,4 @@ class ExoVoicePlayer(context: Context, config: ProxyConfig?) : IVoicePlayer { init { status = IVoicePlayer.STATUS_NO_PLAYBACK } -} \ No newline at end of file +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayerSensored.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayerSensored.kt index 046b0079b..f6417cc38 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayerSensored.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/media/voice/ExoVoicePlayerSensored.kt @@ -10,15 +10,15 @@ import android.hardware.SensorEventListener import android.hardware.SensorManager import android.os.Build import android.os.PowerManager -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.DefaultRenderersFactory -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.PlaybackException -import com.google.android.exoplayer2.Player -import com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.PlaybackException +import androidx.media3.common.Player +import androidx.media3.common.Player.PlayWhenReadyChangeReason +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import dev.ragnarok.fenrir.UserAgentTool import dev.ragnarok.fenrir.media.exo.ExoUtil.pausePlayer import dev.ragnarok.fenrir.media.exo.ExoUtil.startPlayer @@ -39,6 +39,7 @@ import dev.ragnarok.fenrir.util.Utils.firstNonEmptyString import dev.ragnarok.fenrir.util.Utils.getExoPlayerFactory import dev.ragnarok.fenrir.util.Utils.makeMediaItem +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class ExoVoicePlayerSensored(context: Context, config: ProxyConfig?) : IVoicePlayer, SensorEventListener { private val app: Context = context.applicationContext diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/util/Utils.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/util/Utils.kt index dcf159b8f..1d2363b03 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/util/Utils.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/util/Utils.kt @@ -25,10 +25,10 @@ import androidx.annotation.ColorInt import androidx.annotation.StringRes import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.ColorUtils +import androidx.media3.common.MediaItem import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 -import com.google.android.exoplayer2.MediaItem import com.google.android.material.floatingactionbutton.FloatingActionButton import dev.ragnarok.fenrir.* import dev.ragnarok.fenrir.Includes.provideMainThreadScheduler diff --git a/app_fenrir/src/main/res/layout/item_short_link.xml b/app_fenrir/src/main/res/layout/item_short_link.xml index 31209b381..fbf26bea7 100644 --- a/app_fenrir/src/main/res/layout/item_short_link.xml +++ b/app_fenrir/src/main/res/layout/item_short_link.xml @@ -4,48 +4,67 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="4dp" + android:layout_margin="8dp" android:background="@drawable/background_rectangle_stroke" android:baselineAligned="false" - android:orientation="horizontal"> + android:orientation="vertical" + android:padding="8dp"> - + android:ellipsize="end" + android:maxLines="1" + android:textAppearance="@style/TextAppearance.Material3.BodyLarge" + android:textColor="?attr/colorSecondary" + android:textSize="15sp" + tools:text="Short" /> - + - + + + + + - - - - - - - - + tools:text="views" /> - + - + diff --git a/app_filegallery/build.gradle b/app_filegallery/build.gradle index 61d350e1c..bc04c1c2e 100644 --- a/app_filegallery/build.gradle +++ b/app_filegallery/build.gradle @@ -117,10 +117,10 @@ dependencies { implementation("com.squareup.okhttp3:okhttp-android:$okhttpLibraryVersion") //implementation("com.squareup.okhttp3:logging-interceptor:$okhttpLibraryVersion") implementation("com.squareup.okio:okio:$okioVersion") - implementation("com.google.android.exoplayer:exoplayer-core:$exoLibraryVersion") implementation("androidx.constraintlayout:constraintlayout:$constraintlayoutVersion") implementation("androidx.biometric:biometric-ktx:$biometricVersion") implementation("androidx.media:media:$mediaVersion") + implementation("androidx.media3:media3-exoplayer:$media3Version") implementation("androidx.coordinatorlayout:coordinatorlayout:$coordinatorlayoutVersion") implementation("androidx.activity:activity-ktx:$activityVersion") implementation("androidx.fragment:fragment-ktx:$fragmentVersion") diff --git a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/ExoUtil.kt b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/ExoUtil.kt index 4fa277331..4794375ea 100644 --- a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/ExoUtil.kt +++ b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/ExoUtil.kt @@ -1,6 +1,6 @@ package dev.ragnarok.filegallery.media.exo -import com.google.android.exoplayer2.ExoPlayer +import androidx.media3.exoplayer.ExoPlayer object ExoUtil { fun pausePlayer(player: ExoPlayer?) { diff --git a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/OkHttpDataSource.kt b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/OkHttpDataSource.kt index 9e5cbecd2..4861a92e2 100644 --- a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/OkHttpDataSource.kt +++ b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/exo/OkHttpDataSource.kt @@ -1,13 +1,17 @@ package dev.ragnarok.filegallery.media.exo import android.net.Uri -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.ExoPlayerLibraryInfo -import com.google.android.exoplayer2.PlaybackException -import com.google.android.exoplayer2.upstream.* -import com.google.android.exoplayer2.upstream.HttpDataSource.* -import com.google.android.exoplayer2.util.Assertions -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.MediaLibraryInfo +import androidx.media3.common.PlaybackException +import androidx.media3.common.util.Assertions +import androidx.media3.common.util.Util +import androidx.media3.datasource.BaseDataSource +import androidx.media3.datasource.DataSourceException +import androidx.media3.datasource.DataSpec +import androidx.media3.datasource.HttpDataSource +import androidx.media3.datasource.HttpUtil +import androidx.media3.datasource.TransferListener import com.google.common.base.Predicate import com.google.common.net.HttpHeaders import com.google.common.util.concurrent.SettableFuture @@ -28,24 +32,25 @@ import java.util.concurrent.ExecutionException * priority) the `dataSpec`, [.setRequestProperty] and the default parameters used to * construct the instance. */ +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class OkHttpDataSource internal constructor( callFactory: OkHttpClient, userAgent: String?, cacheControl: CacheControl?, - defaultRequestProperties: RequestProperties?, + defaultRequestProperties: HttpDataSource.RequestProperties?, contentTypePredicate: Predicate? ) : BaseDataSource( /* isNetwork = */true), HttpDataSource { companion object { init { - ExoPlayerLibraryInfo.registerModule("goog.exo.okhttp") + MediaLibraryInfo.registerModule("media3.datasource.okhttp") } } private val callFactory: OkHttpClient - private val requestProperties: RequestProperties + private val requestProperties: HttpDataSource.RequestProperties private val userAgent: String? private val cacheControl: CacheControl? - private val defaultRequestProperties: RequestProperties? + private val defaultRequestProperties: HttpDataSource.RequestProperties? private val contentTypePredicate: Predicate? private var dataSpec: DataSpec? = null private var response: Response? = null @@ -80,7 +85,7 @@ class OkHttpDataSource internal constructor( requestProperties.clear() } - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) override fun open(dataSpec: DataSpec): Long { this.dataSpec = dataSpec bytesRead = 0 @@ -96,8 +101,8 @@ class OkHttpDataSource internal constructor( responseBody = response?.body ?: return -1 responseByteStream = responseBody.byteStream() } catch (e: IOException) { - throw HttpDataSourceException.createForIOException( - e, dataSpec, HttpDataSourceException.TYPE_OPEN + throw HttpDataSource.HttpDataSourceException.createForIOException( + e, dataSpec, HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } val responseCode = response.code @@ -123,7 +128,7 @@ class OkHttpDataSource internal constructor( closeConnectionQuietly() val cause: IOException? = if (responseCode == 416) DataSourceException(PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE) else null - throw InvalidResponseCodeException( + throw HttpDataSource.InvalidResponseCodeException( responseCode, response.message, cause, headers, dataSpec, errorResponseBody ) } @@ -133,7 +138,7 @@ class OkHttpDataSource internal constructor( val contentType = mediaType?.toString() ?: "" if (contentTypePredicate != null && !contentTypePredicate.apply(contentType)) { closeConnectionQuietly() - throw InvalidContentTypeException(contentType, dataSpec) + throw HttpDataSource.InvalidContentTypeException(contentType, dataSpec) } // If we requested a range starting from a non-zero position and received a 200 rather than a @@ -153,20 +158,20 @@ class OkHttpDataSource internal constructor( transferStarted(dataSpec) try { skipFully(bytesToSkip, dataSpec) - } catch (e: HttpDataSourceException) { + } catch (e: HttpDataSource.HttpDataSourceException) { closeConnectionQuietly() throw e } return bytesToRead } - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) override fun read(buffer: ByteArray, offset: Int, length: Int): Int { return try { readInternal(buffer, offset, length) } catch (e: IOException) { - throw HttpDataSourceException.createForIOException( - e, Util.castNonNull(dataSpec), HttpDataSourceException.TYPE_READ + throw HttpDataSource.HttpDataSourceException.createForIOException( + e, Util.castNonNull(dataSpec), HttpDataSource.HttpDataSourceException.TYPE_READ ) } } @@ -182,16 +187,16 @@ class OkHttpDataSource internal constructor( /** * Establishes a connection. */ - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) private fun makeRequest(dataSpec: DataSpec): Request { val position = dataSpec.position val length = dataSpec.length val url = dataSpec.uri.toString().toHttpUrlOrNull() - ?: throw HttpDataSourceException( + ?: throw HttpDataSource.HttpDataSourceException( "Malformed URL", dataSpec, PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) val builder: Request.Builder = Request.Builder().url(url) if (cacheControl != null) { @@ -259,11 +264,11 @@ class OkHttpDataSource internal constructor( * * @param bytesToSkipLong The number of bytes to skip. * @param dataSpec The [DataSpec]. - * @throws HttpDataSourceException If the thread is interrupted during the operation, or an error + * @throws HttpDataSource.HttpDataSourceException If the thread is interrupted during the operation, or an error * occurs while reading from the source, or if the data ended before skipping the specified * number of bytes. */ - @Throws(HttpDataSourceException::class) + @Throws(HttpDataSource.HttpDataSourceException::class) private fun skipFully(bytesToSkipLong: Long, dataSpec: DataSpec) { var bytesToSkip = bytesToSkipLong if (bytesToSkip == 0L) { @@ -278,23 +283,23 @@ class OkHttpDataSource internal constructor( throw InterruptedIOException() } if (read == -1) { - throw HttpDataSourceException( + throw HttpDataSource.HttpDataSourceException( dataSpec, PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } bytesToSkip -= read.toLong() bytesTransferred(read) } } catch (e: IOException) { - if (e is HttpDataSourceException) { + if (e is HttpDataSource.HttpDataSourceException) { throw e } else { - throw HttpDataSourceException( + throw HttpDataSource.HttpDataSourceException( dataSpec, PlaybackException.ERROR_CODE_IO_UNSPECIFIED, - HttpDataSourceException.TYPE_OPEN + HttpDataSource.HttpDataSourceException.TYPE_OPEN ) } } @@ -349,10 +354,11 @@ class OkHttpDataSource internal constructor( } /** - * [DataSource.Factory] for [OkHttpDataSource] instances. + * [androidx.media3.datasource.DataSource.Factory] for [OkHttpDataSource] instances. */ class Factory(private val callFactory: OkHttpClient) : HttpDataSource.Factory { - private val defaultRequestProperties: RequestProperties = RequestProperties() + private val defaultRequestProperties: HttpDataSource.RequestProperties = + HttpDataSource.RequestProperties() private var userAgent: String? = null private var transferListener: TransferListener? = null private var cacheControl: CacheControl? = null @@ -419,7 +425,7 @@ class OkHttpDataSource internal constructor( * The default is `null`. * * - * See [DataSource.addTransferListener]. + * See [androidx.media3.datasource.DataSource.addTransferListener]. * * @param transferListener The listener that will be used. * @return This factory. @@ -446,6 +452,6 @@ class OkHttpDataSource internal constructor( this.cacheControl = cacheControl this.defaultRequestProperties = defaultRequestProperties this.contentTypePredicate = contentTypePredicate - requestProperties = RequestProperties() + requestProperties = HttpDataSource.RequestProperties() } } diff --git a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/music/MusicPlaybackService.kt b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/music/MusicPlaybackService.kt index 3959e3afd..613383797 100644 --- a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/music/MusicPlaybackService.kt +++ b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/music/MusicPlaybackService.kt @@ -19,14 +19,20 @@ import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.PlaybackStateCompat import android.util.Log import androidx.media.session.MediaButtonReceiver -import com.google.android.exoplayer2.* -import com.google.android.exoplayer2.DefaultRenderersFactory.* -import com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource -import com.google.android.exoplayer2.upstream.DefaultDataSource -import com.google.android.exoplayer2.upstream.RawResourceDataSource +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.PlaybackException +import androidx.media3.common.Player +import androidx.media3.common.Player.PlayWhenReadyChangeReason +import androidx.media3.datasource.DefaultDataSource +import androidx.media3.datasource.RawResourceDataSource +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON +import androidx.media3.exoplayer.DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import com.squareup.picasso3.BitmapTarget import com.squareup.picasso3.Picasso.LoadedFrom import dev.ragnarok.filegallery.* @@ -925,6 +931,7 @@ class MusicPlaybackService : Service() { } } + @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) private class MultiPlayer(service: MusicPlaybackService) { val mService: WeakReference = WeakReference(service) var mCurrentMediaPlayer: ExoPlayer = ExoPlayer.Builder( diff --git a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/video/ExoVideoPlayer.kt b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/video/ExoVideoPlayer.kt index bb8fa9a0b..93a58b007 100644 --- a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/video/ExoVideoPlayer.kt +++ b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/media/video/ExoVideoPlayer.kt @@ -2,15 +2,15 @@ package dev.ragnarok.filegallery.media.video import android.content.Context import android.view.SurfaceHolder -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.DefaultRenderersFactory -import com.google.android.exoplayer2.ExoPlayer -import com.google.android.exoplayer2.Player -import com.google.android.exoplayer2.audio.AudioAttributes -import com.google.android.exoplayer2.source.MediaSource -import com.google.android.exoplayer2.source.ProgressiveMediaSource -import com.google.android.exoplayer2.upstream.DefaultDataSource -import com.google.android.exoplayer2.video.VideoSize +import androidx.media3.common.AudioAttributes +import androidx.media3.common.C +import androidx.media3.common.Player +import androidx.media3.common.VideoSize +import androidx.media3.datasource.DefaultDataSource +import androidx.media3.exoplayer.DefaultRenderersFactory +import androidx.media3.exoplayer.ExoPlayer +import androidx.media3.exoplayer.source.MediaSource +import androidx.media3.exoplayer.source.ProgressiveMediaSource import dev.ragnarok.filegallery.Constants import dev.ragnarok.filegallery.media.exo.ExoUtil.pausePlayer import dev.ragnarok.filegallery.media.exo.ExoUtil.startPlayer @@ -18,6 +18,7 @@ import dev.ragnarok.filegallery.media.video.IVideoPlayer.IUpdatePlayListener import dev.ragnarok.filegallery.util.Utils import java.lang.ref.WeakReference +@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) class ExoVideoPlayer( context: Context, url: String?, @@ -176,4 +177,4 @@ class ExoVideoPlayer( url ) } -} \ No newline at end of file +} diff --git a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/util/Utils.kt b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/util/Utils.kt index fd26ba48f..dbaa92650 100644 --- a/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/util/Utils.kt +++ b/app_filegallery/src/main/kotlin/dev/ragnarok/filegallery/util/Utils.kt @@ -14,8 +14,8 @@ import android.view.WindowManager import android.widget.ImageView import androidx.annotation.ColorInt import androidx.core.graphics.ColorUtils +import androidx.media3.common.MediaItem import androidx.viewpager2.widget.ViewPager2 -import com.google.android.exoplayer2.MediaItem import com.google.android.material.floatingactionbutton.FloatingActionButton import dev.ragnarok.fenrir.module.rlottie.RLottieDrawable import dev.ragnarok.filegallery.BuildConfig @@ -420,6 +420,7 @@ object Utils { } } + @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) fun getExoPlayerFactory(userAgent: String?): OkHttpDataSource.Factory { val builder: OkHttpClient.Builder = OkHttpClient.Builder() .readTimeout(Constants.EXO_PLAYER_TIMEOUT, TimeUnit.SECONDS) diff --git a/build.gradle b/build.gradle index aedfb3d3a..e135a194f 100644 --- a/build.gradle +++ b/build.gradle @@ -24,23 +24,24 @@ buildscript { ext.concurentVersion = "1.2.0-alpha01" ext.constraintlayoutVersion = "2.2.0-alpha09" ext.coordinatorlayoutVersion = "1.2.0" - ext.coreVersion = "1.10.0-rc01" + ext.coreVersion = "1.10.0" ext.customviewVersion = "1.2.0-alpha02" ext.customviewPoolingcontainerVersion = "1.0.0" ext.drawerlayoutVersion = "1.2.0" ext.dynamicanimationVersion = "1.1.0-alpha03" ext.exifinterfaceVersion = "1.3.6" - ext.fragmentVersion = "1.6.0-alpha08" + ext.fragmentVersion = "1.6.0-alpha09" ext.lifecycleVersion = "2.6.1" ext.loaderVersion = "1.1.0" ext.mediaVersion = "1.7.0-alpha01" + ext.media3Version = "1.0.0" ext.recyclerviewVersion = "1.3.0" ext.savedStateVersion = "1.2.1" ext.swiperefreshlayoutVersion = "1.2.0-alpha01" - ext.tracingVersion = "1.2.0-beta02" + ext.tracingVersion = "1.2.0-beta03" ext.transitionVersion = "1.4.1" ext.vectordrawableVersion = "1.2.0-beta01" - ext.webkitVersion = "1.6.1" + ext.webkitVersion = "1.7.0-beta01" ext.workVersion = "2.8.1" //firebase libraries @@ -48,7 +49,7 @@ buildscript { ext.firebaseMessagingVersion = "23.1.2" //firebase common libraries - ext.firebaseCommonVersion = "20.3.1" + ext.firebaseCommonVersion = "20.3.2" ext.firebaseInstallationsInteropVersion = "17.1.0" ext.firebaseComponentsVersion = "17.1.0" ext.firebaseAnnotationsVersion = "16.2.0" @@ -63,10 +64,9 @@ buildscript { ext.okioVersion = "3.3.0" ext.rxJavaVersion = "3.1.6" ext.guavaVersion = "31.1-android" - ext.exoLibraryVersion = "2.18.5" ext.errorproneVersion = "2.15.0" ext.checkerCompatQualVersion = "2.5.5" - ext.checkerQualAndroidVersion = "3.32.0" + ext.checkerQualAndroidVersion = "3.33.0" ext.desugarLibraryVersion = "2.0.3" //APP_PROPS diff --git a/libfenrir/build.gradle b/libfenrir/build.gradle index f5dd8be68..c725d93e3 100644 --- a/libfenrir/build.gradle +++ b/libfenrir/build.gradle @@ -63,6 +63,6 @@ dependencies { implementation("androidx.collection:collection-ktx:$collectionVersion") implementation("com.squareup.okio:okio:$okioVersion") implementation("com.google.guava:guava:$guavaVersion") - implementation("com.google.android.exoplayer:exoplayer-core:$exoLibraryVersion") + implementation("androidx.media3:media3-exoplayer:$media3Version") implementation("com.google.errorprone:error_prone_annotations:${errorproneVersion}") } diff --git a/libfenrir/src/main/jni/CMakeLists.txt b/libfenrir/src/main/jni/CMakeLists.txt index 71404ca58..1bba3bf3d 100644 --- a/libfenrir/src/main/jni/CMakeLists.txt +++ b/libfenrir/src/main/jni/CMakeLists.txt @@ -148,6 +148,7 @@ add_library(libyuv STATIC animation/libyuv/source/rotate_win.cc animation/libyuv/source/rotate.cc animation/libyuv/source/row_any.cc + animation/libyuv/source/row_rvv.cc animation/libyuv/source/row_lasx.cc animation/libyuv/source/row_lsx.cc animation/libyuv/source/row_common.cc diff --git a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/cpu_id.h b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/cpu_id.h index fb90c6c73..203f7e0d6 100644 --- a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/cpu_id.h +++ b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/cpu_id.h @@ -55,6 +55,11 @@ static const int kCpuHasLOONGARCH = 0x2000000; static const int kCpuHasLSX = 0x4000000; static const int kCpuHasLASX = 0x8000000; +// These flags are only valid on RISCV processors. +static const int kCpuHasRISCV = 0x10000000; +static const int kCpuHasRVV = 0x20000000; +static const int kCpuHasRVVZVFH = 0x40000000; + // Optional init function. TestCpuFlag does an auto-init. // Returns cpu_info flags. LIBYUV_API @@ -78,6 +83,8 @@ LIBYUV_API int ArmCpuCaps(const char* cpuinfo_name); LIBYUV_API int MipsCpuCaps(const char* cpuinfo_name); +LIBYUV_API +int RiscvCpuCaps(const char* cpuinfo_name); // For testing, allow CPU flags to be disabled. // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. diff --git a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/row.h b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/row.h index ff6ffe47c..08004c0cc 100644 --- a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/row.h +++ b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/row.h @@ -757,6 +757,12 @@ extern "C" { #define HAS_RAWTOYJROW_LASX #endif +#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) +#define HAS_RAWTOARGBROW_RVV +#define HAS_RAWTORGBAROW_RVV +#define HAS_RAWTORGB24ROW_RVV +#endif + #if defined(_MSC_VER) && !defined(__CLR_VER) && !defined(__clang__) #if defined(VISUALC_HAS_AVX2) #define SIMD_ALIGNED(var) __declspec(align(32)) var @@ -2960,9 +2966,12 @@ void RAWToRGBARow_NEON(const uint8_t* src_raw, uint8_t* dst_rgba, int width); void RAWToARGBRow_MSA(const uint8_t* src_raw, uint8_t* dst_argb, int width); void RAWToARGBRow_LSX(const uint8_t* src_raw, uint8_t* dst_argb, int width); void RAWToARGBRow_LASX(const uint8_t* src_raw, uint8_t* dst_argb, int width); +void RAWToARGBRow_RVV(const uint8_t* src_raw, uint8_t* dst_argb, int width); +void RAWToRGBARow_RVV(const uint8_t* src_raw, uint8_t* dst_rgba, int width); void RAWToRGB24Row_NEON(const uint8_t* src_raw, uint8_t* dst_rgb24, int width); void RAWToRGB24Row_MSA(const uint8_t* src_raw, uint8_t* dst_rgb24, int width); void RAWToRGB24Row_LSX(const uint8_t* src_raw, uint8_t* dst_rgb24, int width); +void RAWToRGB24Row_RVV(const uint8_t* src_raw, uint8_t* dst_rgb24, int width); void RGB565ToARGBRow_NEON(const uint8_t* src_rgb565, uint8_t* dst_argb, int width); diff --git a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/version.h b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/version.h index 56c41fe5b..c2b342ef9 100644 --- a/libfenrir/src/main/jni/animation/libyuv/include/libyuv/version.h +++ b/libfenrir/src/main/jni/animation/libyuv/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1864 +#define LIBYUV_VERSION 1865 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/libfenrir/src/main/jni/animation/libyuv/source/convert_argb.cc b/libfenrir/src/main/jni/animation/libyuv/source/convert_argb.cc index 64425c596..e25ecefa9 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/convert_argb.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/convert_argb.cc @@ -3124,6 +3124,11 @@ int RAWToARGB(const uint8_t* src_raw, } } #endif +#if defined(HAS_RAWTOARGBROW_RVV) + if (TestCpuFlag(kCpuHasRVV)) { + RAWToARGBRow = RAWToARGBRow_RVV; + } +#endif for (y = 0; y < height; ++y) { RAWToARGBRow(src_raw, dst_argb, width); @@ -3175,6 +3180,11 @@ int RAWToRGBA(const uint8_t* src_raw, } } #endif +#if defined(HAS_RAWTORGBAROW_RVV) + if (TestCpuFlag(kCpuHasRVV)) { + RAWToRGBARow = RAWToRGBARow_RVV; + } +#endif for (y = 0; y < height; ++y) { RAWToRGBARow(src_raw, dst_rgba, width); diff --git a/libfenrir/src/main/jni/animation/libyuv/source/cpu_id.cc b/libfenrir/src/main/jni/animation/libyuv/source/cpu_id.cc index 13e3da7bb..409456e8f 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/cpu_id.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/cpu_id.cc @@ -191,6 +191,63 @@ LIBYUV_API SAFEBUFFERS int MipsCpuCaps(const char* cpuinfo_name) { return flag; } +LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) { + char cpuinfo_line[512]; + int flag = 0x0; + FILE* f = fopen(cpuinfo_name, "r"); + if (!f) { + // Assume nothing if /proc/cpuinfo is unavailable. + // This will occur for Chrome sandbox for Pepper or Render process. + return 0; + } + while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) { + if (memcmp(cpuinfo_line, "isa", 3) == 0) { + // ISA string must begin with rv64{i,e,g} for a 64-bit processor. + char* isa = strstr(cpuinfo_line, "rv64"); + if (isa) { + const int isa_len = strlen(isa); + // 5 ISA characters + 1 new-line character + if (isa_len < 6) { + fclose(f); + return 0; + } + // Skip {i,e,g} canonical checking. + // Skip rvxxx + isa += 5; + + // Find the very first occurrence of 's', 'x' or 'z'. + // To detect multi-letter standard, non-standard, and + // supervisor-level extensions. + int otherExts_len = 0; + char* otherExts = strpbrk(isa, "zxs"); + if (otherExts) { + otherExts_len = strlen(otherExts); + // Multi-letter extensions are seperated by a single underscore + // as described in RISC-V User-Level ISA V2.2. + char* ext = strtok(otherExts, "_"); + while (ext) { + // Search for the ZVFH (Vector FP16) extension. + // The ZVFH implied the (Scalar FP16)ZFH extension. + if (!strcmp(ext, "zvfh") || !strcmp(ext, "zvfh\n")) { + flag |= kCpuHasRVVZVFH; + } + ext = strtok(NULL, "_"); + } + } + const int std_isa_len = isa_len - otherExts_len - 5 - 1; + // Detect the v in the standard single-letter extensions. + // Skip optional Zve* and Zvl* extensions detection at otherExts. + if (memchr(isa, 'v', std_isa_len)) { + // The RVV implied the F extension. + flag |= kCpuHasRVV; + } + } + } + } + fclose(f); + return flag; +} + // TODO(fbarchard): Consider read_loongarch_ir(). #define LOONGARCH_CFG2 0x2 #define LOONGARCH_CFG2_LSX (1 << 6) @@ -277,6 +334,10 @@ static SAFEBUFFERS int GetCpuFlags(void) { #endif cpu_info |= kCpuHasARM; #endif // __arm__ +#if defined(__riscv) && defined(__linux__) + cpu_info = RiscvCpuCaps("/proc/cpuinfo"); + cpu_info |= kCpuHasRISCV; +#endif // __riscv cpu_info |= kCpuInitialized; return cpu_info; } diff --git a/libfenrir/src/main/jni/animation/libyuv/source/planar_functions.cc b/libfenrir/src/main/jni/animation/libyuv/source/planar_functions.cc index e3452f58e..b5a2e1a03 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/planar_functions.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/planar_functions.cc @@ -3234,6 +3234,11 @@ int RAWToRGB24(const uint8_t* src_raw, } } #endif +#if defined(HAS_RAWTORGB24ROW_RVV) + if (TestCpuFlag(kCpuHasRVV)) { + RAWToRGB24Row = RAWToRGB24Row_RVV; + } +#endif for (y = 0; y < height; ++y) { RAWToRGB24Row(src_raw, dst_rgb24, width); diff --git a/libfenrir/src/main/jni/animation/libyuv/source/row_any.cc b/libfenrir/src/main/jni/animation/libyuv/source/row_any.cc index 0168061ff..9d33a294a 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/row_any.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/row_any.cc @@ -2284,7 +2284,7 @@ ANY11S(AYUVToVURow_Any_NEON, AYUVToVURow_NEON, 0, 4, 15) #define ANYDETILE(NAMEANY, ANY_SIMD, T, BPP, MASK) \ void NAMEANY(const T* src, ptrdiff_t src_tile_stride, T* dst, int width) { \ SIMD_ALIGNED(T temp[16 * 2]); \ - memset(temp, 0, 16 * BPP); /* for msan */ \ + memset(temp, 0, sizeof(temp)); /* for msan */ \ int r = width & MASK; \ int n = width & ~MASK; \ if (n > 0) { \ diff --git a/libfenrir/src/main/jni/animation/libyuv/source/row_rvv.cc b/libfenrir/src/main/jni/animation/libyuv/source/row_rvv.cc new file mode 100644 index 000000000..0f264d349 --- /dev/null +++ b/libfenrir/src/main/jni/animation/libyuv/source/row_rvv.cc @@ -0,0 +1,75 @@ +/* + * Copyright 2023 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +/* + * Copyright (c) 2023 SiFive, Inc. All rights reserved. + * + * Contributed by Darren Hsieh + * + */ + +#include + +#include "libyuv/row.h" + +#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) +#include + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +void RAWToARGBRow_RVV(const uint8_t* src_raw, uint8_t* dst_argb, int width) { + size_t vl = __riscv_vsetvl_e8m2(width); + vuint8m2_t v_a = __riscv_vmv_v_x_u8m2(255u, vl); + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_r, &v_g, &v_b, src_raw, vl); + __riscv_vsseg4e8_v_u8m2(dst_argb, v_b, v_g, v_r, v_a, vl); + width -= vl; + src_raw += (3 * vl); + dst_argb += (4 * vl); + } +} + +void RAWToRGBARow_RVV(const uint8_t* src_raw, uint8_t* dst_rgba, int width) { + size_t vl = __riscv_vsetvl_e8m2(width); + vuint8m2_t v_a = __riscv_vmv_v_x_u8m2(255u, vl); + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_r, &v_g, &v_b, src_raw, vl); + __riscv_vsseg4e8_v_u8m2(dst_rgba, v_a, v_b, v_g, v_r, vl); + width -= vl; + src_raw += (3 * vl); + dst_rgba += (4 * vl); + } +} + +void RAWToRGB24Row_RVV(const uint8_t* src_raw, uint8_t* dst_rgb24, int width) { + while (width > 0) { + vuint8m2_t v_b, v_g, v_r; + size_t vl = __riscv_vsetvl_e8m2(width); + __riscv_vlseg3e8_v_u8m2(&v_b, &v_g, &v_r, src_raw, vl); + __riscv_vsseg3e8_v_u8m2(dst_rgb24, v_r, v_g, v_b, vl); + width -= vl; + src_raw += (3 * vl); + dst_rgb24 += (3 * vl); + } +} + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif + +#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) diff --git a/libfenrir/src/main/jni/animation/libyuv/source/scale.cc b/libfenrir/src/main/jni/animation/libyuv/source/scale.cc index 830754ce6..90abaefe8 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/scale.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/scale.cc @@ -820,6 +820,7 @@ static void ScaleAddCols2_C(int dst_width, int ix = x >> 16; x += dx; boxwidth = MIN1((x >> 16) - ix); + assert(((boxwidth - minboxwidth) == 0) || ((boxwidth - minboxwidth) == 1)); *dst_ptr++ = (uint8_t)(SumPixels(boxwidth, src_ptr + ix) * scaletbl[boxwidth - minboxwidth] >> 16); @@ -842,6 +843,7 @@ static void ScaleAddCols2_16_C(int dst_width, int ix = x >> 16; x += dx; boxwidth = MIN1((x >> 16) - ix); + assert(((boxwidth - minboxwidth) == 0) || ((boxwidth - minboxwidth) == 1)); *dst_ptr++ = SumPixels_16(boxwidth, src_ptr + ix) * scaletbl[boxwidth - minboxwidth] >> 16; diff --git a/libfenrir/src/main/jni/animation/libyuv/source/scale_uv.cc b/libfenrir/src/main/jni/animation/libyuv/source/scale_uv.cc index 5b92d0432..1b5b1db1e 100644 --- a/libfenrir/src/main/jni/animation/libyuv/source/scale_uv.cc +++ b/libfenrir/src/main/jni/animation/libyuv/source/scale_uv.cc @@ -644,19 +644,19 @@ void ScaleUVLinearUp2(int src_width, // This function can only scale up by 2 times horizontally. assert(src_width == ((dst_width + 1) / 2)); -#ifdef HAS_SCALEUVROWUP2LINEAR_SSSE3 +#ifdef HAS_SCALEUVROWUP2_LINEAR_SSSE3 if (TestCpuFlag(kCpuHasSSSE3)) { ScaleRowUp = ScaleUVRowUp2_Linear_Any_SSSE3; } #endif -#ifdef HAS_SCALEUVROWUP2LINEAR_AVX2 +#ifdef HAS_SCALEUVROWUP2_LINEAR_AVX2 if (TestCpuFlag(kCpuHasAVX2)) { ScaleRowUp = ScaleUVRowUp2_Linear_Any_AVX2; } #endif -#ifdef HAS_SCALEUVROWUP2LINEAR_NEON +#ifdef HAS_SCALEUVROWUP2_LINEAR_NEON if (TestCpuFlag(kCpuHasNEON)) { ScaleRowUp = ScaleUVRowUp2_Linear_Any_NEON; } @@ -697,19 +697,19 @@ void ScaleUVBilinearUp2(int src_width, assert(src_width == ((dst_width + 1) / 2)); assert(src_height == ((dst_height + 1) / 2)); -#ifdef HAS_SCALEUVROWUP2BILINEAR_SSSE3 +#ifdef HAS_SCALEUVROWUP2_BILINEAR_SSSE3 if (TestCpuFlag(kCpuHasSSSE3)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_Any_SSSE3; } #endif -#ifdef HAS_SCALEUVROWUP2BILINEAR_AVX2 +#ifdef HAS_SCALEUVROWUP2_BILINEAR_AVX2 if (TestCpuFlag(kCpuHasAVX2)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_Any_AVX2; } #endif -#ifdef HAS_SCALEUVROWUP2BILINEAR_NEON +#ifdef HAS_SCALEUVROWUP2_BILINEAR_NEON if (TestCpuFlag(kCpuHasNEON)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_Any_NEON; } @@ -751,19 +751,19 @@ void ScaleUVLinearUp2_16(int src_width, // This function can only scale up by 2 times horizontally. assert(src_width == ((dst_width + 1) / 2)); -#ifdef HAS_SCALEUVROWUP2LINEAR_16_SSE41 +#ifdef HAS_SCALEUVROWUP2_LINEAR_16_SSE41 if (TestCpuFlag(kCpuHasSSE41)) { ScaleRowUp = ScaleUVRowUp2_Linear_16_Any_SSE41; } #endif -#ifdef HAS_SCALEUVROWUP2LINEAR_16_AVX2 +#ifdef HAS_SCALEUVROWUP2_LINEAR_16_AVX2 if (TestCpuFlag(kCpuHasAVX2)) { ScaleRowUp = ScaleUVRowUp2_Linear_16_Any_AVX2; } #endif -#ifdef HAS_SCALEUVROWUP2LINEAR_16_NEON +#ifdef HAS_SCALEUVROWUP2_LINEAR_16_NEON if (TestCpuFlag(kCpuHasNEON)) { ScaleRowUp = ScaleUVRowUp2_Linear_16_Any_NEON; } @@ -804,19 +804,19 @@ void ScaleUVBilinearUp2_16(int src_width, assert(src_width == ((dst_width + 1) / 2)); assert(src_height == ((dst_height + 1) / 2)); -#ifdef HAS_SCALEUVROWUP2BILINEAR_16_SSE41 +#ifdef HAS_SCALEUVROWUP2_BILINEAR_16_SSE41 if (TestCpuFlag(kCpuHasSSE41)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_16_Any_SSE41; } #endif -#ifdef HAS_SCALEUVROWUP2BILINEAR_16_AVX2 +#ifdef HAS_SCALEUVROWUP2_BILINEAR_16_AVX2 if (TestCpuFlag(kCpuHasAVX2)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_16_Any_AVX2; } #endif -#ifdef HAS_SCALEUVROWUP2BILINEAR_16_NEON +#ifdef HAS_SCALEUVROWUP2_BILINEAR_16_NEON if (TestCpuFlag(kCpuHasNEON)) { Scale2RowUp = ScaleUVRowUp2_Bilinear_16_Any_NEON; } diff --git a/libfenrir/src/main/jni/audio/ffmpeg/ffmpeg_jni.cpp b/libfenrir/src/main/jni/audio/ffmpeg/ffmpeg_jni.cpp index 884423cd1..c974d8fe7 100644 --- a/libfenrir/src/main/jni/audio/ffmpeg/ffmpeg_jni.cpp +++ b/libfenrir/src/main/jni/audio/ffmpeg/ffmpeg_jni.cpp @@ -32,24 +32,25 @@ extern "C" { #include } -#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \ - extern "C" { \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_##NAME( \ - JNIEnv *env, jobject thiz, ##__VA_ARGS__); \ - } \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_##NAME( \ - JNIEnv *env, jobject thiz, ##__VA_ARGS__) - -#define AUDIO_DECODER_FUNC(RETURN_TYPE, NAME, ...) \ +#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \ extern "C" { \ JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegAudioDecoder_##NAME( \ - JNIEnv *env, jobject thiz, ##__VA_ARGS__); \ + Java_androidx_media3_decoder_ffmpeg_FfmpegLibrary_##NAME(JNIEnv *env, \ + jobject thiz, \ + ##__VA_ARGS__); \ } \ JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegAudioDecoder_##NAME( \ + Java_androidx_media3_decoder_ffmpeg_FfmpegLibrary_##NAME( \ + JNIEnv *env, jobject thiz, ##__VA_ARGS__) + +#define AUDIO_DECODER_FUNC(RETURN_TYPE, NAME, ...) \ + extern "C" { \ + JNIEXPORT RETURN_TYPE \ + Java_androidx_media3_decoder_ffmpeg_FfmpegAudioDecoder_##NAME( \ + JNIEnv *env, jobject thiz, ##__VA_ARGS__); \ + } \ + JNIEXPORT RETURN_TYPE \ + Java_androidx_media3_decoder_ffmpeg_FfmpegAudioDecoder_##NAME( \ JNIEnv *env, jobject thiz, ##__VA_ARGS__) #define ERROR_STRING_BUFFER_LENGTH 256 diff --git a/libfenrir/src/main/jni/audio/opus/opus_jni.cc b/libfenrir/src/main/jni/audio/opus/opus_jni.cc index 468e8977c..3fbff8643 100644 --- a/libfenrir/src/main/jni/audio/opus/opus_jni.cc +++ b/libfenrir/src/main/jni/audio/opus/opus_jni.cc @@ -22,25 +22,21 @@ #include "opus_multistream.h" // NOLINT #include "fenrir_native.h" -#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \ - extern "C" { \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_##NAME( \ - JNIEnv* env, jobject thiz, ##__VA_ARGS__); \ - } \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_##NAME( \ - JNIEnv* env, jobject thiz, ##__VA_ARGS__) - -#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \ - extern "C" { \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_##NAME( \ - JNIEnv* env, jobject thiz, ##__VA_ARGS__); \ - } \ - JNIEXPORT RETURN_TYPE \ - Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_##NAME( \ - JNIEnv* env, jobject thiz, ##__VA_ARGS__) +#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \ + extern "C" { \ + JNIEXPORT RETURN_TYPE Java_androidx_media3_decoder_opus_OpusDecoder_##NAME( \ + JNIEnv* env, jobject thiz, ##__VA_ARGS__); \ + } \ + JNIEXPORT RETURN_TYPE Java_androidx_media3_decoder_opus_OpusDecoder_##NAME( \ + JNIEnv* env, jobject thiz, ##__VA_ARGS__) + +#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \ + extern "C" { \ + JNIEXPORT RETURN_TYPE Java_androidx_media3_decoder_opus_OpusLibrary_##NAME( \ + JNIEnv* env, jobject thiz, ##__VA_ARGS__); \ + } \ + JNIEXPORT RETURN_TYPE Java_androidx_media3_decoder_opus_OpusLibrary_##NAME( \ + JNIEnv* env, jobject thiz, ##__VA_ARGS__) // JNI references for SimpleOutputBuffer class. static jmethodID outputBufferInit; @@ -75,7 +71,7 @@ DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount, // Populate JNI References. const jclass outputBufferClass = env->FindClass( - "com/google/android/exoplayer2/decoder/SimpleDecoderOutputBuffer"); + "androidx/media3/decoder/SimpleDecoderOutputBuffer"); outputBufferInit = env->GetMethodID(outputBufferClass, "init", "(JI)Ljava/nio/ByteBuffer;"); diff --git a/libfenrir/src/main/jni/compress/zstd/compress/zstd_compress.c b/libfenrir/src/main/jni/compress/zstd/compress/zstd_compress.c index d91f80060..d6133e70b 100644 --- a/libfenrir/src/main/jni/compress/zstd/compress/zstd_compress.c +++ b/libfenrir/src/main/jni/compress/zstd/compress/zstd_compress.c @@ -1232,9 +1232,9 @@ static void ZSTD_dedicatedDictSearch_revertCParams( ZSTD_compressionParameters* cParams); /** - * Initializes the local dict using the requested parameters. - * NOTE: This does not use the pledged src size, because it may be used for more - * than one compression. + * Initializes the local dictionary using requested parameters. + * NOTE: Initialization does not employ the pledged src size, + * because the dictionary may be used for multiple compressions. */ static size_t ZSTD_initLocalDict(ZSTD_CCtx* cctx) { @@ -1247,8 +1247,8 @@ static size_t ZSTD_initLocalDict(ZSTD_CCtx* cctx) return 0; } if (dl->cdict != NULL) { - assert(cctx->cdict == dl->cdict); /* Local dictionary already initialized. */ + assert(cctx->cdict == dl->cdict); return 0; } assert(dl->dictSize > 0); @@ -1268,26 +1268,30 @@ static size_t ZSTD_initLocalDict(ZSTD_CCtx* cctx) } size_t ZSTD_CCtx_loadDictionary_advanced( - ZSTD_CCtx* cctx, const void* dict, size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType) + ZSTD_CCtx* cctx, + const void* dict, size_t dictSize, + ZSTD_dictLoadMethod_e dictLoadMethod, + ZSTD_dictContentType_e dictContentType) { - RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, - "Can't load a dictionary when ctx is not in init stage."); DEBUGLOG(4, "ZSTD_CCtx_loadDictionary_advanced (size: %u)", (U32)dictSize); - ZSTD_clearAllDicts(cctx); /* in case one already exists */ - if (dict == NULL || dictSize == 0) /* no dictionary mode */ + RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, + "Can't load a dictionary when cctx is not in init stage."); + ZSTD_clearAllDicts(cctx); /* erase any previously set dictionary */ + if (dict == NULL || dictSize == 0) /* no dictionary */ return 0; if (dictLoadMethod == ZSTD_dlm_byRef) { cctx->localDict.dict = dict; } else { + /* copy dictionary content inside CCtx to own its lifetime */ void* dictBuffer; RETURN_ERROR_IF(cctx->staticSize, memory_allocation, - "no malloc for static CCtx"); + "static CCtx can't allocate for an internal copy of dictionary"); dictBuffer = ZSTD_customMalloc(dictSize, cctx->customMem); - RETURN_ERROR_IF(!dictBuffer, memory_allocation, "NULL pointer!"); + RETURN_ERROR_IF(dictBuffer==NULL, memory_allocation, + "allocation failed for dictionary content"); ZSTD_memcpy(dictBuffer, dict, dictSize); - cctx->localDict.dictBuffer = dictBuffer; - cctx->localDict.dict = dictBuffer; + cctx->localDict.dictBuffer = dictBuffer; /* owned ptr to free */ + cctx->localDict.dict = dictBuffer; /* read-only reference */ } cctx->localDict.dictSize = dictSize; cctx->localDict.dictContentType = dictContentType; @@ -1357,7 +1361,7 @@ size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset) if ( (reset == ZSTD_reset_parameters) || (reset == ZSTD_reset_session_and_parameters) ) { RETURN_ERROR_IF(cctx->streamStage != zcss_init, stage_wrong, - "Can't reset parameters only when not in init stage."); + "Reset parameters is only possible during init stage."); ZSTD_clearAllDicts(cctx); ZSTD_memset(&cctx->externalMatchCtx, 0, sizeof(cctx->externalMatchCtx)); return ZSTD_CCtxParams_reset(&cctx->requestedParams); diff --git a/libfenrir/src/main/jni/compress/zstd/decompress/zstd_decompress.c b/libfenrir/src/main/jni/compress/zstd/decompress/zstd_decompress.c index 3f3ca57c0..7bc271342 100644 --- a/libfenrir/src/main/jni/compress/zstd/decompress/zstd_decompress.c +++ b/libfenrir/src/main/jni/compress/zstd/decompress/zstd_decompress.c @@ -589,49 +589,52 @@ static size_t readSkippableFrameSize(void const* src, size_t srcSize) sizeU32 = MEM_readLE32((BYTE const*)src + ZSTD_FRAMEIDSIZE); RETURN_ERROR_IF((U32)(sizeU32 + ZSTD_SKIPPABLEHEADERSIZE) < sizeU32, frameParameter_unsupported, ""); - { - size_t const skippableSize = skippableHeaderSize + sizeU32; + { size_t const skippableSize = skippableHeaderSize + sizeU32; RETURN_ERROR_IF(skippableSize > srcSize, srcSize_wrong, ""); return skippableSize; } } /*! ZSTD_readSkippableFrame() : - * Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer. + * Retrieves content of a skippable frame, and writes it to dst buffer. * * The parameter magicVariant will receive the magicVariant that was supplied when the frame was written, * i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested * in the magicVariant. * - * Returns an error if destination buffer is not large enough, or if the frame is not skippable. + * Returns an error if destination buffer is not large enough, or if this is not a valid skippable frame. * * @return : number of bytes written or a ZSTD error. */ -ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant, - const void* src, size_t srcSize) +size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, + unsigned* magicVariant, /* optional, can be NULL */ + const void* src, size_t srcSize) { - U32 const magicNumber = MEM_readLE32(src); - size_t skippableFrameSize = readSkippableFrameSize(src, srcSize); - size_t skippableContentSize = skippableFrameSize - ZSTD_SKIPPABLEHEADERSIZE; - - /* check input validity */ - RETURN_ERROR_IF(!ZSTD_isSkippableFrame(src, srcSize), frameParameter_unsupported, ""); - RETURN_ERROR_IF(skippableFrameSize < ZSTD_SKIPPABLEHEADERSIZE || skippableFrameSize > srcSize, srcSize_wrong, ""); - RETURN_ERROR_IF(skippableContentSize > dstCapacity, dstSize_tooSmall, ""); + RETURN_ERROR_IF(srcSize < ZSTD_SKIPPABLEHEADERSIZE, srcSize_wrong, ""); - /* deliver payload */ - if (skippableContentSize > 0 && dst != NULL) - ZSTD_memcpy(dst, (const BYTE *)src + ZSTD_SKIPPABLEHEADERSIZE, skippableContentSize); - if (magicVariant != NULL) - *magicVariant = magicNumber - ZSTD_MAGIC_SKIPPABLE_START; - return skippableContentSize; + { U32 const magicNumber = MEM_readLE32(src); + size_t skippableFrameSize = readSkippableFrameSize(src, srcSize); + size_t skippableContentSize = skippableFrameSize - ZSTD_SKIPPABLEHEADERSIZE; + + /* check input validity */ + RETURN_ERROR_IF(!ZSTD_isSkippableFrame(src, srcSize), frameParameter_unsupported, ""); + RETURN_ERROR_IF(skippableFrameSize < ZSTD_SKIPPABLEHEADERSIZE || skippableFrameSize > srcSize, srcSize_wrong, ""); + RETURN_ERROR_IF(skippableContentSize > dstCapacity, dstSize_tooSmall, ""); + + /* deliver payload */ + if (skippableContentSize > 0 && dst != NULL) + ZSTD_memcpy(dst, (const BYTE *)src + ZSTD_SKIPPABLEHEADERSIZE, skippableContentSize); + if (magicVariant != NULL) + *magicVariant = magicNumber - ZSTD_MAGIC_SKIPPABLE_START; + return skippableContentSize; + } } /** ZSTD_findDecompressedSize() : - * compatible with legacy mode * `srcSize` must be the exact length of some number of ZSTD compressed and/or * skippable frames - * @return : decompressed size of the frames contained */ + * note: compatible with legacy mode + * @return : decompressed size of the frames contained */ unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize) { unsigned long long totalDstSize = 0; @@ -641,9 +644,7 @@ unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize) if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) { size_t const skippableSize = readSkippableFrameSize(src, srcSize); - if (ZSTD_isError(skippableSize)) { - return ZSTD_CONTENTSIZE_ERROR; - } + if (ZSTD_isError(skippableSize)) return ZSTD_CONTENTSIZE_ERROR; assert(skippableSize <= srcSize); src = (const BYTE *)src + skippableSize; @@ -651,17 +652,17 @@ unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize) continue; } - { unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize); - if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret; + { unsigned long long const fcs = ZSTD_getFrameContentSize(src, srcSize); + if (fcs >= ZSTD_CONTENTSIZE_ERROR) return fcs; - /* check for overflow */ - if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR; - totalDstSize += ret; + if (totalDstSize + fcs < totalDstSize) + return ZSTD_CONTENTSIZE_ERROR; /* check for overflow */ + totalDstSize += fcs; } + /* skip to next frame */ { size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize); - if (ZSTD_isError(frameSrcSize)) { - return ZSTD_CONTENTSIZE_ERROR; - } + if (ZSTD_isError(frameSrcSize)) return ZSTD_CONTENTSIZE_ERROR; + assert(frameSrcSize <= srcSize); src = (const BYTE *)src + frameSrcSize; srcSize -= frameSrcSize; @@ -1091,17 +1092,18 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, } #endif - { U32 const magicNumber = MEM_readLE32(src); - DEBUGLOG(4, "reading magic number %08X (expecting %08X)", - (unsigned)magicNumber, ZSTD_MAGICNUMBER); + if (srcSize >= 4) { + U32 const magicNumber = MEM_readLE32(src); + DEBUGLOG(5, "reading magic number %08X", (unsigned)magicNumber); if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) { + /* skippable frame detected : skip it */ size_t const skippableSize = readSkippableFrameSize(src, srcSize); - FORWARD_IF_ERROR(skippableSize, "readSkippableFrameSize failed"); + FORWARD_IF_ERROR(skippableSize, "invalid skippable frame"); assert(skippableSize <= srcSize); src = (const BYTE *)src + skippableSize; srcSize -= skippableSize; - continue; + continue; /* check next frame */ } } if (ddict) { diff --git a/libfenrir/src/main/jni/rlottie/src/lottie/rapidjson/allocators.h b/libfenrir/src/main/jni/rlottie/src/lottie/rapidjson/allocators.h index ddcf4781b..35650aff4 100644 --- a/libfenrir/src/main/jni/rlottie/src/lottie/rapidjson/allocators.h +++ b/libfenrir/src/main/jni/rlottie/src/lottie/rapidjson/allocators.h @@ -434,7 +434,7 @@ namespace internal { template inline T* Realloc(A& a, T* old_p, size_t old_n, size_t new_n) { - RAPIDJSON_NOEXCEPT_ASSERT(old_n <= std::numeric_limits::max() / sizeof(T) && new_n <= std::numeric_limits::max() / sizeof(T)); + RAPIDJSON_NOEXCEPT_ASSERT(old_n <= (std::numeric_limits::max)() / sizeof(T) && new_n <= (std::numeric_limits::max)() / sizeof(T)); return static_cast(a.Realloc(old_p, old_n * sizeof(T), new_n * sizeof(T))); } diff --git a/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwRenderer.cpp b/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwRenderer.cpp index 6a1a88193..e589d6184 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwRenderer.cpp @@ -150,6 +150,9 @@ struct SwShapeTask : SwTask //Clip Path for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) { + //Guarantee composition targets get ready. + static_cast(*clip)->done(tid); + auto clipper = &static_cast(*clip)->shape; //Clip shape rle if (shape.rle) { @@ -202,6 +205,9 @@ struct SwImageTask : SwTask if (!imageGenRle(&image, bbox, false)) goto end; if (image.rle) { for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) { + //Guarantee composition targets get ready. + static_cast(*clip)->done(tid); + auto clipper = &static_cast(*clip)->shape; if (clipper->fastTrack) rleClipRect(image.rle, &clipper->bbox); else if (clipper->rle) rleClipPath(image.rle, clipper->rle); @@ -590,13 +596,7 @@ void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, //Finish previous task if it has duplicated request. task->done(); - if (clips.count > 0) { - //Guarantee composition targets get ready. - for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) { - static_cast(*clip)->done(); - } - task->clips = clips; - } + if (clips.count > 0) task->clips = clips; if (transform) { if (!task->transform) task->transform = static_cast(malloc(sizeof(Matrix))); diff --git a/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwStroke.cpp b/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwStroke.cpp index c404bf9e0..8a18900d6 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwStroke.cpp +++ b/libfenrir/src/main/jni/thorvg/src/lib/sw_engine/tvgSwStroke.cpp @@ -302,7 +302,7 @@ static void _inside(SwStroke& stroke, int32_t side, SwFixed lineLength) bool intersect = false; /* Only intersect borders if between two line_to's and both - lines are long enough (line length is zero fur curves). */ + lines are long enough (line length is zero for curves). */ if (border->movable && lineLength > 0) { //compute minimum required length of lines SwFixed minLength = abs(mathMultiply(stroke.width, mathTan(theta))); @@ -382,9 +382,16 @@ static void _lineTo(SwStroke& stroke, const SwPoint& to) if (delta.zero()) return; //compute length of line - auto lineLength = mathLength(delta); auto angle = mathAtan(delta); + /* The lineLength is used to determine the intersection of strokes outlines. + The scale needs to be reverted since the stroke width has not been scaled. + An alternative option is to scale the width of the stroke properly by + calculating the mixture of the sx/sy rating on the stroke direction. */ + delta.x /= stroke.sx; + delta.y /= stroke.sy; + auto lineLength = mathLength(delta); + delta = {static_cast(stroke.width), 0}; mathRotate(delta, angle + SW_ANGLE_PI2); SCALE(stroke, delta); diff --git a/libfenrir/src/main/jni/thorvg/src/lib/tvgAccessor.cpp b/libfenrir/src/main/jni/thorvg/src/lib/tvgAccessor.cpp index 753315c56..0c636979b 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/tvgAccessor.cpp +++ b/libfenrir/src/main/jni/thorvg/src/lib/tvgAccessor.cpp @@ -26,15 +26,15 @@ /* Internal Class Implementation */ /************************************************************************/ -static bool accessChildren(Iterator* it, IteratorAccessor& itrAccessor, function func) +static bool accessChildren(Iterator* it, function func) { while (auto child = it->next()) { //Access the child if (!func(child)) return false; //Access the children of the child - if (auto it2 = itrAccessor.iterator(child)) { - if (!accessChildren(it2, itrAccessor, func)) { + if (auto it2 = IteratorAccessor::iterator(child)) { + if (!accessChildren(it2, func)) { delete(it2); return false; } @@ -59,9 +59,8 @@ unique_ptr Accessor::set(unique_ptr picture, functionpImpl->iterator(); } diff --git a/libfenrir/src/main/jni/thorvg/src/lib/tvgSaveModule.h b/libfenrir/src/main/jni/thorvg/src/lib/tvgSaveModule.h index 545252bfc..a997b644a 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/tvgSaveModule.h +++ b/libfenrir/src/main/jni/thorvg/src/lib/tvgSaveModule.h @@ -28,7 +28,7 @@ namespace tvg { -class SaveModule : public IteratorAccessor +class SaveModule { public: virtual ~SaveModule() {} diff --git a/libfenrir/src/main/jni/thorvg/src/lib/tvgShape.cpp b/libfenrir/src/main/jni/thorvg/src/lib/tvgShape.cpp index 3d12698fb..ab07ed659 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/tvgShape.cpp +++ b/libfenrir/src/main/jni/thorvg/src/lib/tvgShape.cpp @@ -242,6 +242,7 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) } +//TODO: kill alpha at TVG 1.0, because we also have opacity Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept { pImpl->rs.color[0] = r; diff --git a/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.cpp b/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.cpp index 79e34a62a..6b4b93c5d 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.cpp +++ b/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.cpp @@ -100,13 +100,12 @@ struct TaskQueue { }; -class TaskSchedulerImpl +struct TaskSchedulerImpl { -public: - unsigned threadCnt; + uint32_t threadCnt; vector threads; vector taskQueues; - atomic idx{0}; + uint32_t idx = 0; TaskSchedulerImpl(unsigned threadCnt) : threadCnt(threadCnt), taskQueues(threadCnt) { diff --git a/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.h b/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.h index 7dd1dce83..8f60903f1 100644 --- a/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.h +++ b/libfenrir/src/main/jni/thorvg/src/lib/tvgTaskScheduler.h @@ -44,20 +44,25 @@ struct Task { private: mutex mtx; - condition_variable cv; - bool ready{true}; - bool pending{false}; + bool finished = true; + bool running = false; public: virtual ~Task() = default; - void done() + void done(unsigned tid = 0) { - if (!pending) return; + if (finished) return; unique_lock lock(mtx); - while (!ready) cv.wait(lock); - pending = false; + + if (finished) return; + + //the job hasn't been launched yet. + running = true; + run(tid); + running = false; + finished = true; } protected: @@ -66,17 +71,21 @@ struct Task private: void operator()(unsigned tid) { - run(tid); + if (finished || running) return; lock_guard lock(mtx); - ready = true; - cv.notify_one(); + + if (finished || running) return; + + running = true; + run(tid); + running = false; + finished = true; } void prepare() { - ready = false; - pending = true; + finished = false; } friend class TaskSchedulerImpl; diff --git a/libfenrir/src/main/jni/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp b/libfenrir/src/main/jni/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp index 50097e427..1d519c43b 100644 --- a/libfenrir/src/main/jni/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/libfenrir/src/main/jni/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -757,9 +757,7 @@ static unique_ptr _sceneBuildHelper(const SvgNode* node, const Box& vBox, static void _applySvgViewFlag(const Scene* scene, float& vx, float& vy, float& vw, float& vh, float& w, float& h, SvgViewFlag viewFlag) { if (!((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Viewbox)) { - scene->bounds(nullptr, nullptr, &vw, &vh, false); - vx = 0.0f; - vy = 0.0f; + scene->bounds(&vx, &vy, &vw, &vh, false); if ((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Width) vw = w; if ((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Height) vh = h; } diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioDecoder.kt similarity index 93% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioDecoder.kt index 1ad0ce1e7..27a4f3675 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioDecoder.kt @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.ffmpeg +package androidx.media3.decoder.ffmpeg -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.C.PcmEncoding -import com.google.android.exoplayer2.Format -import com.google.android.exoplayer2.decoder.DecoderInputBuffer -import com.google.android.exoplayer2.decoder.SimpleDecoder -import com.google.android.exoplayer2.decoder.SimpleDecoderOutputBuffer -import com.google.android.exoplayer2.util.Assertions -import com.google.android.exoplayer2.util.MimeTypes -import com.google.android.exoplayer2.util.ParsableByteArray -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.Format +import androidx.media3.common.MimeTypes +import androidx.media3.common.util.Assertions +import androidx.media3.common.util.ParsableByteArray +import androidx.media3.common.util.UnstableApi +import androidx.media3.common.util.Util +import androidx.media3.decoder.DecoderInputBuffer +import androidx.media3.decoder.SimpleDecoder +import androidx.media3.decoder.SimpleDecoderOutputBuffer import dev.ragnarok.fenrir.module.FenrirNative import java.nio.ByteBuffer @@ -32,6 +32,7 @@ import java.nio.ByteBuffer * FFmpeg audio decoder. */ /* package */ +@UnstableApi @Suppress("UNCHECKED_CAST") class FfmpegAudioDecoder( format: Format, @@ -49,7 +50,7 @@ class FfmpegAudioDecoder( /** * Returns the encoding of output audio. */ - val encoding: @PcmEncoding Int + val encoding: @C.PcmEncoding Int private val outputBufferSize: Int private var nativeContext // May be reassigned on resetting the codec. : Long diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioRenderer.kt similarity index 86% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioRenderer.kt index 69c453b78..6cba9f4e9 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegAudioRenderer.kt @@ -13,24 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.ffmpeg +package androidx.media3.decoder.ffmpeg import android.os.Handler -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.C.PcmEncoding -import com.google.android.exoplayer2.Format -import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport -import com.google.android.exoplayer2.audio.* -import com.google.android.exoplayer2.decoder.CryptoConfig -import com.google.android.exoplayer2.util.Assertions -import com.google.android.exoplayer2.util.MimeTypes -import com.google.android.exoplayer2.util.TraceUtil -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.Format +import androidx.media3.common.MimeTypes +import androidx.media3.common.audio.AudioProcessor +import androidx.media3.common.util.Assertions +import androidx.media3.common.util.TraceUtil +import androidx.media3.common.util.UnstableApi +import androidx.media3.common.util.Util +import androidx.media3.decoder.CryptoConfig +import androidx.media3.exoplayer.RendererCapabilities +import androidx.media3.exoplayer.audio.AudioRendererEventListener +import androidx.media3.exoplayer.audio.AudioSink +import androidx.media3.exoplayer.audio.DecoderAudioRenderer +import androidx.media3.exoplayer.audio.DefaultAudioSink import dev.ragnarok.fenrir.module.FenrirNative /** * Decodes and renders audio using FFmpeg. */ +@UnstableApi @Suppress("UNUSED") class FfmpegAudioRenderer /** @@ -89,7 +94,7 @@ class FfmpegAudioRenderer } } - override fun supportsMixedMimeTypeAdaptation(): @AdaptiveSupport Int { + override fun supportsMixedMimeTypeAdaptation(): @RendererCapabilities.AdaptiveSupport Int { return ADAPTIVE_NOT_SEAMLESS } @@ -121,7 +126,7 @@ class FfmpegAudioRenderer * Returns whether the renderer's [AudioSink] supports the PCM format that will be output * from the decoder for the given input format and requested output encoding. */ - private fun sinkSupportsFormat(inputFormat: Format, pcmEncoding: @PcmEncoding Int): Boolean { + private fun sinkSupportsFormat(inputFormat: Format, pcmEncoding: @C.PcmEncoding Int): Boolean { return sinkSupportsFormat( Util.getPcmFormat(pcmEncoding, inputFormat.channelCount, inputFormat.sampleRate) ) diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegDecoderException.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegDecoderException.kt similarity index 86% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegDecoderException.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegDecoderException.kt index 32f437aaa..f49231f8d 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegDecoderException.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegDecoderException.kt @@ -13,13 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.ffmpeg +package androidx.media3.decoder.ffmpeg -import com.google.android.exoplayer2.decoder.DecoderException +import androidx.media3.common.util.UnstableApi +import androidx.media3.decoder.DecoderException /** * Thrown when an FFmpeg decoder error occurs. */ +@UnstableApi class FfmpegDecoderException : DecoderException { /* package */ internal constructor(message: String) : super(message) diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegLibrary.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegLibrary.kt similarity index 90% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegLibrary.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegLibrary.kt index dd66a4a72..12267a5e7 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/ffmpeg/FfmpegLibrary.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/ffmpeg/FfmpegLibrary.kt @@ -13,17 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.ffmpeg +package androidx.media3.decoder.ffmpeg -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.ExoPlayerLibraryInfo -import com.google.android.exoplayer2.util.Log -import com.google.android.exoplayer2.util.MimeTypes +import androidx.media3.common.C +import androidx.media3.common.MediaLibraryInfo +import androidx.media3.common.MimeTypes +import androidx.media3.common.util.Log +import androidx.media3.common.util.UnstableApi import dev.ragnarok.fenrir.module.FenrirNative /** * Configures and queries the underlying native library. */ +@UnstableApi object FfmpegLibrary { private const val TAG = "FfmpegLibrary" @@ -99,6 +101,6 @@ object FfmpegLibrary { private external fun ffmpegHasDecoder(codecName: String): Boolean init { - ExoPlayerLibraryInfo.registerModule("goog.exo.ffmpeg") + MediaLibraryInfo.registerModule("media3.decoder.ffmpeg") } } \ No newline at end of file diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/LibopusAudioRenderer.kt similarity index 88% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/opus/LibopusAudioRenderer.kt index 11035a704..427c05dcd 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/LibopusAudioRenderer.kt @@ -13,24 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.opus +package androidx.media3.decoder.opus import android.os.Handler -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.Format -import com.google.android.exoplayer2.audio.AudioProcessor -import com.google.android.exoplayer2.audio.AudioRendererEventListener -import com.google.android.exoplayer2.audio.AudioSink -import com.google.android.exoplayer2.audio.DecoderAudioRenderer -import com.google.android.exoplayer2.decoder.CryptoConfig -import com.google.android.exoplayer2.util.MimeTypes -import com.google.android.exoplayer2.util.TraceUtil -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.Format +import androidx.media3.common.MimeTypes +import androidx.media3.common.audio.AudioProcessor +import androidx.media3.common.util.TraceUtil +import androidx.media3.common.util.UnstableApi +import androidx.media3.common.util.Util +import androidx.media3.decoder.CryptoConfig +import androidx.media3.exoplayer.audio.AudioRendererEventListener +import androidx.media3.exoplayer.audio.AudioSink +import androidx.media3.exoplayer.audio.DecoderAudioRenderer import dev.ragnarok.fenrir.module.FenrirNative /** * Decodes and renders audio using the native Opus decoder. */ +@UnstableApi @Suppress("UNUSED") class LibopusAudioRenderer : DecoderAudioRenderer { constructor() : this( /* eventHandler= */null, /* eventListener= */null) diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoder.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoder.kt similarity index 96% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoder.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoder.kt index b3f692210..42656d83d 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoder.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoder.kt @@ -13,13 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.opus +package androidx.media3.decoder.opus import androidx.annotation.VisibleForTesting -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.decoder.* -import com.google.android.exoplayer2.util.Assertions -import com.google.android.exoplayer2.util.Util +import androidx.media3.common.C +import androidx.media3.common.util.Assertions +import androidx.media3.common.util.UnstableApi +import androidx.media3.common.util.Util +import androidx.media3.decoder.CryptoConfig +import androidx.media3.decoder.CryptoException +import androidx.media3.decoder.DecoderInputBuffer +import androidx.media3.decoder.SimpleDecoder +import androidx.media3.decoder.SimpleDecoderOutputBuffer import dev.ragnarok.fenrir.module.FenrirNative import java.nio.ByteBuffer import java.nio.ByteOrder @@ -45,6 +50,7 @@ import kotlin.experimental.or * @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder. */ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) +@UnstableApi @Suppress("UNCHECKED_CAST") class OpusDecoder( numInputBuffers: Int, diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoderException.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoderException.kt similarity index 86% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoderException.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoderException.kt index 3535bf960..4ceb39f7a 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusDecoderException.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusDecoderException.kt @@ -13,13 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.opus +package androidx.media3.decoder.opus -import com.google.android.exoplayer2.decoder.DecoderException +import androidx.media3.common.util.UnstableApi +import androidx.media3.decoder.DecoderException /** * Thrown when an Opus decoder error occurs. */ +@UnstableApi class OpusDecoderException : DecoderException { /* package */ internal constructor(message: String) : super(message) diff --git a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusLibrary.kt b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusLibrary.kt similarity index 83% rename from libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusLibrary.kt rename to libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusLibrary.kt index 905df1f88..532dc637a 100644 --- a/libfenrir/src/main/kotlin/com/google/android/exoplayer2/ext/opus/OpusLibrary.kt +++ b/libfenrir/src/main/kotlin/androidx/media3/decoder/opus/OpusLibrary.kt @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.ext.opus +package androidx.media3.decoder.opus -import com.google.android.exoplayer2.C -import com.google.android.exoplayer2.C.CryptoType -import com.google.android.exoplayer2.ExoPlayerLibraryInfo +import androidx.media3.common.C +import androidx.media3.common.MediaLibraryInfo +import androidx.media3.common.util.UnstableApi import dev.ragnarok.fenrir.module.FenrirNative.isNativeLoaded /** * Configures and queries the underlying native library. */ +@UnstableApi object OpusLibrary { private var cryptoType = C.CRYPTO_TYPE_UNSUPPORTED @@ -35,7 +36,7 @@ object OpusLibrary { * protected content, or [C.CRYPTO_TYPE_UNSUPPORTED] if the library does not support * decryption. */ - fun setCrypto(cryptoType: @CryptoType Int) { + fun setCrypto(cryptoType: @C.CryptoType Int) { OpusLibrary.cryptoType = cryptoType } @@ -48,7 +49,7 @@ object OpusLibrary { /** * Returns whether the library supports the given [C.CryptoType]. */ - fun supportsCryptoType(cryptoType: @CryptoType Int): Boolean { + fun supportsCryptoType(cryptoType: @C.CryptoType Int): Boolean { return (cryptoType == C.CRYPTO_TYPE_NONE || cryptoType != C.CRYPTO_TYPE_UNSUPPORTED && cryptoType == OpusLibrary.cryptoType) } @@ -57,6 +58,6 @@ object OpusLibrary { external fun opusIsSecureDecodeSupported(): Boolean init { - ExoPlayerLibraryInfo.registerModule("goog.exo.opus") + MediaLibraryInfo.registerModule("media3.decoder.opus") } } \ No newline at end of file