mirror of
https://github.com/samsonjs/media.git
synced 2026-04-03 10:55:48 +00: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
69d83a28bb
commit
531ff0e19d
4 changed files with 33 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
@ -338,4 +339,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;
|
||||
|
|
@ -233,8 +234,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;
|
||||
|
|
@ -277,6 +278,12 @@ public class CapturingRenderersFactory implements RenderersFactory, Dumper.Dumpa
|
|||
delegate.signalEndOfInputStream();
|
||||
}
|
||||
|
||||
@RequiresApi(26)
|
||||
@Override
|
||||
public PersistableBundle getMetrics() {
|
||||
return delegate.getMetrics();
|
||||
}
|
||||
|
||||
// Dumpable implementation
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in a new issue