@@ -0,0 +1,2692 @@
+/*%0A * Copyright (C) 2018 The Android Open Source Project%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.google.android.exoplayer2.source.hls.playlist;%0A%0Aimport android.net.Uri;%0Aimport com.google.android.exoplayer2.source.chunk.BaseMediaChunkIterator;%0Aimport com.google.android.exoplayer2.source.chunk.MediaChunkIterator;%0Aimport com.google.android.exoplayer2.upstream.DataSpec;%0Aimport com.google.android.exoplayer2.util.UriUtil;%0A%0A/** %7B@link MediaChunkIterator%7D wrapping a %7B@link HlsMediaPlaylist%7D. */%0Apublic final class HlsMediaPlaylistSegmentIterator extends BaseMediaChunkIterator %7B%0A%0A  private final HlsMediaPlaylist playlist;%0A  private final long startOfPlaylistInPeriodUs;%0A%0A  /**%0A   * Creates iterator.%0A   *%0A   * @param playlist The %7B@link HlsMediaPlaylist%7D to wrap.%0A   * @param startOfPlaylistInPeriodUs The start time of the playlist in the period, in microseconds.%0A   * @param chunkIndex The chunk index in the playlist at which the iterator will start.%0A   */%0A  public HlsMediaPlaylistSegmentIterator(%0A      HlsMediaPlaylist playlist, long startOfPlaylistInPeriodUs, int chunkIndex) %7B%0A    super(/* fromIndex= */ chunkIndex, /* toIndex= */ playlist.segments.size() - 1);%0A    this.playlist = playlist;%0A    this.startOfPlaylistInPeriodUs = startOfPlaylistInPeriodUs;%0A  %7D%0A%0A  @Override%0A  public DataSpec getDataSpec() %7B%0A    checkInBounds();%0A    HlsMediaPlaylist.Segment segment = playlist.segments.get((int) getCurrentIndex());%0A    Uri chunkUri = UriUtil.resolveToUri(playlist.baseUri, segment.url);%0A    return new DataSpec(%0A        chunkUri, segment.byterangeOffset, segment.byterangeLength, /* key= */ null);%0A  %7D%0A%0A  @Override%0A  public long getChunkStartTimeUs() %7B%0A    checkInBounds();%0A    HlsMediaPlaylist.Segment segment = playlist.segments.get((int) getCurrentIndex());%0A    return startOfPlaylistInPeriodUs + segment.relativeStartTimeUs;%0A  %7D%0A%0A  @Override%0A  public long getChunkEndTimeUs() %7B%0A    checkInBounds();%0A    HlsMediaPlaylist.Segment segment = playlist.segments.get((int) getCurrentIndex());%0A    long segmentStartTimeInPeriodUs = startOfPlaylistInPeriodUs + segment.relativeStartTimeUs;%0A    return segmentStartTimeInPeriodUs + segment.durationUs;%0A  %7D%0A%7D%0A

Add MediaChunkIterator for HLS media playlists.