From 800006d08d25651bdde2b19fec9b15a04797dca2 Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 27 May 2016 05:11:14 -0700 Subject: [PATCH] Remove TODOs that we have little urge to actually do. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123410274 --- .../exoplayer/demo/TestMediaDrmCallback.java | 44 ++++++++++++++++- .../android/exoplayer/MediaCodecUtil.java | 2 - .../MediaCodecVideoTrackRenderer.java | 2 - .../android/exoplayer/chunk/ChunkSource.java | 5 -- .../exoplayer/dash/DashSegmentIndex.java | 2 - .../MediaPresentationDescriptionParser.java | 2 - .../extractor/DefaultTrackOutput.java | 6 +-- .../exoplayer/extractor/ts/SeiReader.java | 2 - .../google/android/exoplayer/util/Util.java | 48 ------------------- 9 files changed, 45 insertions(+), 68 deletions(-) diff --git a/demo/src/main/java/com/google/android/exoplayer/demo/TestMediaDrmCallback.java b/demo/src/main/java/com/google/android/exoplayer/demo/TestMediaDrmCallback.java index 16e6dad89e..744ff04ad5 100644 --- a/demo/src/main/java/com/google/android/exoplayer/demo/TestMediaDrmCallback.java +++ b/demo/src/main/java/com/google/android/exoplayer/demo/TestMediaDrmCallback.java @@ -24,6 +24,10 @@ import android.media.MediaDrm.ProvisionRequest; import android.text.TextUtils; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -66,7 +70,7 @@ import java.util.UUID; @Override public byte[] executeProvisionRequest(UUID uuid, ProvisionRequest request) throws IOException { String url = request.getDefaultUrl() + "&signedRequest=" + new String(request.getData()); - return Util.executePost(url, null, null); + return executePost(url, null, null); } @Override @@ -75,7 +79,43 @@ import java.util.UUID; if (TextUtils.isEmpty(url)) { url = defaultUrl; } - return Util.executePost(url, request.getData(), keyRequestProperties); + return executePost(url, request.getData(), keyRequestProperties); + } + + private static byte[] executePost(String url, byte[] data, Map requestProperties) + throws IOException { + HttpURLConnection urlConnection = null; + try { + urlConnection = (HttpURLConnection) new URL(url).openConnection(); + urlConnection.setRequestMethod("POST"); + urlConnection.setDoOutput(data != null); + urlConnection.setDoInput(true); + if (requestProperties != null) { + for (Map.Entry requestProperty : requestProperties.entrySet()) { + urlConnection.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); + } + } + // Write the request body, if there is one. + if (data != null) { + OutputStream out = urlConnection.getOutputStream(); + try { + out.write(data); + } finally { + out.close(); + } + } + // Read and return the response body. + InputStream inputStream = urlConnection.getInputStream(); + try { + return Util.toByteArray(inputStream); + } finally { + inputStream.close(); + } + } finally { + if (urlConnection != null) { + urlConnection.disconnect(); + } + } } } diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java index 95722d28a4..6f2ac3beca 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java @@ -127,8 +127,6 @@ public final class MediaCodecUtil { if (secure && decoderInfos.isEmpty() && 21 <= Util.SDK_INT && Util.SDK_INT <= 23) { // Some devices don't list secure decoders on API level 21 [Internal: b/18678462]. Try the // legacy path. We also try this path on API levels 22 and 23 as a defensive measure. - // TODO: Verify that the issue cannot occur on API levels 22 and 23, and tighten this block - // to execute on API level 21 only if confirmed. mediaCodecList = new MediaCodecListCompatV16(); decoderInfos = getDecoderInfosInternal(key, mediaCodecList); if (!decoderInfos.isEmpty()) { diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java index 044bc28831..f3066e9847 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java @@ -194,8 +194,6 @@ public class MediaCodecVideoTrackRenderer extends MediaCodecTrackRenderer { decoderCapable = decoderInfo.isVideoSizeSupportedV21(format.width, format.height); } } else { - // TODO[REFACTOR]: We should probably assume that we can decode at least the resolution of - // the display, or the camera, as a sanity check? decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize(); } } else { diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java index 05177644a0..528c3557d1 100644 --- a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSource.java @@ -21,11 +21,6 @@ import java.util.List; /** * A provider of {@link Chunk}s for a {@link ChunkTrackStream} to load. */ -/* - * TODO: Share more state between this interface and {@link ChunkSampleSource}. In particular - * implementations of this class needs to know about errors, and should be more tightly integrated - * into the process of resuming loading of a chunk after an error occurs. - */ public interface ChunkSource { /** diff --git a/library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java b/library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java index d2453f03ef..2625a0188f 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java @@ -20,8 +20,6 @@ import com.google.android.exoplayer.dash.mpd.RangedUri; /** * Indexes the segments within a media stream. - * - * TODO: Generalize to cover all chunk streaming modes (e.g. SmoothStreaming) if possible. */ public interface DashSegmentIndex { diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java index 8a9d58b902..7ac3a665cd 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java @@ -75,8 +75,6 @@ public class MediaPresentationDescriptionParser extends DefaultHandler /** * @param contentId An optional content identifier to include in the parsed manifest. */ - // TODO: Remove the need to inject a content identifier here, by not including it in the parsed - // manifest. Instead, it should be injected directly where needed (i.e. DashChunkSource). public MediaPresentationDescriptionParser(String contentId) { this.contentId = contentId; try { diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java b/library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java index 85dcc62742..9c52451273 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java @@ -355,7 +355,6 @@ public final class DefaultTrackOutput implements TrackOutput { * @param target The array into which data should be written. * @param length The number of bytes to read. */ - // TODO: Consider reducing duplication of this method and the one above. private void readData(long absolutePosition, byte[] target, int length) { int bytesRead = 0; while (bytesRead < length) { @@ -713,8 +712,9 @@ public final class DefaultTrackOutput implements TrackOutput { return -1; } - // TODO: This can be optimized further using binary search, although the fact that the array - // is cyclic means we'd need to implement the binary search ourselves. + // This could be optimized to use a binary search, however in practice callers to this method + // often pass times near to the start of the buffer. Hence it's unclear whether switching to + // a binary search would yield any real benefit. int sampleCount = 0; int sampleCountToKeyframe = -1; int searchIndex = relativeReadIndex; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java index ef177acafe..165ce08122 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java @@ -25,8 +25,6 @@ import com.google.android.exoplayer.util.ParsableByteArray; /** * Consumes SEI buffers, outputting contained EIA608 messages to a {@link TrackOutput}. */ -// TODO: Technically, we shouldn't allow a sample to be read from the queue until we're sure that -// a sample with an earlier timestamp won't be added to it. /* package */ final class SeiReader { private final TrackOutput output; diff --git a/library/src/main/java/com/google/android/exoplayer/util/Util.java b/library/src/main/java/com/google/android/exoplayer/util/Util.java index faf9ecee5a..cbcb9f6714 100644 --- a/library/src/main/java/com/google/android/exoplayer/util/Util.java +++ b/library/src/main/java/com/google/android/exoplayer/util/Util.java @@ -36,7 +36,6 @@ import java.io.OutputStream; import java.lang.reflect.Method; import java.math.BigDecimal; import java.net.HttpURLConnection; -import java.net.URL; import java.text.ParseException; import java.util.Arrays; import java.util.Calendar; @@ -44,7 +43,6 @@ import java.util.Collections; import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.TimeZone; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -731,52 +729,6 @@ public final class Util { + ") " + "ExoPlayerLib/" + ExoPlayerLibraryInfo.VERSION; } - /** - * Executes a post request using {@link HttpURLConnection}. - * - * @param url The request URL. - * @param data The request body, or null. - * @param requestProperties Request properties, or null. - * @return The response body. - * @throws IOException If an error occurred making the request. - */ - // TODO: Remove this and use HttpDataSource once DataSpec supports inclusion of a POST body. - public static byte[] executePost(String url, byte[] data, Map requestProperties) - throws IOException { - HttpURLConnection urlConnection = null; - try { - urlConnection = (HttpURLConnection) new URL(url).openConnection(); - urlConnection.setRequestMethod("POST"); - urlConnection.setDoOutput(data != null); - urlConnection.setDoInput(true); - if (requestProperties != null) { - for (Map.Entry requestProperty : requestProperties.entrySet()) { - urlConnection.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); - } - } - // Write the request body, if there is one. - if (data != null) { - OutputStream out = urlConnection.getOutputStream(); - try { - out.write(data); - } finally { - out.close(); - } - } - // Read and return the response body. - InputStream inputStream = urlConnection.getInputStream(); - try { - return toByteArray(inputStream); - } finally { - inputStream.close(); - } - } finally { - if (urlConnection != null) { - urlConnection.disconnect(); - } - } - } - /** * Converts a sample bit depth to a corresponding PCM encoding constant. *