mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add getMetrics() in MediaCodecAdapter
Before the introduction of the MediaCodecAdapter, users could get access directly to the MediaCodec instance from MediaCodecRenderer.getCodec() and then retrieve the codec metrics. This change exposes MediaCodec.getMetrics() on the MediaCodecAdapter. Issue: google/ExoPlayer#9766 #minor-release PiperOrigin-RevId: 416343023
This commit is contained in:
parent
586dd355d1
commit
b5206b8e05
@ -18,6 +18,9 @@
|
||||
around an issue that occurs on some devices when switching a surface
|
||||
from a secure codec to another codec
|
||||
(#8696)[https://github.com/google/ExoPlayer/issues/8696].
|
||||
* Add `MediaCodecAdapter.getMetrics()` to allow users obtain metrics data
|
||||
from `MediaCodec`.
|
||||
([#9766](https://github.com/google/ExoPlayer/issues/9766)).
|
||||
* Android 12 compatibility:
|
||||
* Upgrade the Cast extension to depend on
|
||||
`com.google.android.gms:play-services-cast-framework:20.1.0`. Earlier
|
||||
|
@ -22,6 +22,7 @@ import android.media.MediaFormat;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -306,6 +307,13 @@ import java.nio.ByteBuffer;
|
||||
codec.signalEndOfInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiresApi(26)
|
||||
public PersistableBundle getMetrics() {
|
||||
maybeBlockOnQueueing();
|
||||
return codec.getMetrics();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
/* package */ void onError(MediaCodec.CodecException error) {
|
||||
asynchronousMediaCodecCallback.onError(codec, error);
|
||||
|
@ -20,6 +20,7 @@ import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
@ -336,4 +337,12 @@ public interface MediaCodecAdapter {
|
||||
*/
|
||||
@RequiresApi(18)
|
||||
void signalEndOfInputStream();
|
||||
|
||||
/**
|
||||
* Returns metrics data about the current codec instance.
|
||||
*
|
||||
* @see MediaCodec#getMetrics()
|
||||
*/
|
||||
@RequiresApi(26)
|
||||
PersistableBundle getMetrics();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import android.media.MediaCodec;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.DoNotInline;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -231,8 +232,16 @@ public final class SynchronousMediaCodecAdapter implements MediaCodecAdapter {
|
||||
codec.setVideoScalingMode(scalingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiresApi(26)
|
||||
public PersistableBundle getMetrics() {
|
||||
return codec.getMetrics();
|
||||
}
|
||||
|
||||
@RequiresApi(18)
|
||||
private static final class Api18 {
|
||||
private Api18() {}
|
||||
|
||||
@DoNotInline
|
||||
public static Surface createCodecInputSurface(MediaCodec codec) {
|
||||
return codec.createInputSurface();
|
||||
|
@ -23,6 +23,7 @@ import android.media.MediaCodec;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -275,6 +276,12 @@ public class CapturingRenderersFactory implements RenderersFactory, Dumper.Dumpa
|
||||
delegate.signalEndOfInputStream();
|
||||
}
|
||||
|
||||
@RequiresApi(26)
|
||||
@Override
|
||||
public PersistableBundle getMetrics() {
|
||||
return delegate.getMetrics();
|
||||
}
|
||||
|
||||
// Dumpable implementation
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user