Java Code Examples for com.google.android.exoplayer2.C#SELECTION_REASON_UNKNOWN
The following examples show how to use
com.google.android.exoplayer2.C#SELECTION_REASON_UNKNOWN .
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: BufferSizeAdaptationBuilder.java From MediaSDK with Apache License 2.0 | 5 votes |
private BufferSizeAdaptiveTrackSelection( TrackGroup trackGroup, int[] tracks, BandwidthMeter bandwidthMeter, int minBufferMs, int maxBufferMs, int hysteresisBufferMs, float startUpBandwidthFraction, int startUpMinBufferForQualityIncreaseMs, DynamicFormatFilter dynamicFormatFilter, Clock clock) { super(trackGroup, tracks); this.bandwidthMeter = bandwidthMeter; this.minBufferUs = C.msToUs(minBufferMs); this.maxBufferUs = C.msToUs(maxBufferMs); this.hysteresisBufferUs = C.msToUs(hysteresisBufferMs); this.startUpBandwidthFraction = startUpBandwidthFraction; this.startUpMinBufferForQualityIncreaseUs = C.msToUs(startUpMinBufferForQualityIncreaseMs); this.dynamicFormatFilter = dynamicFormatFilter; this.clock = clock; formatBitrates = new int[length]; maxBitrate = getFormat(/* index= */ 0).bitrate; minBitrate = getFormat(/* index= */ length - 1).bitrate; selectionReason = C.SELECTION_REASON_UNKNOWN; playbackSpeed = 1.0f; // We use a log-linear function to map from bitrate to buffer size: // buffer = slope * ln(bitrate) + intercept, // with buffer(minBitrate) = minBuffer and buffer(maxBitrate) = maxBuffer - hysteresisBuffer. bitrateToBufferFunctionSlope = (maxBufferUs - hysteresisBufferUs - minBufferUs) / Math.log((double) maxBitrate / minBitrate); bitrateToBufferFunctionIntercept = minBufferUs - bitrateToBufferFunctionSlope * Math.log(minBitrate); }
Example 2
Source File: BufferSizeAdaptationBuilder.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void updateSelectedTrack( long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators) { updateFormatBitrates(/* nowMs= */ clock.elapsedRealtime()); // Make initial selection if (selectionReason == C.SELECTION_REASON_UNKNOWN) { selectionReason = C.SELECTION_REASON_INITIAL; selectedIndex = selectIdealIndexUsingBandwidth(/* isInitialSelection= */ true); return; } long bufferUs = getCurrentPeriodBufferedDurationUs(playbackPositionUs, bufferedDurationUs); int oldSelectedIndex = selectedIndex; if (isInSteadyState) { selectIndexSteadyState(bufferUs); } else { selectIndexStartUpPhase(bufferUs); } if (selectedIndex != oldSelectedIndex) { selectionReason = C.SELECTION_REASON_ADAPTIVE; } }
Example 3
Source File: BufferSizeAdaptationBuilder.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private BufferSizeAdaptiveTrackSelection( TrackGroup trackGroup, int[] tracks, BandwidthMeter bandwidthMeter, int minBufferMs, int maxBufferMs, int hysteresisBufferMs, float startUpBandwidthFraction, int startUpMinBufferForQualityIncreaseMs, DynamicFormatFilter dynamicFormatFilter, Clock clock) { super(trackGroup, tracks); this.bandwidthMeter = bandwidthMeter; this.minBufferUs = C.msToUs(minBufferMs); this.maxBufferUs = C.msToUs(maxBufferMs); this.hysteresisBufferUs = C.msToUs(hysteresisBufferMs); this.startUpBandwidthFraction = startUpBandwidthFraction; this.startUpMinBufferForQualityIncreaseUs = C.msToUs(startUpMinBufferForQualityIncreaseMs); this.dynamicFormatFilter = dynamicFormatFilter; this.clock = clock; formatBitrates = new int[length]; maxBitrate = getFormat(/* index= */ 0).bitrate; minBitrate = getFormat(/* index= */ length - 1).bitrate; selectionReason = C.SELECTION_REASON_UNKNOWN; playbackSpeed = 1.0f; // We use a log-linear function to map from bitrate to buffer size: // buffer = slope * ln(bitrate) + intercept, // with buffer(minBitrate) = minBuffer and buffer(maxBitrate) = maxBuffer - hysteresisBuffer. bitrateToBufferFunctionSlope = (maxBufferUs - hysteresisBufferUs - minBufferUs) / Math.log((double) maxBitrate / minBitrate); bitrateToBufferFunctionIntercept = minBufferUs - bitrateToBufferFunctionSlope * Math.log(minBitrate); }
Example 4
Source File: DashUtil.java From K-Sonic with MIT License | 5 votes |
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 5
Source File: AdaptiveTrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private AdaptiveTrackSelection( TrackGroup group, int[] tracks, BandwidthProvider bandwidthProvider, long minDurationForQualityIncreaseMs, long maxDurationForQualityDecreaseMs, long minDurationToRetainAfterDiscardMs, float bufferedFractionToLiveEdgeForQualityIncrease, long minTimeBetweenBufferReevaluationMs, Clock clock) { super(group, tracks); this.bandwidthProvider = bandwidthProvider; this.minDurationForQualityIncreaseUs = minDurationForQualityIncreaseMs * 1000L; this.maxDurationForQualityDecreaseUs = maxDurationForQualityDecreaseMs * 1000L; this.minDurationToRetainAfterDiscardUs = minDurationToRetainAfterDiscardMs * 1000L; this.bufferedFractionToLiveEdgeForQualityIncrease = bufferedFractionToLiveEdgeForQualityIncrease; this.minTimeBetweenBufferReevaluationMs = minTimeBetweenBufferReevaluationMs; this.clock = clock; playbackSpeed = 1f; reason = C.SELECTION_REASON_UNKNOWN; lastBufferEvaluationMs = C.TIME_UNSET; trackBitrateEstimator = TrackBitrateEstimator.DEFAULT; formats = new Format[length]; formatBitrates = new int[length]; trackBitrates = new int[length]; for (int i = 0; i < length; i++) { @SuppressWarnings("nullness:method.invocation.invalid") Format format = getFormat(i); formats[i] = format; formatBitrates[i] = formats[i].bitrate; } }
Example 6
Source File: DashUtil.java From Telegram with GNU General Public License v2.0 | 5 votes |
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 7
Source File: DashUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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: BufferSizeAdaptationBuilder.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void updateSelectedTrack( long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators) { updateFormatBitrates(/* nowMs= */ clock.elapsedRealtime()); // Make initial selection if (selectionReason == C.SELECTION_REASON_UNKNOWN) { selectionReason = C.SELECTION_REASON_INITIAL; selectedIndex = selectIdealIndexUsingBandwidth(/* isInitialSelection= */ true); return; } long bufferUs = getCurrentPeriodBufferedDurationUs(playbackPositionUs, bufferedDurationUs); int oldSelectedIndex = selectedIndex; if (isInSteadyState) { selectIndexSteadyState(bufferUs); } else { selectIndexStartUpPhase(bufferUs); } if (selectedIndex != oldSelectedIndex) { selectionReason = C.SELECTION_REASON_ADAPTIVE; } }
Example 9
Source File: DashUtil.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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: FixedTrackSelection.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public Factory() { this.reason = C.SELECTION_REASON_UNKNOWN; this.data = null; }
Example 11
Source File: AdaptiveTrackSelection.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void updateSelectedTrack( long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators) { long nowMs = clock.elapsedRealtime(); // Update the estimated track bitrates. trackBitrateEstimator.getBitrates(formats, queue, mediaChunkIterators, trackBitrates); // Make initial selection if (reason == C.SELECTION_REASON_UNKNOWN) { reason = C.SELECTION_REASON_INITIAL; selectedIndex = determineIdealSelectedIndex(nowMs, trackBitrates); return; } // Stash the current selection, then make a new one. int currentSelectedIndex = selectedIndex; selectedIndex = determineIdealSelectedIndex(nowMs, trackBitrates); if (selectedIndex == currentSelectedIndex) { return; } if (!isBlacklisted(currentSelectedIndex, nowMs)) { // Revert back to the current selection if conditions are not suitable for switching. Format currentFormat = getFormat(currentSelectedIndex); Format selectedFormat = getFormat(selectedIndex); if (selectedFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs(availableDurationUs)) { // The selected track is a higher quality, but we have insufficient buffer to safely switch // up. Defer switching up for now. selectedIndex = currentSelectedIndex; } else if (selectedFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) { // The selected track is a lower quality, but we have sufficient buffer to defer switching // down for now. selectedIndex = currentSelectedIndex; } } // If we adapted, update the trigger. if (selectedIndex != currentSelectedIndex) { reason = C.SELECTION_REASON_ADAPTIVE; } }
Example 12
Source File: FixedTrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public Factory() { this.reason = C.SELECTION_REASON_UNKNOWN; this.data = null; }
Example 13
Source File: DownloadHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public int getSelectionReason() { return C.SELECTION_REASON_UNKNOWN; }
Example 14
Source File: HlsChunkSource.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public int getSelectionReason() { return C.SELECTION_REASON_UNKNOWN; }
Example 15
Source File: DownloadHelper.java From MediaSDK with Apache License 2.0 | 4 votes |
@Override public int getSelectionReason() { return C.SELECTION_REASON_UNKNOWN; }
Example 16
Source File: AdaptiveTrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void updateSelectedTrack( long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators) { long nowMs = clock.elapsedRealtime(); // Update the estimated track bitrates. trackBitrateEstimator.getBitrates(formats, queue, mediaChunkIterators, trackBitrates); // Make initial selection if (reason == C.SELECTION_REASON_UNKNOWN) { reason = C.SELECTION_REASON_INITIAL; selectedIndex = determineIdealSelectedIndex(nowMs, trackBitrates); return; } // Stash the current selection, then make a new one. int currentSelectedIndex = selectedIndex; selectedIndex = determineIdealSelectedIndex(nowMs, trackBitrates); if (selectedIndex == currentSelectedIndex) { return; } if (!isBlacklisted(currentSelectedIndex, nowMs)) { // Revert back to the current selection if conditions are not suitable for switching. Format currentFormat = getFormat(currentSelectedIndex); Format selectedFormat = getFormat(selectedIndex); if (selectedFormat.bitrate > currentFormat.bitrate && bufferedDurationUs < minDurationForQualityIncreaseUs(availableDurationUs)) { // The selected track is a higher quality, but we have insufficient buffer to safely switch // up. Defer switching up for now. selectedIndex = currentSelectedIndex; } else if (selectedFormat.bitrate < currentFormat.bitrate && bufferedDurationUs >= maxDurationForQualityDecreaseUs) { // The selected track is a lower quality, but we have sufficient buffer to defer switching // down for now. selectedIndex = currentSelectedIndex; } } // If we adapted, update the trigger. if (selectedIndex != currentSelectedIndex) { reason = C.SELECTION_REASON_ADAPTIVE; } }
Example 17
Source File: FixedTrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 2 votes |
/** * @param group The {@link TrackGroup}. Must not be null. * @param track The index of the selected track within the {@link TrackGroup}. */ public FixedTrackSelection(TrackGroup group, int track) { this(group, track, C.SELECTION_REASON_UNKNOWN, null); }
Example 18
Source File: FixedTrackSelection.java From TelePlus-Android with GNU General Public License v2.0 | 2 votes |
/** * @param group The {@link TrackGroup}. Must not be null. * @param track The index of the selected track within the {@link TrackGroup}. */ public FixedTrackSelection(TrackGroup group, int track) { this(group, track, C.SELECTION_REASON_UNKNOWN, null); }
Example 19
Source File: TrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 2 votes |
/** * @param group The {@link TrackGroup}. Must not be null. * @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be * null or empty. May be in any order. */ public Definition(TrackGroup group, int... tracks) { this(group, tracks, C.SELECTION_REASON_UNKNOWN, /* data= */ null); }
Example 20
Source File: FixedTrackSelection.java From MediaSDK with Apache License 2.0 | 2 votes |
/** * @param group The {@link TrackGroup}. Must not be null. * @param track The index of the selected track within the {@link TrackGroup}. */ public FixedTrackSelection(TrackGroup group, int track) { this(group, track, C.SELECTION_REASON_UNKNOWN, null); }