com.google.android.exoplayer2.source.dash.manifest.RangedUri Java Examples

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.RangedUri. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
protected Chunk newInitializationChunk(
    RepresentationHolder representationHolder,
    DataSource dataSource,
    Format trackFormat,
    int trackSelectionReason,
    Object trackSelectionData,
    RangedUri initializationUri,
    RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #2
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
protected Chunk newInitializationChunk(
    RepresentationHolder representationHolder,
    DataSource dataSource,
    Format trackFormat,
    int trackSelectionReason,
    Object trackSelectionData,
    RangedUri initializationUri,
    RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #3
Source File: DefaultDashChunkSource.java    From K-Sonic with MIT License 6 votes vote down vote up
private static Chunk newInitializationChunk(RepresentationHolder representationHolder,
    DataSource dataSource, Format trackFormat, int trackSelectionReason,
    Object trackSelectionData, RangedUri initializationUri, RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #4
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected Chunk newInitializationChunk(
    RepresentationHolder representationHolder,
    DataSource dataSource,
    Format trackFormat,
    int trackSelectionReason,
    Object trackSelectionData,
    RangedUri initializationUri,
    RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #5
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
protected Chunk newInitializationChunk(
    RepresentationHolder representationHolder,
    DataSource dataSource,
    Format trackFormat,
    int trackSelectionReason,
    Object trackSelectionData,
    RangedUri initializationUri,
    RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #6
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
protected Chunk newInitializationChunk(
    RepresentationHolder representationHolder,
    DataSource dataSource,
    Format trackFormat,
    int trackSelectionReason,
    Object trackSelectionData,
    RangedUri initializationUri,
    RangedUri indexUri) {
  RangedUri requestUri;
  String baseUrl = representationHolder.representation.baseUrl;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, baseUrl);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(baseUrl), requestUri.start,
      requestUri.length, representationHolder.representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trackFormat,
      trackSelectionReason, trackSelectionData, representationHolder.extractorWrapper);
}
 
Example #7
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #8
Source File: DashUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then
 * returns a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static ChunkExtractorWrapper loadInitializationData(DataSource dataSource,
    Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #9
Source File: DashUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #10
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DataSpec getDataSpec() {
  checkInBounds();
  Representation representation = representationHolder.representation;
  RangedUri segmentUri = representationHolder.getSegmentUrl(getCurrentIndex());
  Uri resolvedUri = segmentUri.resolveUri(representation.baseUrl);
  String cacheKey = representation.getCacheKey();
  return new DataSpec(resolvedUri, segmentUri.start, segmentUri.length, cacheKey);
}
 
Example #11
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #12
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static @Nullable ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #13
Source File: DashUtil.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static @Nullable ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #14
Source File: DashUtil.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #15
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DataSpec getDataSpec() {
  checkInBounds();
  Representation representation = representationHolder.representation;
  RangedUri segmentUri = representationHolder.getSegmentUrl(getCurrentIndex());
  Uri resolvedUri = segmentUri.resolveUri(representation.baseUrl);
  String cacheKey = representation.getCacheKey();
  return new DataSpec(resolvedUri, segmentUri.start, segmentUri.length, cacheKey);
}
 
Example #16
Source File: DashUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static @Nullable ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #17
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DataSpec getDataSpec() {
  checkInBounds();
  Representation representation = representationHolder.representation;
  RangedUri segmentUri = representationHolder.getSegmentUrl(getCurrentIndex());
  Uri resolvedUri = segmentUri.resolveUri(representation.baseUrl);
  String cacheKey = representation.getCacheKey();
  return new DataSpec(resolvedUri, segmentUri.start, segmentUri.length, cacheKey);
}
 
Example #18
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DataSpec getDataSpec() {
  checkInBounds();
  Representation representation = representationHolder.representation;
  RangedUri segmentUri = representationHolder.getSegmentUrl(getCurrentIndex());
  Uri resolvedUri = segmentUri.resolveUri(representation.baseUrl);
  String cacheKey = representation.getCacheKey();
  return new DataSpec(resolvedUri, segmentUri.start, segmentUri.length, cacheKey);
}
 
Example #19
Source File: DashUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
private static @Nullable ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #20
Source File: DashUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #21
Source File: DashUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Loads initialization data for the {@code representation} and optionally index data then returns
 * a {@link ChunkExtractorWrapper} which contains the output.
 *
 * @param dataSource The source from which the data should be loaded.
 * @param trackType The type of the representation. Typically one of the {@link
 *     com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
 * @param representation The representation which initialization chunk belongs to.
 * @param loadIndex Whether to load index data too.
 * @return A {@link ChunkExtractorWrapper} for the {@code representation}, or null if no
 *     initialization or (if requested) index data exists.
 * @throws IOException Thrown when there is an error while loading.
 * @throws InterruptedException Thrown if the thread was interrupted.
 */
@Nullable
private static ChunkExtractorWrapper loadInitializationData(
    DataSource dataSource, int trackType, Representation representation, boolean loadIndex)
    throws IOException, InterruptedException {
  RangedUri initializationUri = representation.getInitializationUri();
  if (initializationUri == null) {
    return null;
  }
  ChunkExtractorWrapper extractorWrapper = newWrappedExtractor(trackType, representation.format);
  RangedUri requestUri;
  if (loadIndex) {
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri == null) {
      return null;
    }
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri, representation.baseUrl);
    if (requestUri == null) {
      loadInitializationData(dataSource, representation, extractorWrapper, initializationUri);
      requestUri = indexUri;
    }
  } else {
    requestUri = initializationUri;
  }
  loadInitializationData(dataSource, representation, extractorWrapper, requestUri);
  return extractorWrapper;
}
 
Example #22
Source File: DashUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static void loadInitializationData(DataSource dataSource,
    Representation representation, ChunkExtractorWrapper extractorWrapper, RangedUri requestUri)
    throws IOException, InterruptedException {
  DataSpec dataSpec = new DataSpec(requestUri.resolveUri(representation.baseUrl),
      requestUri.start, requestUri.length, representation.getCacheKey());
  InitializationChunk initializationChunk = new InitializationChunk(dataSource, dataSpec,
      representation.format, C.SELECTION_REASON_UNKNOWN, null /* trackSelectionData */,
      extractorWrapper);
  initializationChunk.load();
}
 
Example #23
Source File: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public DataSpec getDataSpec() {
  checkInBounds();
  Representation representation = representationHolder.representation;
  RangedUri segmentUri = representationHolder.getSegmentUrl(getCurrentIndex());
  Uri resolvedUri = segmentUri.resolveUri(representation.baseUrl);
  String cacheKey = representation.getCacheKey();
  return new DataSpec(resolvedUri, segmentUri.start, segmentUri.length, cacheKey);
}
 
Example #24
Source File: DashDownloader.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private static void addSegment(
    long startTimeUs, String baseUrl, RangedUri rangedUri, ArrayList<Segment> out) {
  DataSpec dataSpec =
      new DataSpec(rangedUri.resolveUri(baseUrl), rangedUri.start, rangedUri.length, null);
  out.add(new Segment(startTimeUs, dataSpec));
}
 
Example #25
Source File: DashDownloader.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private static void addSegment(
    long startTimeUs, String baseUrl, RangedUri rangedUri, ArrayList<Segment> out) {
  DataSpec dataSpec =
      new DataSpec(rangedUri.resolveUri(baseUrl), rangedUri.start, rangedUri.length, null);
  out.add(new Segment(startTimeUs, dataSpec));
}
 
Example #26
Source File: DashDownloader.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private static void addSegmentsForAdaptationSet(
    DataSource dataSource,
    AdaptationSet adaptationSet,
    long periodStartUs,
    long periodDurationUs,
    boolean allowIncompleteList,
    ArrayList<Segment> out)
    throws IOException, InterruptedException {
  for (int i = 0; i < adaptationSet.representations.size(); i++) {
    Representation representation = adaptationSet.representations.get(i);
    DashSegmentIndex index;
    try {
      index = getSegmentIndex(dataSource, adaptationSet.type, representation);
      if (index == null) {
        // Loading succeeded but there was no index.
        throw new DownloadException("Missing segment index");
      }
    } catch (IOException e) {
      if (!allowIncompleteList) {
        throw e;
      }
      // Generating an incomplete segment list is allowed. Advance to the next representation.
      continue;
    }

    int segmentCount = index.getSegmentCount(periodDurationUs);
    if (segmentCount == DashSegmentIndex.INDEX_UNBOUNDED) {
      throw new DownloadException("Unbounded segment index");
    }

    String baseUrl = representation.baseUrl;
    RangedUri initializationUri = representation.getInitializationUri();
    if (initializationUri != null) {
      addSegment(periodStartUs, baseUrl, initializationUri, out);
    }
    RangedUri indexUri = representation.getIndexUri();
    if (indexUri != null) {
      addSegment(periodStartUs, baseUrl, indexUri, out);
    }
    long firstSegmentNum = index.getFirstSegmentNum();
    long lastSegmentNum = firstSegmentNum + segmentCount - 1;
    for (long j = firstSegmentNum; j <= lastSegmentNum; j++) {
      addSegment(periodStartUs + index.getTimeUs(j), baseUrl, index.getSegmentUrl(j), out);
    }
  }
}
 
Example #27
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public RangedUri getSegmentUrl(long segmentNum) {
  return segmentIndex.getSegmentUrl(segmentNum - segmentNumShift);
}
 
Example #28
Source File: DashWrappingSegmentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RangedUri getSegmentUrl(long segmentNum) {
  return new RangedUri(
      null, chunkIndex.offsets[(int) segmentNum], chunkIndex.sizes[(int) segmentNum]);
}
 
Example #29
Source File: DashWrappingSegmentIndex.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RangedUri getSegmentUrl(long segmentNum) {
  return new RangedUri(
      null, chunkIndex.offsets[(int) segmentNum], chunkIndex.sizes[(int) segmentNum]);
}
 
Example #30
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public RangedUri getSegmentUrl(long segmentNum) {
  return segmentIndex.getSegmentUrl(segmentNum - segmentNumShift);
}