Skip to content

Commit 8f17ab8

Browse files
ychaparovcopybara-github
authored andcommitted
Add API for sample dependency reading to DefaultMediaSourceFactory
PiperOrigin-RevId: 715372196
1 parent 2eb8e53 commit 8f17ab8

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/DefaultMediaSourceFactory.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ public DefaultMediaSourceFactory setSubtitleParserFactory(
211211
return this;
212212
}
213213

214+
@CanIgnoreReturnValue
215+
@Override
216+
@UnstableApi
217+
public DefaultMediaSourceFactory experimentalSetCodecsToParseWithinGopSampleDependencies(
218+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
219+
delegateFactoryLoader.setCodecsToParseWithinGopSampleDependencies(
220+
codecsToParseWithinGopSampleDependencies);
221+
return this;
222+
}
223+
214224
/**
215225
* Sets the {@link AdsLoader.Provider} that provides {@link AdsLoader} instances for media items
216226
* that have {@link MediaItem.LocalConfiguration#adsConfiguration ads configurations}.
@@ -625,6 +635,7 @@ private static final class DelegateFactoryLoader {
625635
private DataSource.@MonotonicNonNull Factory dataSourceFactory;
626636
private boolean parseSubtitlesDuringExtraction;
627637
private SubtitleParser.Factory subtitleParserFactory;
638+
private @C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies;
628639
@Nullable private CmcdConfiguration.Factory cmcdConfigurationFactory;
629640
@Nullable private DrmSessionManagerProvider drmSessionManagerProvider;
630641
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
@@ -664,6 +675,8 @@ public MediaSource.Factory getMediaSourceFactory(@C.ContentType int contentType)
664675
}
665676
mediaSourceFactory.setSubtitleParserFactory(subtitleParserFactory);
666677
mediaSourceFactory.experimentalParseSubtitlesDuringExtraction(parseSubtitlesDuringExtraction);
678+
mediaSourceFactory.experimentalSetCodecsToParseWithinGopSampleDependencies(
679+
codecsToParseWithinGopSampleDependencies);
667680
mediaSourceFactories.put(contentType, mediaSourceFactory);
668681
return mediaSourceFactory;
669682
}
@@ -695,6 +708,13 @@ public void setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactor
695708
}
696709
}
697710

711+
public void setCodecsToParseWithinGopSampleDependencies(
712+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
713+
this.codecsToParseWithinGopSampleDependencies = codecsToParseWithinGopSampleDependencies;
714+
extractorsFactory.experimentalSetCodecsToParseWithinGopSampleDependencies(
715+
codecsToParseWithinGopSampleDependencies);
716+
}
717+
698718
public void setCmcdConfigurationFactory(CmcdConfiguration.Factory cmcdConfigurationFactory) {
699719
this.cmcdConfigurationFactory = cmcdConfigurationFactory;
700720
for (MediaSource.Factory mediaSourceFactory : mediaSourceFactories.values()) {

libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/MediaSource.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import androidx.media3.exoplayer.upstream.Allocator;
3131
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
3232
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
33+
import androidx.media3.extractor.mp4.Mp4Extractor;
3334
import androidx.media3.extractor.text.SubtitleParser;
35+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3436
import java.io.IOException;
3537

3638
/**
@@ -131,6 +133,26 @@ default Factory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFa
131133
return this;
132134
}
133135

136+
/**
137+
* Sets the set of video codecs for which within GOP sample dependency information should be
138+
* parsed as part of extraction. Defaults to {@code 0} - empty set of codecs.
139+
*
140+
*

Having access to additional sample dependency information can speed up seeking. See {@link

141+
* Mp4Extractor#FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES}.
142+
*
143+
*

This method is experimental and will be renamed or removed in a future release.

144+
*
145+
* @param codecsToParseWithinGopSampleDependencies The set of codecs for which to parse within
146+
* GOP sample dependency information.
147+
* @return This factory, for convenience.
148+
*/
149+
@UnstableApi
150+
@CanIgnoreReturnValue
151+
default Factory experimentalSetCodecsToParseWithinGopSampleDependencies(
152+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
153+
return this;
154+
}
155+
134156
/**
135157
* Returns the {@link C.ContentType content types} supported by media sources created by this
136158
* factory.

libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashChunkSource.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
3131
import androidx.media3.exoplayer.upstream.LoaderErrorThrower;
3232
import androidx.media3.extractor.Extractor;
33+
import androidx.media3.extractor.mp4.Mp4Extractor;
3334
import androidx.media3.extractor.text.SubtitleParser;
3435
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3536
import java.util.List;
@@ -71,6 +72,25 @@ default Factory experimentalParseSubtitlesDuringExtraction(
7172
return this;
7273
}
7374

75+
/**
76+
* Sets the set of video codecs for which within GOP sample dependency information should be
77+
* parsed as part of extraction. Defaults to {@code 0} - empty set of codecs.
78+
*
79+
*

Having access to additional sample dependency information can speed up seeking. See {@link

80+
* Mp4Extractor#FLAG_READ_WITHIN_GOP_SAMPLE_DEPENDENCIES}.
81+
*
82+
*

This method is experimental and will be renamed or removed in a future release.

83+
*
84+
* @param codecsToParseWithinGopSampleDependencies The set of codecs for which to parse within
85+
* GOP sample dependency information.
86+
* @return This factory, for convenience.
87+
*/
88+
@CanIgnoreReturnValue
89+
default Factory experimentalSetCodecsToParseWithinGopSampleDependencies(
90+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
91+
return this;
92+
}
93+
7494
/**
7595
* @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
7696
* @param manifest The initial manifest.

libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ public Factory experimentalParseSubtitlesDuringExtraction(
217217
return this;
218218
}
219219

220+
@Override
221+
@CanIgnoreReturnValue
222+
public Factory experimentalSetCodecsToParseWithinGopSampleDependencies(
223+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
224+
chunkSourceFactory.experimentalSetCodecsToParseWithinGopSampleDependencies(
225+
codecsToParseWithinGopSampleDependencies);
226+
return this;
227+
}
228+
220229
/**
221230
* Sets the target {@link Player#getCurrentLiveOffset() offset for live streams} that is used if
222231
* no value is defined in the {@link MediaItem} or the manifest.

libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DefaultDashChunkSource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ public Factory experimentalParseSubtitlesDuringExtraction(
130130
return this;
131131
}
132132

133+
@CanIgnoreReturnValue
134+
@Override
135+
public Factory experimentalSetCodecsToParseWithinGopSampleDependencies(
136+
@C.VideoCodecFlags int codecsToParseWithinGopSampleDependencies) {
137+
chunkExtractorFactory.experimentalSetCodecsToParseWithinGopSampleDependencies(
138+
codecsToParseWithinGopSampleDependencies);
139+
return this;
140+
}
141+
133142
@Override
134143
public DashChunkSource createDashChunkSource(
135144
LoaderErrorThrower manifestLoaderErrorThrower,

0 commit comments

Comments
 (0)