Commit 72437e44 by bachinger Committed by Ian Baker

Rollback of https://github.com/google/ExoPlayer/commit/ff89170b008b8b3438b7c002a156fbfb41c05174

*** Original commit ***

Fix some logic in AnalyticsCollector.

All events issued from ExoPlayerImpl (i.e. Player.EventListener events) currently
try to use the media period data from the playing media period as set in the
playback thread queue. This is only correct as long as there no pending masking
operations in ExoPlayerImpl. That's why we currently disable this whenever the timeline
is empty or a seek is pending. Since adding all the playlist API methods to the player,
this is no longer the right choice. Moreover,...

***

PiperOrigin-RevId: 290312118
parent 4cf614c6
...@@ -25,6 +25,7 @@ import android.content.Context; ...@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri;
import android.os.Looper; import android.os.Looper;
import android.view.Surface; import android.view.Surface;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -2968,7 +2969,10 @@ public final class ExoPlayerTest { ...@@ -2968,7 +2969,10 @@ public final class ExoPlayerTest {
@Test @Test
public void contentWithInitialSeekPositionAfterPrerollAdStartsAtSeekPosition() throws Exception { public void contentWithInitialSeekPositionAfterPrerollAdStartsAtSeekPosition() throws Exception {
AdPlaybackState adPlaybackState = AdPlaybackState adPlaybackState =
FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs...= */ 0); FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs= */ 0)
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.parse("https://ad1"))
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 1, Uri.parse("https://ad2"))
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 2, Uri.parse("https://ad3"));
Timeline fakeTimeline = Timeline fakeTimeline =
new FakeTimeline( new FakeTimeline(
new TimelineWindowDefinition( new TimelineWindowDefinition(
...@@ -4056,14 +4060,15 @@ public final class ExoPlayerTest { ...@@ -4056,14 +4060,15 @@ public final class ExoPlayerTest {
} }
}) })
.build(); .build();
new ExoPlayerTestRunner.Builder() ExoPlayerTestRunner testRunner =
.setMediaSources(concatenatingMediaSource) new ExoPlayerTestRunner.Builder()
.initialSeek(seekToWindowIndex, 5000) .setMediaSources(concatenatingMediaSource)
.setActionSchedule(actionSchedule) .initialSeek(seekToWindowIndex, 5000)
.build(context) .setActionSchedule(actionSchedule)
.start() .build(context)
.blockUntilActionScheduleFinished(TIMEOUT_MS) .start()
.blockUntilEnded(TIMEOUT_MS); .blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
assertArrayEquals(new long[] {5_000}, currentPlaybackPositions); assertArrayEquals(new long[] {5_000}, currentPlaybackPositions);
assertArrayEquals(new int[] {seekToWindowIndex}, currentWindowIndices); assertArrayEquals(new int[] {seekToWindowIndex}, currentWindowIndices);
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.testutil; package com.google.android.exoplayer2.testutil;
import android.net.Uri;
import android.util.Pair; import android.util.Pair;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
...@@ -161,19 +160,11 @@ public final class FakeTimeline extends Timeline { ...@@ -161,19 +160,11 @@ public final class FakeTimeline extends Timeline {
AdPlaybackState adPlaybackState = new AdPlaybackState(adGroupTimesUs); AdPlaybackState adPlaybackState = new AdPlaybackState(adGroupTimesUs);
long[][] adDurationsUs = new long[adGroupCount][]; long[][] adDurationsUs = new long[adGroupCount][];
for (int i = 0; i < adGroupCount; i++) { for (int i = 0; i < adGroupCount; i++) {
adPlaybackState = adPlaybackState.withAdCount(/* adGroupIndex= */ i, adsPerAdGroup); adPlaybackState = adPlaybackState.withAdCount(i, adsPerAdGroup);
for (int j = 0; j < adsPerAdGroup; j++) {
adPlaybackState =
adPlaybackState.withAdUri(
/* adGroupIndex= */ i,
/* adIndexInAdGroup= */ j,
Uri.parse("https://ad/" + i + "/" + j));
}
adDurationsUs[i] = new long[adsPerAdGroup]; adDurationsUs[i] = new long[adsPerAdGroup];
Arrays.fill(adDurationsUs[i], AD_DURATION_US); Arrays.fill(adDurationsUs[i], AD_DURATION_US);
} }
adPlaybackState = adPlaybackState.withAdDurationsUs(adDurationsUs); adPlaybackState = adPlaybackState.withAdDurationsUs(adDurationsUs);
return adPlaybackState; return adPlaybackState;
} }
......
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