Java 类com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist.Segment 实例源码

项目:Exoplayer2Radio    文件:HlsPlaylistTracker.java   
private long getLoadedPlaylistStartTimeUs(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasProgramDateTime) {
    return loadedPlaylist.startTimeUs;
  }
  long primarySnapshotStartTimeUs = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.startTimeUs : 0;
  if (oldPlaylist == null) {
    return primarySnapshotStartTimeUs;
  }
  int oldPlaylistSize = oldPlaylist.segments.size();
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.startTimeUs + firstOldOverlappingSegment.relativeStartTimeUs;
  } else if (oldPlaylistSize == loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence) {
    return oldPlaylist.getEndTimeUs();
  } else {
    // No segments overlap, we assume the new playlist start coincides with the primary playlist.
    return primarySnapshotStartTimeUs;
  }
}
项目:Exoplayer2Radio    文件:HlsPlaylistTracker.java   
private int getLoadedPlaylistDiscontinuitySequence(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasDiscontinuitySequence) {
    return loadedPlaylist.discontinuitySequence;
  }
  // TODO: Improve cross-playlist discontinuity adjustment.
  int primaryUrlDiscontinuitySequence = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.discontinuitySequence : 0;
  if (oldPlaylist == null) {
    return primaryUrlDiscontinuitySequence;
  }
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.discontinuitySequence
        + firstOldOverlappingSegment.relativeDiscontinuitySequence
        - loadedPlaylist.segments.get(0).relativeDiscontinuitySequence;
  }
  return primaryUrlDiscontinuitySequence;
}
项目:K-Sonic    文件:HlsPlaylistTracker.java   
private long getLoadedPlaylistStartTimeUs(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasProgramDateTime) {
    return loadedPlaylist.startTimeUs;
  }
  long primarySnapshotStartTimeUs = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.startTimeUs : 0;
  if (oldPlaylist == null) {
    return primarySnapshotStartTimeUs;
  }
  int oldPlaylistSize = oldPlaylist.segments.size();
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.startTimeUs + firstOldOverlappingSegment.relativeStartTimeUs;
  } else if (oldPlaylistSize == loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence) {
    return oldPlaylist.getEndTimeUs();
  } else {
    // No segments overlap, we assume the new playlist start coincides with the primary playlist.
    return primarySnapshotStartTimeUs;
  }
}
项目:K-Sonic    文件:HlsPlaylistTracker.java   
private int getLoadedPlaylistDiscontinuitySequence(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasDiscontinuitySequence) {
    return loadedPlaylist.discontinuitySequence;
  }
  // TODO: Improve cross-playlist discontinuity adjustment.
  int primaryUrlDiscontinuitySequence = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.discontinuitySequence : 0;
  if (oldPlaylist == null) {
    return primaryUrlDiscontinuitySequence;
  }
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.discontinuitySequence
        + firstOldOverlappingSegment.relativeDiscontinuitySequence
        - loadedPlaylist.segments.get(0).relativeDiscontinuitySequence;
  }
  return primaryUrlDiscontinuitySequence;
}
项目:transistor    文件:HlsPlaylistTracker.java   
private long getLoadedPlaylistStartTimeUs(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasProgramDateTime) {
    return loadedPlaylist.startTimeUs;
  }
  long primarySnapshotStartTimeUs = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.startTimeUs : 0;
  if (oldPlaylist == null) {
    return primarySnapshotStartTimeUs;
  }
  int oldPlaylistSize = oldPlaylist.segments.size();
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.startTimeUs + firstOldOverlappingSegment.relativeStartTimeUs;
  } else if (oldPlaylistSize == loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence) {
    return oldPlaylist.getEndTimeUs();
  } else {
    // No segments overlap, we assume the new playlist start coincides with the primary playlist.
    return primarySnapshotStartTimeUs;
  }
}
项目:transistor    文件:HlsPlaylistTracker.java   
private int getLoadedPlaylistDiscontinuitySequence(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  if (loadedPlaylist.hasDiscontinuitySequence) {
    return loadedPlaylist.discontinuitySequence;
  }
  // TODO: Improve cross-playlist discontinuity adjustment.
  int primaryUrlDiscontinuitySequence = primaryUrlSnapshot != null
      ? primaryUrlSnapshot.discontinuitySequence : 0;
  if (oldPlaylist == null) {
    return primaryUrlDiscontinuitySequence;
  }
  Segment firstOldOverlappingSegment = getFirstOldOverlappingSegment(oldPlaylist, loadedPlaylist);
  if (firstOldOverlappingSegment != null) {
    return oldPlaylist.discontinuitySequence
        + firstOldOverlappingSegment.relativeDiscontinuitySequence
        - loadedPlaylist.segments.get(0).relativeDiscontinuitySequence;
  }
  return primaryUrlDiscontinuitySequence;
}
项目:videoPickPlayer    文件:HlsChunkSource.java   
private HlsInitializationChunk buildInitializationChunk(HlsMediaPlaylist mediaPlaylist,
    Extractor extractor, Format format) {
  Segment initSegment = mediaPlaylist.initializationSegment;
  // The initialization segment is required before the actual media chunk.
  Uri initSegmentUri = UriUtil.resolveToUri(mediaPlaylist.baseUri, initSegment.url);
  DataSpec initDataSpec = new DataSpec(initSegmentUri, initSegment.byterangeOffset,
      initSegment.byterangeLength, null);
  return new HlsInitializationChunk(dataSource, initDataSpec,
      trackSelection.getSelectionReason(), trackSelection.getSelectionData(), extractor,
      format);
}
项目:Exoplayer2Radio    文件:HlsPlaylistTracker.java   
private static Segment getFirstOldOverlappingSegment(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  int mediaSequenceOffset = loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence;
  List<Segment> oldSegments = oldPlaylist.segments;
  return mediaSequenceOffset < oldSegments.size() ? oldSegments.get(mediaSequenceOffset) : null;
}
项目:K-Sonic    文件:HlsPlaylistTracker.java   
private static Segment getFirstOldOverlappingSegment(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  int mediaSequenceOffset = loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence;
  List<Segment> oldSegments = oldPlaylist.segments;
  return mediaSequenceOffset < oldSegments.size() ? oldSegments.get(mediaSequenceOffset) : null;
}
项目:transistor    文件:HlsPlaylistTracker.java   
private static Segment getFirstOldOverlappingSegment(HlsMediaPlaylist oldPlaylist,
    HlsMediaPlaylist loadedPlaylist) {
  int mediaSequenceOffset = loadedPlaylist.mediaSequence - oldPlaylist.mediaSequence;
  List<Segment> oldSegments = oldPlaylist.segments;
  return mediaSequenceOffset < oldSegments.size() ? oldSegments.get(mediaSequenceOffset) : null;
}