Commit 7cba5429 by hoangtc Committed by Oliver Woodman

Add supports for frame-capture retrying for MetadataRetriever.

For the MetadataRetriever, for certain queries, after setting up the player to
render a frame (by seeking to the position), sometimes the player will seek to
the same position and ignore the seek, leading to the frame not being captured,
leaving the retriever in deadlock, waiting for the frame forever. This CL adds
a retry timer to avoid this and make sure we can return query result after some
time.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=204460200
parent cba6da89
...@@ -242,4 +242,7 @@ public interface ExoPlayer extends Player { ...@@ -242,4 +242,7 @@ public interface ExoPlayer extends Player {
* @param seekParameters The seek parameters, or {@code null} to use the defaults. * @param seekParameters The seek parameters, or {@code null} to use the defaults.
*/ */
void setSeekParameters(@Nullable SeekParameters seekParameters); void setSeekParameters(@Nullable SeekParameters seekParameters);
/** Returns the currently active {@link SeekParameters} of the player. */
SeekParameters getSeekParameters();
} }
...@@ -64,6 +64,7 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -64,6 +64,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
private boolean hasPendingPrepare; private boolean hasPendingPrepare;
private boolean hasPendingSeek; private boolean hasPendingSeek;
private PlaybackParameters playbackParameters; private PlaybackParameters playbackParameters;
private SeekParameters seekParameters;
private @Nullable ExoPlaybackException playbackError; private @Nullable ExoPlaybackException playbackError;
// Playback information when there is no pending seek/set source operation. // Playback information when there is no pending seek/set source operation.
...@@ -108,6 +109,7 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -108,6 +109,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
window = new Timeline.Window(); window = new Timeline.Window();
period = new Timeline.Period(); period = new Timeline.Period();
playbackParameters = PlaybackParameters.DEFAULT; playbackParameters = PlaybackParameters.DEFAULT;
seekParameters = SeekParameters.DEFAULT;
eventHandler = eventHandler =
new Handler(looper) { new Handler(looper) {
@Override @Override
...@@ -339,8 +341,16 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -339,8 +341,16 @@ import java.util.concurrent.CopyOnWriteArraySet;
if (seekParameters == null) { if (seekParameters == null) {
seekParameters = SeekParameters.DEFAULT; seekParameters = SeekParameters.DEFAULT;
} }
if (!this.seekParameters.equals(seekParameters)) {
this.seekParameters = seekParameters;
internalPlayer.setSeekParameters(seekParameters); internalPlayer.setSeekParameters(seekParameters);
} }
}
@Override
public SeekParameters getSeekParameters() {
return seekParameters;
}
@Override @Override
public @Nullable Object getCurrentTag() { public @Nullable Object getCurrentTag() {
......
...@@ -792,6 +792,11 @@ public class SimpleExoPlayer ...@@ -792,6 +792,11 @@ public class SimpleExoPlayer
} }
@Override @Override
public SeekParameters getSeekParameters() {
return player.getSeekParameters();
}
@Override
public @Nullable Object getCurrentTag() { public @Nullable Object getCurrentTag() {
return player.getCurrentTag(); return player.getCurrentTag();
} }
......
...@@ -160,6 +160,11 @@ public abstract class StubExoPlayer implements ExoPlayer { ...@@ -160,6 +160,11 @@ public abstract class StubExoPlayer implements ExoPlayer {
} }
@Override @Override
public SeekParameters getSeekParameters() {
throw new UnsupportedOperationException();
}
@Override
public @Nullable Object getCurrentTag() { public @Nullable Object getCurrentTag() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment