public MediaPlaylistBundle(HlsUrl playlistUrl, long initialLastSnapshotAccessTimeMs) { this.playlistUrl = playlistUrl; lastSnapshotAccessTimeMs = initialLastSnapshotAccessTimeMs; mediaPlaylistLoader = new Loader("HlsPlaylistTracker:MediaPlaylist"); mediaPlaylistLoadable = new ParsingLoadable<>( dataSourceFactory.createDataSource(C.DATA_TYPE_MANIFEST), UriUtil.resolveToUri(masterPlaylist.baseUri, playlistUrl.url), C.DATA_TYPE_MANIFEST, playlistParser); }
/** * Builds a uri for requesting the specified chunk of the specified track. * * @param track The index of the track for which to build the URL. * @param chunkIndex The index of the chunk for which to build the URL. * @return The request uri. */ public Uri buildRequestUri(int track, int chunkIndex) { Assertions.checkState(formats != null); Assertions.checkState(chunkStartTimes != null); Assertions.checkState(chunkIndex < chunkStartTimes.size()); String bitrateString = Integer.toString(formats[track].bitrate); String startTimeString = chunkStartTimes.get(chunkIndex).toString(); String chunkUrl = chunkTemplate .replace(URL_PLACEHOLDER_BITRATE_1, bitrateString) .replace(URL_PLACEHOLDER_BITRATE_2, bitrateString) .replace(URL_PLACEHOLDER_START_TIME_1, startTimeString) .replace(URL_PLACEHOLDER_START_TIME_2, startTimeString); return UriUtil.resolveToUri(baseUri, chunkUrl); }
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); }
private MediaPlaylistChunk newMediaPlaylistChunk(int variantIndex, int trackSelectionReason, Object trackSelectionData) { Uri mediaPlaylistUri = UriUtil.resolveToUri(baseUri, variants[variantIndex].url); DataSpec dataSpec = new DataSpec(mediaPlaylistUri, 0, C.LENGTH_UNSET, null, DataSpec.FLAG_ALLOW_GZIP); return new MediaPlaylistChunk(dataSource, dataSpec, variants[variantIndex].format, trackSelectionReason, trackSelectionData, scratchSpace, playlistParser, variantIndex, mediaPlaylistUri); }
/** * Builds a uri for requesting the specified chunk of the specified track. * * @param track The index of the track for which to build the URL. * @param chunkIndex The index of the chunk for which to build the URL. * @return The request uri. */ public Uri buildRequestUri(int track, int chunkIndex) { Assertions.checkState(formats != null); Assertions.checkState(chunkStartTimes != null); Assertions.checkState(chunkIndex < chunkStartTimes.size()); String chunkUrl = chunkTemplate .replace(URL_PLACEHOLDER_BITRATE, Integer.toString(formats[track].bitrate)) .replace(URL_PLACEHOLDER_START_TIME, chunkStartTimes.get(chunkIndex).toString()); return UriUtil.resolveToUri(baseUri, chunkUrl); }
public MediaPlaylistBundle(HlsUrl playlistUrl) { this.playlistUrl = playlistUrl; mediaPlaylistLoader = new Loader("HlsPlaylistTracker:MediaPlaylist"); mediaPlaylistLoadable = new ParsingLoadable<>( dataSourceFactory.createDataSource(C.DATA_TYPE_MANIFEST), UriUtil.resolveToUri(masterPlaylist.baseUri, playlistUrl.url), C.DATA_TYPE_MANIFEST, playlistParser); }
private static void addSegment(ArrayList<Segment> segments, HlsMediaPlaylist mediaPlaylist, HlsMediaPlaylist.Segment hlsSegment, HashSet<Uri> encryptionKeyUris) throws IOException, InterruptedException { long startTimeUs = mediaPlaylist.startTimeUs + hlsSegment.relativeStartTimeUs; if (hlsSegment.fullSegmentEncryptionKeyUri != null) { Uri keyUri = UriUtil.resolveToUri(mediaPlaylist.baseUri, hlsSegment.fullSegmentEncryptionKeyUri); if (encryptionKeyUris.add(keyUri)) { segments.add(new Segment(startTimeUs, new DataSpec(keyUri))); } } Uri resolvedUri = UriUtil.resolveToUri(mediaPlaylist.baseUri, hlsSegment.url); segments.add(new Segment(startTimeUs, new DataSpec(resolvedUri, hlsSegment.byterangeOffset, hlsSegment.byterangeLength, null))); }
protected static String parseBaseUrl(XmlPullParser xpp, String parentBaseUrl) throws XmlPullParserException, IOException { xpp.next(); return UriUtil.resolve(parentBaseUrl, xpp.getText()); }
/** * Returns the resolved {@link Uri} represented by the instance. * * @param baseUri The base Uri. * @return The {@link Uri} represented by the instance. */ public Uri resolveUri(String baseUri) { return UriUtil.resolveToUri(baseUri, referenceUri); }
/** * Returns the resolved uri represented by the instance as a string. * * @param baseUri The base Uri. * @return The uri represented by the instance. */ public String resolveUriString(String baseUri) { return UriUtil.resolve(baseUri, referenceUri); }
/** * Returns the {@link Uri} represented by the instance. * * @return The {@link Uri} represented by the instance. */ public Uri getUri() { return UriUtil.resolveToUri(baseUri, referenceUri); }
/** * Returns the uri represented by the instance as a string. * * @return The uri represented by the instance. */ public String getUriString() { return UriUtil.resolve(baseUri, referenceUri); }