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); && !MimeTypes.AUDIO_RAW.equals(format.sampleMimeType);
decryptOnlyCodecFormat = decryptOnlyCodecEnabled ? format : null; decryptOnlyCodecFormat = decryptOnlyCodecEnabled ? format : null;
return new MediaCodecAdapter.Configuration( return new MediaCodecAdapter.Configuration(
codecInfo, mediaFormat, /* surface= */ null, crypto, /* flags= */ 0); codecInfo, mediaFormat, format, /* surface= */ null, crypto, /* flags= */ 0);
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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