Clean up irrelevant TODO items.

PiperOrigin-RevId: 380176846
This commit is contained in:
claincly 2021-06-18 14:50:18 +01:00 committed by Oliver Woodman
parent fc1d3dd192
commit b8c315f448
10 changed files with 27 additions and 40 deletions

View File

@ -232,7 +232,6 @@ import java.lang.annotation.RetentionPolicy;
public final int bitrate; public final int bitrate;
/** The assigned media title. */ /** The assigned media title. */
@Nullable public final String mediaTitle; @Nullable public final String mediaTitle;
// TODO(internal b/172331505) Parse the String representations into objects.
/** The connection parameters. */ /** The connection parameters. */
@Nullable public final String connection; @Nullable public final String connection;
/** The encryption parameter. */ /** The encryption parameter. */

View File

@ -106,15 +106,15 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override @Override
public boolean sniff(ExtractorInput input) { public boolean sniff(ExtractorInput input) {
// TODO(b/172331505) Build sniff support. throw new UnsupportedOperationException(
return false; "RTP packets are transmitted in a packet stream do not support sniffing.");
} }
@Override @Override
public void init(ExtractorOutput output) { public void init(ExtractorOutput output) {
payloadReader.createTracks(output, trackId); payloadReader.createTracks(output, trackId);
output.endTracks(); output.endTracks();
// TODO(b/172331505) replace hardcoded unseekable seekmap. // RTP does not embed duration or seek info.
output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET)); output.seekMap(new SeekMap.Unseekable(C.TIME_UNSET));
this.output = output; this.output = output;
} }

View File

@ -36,8 +36,10 @@ import java.util.TreeSet;
private static final int MAX_SEQUENCE_NUMBER = RtpPacket.MAX_SEQUENCE_NUMBER; private static final int MAX_SEQUENCE_NUMBER = RtpPacket.MAX_SEQUENCE_NUMBER;
/** Queue size threshold for resetting the queue. 5000 packets equate about 7MB in buffer size. */
private static final int QUEUE_SIZE_THRESHOLD_FOR_RESET = 5000;
// Use set to eliminate duplicating packets. // Use set to eliminate duplicating packets.
// TODO(b/172331505) Set a upper limit on packetQueue to mitigate out of memory error.
@GuardedBy("this") @GuardedBy("this")
private final TreeSet<RtpPacketContainer> packetQueue; private final TreeSet<RtpPacketContainer> packetQueue;
@ -86,6 +88,11 @@ import java.util.TreeSet;
* returns {@code true}). * returns {@code true}).
*/ */
public synchronized boolean offer(RtpPacket packet, long receivedTimestampMs) { public synchronized boolean offer(RtpPacket packet, long receivedTimestampMs) {
if (packetQueue.size() >= QUEUE_SIZE_THRESHOLD_FOR_RESET) {
throw new IllegalStateException(
"Queue size limit of " + QUEUE_SIZE_THRESHOLD_FOR_RESET + " reached.");
}
int packetSequenceNumber = packet.sequenceNumber; int packetSequenceNumber = packet.sequenceNumber;
if (!started) { if (!started) {
reset(); reset();

View File

@ -420,12 +420,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override @Override
public void endTracks() { public void endTracks() {
// TODO(b/172331505) Implement this method. handler.post(RtspMediaPeriod.this::maybeFinishPrepare);
} }
@Override @Override
public void seekMap(SeekMap seekMap) { public void seekMap(SeekMap seekMap) {
// TODO(b/172331505) Implement this method. // RTSP does not support seek map.
} }
// Loadable.Callback implementation. // Loadable.Callback implementation.
@ -445,16 +445,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
long loadDurationMs, long loadDurationMs,
IOException error, IOException error,
int errorCount) { int errorCount) {
/* TODO(b/172331505) Sort out the retry policy.
Three cases for IOException:
- Socket open failure for RTP or RTCP.
- RETRY for the RTCP open failure.
- ExtractorInput read IOException (socket timeout, etc)
- Keep retrying unless playback is stopped.
- RtpPayloadReader consume ParserException (mal-formatted RTP packet)
- Don't retry? (if a packet is distorted on the fly, the packet is likely discarded by the
system, i.e. the server's sent a mal-formatted packet).
*/
if (!prepared) { if (!prepared) {
preparationError = error; preparationError = error;
} else { } else {

View File

@ -279,7 +279,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override @Override
public void load() throws IOException { public void load() throws IOException {
while (!loadCanceled) { while (!loadCanceled) {
// TODO(internal b/172331505) Use a buffered read.
byte firstByte = dataInputStream.readByte(); byte firstByte = dataInputStream.readByte();
if (firstByte == INTERLEAVED_MESSAGE_MARKER) { if (firstByte == INTERLEAVED_MESSAGE_MARKER) {
handleInterleavedBinaryData(); handleInterleavedBinaryData();

View File

@ -19,8 +19,6 @@ import com.google.common.collect.ImmutableList;
import java.util.List; import java.util.List;
/** Represents an RTSP OPTIONS response. */ /** Represents an RTSP OPTIONS response. */
// TODO(b/180434754) Move all classes under message to the parent rtsp package, and change the
// visibility.
/* package */ final class RtspOptionsResponse { /* package */ final class RtspOptionsResponse {
/** The response's status code. */ /** The response's status code. */
public final int status; public final int status;

View File

@ -18,9 +18,6 @@ package com.google.android.exoplayer2.source.rtsp;
/** Represents an RTSP Response. */ /** Represents an RTSP Response. */
/* package */ final class RtspResponse { /* package */ final class RtspResponse {
// TODO(b/172331505) Move this constant to MimeTypes.
/** The MIME type associated with Session Description Protocol (RFC4566). */
public static final String SDP_MIME_TYPE = "application/sdp";
/** The status code of this response, as defined in RFC 2326 section 11. */ /** The status code of this response, as defined in RFC 2326 section 11. */
public final int status; public final int status;

View File

@ -16,8 +16,6 @@
package com.google.android.exoplayer2.source.rtsp; package com.google.android.exoplayer2.source.rtsp;
/** Represents an RTSP SETUP response. */ /** Represents an RTSP SETUP response. */
// TODO(b/180434754) Move all classes under message to the parent rtsp package, and change the
// visibility.
/* package */ final class RtspSetupResponse { /* package */ final class RtspSetupResponse {
/** The response's status code. */ /** The response's status code. */

View File

@ -237,7 +237,6 @@ import com.google.common.collect.ImmutableMap;
public final ImmutableList<MediaDescription> mediaDescriptionList; public final ImmutableList<MediaDescription> mediaDescriptionList;
/** The name of a session. */ /** The name of a session. */
public final String sessionName; public final String sessionName;
// TODO(internal b/172331505) Parse the String representations into objects.
/** The origin sender info. */ /** The origin sender info. */
public final String origin; public final String origin;
/** The timing info. */ /** The timing info. */

View File

@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer2.source.rtsp.reader; package com.google.android.exoplayer2.source.rtsp.reader;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull; import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import static com.google.android.exoplayer2.util.Util.castNonNull; import static com.google.android.exoplayer2.util.Util.castNonNull;
@ -35,10 +36,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/* package */ final class RtpH264Reader implements RtpPayloadReader { /* package */ final class RtpH264Reader implements RtpPayloadReader {
private static final String TAG = "RtpH264Reader"; private static final String TAG = "RtpH264Reader";
// TODO(b/172331505) Move NAL related constants to NalUnitUtil.
private static final ParsableByteArray NAL_START_CODE =
new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
private static final int NAL_START_CODE_LENGTH = NalUnitUtil.NAL_START_CODE.length;
private static final long MEDIA_CLOCK_FREQUENCY = 90_000; private static final long MEDIA_CLOCK_FREQUENCY = 90_000;
/** Offset of payload data within a FU type A payload. */ /** Offset of payload data within a FU type A payload. */
@ -55,6 +52,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** Scratch for Fragmentation Unit RTP packets. */ /** Scratch for Fragmentation Unit RTP packets. */
private final ParsableByteArray fuScratchBuffer; private final ParsableByteArray fuScratchBuffer;
private final ParsableByteArray nalStartCodeArray =
new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
private final RtpPayloadFormat payloadFormat; private final RtpPayloadFormat payloadFormat;
private @MonotonicNonNull TrackOutput trackOutput; private @MonotonicNonNull TrackOutput trackOutput;
@ -160,7 +160,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
int numBytesInData = data.bytesLeft(); int numBytesInData = data.bytesLeft();
fragmentedSampleSizeBytes += writeStartCode(trackOutput); fragmentedSampleSizeBytes += writeStartCode();
trackOutput.sampleData(data, numBytesInData); trackOutput.sampleData(data, numBytesInData);
fragmentedSampleSizeBytes += numBytesInData; fragmentedSampleSizeBytes += numBytesInData;
@ -203,13 +203,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
int nalUnitLength; int nalUnitLength;
while (data.bytesLeft() > 4) { while (data.bytesLeft() > 4) {
nalUnitLength = data.readUnsignedShort(); nalUnitLength = data.readUnsignedShort();
fragmentedSampleSizeBytes += writeStartCode(trackOutput); fragmentedSampleSizeBytes += writeStartCode();
trackOutput.sampleData(data, nalUnitLength); trackOutput.sampleData(data, nalUnitLength);
fragmentedSampleSizeBytes += nalUnitLength; fragmentedSampleSizeBytes += nalUnitLength;
} }
// Treat Aggregated NAL units as non key frames. // Treat Aggregated NAL units as non key frames.
// TODO(internal b/172331505) examine whether STAP mode carries keyframes.
bufferFlags = 0; bufferFlags = 0;
} }
@ -252,7 +251,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
if (isFirstFuPacket) { if (isFirstFuPacket) {
// Prepends starter code. // Prepends starter code.
fragmentedSampleSizeBytes += writeStartCode(trackOutput); fragmentedSampleSizeBytes += writeStartCode();
// The bytes needed is 1 (NALU header) + payload size. The original data array has size 2 (FU // The bytes needed is 1 (NALU header) + payload size. The original data array has size 2 (FU
// indicator/header) + payload size. Thus setting the correct header and set position to 1. // indicator/header) + payload size. Thus setting the correct header and set position to 1.
@ -286,6 +285,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
} }
} }
private int writeStartCode() {
nalStartCodeArray.setPosition(/* position= */ 0);
int bytesWritten = nalStartCodeArray.bytesLeft();
checkNotNull(trackOutput).sampleData(nalStartCodeArray, bytesWritten);
return bytesWritten;
}
private static long toSampleUs( private static long toSampleUs(
long startTimeOffsetUs, long rtpTimestamp, long firstReceivedRtpTimestamp) { long startTimeOffsetUs, long rtpTimestamp, long firstReceivedRtpTimestamp) {
return startTimeOffsetUs return startTimeOffsetUs
@ -295,12 +301,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/* divisor= */ MEDIA_CLOCK_FREQUENCY); /* divisor= */ MEDIA_CLOCK_FREQUENCY);
} }
private static int writeStartCode(TrackOutput trackOutput) {
trackOutput.sampleData(NAL_START_CODE, NAL_START_CODE_LENGTH);
NAL_START_CODE.setPosition(/* position= */ 0);
return NAL_START_CODE_LENGTH;
}
@C.BufferFlags @C.BufferFlags
private static int getBufferFlagsFromNalType(int nalType) { private static int getBufferFlagsFromNalType(int nalType) {
return nalType == NAL_UNIT_TYPE_IDR ? C.BUFFER_FLAG_KEY_FRAME : 0; return nalType == NAL_UNIT_TYPE_IDR ? C.BUFFER_FLAG_KEY_FRAME : 0;