Skip to content

Commit

Permalink
Merge pull request #5187 from BrainCrumbz:feat/get-tag
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 224166374
  • Loading branch information
ojw28 committed Dec 5, 2018
2 parents b993367 + a11a871 commit 556dd7e
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public ImaAdsMediaSource(
adUiViewGroup, eventHandler, eventListener);
}

@Override
@Nullable
public Object getTag() {
return adsMediaSource.getTag();
}

@Override
public void prepareSourceInternal(
final ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ public ClippingMediaSource(
window = new Timeline.Window();
}

@Override
@Nullable
public Object getTag() {
return mediaSource.getTag();
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,12 @@ public final synchronized void setShuffleOrder(
}
}

@Override
@Nullable
public Object getTag() {
return null;
}

@Override
public final synchronized void prepareSourceInternal(
ExoPlayer player,
Expand Down Expand Up @@ -1069,6 +1075,12 @@ protected void prepareSourceInternal(
// Do nothing.
}

@Override
@Nullable
public Object getTag() {
return null;
}

@Override
protected void releaseSourceInternal() {
// Do nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ private ExtractorMediaSource(
this.tag = tag;
}

@Override
@Nullable
public Object getTag() {
return tag;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public LoopingMediaSource(MediaSource childSource, int loopCount) {
mediaPeriodToChildMediaPeriodId = new HashMap<>();
}

@Override
@Nullable
public Object getTag() {
return childSource.getTag();
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ public int hashCode() {
*/
void removeEventListener(MediaSourceEventListener eventListener);

/** Returns the tag set on the media source, or null if none was set. */
@Nullable
default Object getTag() {
return null;
}

/**
* Starts source preparation if not yet started, and adds a listener for timeline and/or manifest
* updates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public MergingMediaSource(CompositeSequenceableLoaderFactory compositeSequenceab
timelines = new Timeline[mediaSources.length];
}

@Override
@Nullable
public Object getTag() {
return mediaSources.length > 0 ? mediaSources[0].getTag() : null;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public SingleSampleMediaSource createMediaSource(
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private final boolean treatLoadErrorsAsEndOfStream;
private final Timeline timeline;
@Nullable private final Object tag;

private @Nullable TransferListener transferListener;

Expand Down Expand Up @@ -287,13 +288,20 @@ private SingleSampleMediaSource(
this.durationUs = durationUs;
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
this.tag = tag;
dataSpec = new DataSpec(uri, DataSpec.FLAG_ALLOW_GZIP);
timeline =
new SinglePeriodTimeline(durationUs, /* isSeekable= */ true, /* isDynamic= */ false, tag);
}

// MediaSource implementation.

@Override
@Nullable
public Object getTag() {
return tag;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ public AdsMediaSource(
adsLoader.setSupportedContentTypes(adMediaSourceFactory.getSupportedTypes());
}

@Override
@Nullable
public Object getTag() {
return contentMediaSource.getTag();
}

@Override
public void prepareSourceInternal(
final ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,12 @@ public void replaceManifestUri(Uri manifestUri) {

// MediaSource implementation.

@Override
@Nullable
public Object getTag() {
return tag;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ private HlsMediaSource(
this.tag = tag;
}

@Override
@Nullable
public Object getTag() {
return tag;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ private SsMediaSource(

// MediaSource implementation.

@Override
@Nullable
public Object getTag() {
return tag;
}

@Override
public void prepareSourceInternal(
ExoPlayer player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public FakeMediaSource(@Nullable Timeline timeline, Object manifest,
this.trackGroupArray = trackGroupArray;
}

@Override
@Nullable
public Object getTag() {
boolean hasTimeline = timeline != null && !timeline.isEmpty();
return hasTimeline ? timeline.getWindow(0, new Timeline.Window()).tag : null;
}

@Override
public synchronized void prepareSourceInternal(
ExoPlayer player,
Expand Down

0 comments on commit 556dd7e

Please sign in to comment.