Java Code Examples for com.google.android.exoplayer2.util.Util#getPlayoutDurationForMediaDuration()
The following examples show how to use
com.google.android.exoplayer2.util.Util#getPlayoutDurationForMediaDuration() .
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: DefaultLoadControl.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public boolean shouldStartPlayback( long bufferedDurationUs, float playbackSpeed, boolean rebuffering) { bufferedDurationUs = Util.getPlayoutDurationForMediaDuration(bufferedDurationUs, playbackSpeed); long minBufferDurationUs = rebuffering ? bufferForPlaybackAfterRebufferUs : bufferForPlaybackUs; return minBufferDurationUs <= 0 || bufferedDurationUs >= minBufferDurationUs || (!prioritizeTimeOverSizeThresholds && allocator.getTotalBytesAllocated() >= targetBufferSize); }
Example 2
Source File: DefaultLoadControl.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean shouldStartPlayback( long bufferedDurationUs, float playbackSpeed, boolean rebuffering) { bufferedDurationUs = Util.getPlayoutDurationForMediaDuration(bufferedDurationUs, playbackSpeed); long minBufferDurationUs = rebuffering ? bufferForPlaybackAfterRebufferUs : bufferForPlaybackUs; return minBufferDurationUs <= 0 || bufferedDurationUs >= minBufferDurationUs || (!prioritizeTimeOverSizeThresholds && allocator.getTotalBytesAllocated() >= targetBufferSize); }
Example 3
Source File: DefaultLoadControl.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean shouldStartPlayback( long bufferedDurationUs, float playbackSpeed, boolean rebuffering) { bufferedDurationUs = Util.getPlayoutDurationForMediaDuration(bufferedDurationUs, playbackSpeed); long minBufferDurationUs = rebuffering ? bufferForPlaybackAfterRebufferUs : bufferForPlaybackUs; return minBufferDurationUs <= 0 || bufferedDurationUs >= minBufferDurationUs || (!prioritizeTimeOverSizeThresholds && allocator.getTotalBytesAllocated() >= targetBufferSize); }
Example 4
Source File: DefaultLoadControl.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public boolean shouldStartPlayback( long bufferedDurationUs, float playbackSpeed, boolean rebuffering) { bufferedDurationUs = Util.getPlayoutDurationForMediaDuration(bufferedDurationUs, playbackSpeed); long minBufferDurationUs = rebuffering ? bufferForPlaybackAfterRebufferUs : bufferForPlaybackUs; return minBufferDurationUs <= 0 || bufferedDurationUs >= minBufferDurationUs || (!prioritizeTimeOverSizeThresholds && allocator.getTotalBytesAllocated() >= targetBufferSize); }
Example 5
Source File: DefaultLoadControl.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public boolean shouldStartPlayback( long bufferedDurationUs, float playbackSpeed, boolean rebuffering) { bufferedDurationUs = Util.getPlayoutDurationForMediaDuration(bufferedDurationUs, playbackSpeed); long minBufferDurationUs = rebuffering ? bufferForPlaybackAfterRebufferUs : bufferForPlaybackUs; return minBufferDurationUs <= 0 || bufferedDurationUs >= minBufferDurationUs || (!prioritizeTimeOverSizeThresholds && allocator.getTotalBytesAllocated() >= targetBufferSize); }
Example 6
Source File: AdaptiveTrackSelection.java From MediaSDK with Apache License 2.0 | 4 votes |
@Override public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) { long nowMs = clock.elapsedRealtime(); if (!shouldEvaluateQueueSize(nowMs)) { return queue.size(); } lastBufferEvaluationMs = nowMs; if (queue.isEmpty()) { return 0; } int queueSize = queue.size(); MediaChunk lastChunk = queue.get(queueSize - 1); long playoutBufferedDurationBeforeLastChunkUs = Util.getPlayoutDurationForMediaDuration( lastChunk.startTimeUs - playbackPositionUs, playbackSpeed); long minDurationToRetainAfterDiscardUs = getMinDurationToRetainAfterDiscardUs(); if (playoutBufferedDurationBeforeLastChunkUs < minDurationToRetainAfterDiscardUs) { return queueSize; } int idealSelectedIndex = determineIdealSelectedIndex(nowMs); Format idealFormat = getFormat(idealSelectedIndex); // If the chunks contain video, discard from the first SD chunk beyond // minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal // track. for (int i = 0; i < queueSize; i++) { MediaChunk chunk = queue.get(i); Format format = chunk.trackFormat; long mediaDurationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs; long playoutDurationBeforeThisChunkUs = Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate && format.height != Format.NO_VALUE && format.height < 720 && format.width != Format.NO_VALUE && format.width < 1280 && format.height < idealFormat.height) { return i; } } return queueSize; }
Example 7
Source File: AdaptiveTrackSelection.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) { long nowMs = clock.elapsedRealtime(); if (lastBufferEvaluationMs != C.TIME_UNSET && nowMs - lastBufferEvaluationMs < minTimeBetweenBufferReevaluationMs) { return queue.size(); } lastBufferEvaluationMs = nowMs; if (queue.isEmpty()) { return 0; } int queueSize = queue.size(); MediaChunk lastChunk = queue.get(queueSize - 1); long playoutBufferedDurationBeforeLastChunkUs = Util.getPlayoutDurationForMediaDuration( lastChunk.startTimeUs - playbackPositionUs, playbackSpeed); if (playoutBufferedDurationBeforeLastChunkUs < minDurationToRetainAfterDiscardUs) { return queueSize; } int idealSelectedIndex = determineIdealSelectedIndex(nowMs); Format idealFormat = getFormat(idealSelectedIndex); // If the chunks contain video, discard from the first SD chunk beyond // minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal // track. for (int i = 0; i < queueSize; i++) { MediaChunk chunk = queue.get(i); Format format = chunk.trackFormat; long mediaDurationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs; long playoutDurationBeforeThisChunkUs = Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate && format.height != Format.NO_VALUE && format.height < 720 && format.width != Format.NO_VALUE && format.width < 1280 && format.height < idealFormat.height) { return i; } } return queueSize; }
Example 8
Source File: AdaptiveTrackSelection.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) { long nowMs = clock.elapsedRealtime(); if (lastBufferEvaluationMs != C.TIME_UNSET && nowMs - lastBufferEvaluationMs < minTimeBetweenBufferReevaluationMs) { return queue.size(); } lastBufferEvaluationMs = nowMs; if (queue.isEmpty()) { return 0; } int queueSize = queue.size(); MediaChunk lastChunk = queue.get(queueSize - 1); long playoutBufferedDurationBeforeLastChunkUs = Util.getPlayoutDurationForMediaDuration( lastChunk.startTimeUs - playbackPositionUs, playbackSpeed); if (playoutBufferedDurationBeforeLastChunkUs < minDurationToRetainAfterDiscardUs) { return queueSize; } int idealSelectedIndex = determineIdealSelectedIndex(nowMs); Format idealFormat = getFormat(idealSelectedIndex); // If the chunks contain video, discard from the first SD chunk beyond // minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal // track. for (int i = 0; i < queueSize; i++) { MediaChunk chunk = queue.get(i); Format format = chunk.trackFormat; long mediaDurationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs; long playoutDurationBeforeThisChunkUs = Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate && format.height != Format.NO_VALUE && format.height < 720 && format.width != Format.NO_VALUE && format.width < 1280 && format.height < idealFormat.height) { return i; } } return queueSize; }
Example 9
Source File: AdaptiveTrackSelection.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) { long nowMs = clock.elapsedRealtime(); if (!shouldEvaluateQueueSize(nowMs)) { return queue.size(); } lastBufferEvaluationMs = nowMs; if (queue.isEmpty()) { return 0; } int queueSize = queue.size(); MediaChunk lastChunk = queue.get(queueSize - 1); long playoutBufferedDurationBeforeLastChunkUs = Util.getPlayoutDurationForMediaDuration( lastChunk.startTimeUs - playbackPositionUs, playbackSpeed); long minDurationToRetainAfterDiscardUs = getMinDurationToRetainAfterDiscardUs(); if (playoutBufferedDurationBeforeLastChunkUs < minDurationToRetainAfterDiscardUs) { return queueSize; } int idealSelectedIndex = determineIdealSelectedIndex(nowMs, formatBitrates); Format idealFormat = getFormat(idealSelectedIndex); // If the chunks contain video, discard from the first SD chunk beyond // minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal // track. for (int i = 0; i < queueSize; i++) { MediaChunk chunk = queue.get(i); Format format = chunk.trackFormat; long mediaDurationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs; long playoutDurationBeforeThisChunkUs = Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate && format.height != Format.NO_VALUE && format.height < 720 && format.width != Format.NO_VALUE && format.width < 1280 && format.height < idealFormat.height) { return i; } } return queueSize; }
Example 10
Source File: AdaptiveTrackSelection.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue) { long nowMs = clock.elapsedRealtime(); if (!shouldEvaluateQueueSize(nowMs)) { return queue.size(); } lastBufferEvaluationMs = nowMs; if (queue.isEmpty()) { return 0; } int queueSize = queue.size(); MediaChunk lastChunk = queue.get(queueSize - 1); long playoutBufferedDurationBeforeLastChunkUs = Util.getPlayoutDurationForMediaDuration( lastChunk.startTimeUs - playbackPositionUs, playbackSpeed); long minDurationToRetainAfterDiscardUs = getMinDurationToRetainAfterDiscardUs(); if (playoutBufferedDurationBeforeLastChunkUs < minDurationToRetainAfterDiscardUs) { return queueSize; } int idealSelectedIndex = determineIdealSelectedIndex(nowMs, formatBitrates); Format idealFormat = getFormat(idealSelectedIndex); // If the chunks contain video, discard from the first SD chunk beyond // minDurationToRetainAfterDiscardUs whose resolution and bitrate are both lower than the ideal // track. for (int i = 0; i < queueSize; i++) { MediaChunk chunk = queue.get(i); Format format = chunk.trackFormat; long mediaDurationBeforeThisChunkUs = chunk.startTimeUs - playbackPositionUs; long playoutDurationBeforeThisChunkUs = Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate && format.height != Format.NO_VALUE && format.height < 720 && format.width != Format.NO_VALUE && format.width < 1280 && format.height < idealFormat.height) { return i; } } return queueSize; }