mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make minor improvements for IAMF decoder module
- Create `LibiamfAudioRenderer` with `DefaultRenderersFactory` in `ExoPlayerModuleProguard`. - Remove redundant library availability check from `IamfModuleProguard`. - Move `proguard-rules.txt` to the root folder. - Removed unused `cryptoType` parameter from `setLibraries()` method in `IamfLibrary`. - Added log when `LibiamfAudioRenderer` is loaded in `DefaultRenderersFactory`. - Annotated missing classes with `@UnstableApi`. - Check for library availability and throw exception in `IamfDecoder` constructor. #cherrypick PiperOrigin-RevId: 689330016
This commit is contained in:
parent
4a406be1bf
commit
5f99955f31
@ -56,6 +56,9 @@ public final class IamfDecoder
|
||||
public IamfDecoder(List<byte[]> initializationData, boolean spatializationSupported)
|
||||
throws IamfDecoderException {
|
||||
super(new DecoderInputBuffer[1], new SimpleDecoderOutputBuffer[1]);
|
||||
if (!IamfLibrary.isAvailable()) {
|
||||
throw new IamfDecoderException("Failed to load decoder native libraries.");
|
||||
}
|
||||
if (initializationData.size() != 1) {
|
||||
throw new IamfDecoderException("Initialization data must contain a single element.");
|
||||
}
|
||||
|
@ -15,10 +15,12 @@
|
||||
*/
|
||||
package androidx.media3.decoder.iamf;
|
||||
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.decoder.DecoderException;
|
||||
|
||||
/** Thrown when an IAMF decoder error occurs. */
|
||||
final class IamfDecoderException extends DecoderException {
|
||||
@UnstableApi
|
||||
public final class IamfDecoderException extends DecoderException {
|
||||
|
||||
/* package */ IamfDecoderException(String message) {
|
||||
super(message);
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package androidx.media3.decoder.iamf;
|
||||
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.MediaLibraryInfo;
|
||||
import androidx.media3.common.util.LibraryLoader;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
@ -43,12 +42,9 @@ public final class IamfLibrary {
|
||||
* it must do so before calling any other method defined by this class, and before instantiating a
|
||||
* {@link LibiamfAudioRenderer} instance.
|
||||
*
|
||||
* @param cryptoType The {@link C.CryptoType} for which the decoder library supports decrypting
|
||||
* protected content, or {@link C#CRYPTO_TYPE_UNSUPPORTED} if the library does not support
|
||||
* decryption.
|
||||
* @param libraries The names of the IAMF native libraries.
|
||||
*/
|
||||
public static void setLibraries(@C.CryptoType int cryptoType, String... libraries) {
|
||||
public static void setLibraries(String... libraries) {
|
||||
LOADER.setLibraries(libraries);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
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.decoder.DecoderException;
|
||||
@ -36,6 +37,7 @@ import androidx.media3.exoplayer.audio.DecoderAudioRenderer;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Decodes and renders audio using the native IAMF decoder. */
|
||||
@UnstableApi
|
||||
public class LibiamfAudioRenderer extends DecoderAudioRenderer<IamfDecoder> {
|
||||
private final Context context;
|
||||
|
||||
|
@ -547,6 +547,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
|
||||
// The extension is present, but instantiation failed.
|
||||
throw new IllegalStateException("Error instantiating FFmpeg extension", e);
|
||||
}
|
||||
|
||||
try {
|
||||
// Full class names used for constructor args so the LINT rule triggers if any of them move.
|
||||
Class<?> clazz = Class.forName("androidx.media3.decoder.iamf.LibiamfAudioRenderer");
|
||||
@ -559,6 +560,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
|
||||
Renderer renderer =
|
||||
(Renderer) constructor.newInstance(context, eventHandler, eventListener, audioSink);
|
||||
out.add(extensionRendererIndex++, renderer);
|
||||
Log.i(TAG, "Loaded LibiamfAudioRenderer.");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Expected if the app was built without the extension.
|
||||
} catch (Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user