mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Move DAI MediaSource.Factory from constructor parameter to setter
This allows the same DefaultMediaSourceFactory instance to be used as the contentMediaSourceFactory inside ImaServerSideAdInsertionMediaSource. PiperOrigin-RevId: 425846609
This commit is contained in:
parent
0a8e5d978a
commit
63bc675549
2 changed files with 25 additions and 20 deletions
|
|
@ -890,8 +890,7 @@ public final class DownloadHelper {
|
||||||
MediaItem mediaItem,
|
MediaItem mediaItem,
|
||||||
DataSource.Factory dataSourceFactory,
|
DataSource.Factory dataSourceFactory,
|
||||||
@Nullable DrmSessionManager drmSessionManager) {
|
@Nullable DrmSessionManager drmSessionManager) {
|
||||||
return new DefaultMediaSourceFactory(
|
return new DefaultMediaSourceFactory(dataSourceFactory, ExtractorsFactory.EMPTY)
|
||||||
dataSourceFactory, ExtractorsFactory.EMPTY, /* serverSideDaiMediaSourceFactory= */ null)
|
|
||||||
.setDrmSessionManagerProvider(
|
.setDrmSessionManagerProvider(
|
||||||
drmSessionManager != null ? unusedMediaItem -> drmSessionManager : null)
|
drmSessionManager != null ? unusedMediaItem -> drmSessionManager : null)
|
||||||
.createMediaSource(mediaItem);
|
.createMediaSource(mediaItem);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
private final DelegateFactoryLoader delegateFactoryLoader;
|
private final DelegateFactoryLoader delegateFactoryLoader;
|
||||||
|
|
||||||
@Nullable private final MediaSource.Factory serverSideDaiMediaSourceFactory;
|
@Nullable private MediaSource.Factory imaServerSideAdInsertionMediaSourceFactory;
|
||||||
@Nullable private AdsLoader.Provider adsLoaderProvider;
|
@Nullable private AdsLoader.Provider adsLoaderProvider;
|
||||||
@Nullable private AdViewProvider adViewProvider;
|
@Nullable private AdViewProvider adViewProvider;
|
||||||
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
|
|
@ -132,10 +132,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
* its container.
|
* its container.
|
||||||
*/
|
*/
|
||||||
public DefaultMediaSourceFactory(Context context, ExtractorsFactory extractorsFactory) {
|
public DefaultMediaSourceFactory(Context context, ExtractorsFactory extractorsFactory) {
|
||||||
this(
|
this(new DefaultDataSource.Factory(context), extractorsFactory);
|
||||||
new DefaultDataSource.Factory(context),
|
|
||||||
extractorsFactory,
|
|
||||||
/* serverSideDaiMediaSourceFactory= */ null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,10 +142,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
* for requesting media data.
|
* for requesting media data.
|
||||||
*/
|
*/
|
||||||
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory) {
|
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory) {
|
||||||
this(
|
this(dataSourceFactory, new DefaultExtractorsFactory());
|
||||||
dataSourceFactory,
|
|
||||||
new DefaultExtractorsFactory(),
|
|
||||||
/* serverSideDaiMediaSourceFactory= */ null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -158,17 +152,10 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
* for requesting media data.
|
* for requesting media data.
|
||||||
* @param extractorsFactory An {@link ExtractorsFactory} used to extract progressive media from
|
* @param extractorsFactory An {@link ExtractorsFactory} used to extract progressive media from
|
||||||
* its container.
|
* its container.
|
||||||
* @param serverSideDaiMediaSourceFactory A {@link MediaSource.Factory} for creating server side
|
|
||||||
* inserted ad media sources.
|
|
||||||
*/
|
*/
|
||||||
public DefaultMediaSourceFactory(
|
public DefaultMediaSourceFactory(
|
||||||
DataSource.Factory dataSourceFactory,
|
DataSource.Factory dataSourceFactory, ExtractorsFactory extractorsFactory) {
|
||||||
ExtractorsFactory extractorsFactory,
|
|
||||||
@Nullable MediaSource.Factory serverSideDaiMediaSourceFactory) {
|
|
||||||
this.dataSourceFactory = dataSourceFactory;
|
this.dataSourceFactory = dataSourceFactory;
|
||||||
// Temporary until factory registration is agreed upon.
|
|
||||||
this.serverSideDaiMediaSourceFactory = serverSideDaiMediaSourceFactory;
|
|
||||||
|
|
||||||
delegateFactoryLoader = new DelegateFactoryLoader(dataSourceFactory, extractorsFactory);
|
delegateFactoryLoader = new DelegateFactoryLoader(dataSourceFactory, extractorsFactory);
|
||||||
liveTargetOffsetMs = C.TIME_UNSET;
|
liveTargetOffsetMs = C.TIME_UNSET;
|
||||||
liveMinOffsetMs = C.TIME_UNSET;
|
liveMinOffsetMs = C.TIME_UNSET;
|
||||||
|
|
@ -218,6 +205,25 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link MediaSource.Factory} used to handle {@link MediaItem} instances containing <a
|
||||||
|
* href="https://support.google.com/admanager/answer/6147120">IMA Dynamic Ad Insertion URIs</a>.
|
||||||
|
*
|
||||||
|
* <p>In most cases this will be an {@code ImaServerSideAdInsertionMediaSource.Factory} from the
|
||||||
|
* IMA extension.
|
||||||
|
*
|
||||||
|
* <p>IMA DAI URIs are those with a scheme of {@code "imadai"}.
|
||||||
|
*
|
||||||
|
* @param imaServerSideAdInsertionMediaSourceFactory The {@link MediaSource.Factory} for IMA DAI
|
||||||
|
* content, or {@code null} to remove a previously set {@link MediaSource.Factory}.
|
||||||
|
* @return This factory, for convenience.
|
||||||
|
*/
|
||||||
|
public DefaultMediaSourceFactory setImaServerSideAdInsertionMediaSourceFactory(
|
||||||
|
@Nullable MediaSource.Factory imaServerSideAdInsertionMediaSourceFactory) {
|
||||||
|
this.imaServerSideAdInsertionMediaSourceFactory = imaServerSideAdInsertionMediaSourceFactory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the target live offset for live streams, in milliseconds.
|
* Sets the target live offset for live streams, in milliseconds.
|
||||||
*
|
*
|
||||||
|
|
@ -303,7 +309,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
Assertions.checkNotNull(mediaItem.localConfiguration);
|
Assertions.checkNotNull(mediaItem.localConfiguration);
|
||||||
@Nullable String scheme = mediaItem.localConfiguration.uri.getScheme();
|
@Nullable String scheme = mediaItem.localConfiguration.uri.getScheme();
|
||||||
if (scheme != null && scheme.equals("imadai")) {
|
if (scheme != null && scheme.equals("imadai")) {
|
||||||
return checkNotNull(serverSideDaiMediaSourceFactory).createMediaSource(mediaItem);
|
return checkNotNull(imaServerSideAdInsertionMediaSourceFactory).createMediaSource(mediaItem);
|
||||||
}
|
}
|
||||||
@C.ContentType
|
@C.ContentType
|
||||||
int type =
|
int type =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue