Add FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED to HLS preload media chunks

Issue: #5011
PiperOrigin-RevId: 345425048
This commit is contained in:
bachinger 2020-12-03 12:35:00 +00:00 committed by Oliver Woodman
parent 09509c2390
commit 4907c2153b

View File

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.source.hls;
import static com.google.android.exoplayer2.upstream.DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED;
import android.net.Uri;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
@ -92,10 +94,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
// Media segment.
HlsMediaPlaylist.SegmentBase mediaSegment = segmentBaseHolder.segmentBase;
DataSpec dataSpec =
new DataSpec(
UriUtil.resolveToUri(mediaPlaylist.baseUri, mediaSegment.url),
mediaSegment.byteRangeOffset,
mediaSegment.byteRangeLength);
new DataSpec.Builder()
.setUri(UriUtil.resolveToUri(mediaPlaylist.baseUri, mediaSegment.url))
.setPosition(mediaSegment.byteRangeOffset)
.setLength(mediaSegment.byteRangeLength)
.setFlags(segmentBaseHolder.isPreload ? FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED : 0)
.build();
boolean mediaSegmentEncrypted = mediaSegmentKey != null;
@Nullable
byte[] mediaSegmentIv =