Enable re-preparing the ImaSSAIMediaSource
#minor-release PiperOrigin-RevId: 538927855
This commit is contained in:
parent
605af62d00
commit
a67ce066df
@ -110,8 +110,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
|
|
||||||
/** MediaSource for IMA server side inserted ad streams. */
|
/** MediaSource for IMA server side inserted ad streams. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -520,7 +518,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
@Nullable private StreamManager streamManager;
|
@Nullable private StreamManager streamManager;
|
||||||
@Nullable private ServerSideAdInsertionMediaSource serverSideAdInsertionMediaSource;
|
@Nullable private ServerSideAdInsertionMediaSource serverSideAdInsertionMediaSource;
|
||||||
@Nullable private IOException loadError;
|
@Nullable private IOException loadError;
|
||||||
private @MonotonicNonNull Timeline contentTimeline;
|
@Nullable private Timeline contentTimeline;
|
||||||
private AdPlaybackState adPlaybackState;
|
private AdPlaybackState adPlaybackState;
|
||||||
|
|
||||||
private ImaServerSideAdInsertionMediaSource(
|
private ImaServerSideAdInsertionMediaSource(
|
||||||
@ -635,6 +633,8 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
});
|
});
|
||||||
loader = null;
|
loader = null;
|
||||||
}
|
}
|
||||||
|
contentTimeline = null;
|
||||||
|
serverSideAdInsertionMediaSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal methods (called on the main thread).
|
// Internal methods (called on the main thread).
|
||||||
@ -682,7 +682,6 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
@EnsuresNonNull("this.contentTimeline")
|
|
||||||
private void setContentTimeline(Timeline contentTimeline) {
|
private void setContentTimeline(Timeline contentTimeline) {
|
||||||
if (contentTimeline.equals(this.contentTimeline)) {
|
if (contentTimeline.equals(this.contentTimeline)) {
|
||||||
return;
|
return;
|
||||||
@ -700,6 +699,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
@MainThread
|
@MainThread
|
||||||
private void invalidateServerSideAdInsertionAdPlaybackState() {
|
private void invalidateServerSideAdInsertionAdPlaybackState() {
|
||||||
if (!adPlaybackState.equals(AdPlaybackState.NONE) && contentTimeline != null) {
|
if (!adPlaybackState.equals(AdPlaybackState.NONE) && contentTimeline != null) {
|
||||||
|
Timeline contentTimeline = checkNotNull(this.contentTimeline);
|
||||||
ImmutableMap<Object, AdPlaybackState> splitAdPlaybackStates;
|
ImmutableMap<Object, AdPlaybackState> splitAdPlaybackStates;
|
||||||
if (Objects.equals(streamRequest.getFormat(), StreamFormat.DASH)) {
|
if (Objects.equals(streamRequest.getFormat(), StreamFormat.DASH)) {
|
||||||
// DASH ad groups are always split by period.
|
// DASH ad groups are always split by period.
|
||||||
@ -727,9 +727,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
// Internal methods (called on the playback thread).
|
// Internal methods (called on the playback thread).
|
||||||
|
|
||||||
private void setContentUri(Uri contentUri) {
|
private void setContentUri(Uri contentUri) {
|
||||||
if (serverSideAdInsertionMediaSource != null) {
|
if (serverSideAdInsertionMediaSource == null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
MediaItem contentMediaItem =
|
MediaItem contentMediaItem =
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(contentUri)
|
.setUri(contentUri)
|
||||||
@ -745,10 +743,12 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
if (isLiveStream) {
|
if (isLiveStream) {
|
||||||
mainHandler.post(
|
mainHandler.post(
|
||||||
() ->
|
() ->
|
||||||
setAdPlaybackState(new AdPlaybackState(adsId).withLivePostrollPlaceholderAppended()));
|
setAdPlaybackState(
|
||||||
|
new AdPlaybackState(adsId).withLivePostrollPlaceholderAppended()));
|
||||||
}
|
}
|
||||||
prepareChildSource(/* id= */ null, serverSideAdInsertionMediaSource);
|
prepareChildSource(/* id= */ null, serverSideAdInsertionMediaSource);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Static methods.
|
// Static methods.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user