mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Allow setting the ad media bitrate in ImaAdsLoader
This commit is contained in:
parent
1ef3efaa90
commit
861b81694d
1 changed files with 26 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ public final class ImaAdsLoader
|
||||||
private @Nullable AdEventListener adEventListener;
|
private @Nullable AdEventListener adEventListener;
|
||||||
private int vastLoadTimeoutMs;
|
private int vastLoadTimeoutMs;
|
||||||
private int mediaLoadTimeoutMs;
|
private int mediaLoadTimeoutMs;
|
||||||
|
private int mediaBitrateKbps;
|
||||||
private ImaFactory imaFactory;
|
private ImaFactory imaFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -104,6 +105,7 @@ public final class ImaAdsLoader
|
||||||
this.context = Assertions.checkNotNull(context);
|
this.context = Assertions.checkNotNull(context);
|
||||||
vastLoadTimeoutMs = TIMEOUT_UNSET;
|
vastLoadTimeoutMs = TIMEOUT_UNSET;
|
||||||
mediaLoadTimeoutMs = TIMEOUT_UNSET;
|
mediaLoadTimeoutMs = TIMEOUT_UNSET;
|
||||||
|
mediaBitrateKbps = BITRATE_UNSET;
|
||||||
imaFactory = new DefaultImaFactory();
|
imaFactory = new DefaultImaFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,6 +161,19 @@ public final class ImaAdsLoader
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ad media maximum recommended bitrate, in Kbps.
|
||||||
|
*
|
||||||
|
* @param mediaBitrateKbps The ad media maximum recommended bitrate, in Kbps.
|
||||||
|
* @return This builder, for convenience.
|
||||||
|
* @see AdsRenderingSettings#setBitrateKbps(int)
|
||||||
|
*/
|
||||||
|
public Builder setMediaBitrateKbps(int mediaBitrateKbps) {
|
||||||
|
Assertions.checkArgument(mediaBitrateKbps > 0);
|
||||||
|
this.mediaBitrateKbps = mediaBitrateKbps;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// @VisibleForTesting
|
// @VisibleForTesting
|
||||||
/* package */ Builder setImaFactory(ImaFactory imaFactory) {
|
/* package */ Builder setImaFactory(ImaFactory imaFactory) {
|
||||||
this.imaFactory = Assertions.checkNotNull(imaFactory);
|
this.imaFactory = Assertions.checkNotNull(imaFactory);
|
||||||
|
|
@ -181,6 +196,7 @@ public final class ImaAdsLoader
|
||||||
null,
|
null,
|
||||||
vastLoadTimeoutMs,
|
vastLoadTimeoutMs,
|
||||||
mediaLoadTimeoutMs,
|
mediaLoadTimeoutMs,
|
||||||
|
mediaBitrateKbps,
|
||||||
adEventListener,
|
adEventListener,
|
||||||
imaFactory);
|
imaFactory);
|
||||||
}
|
}
|
||||||
|
|
@ -200,6 +216,7 @@ public final class ImaAdsLoader
|
||||||
adsResponse,
|
adsResponse,
|
||||||
vastLoadTimeoutMs,
|
vastLoadTimeoutMs,
|
||||||
mediaLoadTimeoutMs,
|
mediaLoadTimeoutMs,
|
||||||
|
mediaBitrateKbps,
|
||||||
adEventListener,
|
adEventListener,
|
||||||
imaFactory);
|
imaFactory);
|
||||||
}
|
}
|
||||||
|
|
@ -229,6 +246,7 @@ public final class ImaAdsLoader
|
||||||
private static final long MAXIMUM_PRELOAD_DURATION_MS = 8000;
|
private static final long MAXIMUM_PRELOAD_DURATION_MS = 8000;
|
||||||
|
|
||||||
private static final int TIMEOUT_UNSET = -1;
|
private static final int TIMEOUT_UNSET = -1;
|
||||||
|
private static final int BITRATE_UNSET = -1;
|
||||||
|
|
||||||
/** The state of ad playback. */
|
/** The state of ad playback. */
|
||||||
@Documented
|
@Documented
|
||||||
|
|
@ -252,6 +270,7 @@ public final class ImaAdsLoader
|
||||||
private final @Nullable String adsResponse;
|
private final @Nullable String adsResponse;
|
||||||
private final int vastLoadTimeoutMs;
|
private final int vastLoadTimeoutMs;
|
||||||
private final int mediaLoadTimeoutMs;
|
private final int mediaLoadTimeoutMs;
|
||||||
|
private final int mediaBitrateKbps;
|
||||||
private final @Nullable AdEventListener adEventListener;
|
private final @Nullable AdEventListener adEventListener;
|
||||||
private final ImaFactory imaFactory;
|
private final ImaFactory imaFactory;
|
||||||
private final Timeline.Period period;
|
private final Timeline.Period period;
|
||||||
|
|
@ -338,6 +357,7 @@ public final class ImaAdsLoader
|
||||||
/* adsResponse= */ null,
|
/* adsResponse= */ null,
|
||||||
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
|
/* mediaBitrateKpbs= */ BITRATE_UNSET,
|
||||||
/* adEventListener= */ null,
|
/* adEventListener= */ null,
|
||||||
/* imaFactory= */ new DefaultImaFactory());
|
/* imaFactory= */ new DefaultImaFactory());
|
||||||
}
|
}
|
||||||
|
|
@ -362,6 +382,7 @@ public final class ImaAdsLoader
|
||||||
/* adsResponse= */ null,
|
/* adsResponse= */ null,
|
||||||
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
|
||||||
|
/* mediaBitrateKbps= */ BITRATE_UNSET,
|
||||||
/* adEventListener= */ null,
|
/* adEventListener= */ null,
|
||||||
/* imaFactory= */ new DefaultImaFactory());
|
/* imaFactory= */ new DefaultImaFactory());
|
||||||
}
|
}
|
||||||
|
|
@ -373,6 +394,7 @@ public final class ImaAdsLoader
|
||||||
@Nullable String adsResponse,
|
@Nullable String adsResponse,
|
||||||
int vastLoadTimeoutMs,
|
int vastLoadTimeoutMs,
|
||||||
int mediaLoadTimeoutMs,
|
int mediaLoadTimeoutMs,
|
||||||
|
int mediaBitrateKbps,
|
||||||
@Nullable AdEventListener adEventListener,
|
@Nullable AdEventListener adEventListener,
|
||||||
ImaFactory imaFactory) {
|
ImaFactory imaFactory) {
|
||||||
Assertions.checkArgument(adTagUri != null || adsResponse != null);
|
Assertions.checkArgument(adTagUri != null || adsResponse != null);
|
||||||
|
|
@ -380,6 +402,7 @@ public final class ImaAdsLoader
|
||||||
this.adsResponse = adsResponse;
|
this.adsResponse = adsResponse;
|
||||||
this.vastLoadTimeoutMs = vastLoadTimeoutMs;
|
this.vastLoadTimeoutMs = vastLoadTimeoutMs;
|
||||||
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
|
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
|
||||||
|
this.mediaBitrateKbps = mediaBitrateKbps;
|
||||||
this.adEventListener = adEventListener;
|
this.adEventListener = adEventListener;
|
||||||
this.imaFactory = imaFactory;
|
this.imaFactory = imaFactory;
|
||||||
if (imaSdkSettings == null) {
|
if (imaSdkSettings == null) {
|
||||||
|
|
@ -926,6 +949,9 @@ public final class ImaAdsLoader
|
||||||
if (mediaLoadTimeoutMs != TIMEOUT_UNSET) {
|
if (mediaLoadTimeoutMs != TIMEOUT_UNSET) {
|
||||||
adsRenderingSettings.setLoadVideoTimeout(mediaLoadTimeoutMs);
|
adsRenderingSettings.setLoadVideoTimeout(mediaLoadTimeoutMs);
|
||||||
}
|
}
|
||||||
|
if (mediaBitrateKbps != BITRATE_UNSET) {
|
||||||
|
adsRenderingSettings.setBitrateKbps(mediaBitrateKbps);
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the ad playback state, skipping ads based on the start position as required.
|
// Set up the ad playback state, skipping ads based on the start position as required.
|
||||||
long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints());
|
long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue