mirror of
https://github.com/androidx/media.git
synced 2025-05-10 09:12:16 +08: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
57277a23da
commit
363c75b69c
@ -893,8 +893,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);
|
||||||
|
@ -106,7 +106,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;
|
||||||
@ -135,10 +135,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,10 +146,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory) {
|
public DefaultMediaSourceFactory(DataSource.Factory dataSourceFactory) {
|
||||||
this(
|
this(dataSourceFactory, new DefaultExtractorsFactory());
|
||||||
dataSourceFactory,
|
|
||||||
new DefaultExtractorsFactory(),
|
|
||||||
/* serverSideDaiMediaSourceFactory= */ null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,18 +156,11 @@ 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.
|
|
||||||
*/
|
*/
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
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;
|
||||||
@ -224,6 +211,26 @@ 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.
|
||||||
|
*/
|
||||||
|
@UnstableApi
|
||||||
|
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.
|
||||||
*
|
*
|
||||||
@ -318,7 +325,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…
x
Reference in New Issue
Block a user