mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Report additional position discontinuities
- Properly report internal discontinuities - Add DISCONTINUITY_REASON_SEEK_ADJUSTMENT to distinguish seek adjustments from other internal discontinuity events ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176367365
This commit is contained in:
parent
b688a56250
commit
fa3052d36b
5 changed files with 31 additions and 11 deletions
|
|
@ -11,6 +11,10 @@
|
|||
* SimpleExoPlayer: Support for multiple video, text and metadata outputs.
|
||||
* Support for `Renderer`s that don't consume any media
|
||||
([#3212](https://github.com/google/ExoPlayer/issues/3212)).
|
||||
* Fix reporting of internal position discontinuities via
|
||||
`Player.onPositionDiscontinuity`. `DISCONTINUITY_REASON_SEEK_ADJUSTMENT` is
|
||||
added to disambiguate position adjustments during seeks from other types of
|
||||
internal position discontinuity.
|
||||
* Fix potential `IndexOutOfBoundsException` when calling `ExoPlayer.getDuration`
|
||||
([#3362](https://github.com/google/ExoPlayer/issues/3362)).
|
||||
* Fix playbacks involving looping, concatenation and ads getting stuck when
|
||||
|
|
|
|||
|
|
@ -496,6 +496,8 @@ import java.util.Locale;
|
|||
return "PERIOD_TRANSITION";
|
||||
case Player.DISCONTINUITY_REASON_SEEK:
|
||||
return "SEEK";
|
||||
case Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT:
|
||||
return "SEEK_ADJUSTMENT";
|
||||
case Player.DISCONTINUITY_REASON_INTERNAL:
|
||||
return "INTERNAL";
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -473,7 +473,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
case ExoPlayerImplInternal.MSG_SOURCE_INFO_REFRESHED: {
|
||||
int prepareAcks = msg.arg1;
|
||||
int seekAcks = msg.arg2;
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, prepareAcks, seekAcks, false);
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, prepareAcks, seekAcks, false,
|
||||
/* ignored */ DISCONTINUITY_REASON_INTERNAL);
|
||||
break;
|
||||
}
|
||||
case ExoPlayerImplInternal.MSG_TRACKS_CHANGED: {
|
||||
|
|
@ -491,11 +492,13 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
}
|
||||
case ExoPlayerImplInternal.MSG_SEEK_ACK: {
|
||||
boolean seekPositionAdjusted = msg.arg1 != 0;
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, 0, 1, seekPositionAdjusted);
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, 0, 1, seekPositionAdjusted,
|
||||
DISCONTINUITY_REASON_SEEK_ADJUSTMENT);
|
||||
break;
|
||||
}
|
||||
case ExoPlayerImplInternal.MSG_POSITION_DISCONTINUITY: {
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, 0, 0, true);
|
||||
@DiscontinuityReason int discontinuityReason = msg.arg1;
|
||||
handlePlaybackInfo((PlaybackInfo) msg.obj, 0, 0, true, discontinuityReason);
|
||||
break;
|
||||
}
|
||||
case ExoPlayerImplInternal.MSG_PLAYBACK_PARAMETERS_CHANGED: {
|
||||
|
|
@ -521,7 +524,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
}
|
||||
|
||||
private void handlePlaybackInfo(PlaybackInfo playbackInfo, int prepareAcks, int seekAcks,
|
||||
boolean positionDiscontinuity) {
|
||||
boolean positionDiscontinuity, @DiscontinuityReason int positionDiscontinuityReason) {
|
||||
Assertions.checkNotNull(playbackInfo.timeline);
|
||||
pendingPrepareAcks -= prepareAcks;
|
||||
pendingSeekAcks -= seekAcks;
|
||||
|
|
@ -542,9 +545,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
}
|
||||
if (positionDiscontinuity) {
|
||||
for (Player.EventListener listener : listeners) {
|
||||
listener.onPositionDiscontinuity(
|
||||
seekAcks > 0 ? DISCONTINUITY_REASON_INTERNAL : DISCONTINUITY_REASON_PERIOD_TRANSITION
|
||||
);
|
||||
listener.onPositionDiscontinuity(positionDiscontinuityReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,6 +503,10 @@ import java.io.IOException;
|
|||
long periodPositionUs = playingPeriodHolder.mediaPeriod.readDiscontinuity();
|
||||
if (periodPositionUs != C.TIME_UNSET) {
|
||||
resetRendererPosition(periodPositionUs);
|
||||
playbackInfo = playbackInfo.fromNewPosition(playbackInfo.periodId, periodPositionUs,
|
||||
playbackInfo.contentPositionUs);
|
||||
eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY, Player.DISCONTINUITY_REASON_INTERNAL,
|
||||
0, playbackInfo).sendToTarget();
|
||||
} else {
|
||||
// Use the standalone clock if there's no renderer clock, or if the providing renderer has
|
||||
// ended or needs the next sample stream to reenter the ready state. The latter case uses the
|
||||
|
|
@ -893,7 +897,10 @@ import java.io.IOException;
|
|||
long periodPositionUs = playingPeriodHolder.updatePeriodTrackSelection(
|
||||
playbackInfo.positionUs, recreateStreams, streamResetFlags);
|
||||
if (periodPositionUs != playbackInfo.positionUs) {
|
||||
playbackInfo.positionUs = periodPositionUs;
|
||||
playbackInfo = playbackInfo.fromNewPosition(playbackInfo.periodId, periodPositionUs,
|
||||
playbackInfo.contentPositionUs);
|
||||
eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY, Player.DISCONTINUITY_REASON_INTERNAL,
|
||||
0, playbackInfo).sendToTarget();
|
||||
resetRendererPosition(periodPositionUs);
|
||||
}
|
||||
|
||||
|
|
@ -1280,7 +1287,8 @@ import java.io.IOException;
|
|||
playbackInfo = playbackInfo.fromNewPosition(playingPeriodHolder.info.id,
|
||||
playingPeriodHolder.info.startPositionUs, playingPeriodHolder.info.contentPositionUs);
|
||||
updatePlaybackPositions();
|
||||
eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY, playbackInfo).sendToTarget();
|
||||
eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY,
|
||||
Player.DISCONTINUITY_REASON_PERIOD_TRANSITION, 0, playbackInfo).sendToTarget();
|
||||
}
|
||||
|
||||
if (readingPeriodHolder.info.isFinal) {
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ public interface Player {
|
|||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({DISCONTINUITY_REASON_PERIOD_TRANSITION, DISCONTINUITY_REASON_SEEK,
|
||||
DISCONTINUITY_REASON_INTERNAL})
|
||||
DISCONTINUITY_REASON_SEEK_ADJUSTMENT, DISCONTINUITY_REASON_INTERNAL})
|
||||
public @interface DiscontinuityReason {}
|
||||
/**
|
||||
* Automatic playback transition from one period in the timeline to the next. The period index may
|
||||
|
|
@ -254,10 +254,15 @@ public interface Player {
|
|||
* Seek within the current period or to another period.
|
||||
*/
|
||||
int DISCONTINUITY_REASON_SEEK = 1;
|
||||
/**
|
||||
* Seek adjustment due to being unable to seek to the requested position or because the seek was
|
||||
* permitted to be inexact.
|
||||
*/
|
||||
int DISCONTINUITY_REASON_SEEK_ADJUSTMENT = 2;
|
||||
/**
|
||||
* Discontinuity introduced internally by the source.
|
||||
*/
|
||||
int DISCONTINUITY_REASON_INTERNAL = 2;
|
||||
int DISCONTINUITY_REASON_INTERNAL = 3;
|
||||
|
||||
/**
|
||||
* Register a listener to receive events from the player. The listener's methods will be called on
|
||||
|
|
|
|||
Loading…
Reference in a new issue