mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
Rename ServerSideInsertedAdMediaSource et al
PiperOrigin-RevId: 411657479
This commit is contained in:
parent
92c971ecd0
commit
cbceb2a275
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.source.ads;
|
||||
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getAdCountInGroup;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getMediaPeriodPositionUs;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getMediaPeriodPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getMediaPeriodPositionUsForContent;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getStreamPositionUs;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getAdCountInGroup;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getMediaPeriodPositionUs;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getMediaPeriodPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getMediaPeriodPositionUsForContent;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getStreamPositionUs;
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
|
||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||
@ -76,7 +76,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
* <p>The ad breaks need to be specified using {@link #setAdPlaybackState} and can be updated during
|
||||
* playback.
|
||||
*/
|
||||
public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
||||
public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
|
||||
implements MediaSource.MediaSourceCaller, MediaSourceEventListener, DrmSessionEventListener {
|
||||
|
||||
private final MediaSource mediaSource;
|
||||
@ -99,7 +99,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
||||
*/
|
||||
// Calling BaseMediaSource.createEventDispatcher from the constructor.
|
||||
@SuppressWarnings("nullness:method.invocation")
|
||||
public ServerSideInsertedAdsMediaSource(MediaSource mediaSource) {
|
||||
public ServerSideAdInsertionMediaSource(MediaSource mediaSource) {
|
||||
this.mediaSource = mediaSource;
|
||||
mediaPeriods = ArrayListMultimap.create();
|
||||
adPlaybackState = AdPlaybackState.NONE;
|
||||
@ -148,7 +148,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
||||
this.adPlaybackState = adPlaybackState;
|
||||
if (contentTimeline != null) {
|
||||
refreshSourceInfo(
|
||||
new ServerSideInsertedAdsTimeline(contentTimeline, adPlaybackState));
|
||||
new ServerSideAdInsertionTimeline(contentTimeline, adPlaybackState));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -193,7 +193,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
||||
if (AdPlaybackState.NONE.equals(adPlaybackState)) {
|
||||
return;
|
||||
}
|
||||
refreshSourceInfo(new ServerSideInsertedAdsTimeline(timeline, adPlaybackState));
|
||||
refreshSourceInfo(new ServerSideAdInsertionTimeline(timeline, adPlaybackState));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -899,11 +899,11 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ServerSideInsertedAdsTimeline extends ForwardingTimeline {
|
||||
private static final class ServerSideAdInsertionTimeline extends ForwardingTimeline {
|
||||
|
||||
private final AdPlaybackState adPlaybackState;
|
||||
|
||||
public ServerSideInsertedAdsTimeline(
|
||||
public ServerSideAdInsertionTimeline(
|
||||
Timeline contentTimeline, AdPlaybackState adPlaybackState) {
|
||||
super(contentTimeline);
|
||||
Assertions.checkState(contentTimeline.getPeriodCount() == 1);
|
@ -26,9 +26,9 @@ import com.google.android.exoplayer2.source.MediaPeriodId;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
/** A static utility class with methods to work with server-side inserted ads. */
|
||||
public final class ServerSideInsertedAdsUtil {
|
||||
public final class ServerSideAdInsertionUtil {
|
||||
|
||||
private ServerSideInsertedAdsUtil() {}
|
||||
private ServerSideAdInsertionUtil() {}
|
||||
|
||||
/**
|
||||
* Adds a new server-side inserted ad group to an {@link AdPlaybackState}.
|
@ -19,7 +19,7 @@ import static com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainL
|
||||
import static com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.playUntilPosition;
|
||||
import static com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPendingCommandsAreFullyHandled;
|
||||
import static com.google.android.exoplayer2.robolectric.TestPlayerRunHelper.runUntilPlaybackState;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.addAdGroupToAdPlaybackState;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@ -54,9 +54,9 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit test for {@link ServerSideInsertedAdsMediaSource}. */
|
||||
/** Unit test for {@link ServerSideAdInsertionMediaSource}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class ServerSideInsertedAdMediaSourceTest {
|
||||
public final class ServerSideAdInsertionMediaSourceTest {
|
||||
|
||||
@Rule
|
||||
public ShadowMediaCodecConfig mediaCodecConfig =
|
||||
@ -80,8 +80,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
|
||||
/* defaultPositionUs= */ 3_000_000,
|
||||
/* windowOffsetInFirstPeriodUs= */ 42_000_000L,
|
||||
AdPlaybackState.NONE));
|
||||
ServerSideInsertedAdsMediaSource mediaSource =
|
||||
new ServerSideInsertedAdsMediaSource(new FakeMediaSource(wrappedTimeline));
|
||||
ServerSideAdInsertionMediaSource mediaSource =
|
||||
new ServerSideAdInsertionMediaSource(new FakeMediaSource(wrappedTimeline));
|
||||
// Test with one ad group before the window, and the window starting within the second ad group.
|
||||
AdPlaybackState adPlaybackState =
|
||||
new AdPlaybackState(
|
||||
@ -152,8 +152,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
|
||||
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));
|
||||
PlaybackOutput playbackOutput = PlaybackOutput.register(player, renderersFactory);
|
||||
|
||||
ServerSideInsertedAdsMediaSource mediaSource =
|
||||
new ServerSideInsertedAdsMediaSource(
|
||||
ServerSideAdInsertionMediaSource mediaSource =
|
||||
new ServerSideAdInsertionMediaSource(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.createMediaSource(MediaItem.fromUri(TEST_ASSET)));
|
||||
AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */ new Object());
|
||||
@ -211,8 +211,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
|
||||
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));
|
||||
PlaybackOutput playbackOutput = PlaybackOutput.register(player, renderersFactory);
|
||||
|
||||
ServerSideInsertedAdsMediaSource mediaSource =
|
||||
new ServerSideInsertedAdsMediaSource(
|
||||
ServerSideAdInsertionMediaSource mediaSource =
|
||||
new ServerSideAdInsertionMediaSource(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.createMediaSource(MediaItem.fromUri(TEST_ASSET)));
|
||||
AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */ new Object());
|
||||
@ -271,8 +271,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
|
||||
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));
|
||||
PlaybackOutput playbackOutput = PlaybackOutput.register(player, renderersFactory);
|
||||
|
||||
ServerSideInsertedAdsMediaSource mediaSource =
|
||||
new ServerSideInsertedAdsMediaSource(
|
||||
ServerSideAdInsertionMediaSource mediaSource =
|
||||
new ServerSideAdInsertionMediaSource(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.createMediaSource(MediaItem.fromUri(TEST_ASSET)));
|
||||
AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */ new Object());
|
||||
@ -325,8 +325,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
|
||||
new ExoPlayer.Builder(context).setClock(new FakeClock(/* isAutoAdvancing= */ true)).build();
|
||||
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));
|
||||
|
||||
ServerSideInsertedAdsMediaSource mediaSource =
|
||||
new ServerSideInsertedAdsMediaSource(
|
||||
ServerSideAdInsertionMediaSource mediaSource =
|
||||
new ServerSideAdInsertionMediaSource(
|
||||
new DefaultMediaSourceFactory(context)
|
||||
.createMediaSource(MediaItem.fromUri(TEST_ASSET)));
|
||||
AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */ new Object());
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.source.ads;
|
||||
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.addAdGroupToAdPlaybackState;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getAdCountInGroup;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getMediaPeriodPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getMediaPeriodPositionUsForContent;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getStreamPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideInsertedAdsUtil.getStreamPositionUsForContent;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getAdCountInGroup;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getMediaPeriodPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getMediaPeriodPositionUsForContent;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getStreamPositionUsForAd;
|
||||
import static com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.getStreamPositionUsForContent;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@ -28,9 +28,9 @@ import com.google.android.exoplayer2.C;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit tests for {@link ServerSideInsertedAdsUtil}. */
|
||||
/** Unit tests for {@link ServerSideAdInsertionUtil}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class ServerSideInsertedAdsUtilTest {
|
||||
public final class ServerSideAdInsertionUtilTest {
|
||||
|
||||
private static final Object ADS_ID = new Object();
|
||||
|
Loading…
x
Reference in New Issue
Block a user