Adds Format to MediaCodecAdapter.Configuration.

PiperOrigin-RevId: 369444747
This commit is contained in:
olly 2021-04-20 16:28:12 +01:00 committed by Oliver Woodman
parent efce7b9e2c
commit 32c5ea0643
5 changed files with 12 additions and 3 deletions

View File

@ -362,7 +362,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
&& !MimeTypes.AUDIO_RAW.equals(format.sampleMimeType);
decryptOnlyCodecFormat = decryptOnlyCodecEnabled ? format : null;
return new MediaCodecAdapter.Configuration(
codecInfo, mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
codecInfo, mediaFormat, format, /* surface= */ null, crypto, /* flags= */ 0);
}
@Override

View File

@ -25,6 +25,7 @@ import android.view.Surface;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.CryptoInfo;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -37,11 +38,13 @@ import java.nio.ByteBuffer;
*/
public interface MediaCodecAdapter {
/** Configuration parameters for a {@link MediaCodecAdapter}. */
class Configuration {
final class Configuration {
/** Information about the {@link MediaCodec} being configured. */
public final MediaCodecInfo codecInfo;
/** The {@link MediaFormat} for which the codec is being configured. */
public final MediaFormat mediaFormat;
/** The {@link Format} for which the codec is being configured. */
public final Format format;
/** For video playbacks, the output where the object will render the decoded frames. */
@Nullable public final Surface surface;
/** For DRM protected playbacks, a {@link MediaCrypto} to use for decryption. */
@ -56,11 +59,13 @@ public interface MediaCodecAdapter {
public Configuration(
MediaCodecInfo codecInfo,
MediaFormat mediaFormat,
Format format,
@Nullable Surface surface,
@Nullable MediaCrypto crypto,
int flags) {
this.codecInfo = codecInfo;
this.mediaFormat = mediaFormat;
this.format = format;
this.surface = surface;
this.crypto = crypto;
this.flags = flags;

View File

@ -625,7 +625,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
surface = dummySurface;
}
return new MediaCodecAdapter.Configuration(
codecInfo, mediaFormat, surface, crypto, /* flags= */ 0);
codecInfo, mediaFormat, format, surface, crypto, /* flags= */ 0);
}
@Override

View File

@ -24,6 +24,7 @@ import android.media.MediaCodec;
import android.media.MediaFormat;
import android.os.HandlerThread;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.Format;
import java.lang.reflect.Constructor;
import org.junit.After;
import org.junit.Before;
@ -45,6 +46,7 @@ public class AsynchronousMediaCodecAdapterTest {
new MediaCodecAdapter.Configuration(
codecInfo,
createMediaFormat("format"),
/* format= */ new Format.Builder().build(),
/* surface= */ null,
/* crypto= */ null,
/* flags= */ 0);

View File

@ -116,6 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
new MediaCodecAdapter.Configuration(
createPlaceholderMediaCodecInfo(),
mediaFormat,
format,
/* surface= */ null,
/* crypto= */ null,
/* flags= */ 0));
@ -151,6 +152,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
new MediaCodecAdapter.Configuration(
createPlaceholderMediaCodecInfo(),
mediaFormat,
format,
/* surface= */ null,
/* crypto= */ null,
/* flags= */ MediaCodec.CONFIGURE_FLAG_ENCODE));