Remove Flac and Opus renderers from nullness blacklist

PiperOrigin-RevId: 256213895
This commit is contained in:
olly 2019-07-02 20:14:38 +01:00 committed by Toni
parent 7964e51e0e
commit 4c2f211e28
4 changed files with 33 additions and 14 deletions

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.ext.flac; package com.google.android.exoplayer2.ext.flac;
import android.os.Handler; import android.os.Handler;
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.exoplayer2.audio.AudioProcessor; import com.google.android.exoplayer2.audio.AudioProcessor;
@ -33,7 +34,7 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
private static final int NUM_BUFFERS = 16; private static final int NUM_BUFFERS = 16;
public LibflacAudioRenderer() { public LibflacAudioRenderer() {
this(null, null); this(/* eventHandler= */ null, /* eventListener= */ null);
} }
/** /**
@ -43,8 +44,8 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output. * @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/ */
public LibflacAudioRenderer( public LibflacAudioRenderer(
Handler eventHandler, @Nullable Handler eventHandler,
AudioRendererEventListener eventListener, @Nullable AudioRendererEventListener eventListener,
AudioProcessor... audioProcessors) { AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, audioProcessors); super(eventHandler, eventListener, audioProcessors);
} }

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.ext.opus; package com.google.android.exoplayer2.ext.opus;
import android.os.Handler; import android.os.Handler;
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.exoplayer2.audio.AudioProcessor; import com.google.android.exoplayer2.audio.AudioProcessor;
@ -35,10 +36,12 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
/** The default input buffer size. */ /** The default input buffer size. */
private static final int DEFAULT_INPUT_BUFFER_SIZE = 960 * 6; private static final int DEFAULT_INPUT_BUFFER_SIZE = 960 * 6;
private OpusDecoder decoder; @Nullable private OpusDecoder decoder;
private int channelCount;
private int sampleRate;
public LibopusAudioRenderer() { public LibopusAudioRenderer() {
this(null, null); this(/* eventHandler= */ null, /* eventListener= */ null);
} }
/** /**
@ -48,8 +51,8 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output. * @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/ */
public LibopusAudioRenderer( public LibopusAudioRenderer(
Handler eventHandler, @Nullable Handler eventHandler,
AudioRendererEventListener eventListener, @Nullable AudioRendererEventListener eventListener,
AudioProcessor... audioProcessors) { AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, audioProcessors); super(eventHandler, eventListener, audioProcessors);
} }
@ -67,8 +70,11 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
* has obtained the keys necessary to decrypt encrypted regions of the media. * has obtained the keys necessary to decrypt encrypted regions of the media.
* @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output. * @param audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
*/ */
public LibopusAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener, public LibopusAudioRenderer(
DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys, @Nullable Handler eventHandler,
@Nullable AudioRendererEventListener eventListener,
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager,
boolean playClearSamplesWithoutKeys,
AudioProcessor... audioProcessors) { AudioProcessor... audioProcessors) {
super(eventHandler, eventListener, null, drmSessionManager, playClearSamplesWithoutKeys, super(eventHandler, eventListener, null, drmSessionManager, playClearSamplesWithoutKeys,
audioProcessors); audioProcessors);
@ -106,13 +112,25 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
initialInputBufferSize, initialInputBufferSize,
format.initializationData, format.initializationData,
mediaCrypto); mediaCrypto);
channelCount = decoder.getChannelCount();
sampleRate = decoder.getSampleRate();
return decoder; return decoder;
} }
@Override @Override
protected Format getOutputFormat() { protected Format getOutputFormat() {
return Format.createAudioSampleFormat(null, MimeTypes.AUDIO_RAW, null, Format.NO_VALUE, return Format.createAudioSampleFormat(
Format.NO_VALUE, decoder.getChannelCount(), decoder.getSampleRate(), C.ENCODING_PCM_16BIT, /* id= */ null,
null, null, 0, null); MimeTypes.AUDIO_RAW,
/* codecs= */ null,
Format.NO_VALUE,
Format.NO_VALUE,
channelCount,
sampleRate,
C.ENCODING_PCM_16BIT,
/* initializationData= */ null,
/* drmInitData= */ null,
/* selectionFlags= */ 0,
/* language= */ null);
} }
} }

View File

@ -68,7 +68,7 @@ public final class OpusLibrary {
* protected content. * protected content.
*/ */
public static boolean matchesExpectedExoMediaCryptoType( public static boolean matchesExpectedExoMediaCryptoType(
Class<? extends ExoMediaCrypto> exoMediaCryptoType) { @Nullable Class<? extends ExoMediaCrypto> exoMediaCryptoType) {
return Util.areEqual(OpusLibrary.exoMediaCryptoType, exoMediaCryptoType); return Util.areEqual(OpusLibrary.exoMediaCryptoType, exoMediaCryptoType);
} }

View File

@ -87,7 +87,7 @@ public final class VpxLibrary {
* protected content. * protected content.
*/ */
public static boolean matchesExpectedExoMediaCryptoType( public static boolean matchesExpectedExoMediaCryptoType(
Class<? extends ExoMediaCrypto> exoMediaCryptoType) { @Nullable Class<? extends ExoMediaCrypto> exoMediaCryptoType) {
return Util.areEqual(VpxLibrary.exoMediaCryptoType, exoMediaCryptoType); return Util.areEqual(VpxLibrary.exoMediaCryptoType, exoMediaCryptoType);
} }