Commit 0e331239 by tonihei Committed by Andrew Lewis

Turn on non-null-by-default for some core library packages.

And add missing some missing annotations to the publicly visible API of these
packages.

PiperOrigin-RevId: 263134804
parent 860aa2f9
Showing with 314 additions and 57 deletions
...@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.decoder.SimpleOutputBuffer; ...@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.decoder.SimpleOutputBuffer;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.List; import java.util.List;
...@@ -106,7 +107,7 @@ import java.util.List; ...@@ -106,7 +107,7 @@ import java.util.List;
return new FfmpegDecoderException("Error resetting (see logcat)."); return new FfmpegDecoderException("Error resetting (see logcat).");
} }
} }
ByteBuffer inputData = inputBuffer.data; ByteBuffer inputData = Util.castNonNull(inputBuffer.data);
int inputSize = inputData.limit(); int inputSize = inputData.limit();
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, outputBufferSize); ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, outputBufferSize);
int result = ffmpegDecode(nativeContext, inputData, inputSize, outputData, outputBufferSize); int result = ffmpegDecode(nativeContext, inputData, inputSize, outputData, outputBufferSize);
...@@ -132,8 +133,8 @@ import java.util.List; ...@@ -132,8 +133,8 @@ import java.util.List;
} }
hasOutputFormat = true; hasOutputFormat = true;
} }
outputBuffer.data.position(0); outputData.position(0);
outputBuffer.data.limit(result); outputData.limit(result);
return null; return null;
} }
......
...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer; ...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.decoder.SimpleDecoder; import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.decoder.SimpleOutputBuffer; import com.google.android.exoplayer2.decoder.SimpleOutputBuffer;
import com.google.android.exoplayer2.util.FlacStreamMetadata; import com.google.android.exoplayer2.util.FlacStreamMetadata;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.List; import java.util.List;
...@@ -101,7 +102,7 @@ import java.util.List; ...@@ -101,7 +102,7 @@ import java.util.List;
if (reset) { if (reset) {
decoderJni.flush(); decoderJni.flush();
} }
decoderJni.setData(inputBuffer.data); decoderJni.setData(Util.castNonNull(inputBuffer.data));
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, maxOutputBufferSize); ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, maxOutputBufferSize);
try { try {
decoderJni.decodeSample(outputData); decoderJni.decodeSample(outputData);
......
...@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.decoder.SimpleDecoder; ...@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.decoder.SimpleOutputBuffer; import com.google.android.exoplayer2.decoder.SimpleOutputBuffer;
import com.google.android.exoplayer2.drm.DecryptionException; import com.google.android.exoplayer2.drm.DecryptionException;
import com.google.android.exoplayer2.drm.ExoMediaCrypto; import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.Util;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.List; import java.util.List;
...@@ -165,7 +166,7 @@ import java.util.List; ...@@ -165,7 +166,7 @@ import java.util.List;
// any other time, skip number of samples as specified by seek preroll. // any other time, skip number of samples as specified by seek preroll.
skipSamples = (inputBuffer.timeUs == 0) ? headerSkipSamples : headerSeekPreRollSamples; skipSamples = (inputBuffer.timeUs == 0) ? headerSkipSamples : headerSeekPreRollSamples;
} }
ByteBuffer inputData = inputBuffer.data; ByteBuffer inputData = Util.castNonNull(inputBuffer.data);
CryptoInfo cryptoInfo = inputBuffer.cryptoInfo; CryptoInfo cryptoInfo = inputBuffer.cryptoInfo;
int result = inputBuffer.isEncrypted() int result = inputBuffer.isEncrypted()
? opusSecureDecode(nativeDecoderContext, inputBuffer.timeUs, inputData, inputData.limit(), ? opusSecureDecode(nativeDecoderContext, inputBuffer.timeUs, inputData, inputData.limit(),
...@@ -185,7 +186,7 @@ import java.util.List; ...@@ -185,7 +186,7 @@ import java.util.List;
} }
} }
ByteBuffer outputData = outputBuffer.data; ByteBuffer outputData = Util.castNonNull(outputBuffer.data);
outputData.position(0); outputData.position(0);
outputData.limit(result); outputData.limit(result);
if (skipSamples > 0) { if (skipSamples > 0) {
......
...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.decoder.CryptoInfo; ...@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.decoder.CryptoInfo;
import com.google.android.exoplayer2.decoder.SimpleDecoder; import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.drm.DecryptionException; import com.google.android.exoplayer2.drm.DecryptionException;
import com.google.android.exoplayer2.drm.ExoMediaCrypto; import com.google.android.exoplayer2.drm.ExoMediaCrypto;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderInputBuffer; import com.google.android.exoplayer2.video.VideoDecoderInputBuffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -118,7 +119,7 @@ import java.nio.ByteBuffer; ...@@ -118,7 +119,7 @@ import java.nio.ByteBuffer;
@Nullable @Nullable
protected VpxDecoderException decode( protected VpxDecoderException decode(
VideoDecoderInputBuffer inputBuffer, VpxOutputBuffer outputBuffer, boolean reset) { VideoDecoderInputBuffer inputBuffer, VpxOutputBuffer outputBuffer, boolean reset) {
ByteBuffer inputData = inputBuffer.data; ByteBuffer inputData = Util.castNonNull(inputBuffer.data);
int inputSize = inputData.limit(); int inputSize = inputData.limit();
CryptoInfo cryptoInfo = inputBuffer.cryptoInfo; CryptoInfo cryptoInfo = inputBuffer.cryptoInfo;
final long result = inputBuffer.isEncrypted() final long result = inputBuffer.isEncrypted()
......
...@@ -65,6 +65,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { ...@@ -65,6 +65,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
} }
@Override @Override
@Nullable
public MediaClock getMediaClock() { public MediaClock getMediaClock() {
return null; return null;
} }
...@@ -105,6 +106,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { ...@@ -105,6 +106,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
} }
@Override @Override
@Nullable
public final SampleStream getStream() { public final SampleStream getStream() {
return stream; return stream;
} }
......
...@@ -49,6 +49,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities ...@@ -49,6 +49,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities
} }
@Override @Override
@Nullable
public MediaClock getMediaClock() { public MediaClock getMediaClock() {
return null; return null;
} }
...@@ -113,6 +114,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities ...@@ -113,6 +114,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities
} }
@Override @Override
@Nullable
public final SampleStream getStream() { public final SampleStream getStream() {
return stream; return stream;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.source.SampleStream; import com.google.android.exoplayer2.source.SampleStream;
import com.google.android.exoplayer2.util.MediaClock; import com.google.android.exoplayer2.util.MediaClock;
import java.io.IOException; import java.io.IOException;
...@@ -87,11 +88,12 @@ public interface Renderer extends PlayerMessage.Target { ...@@ -87,11 +88,12 @@ public interface Renderer extends PlayerMessage.Target {
/** /**
* If the renderer advances its own playback position then this method returns a corresponding * If the renderer advances its own playback position then this method returns a corresponding
* {@link MediaClock}. If provided, the player will use the returned {@link MediaClock} as its * {@link MediaClock}. If provided, the player will use the returned {@link MediaClock} as its
* source of time during playback. A player may have at most one renderer that returns a * source of time during playback. A player may have at most one renderer that returns a {@link
* {@link MediaClock} from this method. * MediaClock} from this method.
* *
* @return The {@link MediaClock} tracking the playback position of the renderer, or null. * @return The {@link MediaClock} tracking the playback position of the renderer, or null.
*/ */
@Nullable
MediaClock getMediaClock(); MediaClock getMediaClock();
/** /**
...@@ -147,9 +149,8 @@ public interface Renderer extends PlayerMessage.Target { ...@@ -147,9 +149,8 @@ public interface Renderer extends PlayerMessage.Target {
void replaceStream(Format[] formats, SampleStream stream, long offsetUs) void replaceStream(Format[] formats, SampleStream stream, long offsetUs)
throws ExoPlaybackException; throws ExoPlaybackException;
/** /** Returns the {@link SampleStream} being consumed, or null if the renderer is disabled. */
* Returns the {@link SampleStream} being consumed, or null if the renderer is disabled. @Nullable
*/
SampleStream getStream(); SampleStream getStream();
/** /**
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.analytics;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -156,7 +156,7 @@ public final class Ac3Util { ...@@ -156,7 +156,7 @@ public final class Ac3Util {
* @return The AC-3 format parsed from data in the header. * @return The AC-3 format parsed from data in the header.
*/ */
public static Format parseAc3AnnexFFormat( public static Format parseAc3AnnexFFormat(
ParsableByteArray data, String trackId, String language, DrmInitData drmInitData) { ParsableByteArray data, String trackId, String language, @Nullable DrmInitData drmInitData) {
int fscod = (data.readUnsignedByte() & 0xC0) >> 6; int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod]; int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
int nextByte = data.readUnsignedByte(); int nextByte = data.readUnsignedByte();
...@@ -189,7 +189,7 @@ public final class Ac3Util { ...@@ -189,7 +189,7 @@ public final class Ac3Util {
* @return The E-AC-3 format parsed from data in the header. * @return The E-AC-3 format parsed from data in the header.
*/ */
public static Format parseEAc3AnnexFFormat( public static Format parseEAc3AnnexFFormat(
ParsableByteArray data, String trackId, String language, DrmInitData drmInitData) { ParsableByteArray data, String trackId, String language, @Nullable DrmInitData drmInitData) {
data.skipBytes(2); // data_rate, num_ind_sub data.skipBytes(2); // data_rate, num_ind_sub
// Read the first independent substream. // Read the first independent substream.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
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.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
...@@ -95,7 +96,7 @@ public final class Ac4Util { ...@@ -95,7 +96,7 @@ public final class Ac4Util {
* @return The AC-4 format parsed from data in the header. * @return The AC-4 format parsed from data in the header.
*/ */
public static Format parseAc4AnnexEFormat( public static Format parseAc4AnnexEFormat(
ParsableByteArray data, String trackId, String language, DrmInitData drmInitData) { ParsableByteArray data, String trackId, String language, @Nullable DrmInitData drmInitData) {
data.skipBytes(1); // ac4_dsi_version, bitstream_version[0:5] data.skipBytes(1); // ac4_dsi_version, bitstream_version[0:5]
int sampleRate = ((data.readUnsignedByte() & 0x20) >> 5 == 1) ? 48000 : 44100; int sampleRate = ((data.readUnsignedByte() & 0x20) >> 5 == 1) ? 48000 : 44100;
return Format.createAudioSampleFormat( return Format.createAudioSampleFormat(
......
...@@ -92,7 +92,7 @@ public final class AudioAttributes { ...@@ -92,7 +92,7 @@ public final class AudioAttributes {
public final @C.AudioFlags int flags; public final @C.AudioFlags int flags;
public final @C.AudioUsage int usage; public final @C.AudioUsage int usage;
private @Nullable android.media.AudioAttributes audioAttributesV21; @Nullable private android.media.AudioAttributes audioAttributesV21;
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags, private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
@C.AudioUsage int usage) { @C.AudioUsage int usage) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer2.audio; package com.google.android.exoplayer2.audio;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
...@@ -80,7 +81,7 @@ public final class DtsUtil { ...@@ -80,7 +81,7 @@ public final class DtsUtil {
* @return The DTS format parsed from data in the header. * @return The DTS format parsed from data in the header.
*/ */
public static Format parseDtsFormat( public static Format parseDtsFormat(
byte[] frame, String trackId, String language, DrmInitData drmInitData) { byte[] frame, String trackId, @Nullable String language, @Nullable DrmInitData drmInitData) {
ParsableBitArray frameBits = getNormalizedFrameHeader(frame); ParsableBitArray frameBits = getNormalizedFrameHeader(frame);
frameBits.skipBits(32 + 1 + 5 + 1 + 7 + 14); // SYNC, FTYPE, SHORT, CPF, NBLKS, FSIZE frameBits.skipBits(32 + 1 + 5 + 1 + 7 + 14); // SYNC, FTYPE, SHORT, CPF, NBLKS, FSIZE
int amode = frameBits.readBits(6); int amode = frameBits.readBits(6);
......
...@@ -300,8 +300,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -300,8 +300,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
} }
@Override @Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, protected int supportsFormat(
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format) MediaCodecSelector mediaCodecSelector,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
Format format)
throws DecoderQueryException { throws DecoderQueryException {
String mimeType = format.sampleMimeType; String mimeType = format.sampleMimeType;
if (!MimeTypes.isAudio(mimeType)) { if (!MimeTypes.isAudio(mimeType)) {
...@@ -386,7 +388,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -386,7 +388,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
MediaCodecInfo codecInfo, MediaCodecInfo codecInfo,
MediaCodec codec, MediaCodec codec,
Format format, Format format,
MediaCrypto crypto, @Nullable MediaCrypto crypto,
float codecOperatingRate) { float codecOperatingRate) {
codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats()); codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name); codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.audio;
import com.google.android.exoplayer2.util.NonNullApi;
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.database;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.decoder; package com.google.android.exoplayer2.decoder;
import androidx.annotation.Nullable;
/** /**
* A media decoder. * A media decoder.
* *
...@@ -37,6 +39,7 @@ public interface Decoder<I, O, E extends Exception> { ...@@ -37,6 +39,7 @@ public interface Decoder<I, O, E extends Exception> {
* @return The input buffer, which will have been cleared, or null if a buffer isn't available. * @return The input buffer, which will have been cleared, or null if a buffer isn't available.
* @throws E If a decoder error has occurred. * @throws E If a decoder error has occurred.
*/ */
@Nullable
I dequeueInputBuffer() throws E; I dequeueInputBuffer() throws E;
/** /**
...@@ -53,6 +56,7 @@ public interface Decoder<I, O, E extends Exception> { ...@@ -53,6 +56,7 @@ public interface Decoder<I, O, E extends Exception> {
* @return The output buffer, or null if an output buffer isn't available. * @return The output buffer, or null if an output buffer isn't available.
* @throws E If a decoder error has occurred. * @throws E If a decoder error has occurred.
*/ */
@Nullable
O dequeueOutputBuffer() throws E; O dequeueOutputBuffer() throws E;
/** /**
......
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
package com.google.android.exoplayer2.decoder; package com.google.android.exoplayer2.decoder;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
/** /**
* Holds input for a decoder. * Holds input for a decoder.
...@@ -58,10 +60,8 @@ public class DecoderInputBuffer extends Buffer { ...@@ -58,10 +60,8 @@ public class DecoderInputBuffer extends Buffer {
*/ */
public final CryptoInfo cryptoInfo; public final CryptoInfo cryptoInfo;
/** /** The buffer's data, or {@code null} if no data has been set. */
* The buffer's data, or {@code null} if no data has been set. @Nullable public ByteBuffer data;
*/
public ByteBuffer data;
/** /**
* The time at which the sample should be presented. * The time at which the sample should be presented.
...@@ -101,6 +101,7 @@ public class DecoderInputBuffer extends Buffer { ...@@ -101,6 +101,7 @@ public class DecoderInputBuffer extends Buffer {
* @throws IllegalStateException If there is insufficient capacity to accommodate the write and * @throws IllegalStateException If there is insufficient capacity to accommodate the write and
* the buffer replacement mode of the holder is {@link #BUFFER_REPLACEMENT_MODE_DISABLED}. * the buffer replacement mode of the holder is {@link #BUFFER_REPLACEMENT_MODE_DISABLED}.
*/ */
@EnsuresNonNull("data")
public void ensureSpaceForWrite(int length) { public void ensureSpaceForWrite(int length) {
if (data == null) { if (data == null) {
data = createReplacementByteBuffer(length); data = createReplacementByteBuffer(length);
......
...@@ -86,6 +86,7 @@ public abstract class SimpleDecoder< ...@@ -86,6 +86,7 @@ public abstract class SimpleDecoder<
} }
@Override @Override
@Nullable
public final I dequeueInputBuffer() throws E { public final I dequeueInputBuffer() throws E {
synchronized (lock) { synchronized (lock) {
maybeThrowException(); maybeThrowException();
...@@ -108,6 +109,7 @@ public abstract class SimpleDecoder< ...@@ -108,6 +109,7 @@ public abstract class SimpleDecoder<
} }
@Override @Override
@Nullable
public final O dequeueOutputBuffer() throws E { public final O dequeueOutputBuffer() throws E {
synchronized (lock) { synchronized (lock) {
maybeThrowException(); maybeThrowException();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer2.decoder; package com.google.android.exoplayer2.decoder;
import androidx.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
...@@ -25,7 +26,7 @@ public class SimpleOutputBuffer extends OutputBuffer { ...@@ -25,7 +26,7 @@ public class SimpleOutputBuffer extends OutputBuffer {
private final SimpleDecoder<?, SimpleOutputBuffer, ?> owner; private final SimpleDecoder<?, SimpleOutputBuffer, ?> owner;
public ByteBuffer data; @Nullable public ByteBuffer data;
public SimpleOutputBuffer(SimpleDecoder<?, SimpleOutputBuffer, ?> owner) { public SimpleOutputBuffer(SimpleDecoder<?, SimpleOutputBuffer, ?> owner) {
this.owner = owner; this.owner = owner;
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.decoder;
import com.google.android.exoplayer2.util.NonNullApi;
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.drm;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -452,12 +452,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -452,12 +452,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
* @param mediaCodecSelector The decoder selector. * @param mediaCodecSelector The decoder selector.
* @param drmSessionManager The renderer's {@link DrmSessionManager}. * @param drmSessionManager The renderer's {@link DrmSessionManager}.
* @param format The format. * @param format The format.
* @return The extent to which the renderer is capable of supporting the given format. See * @return The extent to which the renderer is capable of supporting the given format. See {@link
* {@link #supportsFormat(Format)} for more detail. * #supportsFormat(Format)} for more detail.
* @throws DecoderQueryException If there was an error querying decoders. * @throws DecoderQueryException If there was an error querying decoders.
*/ */
protected abstract int supportsFormat(MediaCodecSelector mediaCodecSelector, protected abstract int supportsFormat(
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format) MediaCodecSelector mediaCodecSelector,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
Format format)
throws DecoderQueryException; throws DecoderQueryException;
/** /**
...@@ -487,7 +489,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -487,7 +489,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
MediaCodecInfo codecInfo, MediaCodecInfo codecInfo,
MediaCodec codec, MediaCodec codec,
Format format, Format format,
MediaCrypto crypto, @Nullable MediaCrypto crypto,
float codecOperatingRate); float codecOperatingRate);
protected final void maybeInitCodec() throws ExoPlaybackException { protected final void maybeInitCodec() throws ExoPlaybackException {
......
...@@ -239,6 +239,7 @@ public final class MediaCodecUtil { ...@@ -239,6 +239,7 @@ public final class MediaCodecUtil {
* @return A pair (profile constant, level constant) if the codec of the {@code format} is * @return A pair (profile constant, level constant) if the codec of the {@code format} is
* well-formed and recognized, or null otherwise. * well-formed and recognized, or null otherwise.
*/ */
@Nullable
public static Pair<Integer, Integer> getCodecProfileAndLevel(Format format) { public static Pair<Integer, Integer> getCodecProfileAndLevel(Format format) {
if (format.codecs == null) { if (format.codecs == null) {
return null; return null;
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.mediacodec;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -29,7 +29,7 @@ public final class EventMessageDecoder implements MetadataDecoder { ...@@ -29,7 +29,7 @@ public final class EventMessageDecoder implements MetadataDecoder {
@SuppressWarnings("ByteBufferBackingArray") @SuppressWarnings("ByteBufferBackingArray")
@Override @Override
public Metadata decode(MetadataInputBuffer inputBuffer) { public Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data; ByteBuffer buffer = Assertions.checkNotNull(inputBuffer.data);
byte[] data = buffer.array(); byte[] data = buffer.array();
int size = buffer.limit(); int size = buffer.limit();
return new Metadata(decode(new ParsableByteArray(data, size))); return new Metadata(decode(new ParsableByteArray(data, size)));
......
...@@ -20,6 +20,7 @@ import androidx.annotation.VisibleForTesting; ...@@ -20,6 +20,7 @@ import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataDecoder; import com.google.android.exoplayer2.metadata.MetadataDecoder;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer; import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -39,7 +40,7 @@ public final class IcyDecoder implements MetadataDecoder { ...@@ -39,7 +40,7 @@ public final class IcyDecoder implements MetadataDecoder {
@Nullable @Nullable
@SuppressWarnings("ByteBufferBackingArray") @SuppressWarnings("ByteBufferBackingArray")
public Metadata decode(MetadataInputBuffer inputBuffer) { public Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data; ByteBuffer buffer = Assertions.checkNotNull(inputBuffer.data);
byte[] data = buffer.array(); byte[] data = buffer.array();
int length = buffer.limit(); int length = buffer.limit();
return decode(Util.fromUtf8Bytes(data, 0, length)); return decode(Util.fromUtf8Bytes(data, 0, length));
......
...@@ -20,6 +20,7 @@ import com.google.android.exoplayer2.C; ...@@ -20,6 +20,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataDecoder; import com.google.android.exoplayer2.metadata.MetadataDecoder;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer; import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.ParsableBitArray; import com.google.android.exoplayer2.util.ParsableBitArray;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
...@@ -99,7 +100,7 @@ public final class Id3Decoder implements MetadataDecoder { ...@@ -99,7 +100,7 @@ public final class Id3Decoder implements MetadataDecoder {
@Override @Override
@Nullable @Nullable
public Metadata decode(MetadataInputBuffer inputBuffer) { public Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data; ByteBuffer buffer = Assertions.checkNotNull(inputBuffer.data);
return decode(buffer.array(), buffer.limit()); return decode(buffer.array(), buffer.limit());
} }
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2;
import com.google.android.exoplayer2.util.NonNullApi;
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.scheduler;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -220,9 +220,9 @@ public final class SilenceMediaSource extends BaseMediaSource { ...@@ -220,9 +220,9 @@ public final class SilenceMediaSource extends BaseMediaSource {
int bytesToWrite = (int) Math.min(SILENCE_SAMPLE.length, bytesRemaining); int bytesToWrite = (int) Math.min(SILENCE_SAMPLE.length, bytesRemaining);
buffer.ensureSpaceForWrite(bytesToWrite); buffer.ensureSpaceForWrite(bytesToWrite);
buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
buffer.data.put(SILENCE_SAMPLE, /* offset= */ 0, bytesToWrite); buffer.data.put(SILENCE_SAMPLE, /* offset= */ 0, bytesToWrite);
buffer.timeUs = getAudioPositionUs(positionBytes); buffer.timeUs = getAudioPositionUs(positionBytes);
buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
positionBytes += bytesToWrite; positionBytes += bytesToWrite;
return C.RESULT_BUFFER_READ; return C.RESULT_BUFFER_READ;
} }
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.trackselection;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import androidx.annotation.NonNull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -189,12 +188,12 @@ public final class AtomicFile { ...@@ -189,12 +188,12 @@ public final class AtomicFile {
} }
@Override @Override
public void write(@NonNull byte[] b) throws IOException { public void write(byte[] b) throws IOException {
fileOutputStream.write(b); fileOutputStream.write(b);
} }
@Override @Override
public void write(@NonNull byte[] b, int off, int len) throws IOException { public void write(byte[] b, int off, int len) throws IOException {
fileOutputStream.write(b, off, len); fileOutputStream.write(b, off, len);
} }
} }
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.util; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.util;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import androidx.annotation.Nullable;
/** /**
* An interface to call through to a {@link Handler}. Instances must be created by calling {@link * An interface to call through to a {@link Handler}. Instances must be created by calling {@link
...@@ -32,13 +33,13 @@ public interface HandlerWrapper { ...@@ -32,13 +33,13 @@ public interface HandlerWrapper {
Message obtainMessage(int what); Message obtainMessage(int what);
/** @see Handler#obtainMessage(int, Object) */ /** @see Handler#obtainMessage(int, Object) */
Message obtainMessage(int what, Object obj); Message obtainMessage(int what, @Nullable Object obj);
/** @see Handler#obtainMessage(int, int, int) */ /** @see Handler#obtainMessage(int, int, int) */
Message obtainMessage(int what, int arg1, int arg2); Message obtainMessage(int what, int arg1, int arg2);
/** @see Handler#obtainMessage(int, int, int, Object) */ /** @see Handler#obtainMessage(int, int, int, Object) */
Message obtainMessage(int what, int arg1, int arg2, Object obj); Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj);
/** @see Handler#sendEmptyMessage(int) */ /** @see Handler#sendEmptyMessage(int) */
boolean sendEmptyMessage(int what); boolean sendEmptyMessage(int what);
...@@ -50,7 +51,7 @@ public interface HandlerWrapper { ...@@ -50,7 +51,7 @@ public interface HandlerWrapper {
void removeMessages(int what); void removeMessages(int what);
/** @see Handler#removeCallbacksAndMessages(Object) */ /** @see Handler#removeCallbacksAndMessages(Object) */
void removeCallbacksAndMessages(Object token); void removeCallbacksAndMessages(@Nullable Object token);
/** @see Handler#post(Runnable) */ /** @see Handler#post(Runnable) */
boolean post(Runnable runnable); boolean post(Runnable runnable);
......
...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.util; ...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.util;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import androidx.annotation.Nullable;
/** The standard implementation of {@link HandlerWrapper}. */ /** The standard implementation of {@link HandlerWrapper}. */
/* package */ final class SystemHandlerWrapper implements HandlerWrapper { /* package */ final class SystemHandlerWrapper implements HandlerWrapper {
...@@ -38,7 +39,7 @@ import android.os.Message; ...@@ -38,7 +39,7 @@ import android.os.Message;
} }
@Override @Override
public Message obtainMessage(int what, Object obj) { public Message obtainMessage(int what, @Nullable Object obj) {
return handler.obtainMessage(what, obj); return handler.obtainMessage(what, obj);
} }
...@@ -48,7 +49,7 @@ import android.os.Message; ...@@ -48,7 +49,7 @@ import android.os.Message;
} }
@Override @Override
public Message obtainMessage(int what, int arg1, int arg2, Object obj) { public Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj) {
return handler.obtainMessage(what, arg1, arg2, obj); return handler.obtainMessage(what, arg1, arg2, obj);
} }
...@@ -68,7 +69,7 @@ import android.os.Message; ...@@ -68,7 +69,7 @@ import android.os.Message;
} }
@Override @Override
public void removeCallbacksAndMessages(Object token) { public void removeCallbacksAndMessages(@Nullable Object token) {
handler.removeCallbacksAndMessages(token); handler.removeCallbacksAndMessages(token);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import android.net.Uri; import android.net.Uri;
import androidx.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
/** /**
...@@ -69,19 +70,19 @@ public final class UriUtil { ...@@ -69,19 +70,19 @@ public final class UriUtil {
* @param baseUri The base URI. * @param baseUri The base URI.
* @param referenceUri The reference URI to resolve. * @param referenceUri The reference URI to resolve.
*/ */
public static Uri resolveToUri(String baseUri, String referenceUri) { public static Uri resolveToUri(@Nullable String baseUri, @Nullable String referenceUri) {
return Uri.parse(resolve(baseUri, referenceUri)); return Uri.parse(resolve(baseUri, referenceUri));
} }
/** /**
* Performs relative resolution of a {@code referenceUri} with respect to a {@code baseUri}. * Performs relative resolution of a {@code referenceUri} with respect to a {@code baseUri}.
* <p> *
* The resolution is performed as specified by RFC-3986. * <p>The resolution is performed as specified by RFC-3986.
* *
* @param baseUri The base URI. * @param baseUri The base URI.
* @param referenceUri The reference URI to resolve. * @param referenceUri The reference URI to resolve.
*/ */
public static String resolve(String baseUri, String referenceUri) { public static String resolve(@Nullable String baseUri, @Nullable String referenceUri) {
StringBuilder uri = new StringBuilder(); StringBuilder uri = new StringBuilder();
// Map null onto empty string, to make the following logic simpler. // Map null onto empty string, to make the following logic simpler.
......
...@@ -252,14 +252,14 @@ public final class Util { ...@@ -252,14 +252,14 @@ public final class Util {
/** /**
* Tests whether an {@code items} array contains an object equal to {@code item}, according to * Tests whether an {@code items} array contains an object equal to {@code item}, according to
* {@link Object#equals(Object)}. * {@link Object#equals(Object)}.
* <p> *
* If {@code item} is null then true is returned if and only if {@code items} contains null. * <p>If {@code item} is null then true is returned if and only if {@code items} contains null.
* *
* @param items The array of items to search. * @param items The array of items to search.
* @param item The item to search for. * @param item The item to search for.
* @return True if the array contains an object equal to the item being searched for. * @return True if the array contains an object equal to the item being searched for.
*/ */
public static boolean contains(Object[] items, Object item) { public static boolean contains(@NullableType Object[] items, @Nullable Object item) {
for (Object arrayItem : items) { for (Object arrayItem : items) {
if (areEqual(arrayItem, item)) { if (areEqual(arrayItem, item)) {
return true; return true;
...@@ -1486,7 +1486,7 @@ public final class Util { ...@@ -1486,7 +1486,7 @@ public final class Util {
* @return The content type. * @return The content type.
*/ */
@C.ContentType @C.ContentType
public static int inferContentType(Uri uri, String overrideExtension) { public static int inferContentType(Uri uri, @Nullable String overrideExtension) {
return TextUtils.isEmpty(overrideExtension) return TextUtils.isEmpty(overrideExtension)
? inferContentType(uri) ? inferContentType(uri)
: inferContentType("." + overrideExtension); : inferContentType("." + overrideExtension);
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.util;
...@@ -308,8 +308,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -308,8 +308,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
} }
@Override @Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, protected int supportsFormat(
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format) MediaCodecSelector mediaCodecSelector,
@Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
Format format)
throws DecoderQueryException { throws DecoderQueryException {
String mimeType = format.sampleMimeType; String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) { if (!MimeTypes.isVideo(mimeType)) {
...@@ -601,7 +603,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { ...@@ -601,7 +603,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
MediaCodecInfo codecInfo, MediaCodecInfo codecInfo,
MediaCodec codec, MediaCodec codec,
Format format, Format format,
MediaCrypto crypto, @Nullable MediaCrypto crypto,
float codecOperatingRate) { float codecOperatingRate) {
String codecMimeType = codecInfo.codecMimeType; String codecMimeType = codecInfo.codecMimeType;
codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats()); codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
......
...@@ -544,9 +544,10 @@ public abstract class SimpleDecoderVideoRenderer extends BaseRenderer { ...@@ -544,9 +544,10 @@ public abstract class SimpleDecoderVideoRenderer extends BaseRenderer {
/** /**
* Dequeues output buffer. * Dequeues output buffer.
* *
* @return Dequeued video decoder output buffer. * @return Dequeued video decoder output buffer, or null if an output buffer isn't available.
* @throws VideoDecoderException If an error occurs while dequeuing the output buffer. * @throws VideoDecoderException If an error occurs while dequeuing the output buffer.
*/ */
@Nullable
protected abstract VideoDecoderOutputBuffer dequeueOutputBuffer() throws VideoDecoderException; protected abstract VideoDecoderOutputBuffer dequeueOutputBuffer() throws VideoDecoderException;
/** Clears output buffer. */ /** Clears output buffer. */
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.video;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -93,7 +93,7 @@ public class CameraMotionRenderer extends BaseRenderer { ...@@ -93,7 +93,7 @@ public class CameraMotionRenderer extends BaseRenderer {
buffer.flip(); buffer.flip();
lastTimestampUs = buffer.timeUs; lastTimestampUs = buffer.timeUs;
if (listener != null) { if (listener != null) {
float[] rotation = parseMetadata(buffer.data); float[] rotation = parseMetadata(Util.castNonNull(buffer.data));
if (rotation != null) { if (rotation != null) {
Util.castNonNull(listener).onCameraMotion(lastTimestampUs - offsetUs, rotation); Util.castNonNull(listener).onCameraMotion(lastTimestampUs - offsetUs, rotation);
} }
......
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.video.spherical;
import com.google.android.exoplayer2.util.NonNullApi;
...@@ -115,9 +115,9 @@ import java.io.IOException; ...@@ -115,9 +115,9 @@ import java.io.IOException;
byte[] serializedEvent = eventMessageEncoder.encode(eventStream.events[sampleIndex]); byte[] serializedEvent = eventMessageEncoder.encode(eventStream.events[sampleIndex]);
if (serializedEvent != null) { if (serializedEvent != null) {
buffer.ensureSpaceForWrite(serializedEvent.length); buffer.ensureSpaceForWrite(serializedEvent.length);
buffer.setFlags(C.BUFFER_FLAG_KEY_FRAME);
buffer.data.put(serializedEvent); buffer.data.put(serializedEvent);
buffer.timeUs = eventTimesUs[sampleIndex]; buffer.timeUs = eventTimesUs[sampleIndex];
buffer.setFlags(C.BUFFER_FLAG_KEY_FRAME);
return C.RESULT_BUFFER_READ; return C.RESULT_BUFFER_READ;
} else { } else {
return C.RESULT_NOTHING_READ; return C.RESULT_NOTHING_READ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment