@@ -0,0 +1,3200 @@
+/*%0A * Copyright (C) 2014 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.exoplayer.chunk;%0A%0Aimport com.google.android.exoplayer.MediaFormat;%0Aimport com.google.android.exoplayer.TrackInfo;%0Aimport com.google.android.exoplayer.upstream.DataSource;%0Aimport com.google.android.exoplayer.upstream.DataSpec;%0A%0Aimport java.io.IOException;%0Aimport java.util.List;%0A%0A/**%0A * A chunk source that provides a single chunk containing a single sample.%0A * %3Cp%3E%0A * An example use case for this implementation is to act as the source for loading out-of-band%0A * subtitles, where subtitles for the entire video are delivered as a single file.%0A */%0Apublic class SingleSampleChunkSource implements ChunkSource %7B%0A%0A  private final DataSource dataSource;%0A  private final DataSpec dataSpec;%0A  private final Format format;%0A  private final long durationUs;%0A  private final MediaFormat mediaFormat;%0A  private final TrackInfo trackInfo;%0A%0A  /**%0A   * @param dataSource A %7B@link DataSource%7D suitable for loading the sample data.%0A   * @param dataSpec Defines the location of the sample.%0A   * @param format The format of the sample.%0A   * @param durationUs The duration of the sample in microseconds.%0A   * @param mediaFormat The sample media format. May be null.%0A   */%0A  public SingleSampleChunkSource(DataSource dataSource, DataSpec dataSpec, Format format,%0A      long durationUs, MediaFormat mediaFormat) %7B%0A    this.dataSource = dataSource;%0A    this.dataSpec = dataSpec;%0A    this.format = format;%0A    this.durationUs = durationUs;%0A    this.mediaFormat = mediaFormat;%0A    trackInfo = new TrackInfo(format.mimeType, durationUs);%0A  %7D%0A%0A  @Override%0A  public TrackInfo getTrackInfo() %7B%0A    return trackInfo;%0A  %7D%0A%0A  @Override%0A  public void getMaxVideoDimensions(MediaFormat out) %7B%0A    // Do nothing.%0A  %7D%0A%0A  @Override%0A  public void enable() %7B%0A    // Do nothing.%0A  %7D%0A%0A  @Override%0A  public void continueBuffering(long playbackPositionUs) %7B%0A    // Do nothing.%0A  %7D%0A%0A  @Override%0A  public void getChunkOperation(List%3C? extends MediaChunk%3E queue, long seekPositionUs,%0A      long playbackPositionUs, ChunkOperationHolder out) %7B%0A    if (!queue.isEmpty()) %7B%0A      // We've already provided the single sample.%0A      return;%0A    %7D%0A    out.chunk = initChunk();%0A  %7D%0A%0A  @Override%0A  public void disable(List%3C? extends MediaChunk%3E queue) %7B%0A    // Do nothing.%0A  %7D%0A%0A  @Override%0A  public IOException getError() %7B%0A    return null;%0A  %7D%0A%0A  @Override%0A  public void onChunkLoadError(Chunk chunk, Exception e) %7B%0A    // Do nothing.%0A  %7D%0A%0A  private SingleSampleMediaChunk initChunk() %7B%0A    return new SingleSampleMediaChunk(dataSource, dataSpec, format, 0, 0, durationUs, -1,%0A        mediaFormat);%0A  %7D%0A%0A%7D%0A

Add class to enable loading of out-of-band subtitle files.