mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +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;
|
package com.google.android.exoplayer2.ext.cast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.gms.cast.CastStatusCodes;
|
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.
|
* @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.
|
* @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) {
|
if (mediaInfo == null) {
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
protected int supportsFormatInternal(
|
||||||
Format format) {
|
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||||
Assertions.checkNotNull(format.sampleMimeType);
|
Assertions.checkNotNull(format.sampleMimeType);
|
||||||
if (!FfmpegLibrary.isAvailable()) {
|
if (!FfmpegLibrary.isAvailable()) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return FORMAT_UNSUPPORTED_TYPE;
|
||||||
@ -113,7 +113,7 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FfmpegDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
protected FfmpegDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws FfmpegDecoderException {
|
throws FfmpegDecoderException {
|
||||||
int initialInputBufferSize =
|
int initialInputBufferSize =
|
||||||
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
||||||
|
@ -51,8 +51,8 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
protected int supportsFormatInternal(
|
||||||
Format format) {
|
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||||
if (!FlacLibrary.isAvailable()
|
if (!FlacLibrary.isAvailable()
|
||||||
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
|
|| !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
|
||||||
return FORMAT_UNSUPPORTED_TYPE;
|
return FORMAT_UNSUPPORTED_TYPE;
|
||||||
@ -66,7 +66,7 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FlacDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
protected FlacDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws FlacDecoderException {
|
throws FlacDecoderException {
|
||||||
return new FlacDecoder(
|
return new FlacDecoder(
|
||||||
NUM_BUFFERS, NUM_BUFFERS, format.maxInputSize, format.initializationData);
|
NUM_BUFFERS, NUM_BUFFERS, format.maxInputSize, format.initializationData);
|
||||||
|
@ -79,8 +79,8 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
protected int supportsFormatInternal(
|
||||||
Format format) {
|
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||||
boolean drmIsSupported =
|
boolean drmIsSupported =
|
||||||
format.drmInitData == null
|
format.drmInitData == null
|
||||||
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType)
|
|| OpusLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType)
|
||||||
@ -99,7 +99,7 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OpusDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
protected OpusDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws OpusDecoderException {
|
throws OpusDecoderException {
|
||||||
int initialInputBufferSize =
|
int initialInputBufferSize =
|
||||||
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
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 DECODE_ERROR = -1;
|
||||||
private static final int DRM_ERROR = -2;
|
private static final int DRM_ERROR = -2;
|
||||||
|
|
||||||
private final ExoMediaCrypto exoMediaCrypto;
|
@Nullable private final ExoMediaCrypto exoMediaCrypto;
|
||||||
|
|
||||||
private final int channelCount;
|
private final int channelCount;
|
||||||
private final int headerSkipSamples;
|
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.
|
* 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.
|
* @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder.
|
||||||
*/
|
*/
|
||||||
public OpusDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
|
public OpusDecoder(
|
||||||
List<byte[]> initializationData, ExoMediaCrypto exoMediaCrypto) throws OpusDecoderException {
|
int numInputBuffers,
|
||||||
|
int numOutputBuffers,
|
||||||
|
int initialInputBufferSize,
|
||||||
|
List<byte[]> initializationData,
|
||||||
|
@Nullable ExoMediaCrypto exoMediaCrypto)
|
||||||
|
throws OpusDecoderException {
|
||||||
super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]);
|
super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]);
|
||||||
if (!OpusLibrary.isAvailable()) {
|
if (!OpusLibrary.isAvailable()) {
|
||||||
throw new OpusDecoderException("Failed to load decoder native libraries.");
|
throw new OpusDecoderException("Failed to load decoder native libraries.");
|
||||||
@ -232,10 +237,22 @@ import java.util.List;
|
|||||||
int gain, byte[] streamMap);
|
int gain, byte[] streamMap);
|
||||||
private native int opusDecode(long decoder, long timeUs, ByteBuffer inputBuffer, int inputSize,
|
private native int opusDecode(long decoder, long timeUs, ByteBuffer inputBuffer, int inputSize,
|
||||||
SimpleOutputBuffer outputBuffer);
|
SimpleOutputBuffer outputBuffer);
|
||||||
private native int opusSecureDecode(long decoder, long timeUs, ByteBuffer inputBuffer,
|
|
||||||
int inputSize, SimpleOutputBuffer outputBuffer, int sampleRate,
|
private native int opusSecureDecode(
|
||||||
ExoMediaCrypto mediaCrypto, int inputMode, byte[] key, byte[] iv,
|
long decoder,
|
||||||
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
|
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 opusClose(long decoder);
|
||||||
private native void opusReset(long decoder);
|
private native void opusReset(long decoder);
|
||||||
private native int opusGetErrorCode(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.
|
* @return The extent to which the renderer supports the format itself.
|
||||||
*/
|
*/
|
||||||
protected abstract int supportsFormatInternal(
|
protected abstract int supportsFormatInternal(
|
||||||
DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
|
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the sink supports the audio format.
|
* Returns whether the sink supports the audio format.
|
||||||
@ -341,8 +341,9 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||||||
* @return The decoder.
|
* @return The decoder.
|
||||||
* @throws AudioDecoderException If an error occurred creating a suitable decoder.
|
* @throws AudioDecoderException If an error occurred creating a suitable decoder.
|
||||||
*/
|
*/
|
||||||
protected abstract SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
|
protected abstract SimpleDecoder<
|
||||||
? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
|
||||||
|
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws AudioDecoderException;
|
throws AudioDecoderException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
@ -54,16 +55,18 @@ public class SimpleDecoderAudioRendererTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
audioRenderer = new SimpleDecoderAudioRenderer(null, null, null, false, mockAudioSink) {
|
audioRenderer =
|
||||||
|
new SimpleDecoderAudioRenderer(null, null, null, false, mockAudioSink) {
|
||||||
@Override
|
@Override
|
||||||
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
|
protected int supportsFormatInternal(
|
||||||
Format format) {
|
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
|
||||||
return FORMAT_HANDLED;
|
return FORMAT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
|
protected SimpleDecoder<
|
||||||
? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>
|
||||||
|
createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws AudioDecoderException {
|
throws AudioDecoderException {
|
||||||
return new FakeDecoder();
|
return new FakeDecoder();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user