Commit d7b4f8a6 by tonihei Committed by Oliver Woodman

Amend seek action in ActionSchedule to optionally wait until playback resumes.

This allows more deterministic action schedules, especially for real media
which may take an arbitrary amount of time to rebuffer after seeking.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171005231
parent 498ff144
...@@ -39,8 +39,8 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa ...@@ -39,8 +39,8 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
// Seeks help reproduce playback issues in certain devices. // Seeks help reproduce playback issues in certain devices.
private static final ActionSchedule ACTION_SCHEDULE_WITH_SEEKS = new ActionSchedule.Builder(TAG) private static final ActionSchedule ACTION_SCHEDULE_WITH_SEEKS = new ActionSchedule.Builder(TAG)
.delay(30000).seek(300000).delay(10000).seek(270000).delay(10000).seek(200000).delay(10000) .delay(30000).seekAndWait(300000).delay(10000).seekAndWait(270000).delay(10000)
.seek(732000).build(); .seekAndWait(200000).delay(10000).seekAndWait(732000).build();
private DashTestRunner testRunner; private DashTestRunner testRunner;
......
...@@ -33,10 +33,10 @@ public final class DashStreamingTest extends ActivityInstrumentationTestCase2<Ho ...@@ -33,10 +33,10 @@ public final class DashStreamingTest extends ActivityInstrumentationTestCase2<Ho
private static final String TAG = "DashStreamingTest"; private static final String TAG = "DashStreamingTest";
private static final ActionSchedule SEEKING_SCHEDULE = new ActionSchedule.Builder(TAG) private static final ActionSchedule SEEKING_SCHEDULE = new ActionSchedule.Builder(TAG)
.delay(10000).seek(15000) .delay(10000).seekAndWait(15000)
.delay(10000).seek(30000).seek(31000).seek(32000).seek(33000).seek(34000) .delay(10000).seek(30000).seek(31000).seek(32000).seek(33000).seekAndWait(34000)
.delay(1000).pause().delay(1000).play() .delay(1000).pause().delay(1000).play()
.delay(1000).pause().seek(120000).delay(1000).play() .delay(1000).pause().seekAndWait(120000).delay(1000).play()
.build(); .build();
private static final ActionSchedule RENDERER_DISABLING_SCHEDULE = new ActionSchedule.Builder(TAG) private static final ActionSchedule RENDERER_DISABLING_SCHEDULE = new ActionSchedule.Builder(TAG)
// Wait 10 seconds, disable the video renderer, wait another 10 seconds and enable it again. // Wait 10 seconds, disable the video renderer, wait another 10 seconds and enable it again.
......
...@@ -423,6 +423,39 @@ public abstract class Action { ...@@ -423,6 +423,39 @@ public abstract class Action {
} }
/** /**
* Waits for {@link Player.EventListener#onSeekProcessed()}.
*/
public static final class WaitForSeekProcessed extends Action {
/**
* @param tag A tag to use for logging.
*/
public WaitForSeekProcessed(String tag) {
super(tag, "WaitForSeekProcessed");
}
@Override
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
final ActionNode nextAction) {
player.addListener(new Player.DefaultEventListener() {
@Override
public void onSeekProcessed() {
player.removeListener(this);
nextAction.schedule(player, trackSelector, surface, handler);
}
});
}
@Override
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
Surface surface) {
// Not triggered.
}
}
/**
* Calls {@link Runnable#run()}. * Calls {@link Runnable#run()}.
*/ */
public static final class ExecuteRunnable extends Action { public static final class ExecuteRunnable extends Action {
......
...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.testutil.Action.SetVideoSurface; ...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.testutil.Action.SetVideoSurface;
import com.google.android.exoplayer2.testutil.Action.Stop; import com.google.android.exoplayer2.testutil.Action.Stop;
import com.google.android.exoplayer2.testutil.Action.WaitForPlaybackState; import com.google.android.exoplayer2.testutil.Action.WaitForPlaybackState;
import com.google.android.exoplayer2.testutil.Action.WaitForPositionDiscontinuity; import com.google.android.exoplayer2.testutil.Action.WaitForPositionDiscontinuity;
import com.google.android.exoplayer2.testutil.Action.WaitForSeekProcessed;
import com.google.android.exoplayer2.testutil.Action.WaitForTimelineChanged; import com.google.android.exoplayer2.testutil.Action.WaitForTimelineChanged;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
...@@ -139,6 +140,18 @@ public final class ActionSchedule { ...@@ -139,6 +140,18 @@ public final class ActionSchedule {
} }
/** /**
* Schedules a seek action to be executed and waits until playback resumes after the seek.
*
* @param positionMs The seek position.
* @return The builder, for convenience.
*/
public Builder seekAndWait(long positionMs) {
return apply(new Seek(tag, positionMs))
.apply(new WaitForSeekProcessed(tag))
.apply(new WaitForPlaybackState(tag, Player.STATE_READY));
}
/**
* Schedules a stop action to be executed. * Schedules a stop action to be executed.
* *
* @return The builder, for convenience. * @return The builder, for convenience.
......
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