mirror of
https://github.com/androidx/media.git
synced 2025-05-15 11:39:56 +08:00
Fix some remaining extension API nullability issues.
PiperOrigin-RevId: 261910303
This commit is contained in:
parent
b0330edc0b
commit
a9b93d7ec2
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.ext.cast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.gms.cast.CastStatusCodes;
|
||||
@ -33,7 +34,7 @@ import com.google.android.gms.cast.MediaTrack;
|
||||
* @param mediaInfo The media info to get the duration from.
|
||||
* @return The duration in microseconds, or {@link C#TIME_UNSET} if unknown or not applicable.
|
||||
*/
|
||||
public static long getStreamDurationUs(MediaInfo mediaInfo) {
|
||||
public static long getStreamDurationUs(@Nullable MediaInfo mediaInfo) {
|
||||
if (mediaInfo == null) {
|
||||
return C.TIME_UNSET;
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
||||
Format format) {
|
||||
protected int supportsFormatInternal(
|
||||
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||
Assertions.checkNotNull(format.sampleMimeType);
|
||||
if (!FfmpegLibrary.isAvailable()) {
|
||||
return FORMAT_UNSUPPORTED_TYPE;
|
||||
@ -113,7 +113,7 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FfmpegDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
protected FfmpegDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||
throws FfmpegDecoderException {
|
||||
int initialInputBufferSize =
|
||||
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
||||
|
@ -51,8 +51,8 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
||||
Format format) {
|
||||
protected int supportsFormatInternal(
|
||||
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||
if (!FlacLibrary.isAvailable()
|
||||
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
|
||||
return FORMAT_UNSUPPORTED_TYPE;
|
||||
@ -66,7 +66,7 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FlacDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
protected FlacDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||
throws FlacDecoderException {
|
||||
return new FlacDecoder(
|
||||
NUM_BUFFERS, NUM_BUFFERS, format.maxInputSize, format.initializationData);
|
||||
|
@ -79,8 +79,8 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
||||
Format format) {
|
||||
protected int supportsFormatInternal(
|
||||
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||
boolean drmIsSupported =
|
||||
format.drmInitData == null
|
||||
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType)
|
||||
@ -99,7 +99,7 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OpusDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
protected OpusDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||
throws OpusDecoderException {
|
||||
int initialInputBufferSize =
|
||||
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
||||
|
@ -44,7 +44,7 @@ import java.util.List;
|
||||
private static final int DECODE_ERROR = -1;
|
||||
private static final int DRM_ERROR = -2;
|
||||
|
||||
private final ExoMediaCrypto exoMediaCrypto;
|
||||
@Nullable private final ExoMediaCrypto exoMediaCrypto;
|
||||
|
||||
private final int channelCount;
|
||||
private final int headerSkipSamples;
|
||||
@ -66,8 +66,13 @@ import java.util.List;
|
||||
* content. Maybe null and can be ignored if decoder does not handle encrypted content.
|
||||
* @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder.
|
||||
*/
|
||||
public OpusDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
|
||||
List<byte[]> initializationData, ExoMediaCrypto exoMediaCrypto) throws OpusDecoderException {
|
||||
public OpusDecoder(
|
||||
int numInputBuffers,
|
||||
int numOutputBuffers,
|
||||
int initialInputBufferSize,
|
||||
List<byte[]> initializationData,
|
||||
@Nullable ExoMediaCrypto exoMediaCrypto)
|
||||
throws OpusDecoderException {
|
||||
super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]);
|
||||
if (!OpusLibrary.isAvailable()) {
|
||||
throw new OpusDecoderException("Failed to load decoder native libraries.");
|
||||
@ -232,10 +237,22 @@ import java.util.List;
|
||||
int gain, byte[] streamMap);
|
||||
private native int opusDecode(long decoder, long timeUs, ByteBuffer inputBuffer, int inputSize,
|
||||
SimpleOutputBuffer outputBuffer);
|
||||
private native int opusSecureDecode(long decoder, long timeUs, ByteBuffer inputBuffer,
|
||||
int inputSize, SimpleOutputBuffer outputBuffer, int sampleRate,
|
||||
ExoMediaCrypto mediaCrypto, int inputMode, byte[] key, byte[] iv,
|
||||
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
|
||||
|
||||
private native int opusSecureDecode(
|
||||
long decoder,
|
||||
long timeUs,
|
||||
ByteBuffer inputBuffer,
|
||||
int inputSize,
|
||||
SimpleOutputBuffer outputBuffer,
|
||||
int sampleRate,
|
||||
@Nullable ExoMediaCrypto mediaCrypto,
|
||||
int inputMode,
|
||||
byte[] key,
|
||||
byte[] iv,
|
||||
int numSubSamples,
|
||||
int[] numBytesOfClearData,
|
||||
int[] numBytesOfEncryptedData);
|
||||
|
||||
private native void opusClose(long decoder);
|
||||
private native void opusReset(long decoder);
|
||||
private native int opusGetErrorCode(long decoder);
|
||||
|
@ -246,7 +246,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
||||
* @return The extent to which the renderer supports the format itself.
|
||||
*/
|
||||
protected abstract int supportsFormatInternal(
|
||||
DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
|
||||
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
|
||||
|
||||
/**
|
||||
* Returns whether the sink supports the audio format.
|
||||
@ -341,9 +341,10 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
||||
* @return The decoder.
|
||||
* @throws AudioDecoderException If an error occurred creating a suitable decoder.
|
||||
*/
|
||||
protected abstract SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
|
||||
? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
throws AudioDecoderException;
|
||||
protected abstract SimpleDecoder<
|
||||
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
|
||||
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||
throws AudioDecoderException;
|
||||
|
||||
/**
|
||||
* Returns the format of audio buffers output by the decoder. Will not be called until the first
|
||||
|
@ -24,6 +24,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
@ -54,20 +55,22 @@ public class SimpleDecoderAudioRendererTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
audioRenderer = new SimpleDecoderAudioRenderer(null, null, null, false, mockAudioSink) {
|
||||
@Override
|
||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
||||
Format format) {
|
||||
return FORMAT_HANDLED;
|
||||
}
|
||||
audioRenderer =
|
||||
new SimpleDecoderAudioRenderer(null, null, null, false, mockAudioSink) {
|
||||
@Override
|
||||
protected int supportsFormatInternal(
|
||||
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||
return FORMAT_HANDLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
|
||||
? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
throws AudioDecoderException {
|
||||
return new FakeDecoder();
|
||||
}
|
||||
};
|
||||
@Override
|
||||
protected SimpleDecoder<
|
||||
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
|
||||
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||
throws AudioDecoderException {
|
||||
return new FakeDecoder();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Config(sdk = 19)
|
||||
|
Loading…
x
Reference in New Issue
Block a user