Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
861b8169
authored
Oct 21, 2018
by
ogaclejapan
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow setting the ad media bitrate in ImaAdsLoader
parent
1ef3efaa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
View file @
861b8169
...
@@ -93,6 +93,7 @@ public final class ImaAdsLoader
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment