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
2ada01c1
authored
Oct 19, 2020
by
andrewlewis
Committed by
Oliver Woodman
Oct 20, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Allow enabling IMA ext debug mode programmatically
PiperOrigin-RevId: 337824945
parent
febf5d20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
20 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/ImaUtil.java
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java
View file @
2ada01c1
...
@@ -144,6 +144,7 @@ public final class ImaAdsLoader
...
@@ -144,6 +144,7 @@ public final class ImaAdsLoader
private
int
mediaBitrate
;
private
int
mediaBitrate
;
private
boolean
focusSkipButtonWhenAvailable
;
private
boolean
focusSkipButtonWhenAvailable
;
private
boolean
playAdBeforeStartPosition
;
private
boolean
playAdBeforeStartPosition
;
private
boolean
debugModeEnabled
;
private
ImaUtil
.
ImaFactory
imaFactory
;
private
ImaUtil
.
ImaFactory
imaFactory
;
/**
/**
...
@@ -345,6 +346,21 @@ public final class ImaAdsLoader
...
@@ -345,6 +346,21 @@ public final class ImaAdsLoader
return
this
;
return
this
;
}
}
/**
* Sets whether to enable outputting verbose logs for the IMA extension and IMA SDK. The default
* value is {@code false}. This setting is intended for debugging only, and should not be
* enabled in production applications.
*
* @param debugModeEnabled Whether to enable outputting verbose logs for the IMA extension and
* IMA SDK.
* @return This builder, for convenience.
* @see ImaSdkSettings#setDebugMode(boolean)
*/
public
Builder
setDebugModeEnabled
(
boolean
debugModeEnabled
)
{
this
.
debugModeEnabled
=
debugModeEnabled
;
return
this
;
}
@VisibleForTesting
@VisibleForTesting
/* package */
Builder
setImaFactory
(
ImaUtil
.
ImaFactory
imaFactory
)
{
/* package */
Builder
setImaFactory
(
ImaUtil
.
ImaFactory
imaFactory
)
{
this
.
imaFactory
=
checkNotNull
(
imaFactory
);
this
.
imaFactory
=
checkNotNull
(
imaFactory
);
...
@@ -411,11 +427,11 @@ public final class ImaAdsLoader
...
@@ -411,11 +427,11 @@ public final class ImaAdsLoader
adErrorListener
,
adErrorListener
,
adEventListener
,
adEventListener
,
videoAdPlayerCallback
,
videoAdPlayerCallback
,
imaSdkSettings
);
imaSdkSettings
,
debugModeEnabled
);
}
}
}
}
private
static
final
boolean
DEBUG
=
false
;
private
static
final
String
TAG
=
"ImaAdsLoader"
;
private
static
final
String
TAG
=
"ImaAdsLoader"
;
private
static
final
String
IMA_SDK_SETTINGS_PLAYER_TYPE
=
"google/exo.ext.ima"
;
private
static
final
String
IMA_SDK_SETTINGS_PLAYER_TYPE
=
"google/exo.ext.ima"
;
...
@@ -594,7 +610,7 @@ public final class ImaAdsLoader
...
@@ -594,7 +610,7 @@ public final class ImaAdsLoader
@Nullable
ImaSdkSettings
imaSdkSettings
=
configuration
.
imaSdkSettings
;
@Nullable
ImaSdkSettings
imaSdkSettings
=
configuration
.
imaSdkSettings
;
if
(
imaSdkSettings
==
null
)
{
if
(
imaSdkSettings
==
null
)
{
imaSdkSettings
=
imaFactory
.
createImaSdkSettings
();
imaSdkSettings
=
imaFactory
.
createImaSdkSettings
();
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
imaSdkSettings
.
setDebugMode
(
true
);
imaSdkSettings
.
setDebugMode
(
true
);
}
}
}
}
...
@@ -870,7 +886,7 @@ public final class ImaAdsLoader
...
@@ -870,7 +886,7 @@ public final class ImaAdsLoader
@Override
@Override
public
void
handlePrepareComplete
(
int
adGroupIndex
,
int
adIndexInAdGroup
)
{
public
void
handlePrepareComplete
(
int
adGroupIndex
,
int
adIndexInAdGroup
)
{
AdInfo
adInfo
=
new
AdInfo
(
adGroupIndex
,
adIndexInAdGroup
);
AdInfo
adInfo
=
new
AdInfo
(
adGroupIndex
,
adIndexInAdGroup
);
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"Prepared ad "
+
adInfo
);
Log
.
d
(
TAG
,
"Prepared ad "
+
adInfo
);
}
}
@Nullable
AdMediaInfo
adMediaInfo
=
adInfoByAdMediaInfo
.
inverse
().
get
(
adInfo
);
@Nullable
AdMediaInfo
adMediaInfo
=
adInfoByAdMediaInfo
.
inverse
().
get
(
adInfo
);
...
@@ -920,7 +936,7 @@ public final class ImaAdsLoader
...
@@ -920,7 +936,7 @@ public final class ImaAdsLoader
}
else
{
}
else
{
adsManager
.
init
(
adsRenderingSettings
);
adsManager
.
init
(
adsRenderingSettings
);
adsManager
.
start
();
adsManager
.
start
();
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"Initialized with ads rendering settings: "
+
adsRenderingSettings
);
Log
.
d
(
TAG
,
"Initialized with ads rendering settings: "
+
adsRenderingSettings
);
}
}
}
}
...
@@ -1143,7 +1159,7 @@ public final class ImaAdsLoader
...
@@ -1143,7 +1159,7 @@ public final class ImaAdsLoader
switch
(
adEvent
.
getType
())
{
switch
(
adEvent
.
getType
())
{
case
AD_BREAK_FETCH_ERROR:
case
AD_BREAK_FETCH_ERROR:
String
adGroupTimeSecondsString
=
checkNotNull
(
adEvent
.
getAdData
().
get
(
"adBreakTime"
));
String
adGroupTimeSecondsString
=
checkNotNull
(
adEvent
.
getAdData
().
get
(
"adBreakTime"
));
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"Fetch error for ad at "
+
adGroupTimeSecondsString
+
" seconds"
);
Log
.
d
(
TAG
,
"Fetch error for ad at "
+
adGroupTimeSecondsString
+
" seconds"
);
}
}
double
adGroupTimeSeconds
=
Double
.
parseDouble
(
adGroupTimeSecondsString
);
double
adGroupTimeSeconds
=
Double
.
parseDouble
(
adGroupTimeSecondsString
);
...
@@ -1230,7 +1246,7 @@ public final class ImaAdsLoader
...
@@ -1230,7 +1246,7 @@ public final class ImaAdsLoader
adCallbacks
.
get
(
i
).
onEnded
(
adMediaInfo
);
adCallbacks
.
get
(
i
).
onEnded
(
adMediaInfo
);
}
}
}
}
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"VideoAdPlayerCallback.onEnded in onPlaybackStateChanged"
);
Log
.
d
(
TAG
,
"VideoAdPlayerCallback.onEnded in onPlaybackStateChanged"
);
}
}
}
}
...
@@ -1270,7 +1286,7 @@ public final class ImaAdsLoader
...
@@ -1270,7 +1286,7 @@ public final class ImaAdsLoader
adCallbacks
.
get
(
i
).
onEnded
(
adMediaInfo
);
adCallbacks
.
get
(
i
).
onEnded
(
adMediaInfo
);
}
}
}
}
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"VideoAdPlayerCallback.onEnded in onTimelineChanged/onPositionDiscontinuity"
);
Log
.
d
(
TAG
,
"VideoAdPlayerCallback.onEnded in onTimelineChanged/onPositionDiscontinuity"
);
}
}
}
}
...
@@ -1292,7 +1308,7 @@ public final class ImaAdsLoader
...
@@ -1292,7 +1308,7 @@ public final class ImaAdsLoader
private
void
loadAdInternal
(
AdMediaInfo
adMediaInfo
,
AdPodInfo
adPodInfo
)
{
private
void
loadAdInternal
(
AdMediaInfo
adMediaInfo
,
AdPodInfo
adPodInfo
)
{
if
(
adsManager
==
null
)
{
if
(
adsManager
==
null
)
{
// Drop events after release.
// Drop events after release.
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
Log
.
d
(
TAG
,
TAG
,
"loadAd after release "
+
getAdMediaInfoString
(
adMediaInfo
)
+
", ad pod "
+
adPodInfo
);
"loadAd after release "
+
getAdMediaInfoString
(
adMediaInfo
)
+
", ad pod "
+
adPodInfo
);
...
@@ -1304,7 +1320,7 @@ public final class ImaAdsLoader
...
@@ -1304,7 +1320,7 @@ public final class ImaAdsLoader
int
adIndexInAdGroup
=
adPodInfo
.
getAdPosition
()
-
1
;
int
adIndexInAdGroup
=
adPodInfo
.
getAdPosition
()
-
1
;
AdInfo
adInfo
=
new
AdInfo
(
adGroupIndex
,
adIndexInAdGroup
);
AdInfo
adInfo
=
new
AdInfo
(
adGroupIndex
,
adIndexInAdGroup
);
adInfoByAdMediaInfo
.
put
(
adMediaInfo
,
adInfo
);
adInfoByAdMediaInfo
.
put
(
adMediaInfo
,
adInfo
);
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"loadAd "
+
getAdMediaInfoString
(
adMediaInfo
));
Log
.
d
(
TAG
,
"loadAd "
+
getAdMediaInfoString
(
adMediaInfo
));
}
}
if
(
adPlaybackState
.
isAdInErrorState
(
adGroupIndex
,
adIndexInAdGroup
))
{
if
(
adPlaybackState
.
isAdInErrorState
(
adGroupIndex
,
adIndexInAdGroup
))
{
...
@@ -1335,7 +1351,7 @@ public final class ImaAdsLoader
...
@@ -1335,7 +1351,7 @@ public final class ImaAdsLoader
}
}
private
void
playAdInternal
(
AdMediaInfo
adMediaInfo
)
{
private
void
playAdInternal
(
AdMediaInfo
adMediaInfo
)
{
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"playAd "
+
getAdMediaInfoString
(
adMediaInfo
));
Log
.
d
(
TAG
,
"playAd "
+
getAdMediaInfoString
(
adMediaInfo
));
}
}
if
(
adsManager
==
null
)
{
if
(
adsManager
==
null
)
{
...
@@ -1379,7 +1395,7 @@ public final class ImaAdsLoader
...
@@ -1379,7 +1395,7 @@ public final class ImaAdsLoader
}
}
private
void
pauseAdInternal
(
AdMediaInfo
adMediaInfo
)
{
private
void
pauseAdInternal
(
AdMediaInfo
adMediaInfo
)
{
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"pauseAd "
+
getAdMediaInfoString
(
adMediaInfo
));
Log
.
d
(
TAG
,
"pauseAd "
+
getAdMediaInfoString
(
adMediaInfo
));
}
}
if
(
adsManager
==
null
)
{
if
(
adsManager
==
null
)
{
...
@@ -1399,7 +1415,7 @@ public final class ImaAdsLoader
...
@@ -1399,7 +1415,7 @@ public final class ImaAdsLoader
}
}
private
void
stopAdInternal
(
AdMediaInfo
adMediaInfo
)
{
private
void
stopAdInternal
(
AdMediaInfo
adMediaInfo
)
{
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"stopAd "
+
getAdMediaInfoString
(
adMediaInfo
));
Log
.
d
(
TAG
,
"stopAd "
+
getAdMediaInfoString
(
adMediaInfo
));
}
}
if
(
adsManager
==
null
)
{
if
(
adsManager
==
null
)
{
...
@@ -1459,7 +1475,7 @@ public final class ImaAdsLoader
...
@@ -1459,7 +1475,7 @@ public final class ImaAdsLoader
}
}
for
(
int
i
=
0
;
i
<
adGroup
.
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
adGroup
.
count
;
i
++)
{
if
(
adGroup
.
states
[
i
]
==
AdPlaybackState
.
AD_STATE_UNAVAILABLE
)
{
if
(
adGroup
.
states
[
i
]
==
AdPlaybackState
.
AD_STATE_UNAVAILABLE
)
{
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"Removing ad "
+
i
+
" in ad group "
+
adGroupIndex
);
Log
.
d
(
TAG
,
"Removing ad "
+
i
+
" in ad group "
+
adGroupIndex
);
}
}
adPlaybackState
=
adPlaybackState
.
withAdLoadError
(
adGroupIndex
,
i
);
adPlaybackState
=
adPlaybackState
.
withAdLoadError
(
adGroupIndex
,
i
);
...
@@ -1472,7 +1488,7 @@ public final class ImaAdsLoader
...
@@ -1472,7 +1488,7 @@ public final class ImaAdsLoader
}
}
private
void
handleAdPrepareError
(
int
adGroupIndex
,
int
adIndexInAdGroup
,
Exception
exception
)
{
private
void
handleAdPrepareError
(
int
adGroupIndex
,
int
adIndexInAdGroup
,
Exception
exception
)
{
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
Log
.
d
(
TAG
,
"Prepare error for ad "
+
adIndexInAdGroup
+
" in group "
+
adGroupIndex
,
exception
);
TAG
,
"Prepare error for ad "
+
adIndexInAdGroup
+
" in group "
+
adGroupIndex
,
exception
);
}
}
...
@@ -1524,7 +1540,7 @@ public final class ImaAdsLoader
...
@@ -1524,7 +1540,7 @@ public final class ImaAdsLoader
adCallbacks
.
get
(
i
).
onContentComplete
();
adCallbacks
.
get
(
i
).
onContentComplete
();
}
}
sentContentComplete
=
true
;
sentContentComplete
=
true
;
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"adsLoader.contentComplete"
);
Log
.
d
(
TAG
,
"adsLoader.contentComplete"
);
}
}
for
(
int
i
=
0
;
i
<
adPlaybackState
.
adGroupCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
adPlaybackState
.
adGroupCount
;
i
++)
{
...
@@ -1699,7 +1715,7 @@ public final class ImaAdsLoader
...
@@ -1699,7 +1715,7 @@ public final class ImaAdsLoader
@Override
@Override
public
VideoProgressUpdate
getContentProgress
()
{
public
VideoProgressUpdate
getContentProgress
()
{
VideoProgressUpdate
videoProgressUpdate
=
getContentVideoProgressUpdate
();
VideoProgressUpdate
videoProgressUpdate
=
getContentVideoProgressUpdate
();
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
if
(
VideoProgressUpdate
.
VIDEO_TIME_NOT_READY
.
equals
(
videoProgressUpdate
))
{
if
(
VideoProgressUpdate
.
VIDEO_TIME_NOT_READY
.
equals
(
videoProgressUpdate
))
{
Log
.
d
(
TAG
,
"Content progress: not ready"
);
Log
.
d
(
TAG
,
"Content progress: not ready"
);
}
else
{
}
else
{
...
@@ -1731,7 +1747,7 @@ public final class ImaAdsLoader
...
@@ -1731,7 +1747,7 @@ public final class ImaAdsLoader
@Override
@Override
public
void
onAdEvent
(
AdEvent
adEvent
)
{
public
void
onAdEvent
(
AdEvent
adEvent
)
{
AdEventType
adEventType
=
adEvent
.
getType
();
AdEventType
adEventType
=
adEvent
.
getType
();
if
(
DEBUG
&&
adEventType
!=
AdEventType
.
AD_PROGRESS
)
{
if
(
configuration
.
debugModeEnabled
&&
adEventType
!=
AdEventType
.
AD_PROGRESS
)
{
Log
.
d
(
TAG
,
"onAdEvent: "
+
adEventType
);
Log
.
d
(
TAG
,
"onAdEvent: "
+
adEventType
);
}
}
try
{
try
{
...
@@ -1746,7 +1762,7 @@ public final class ImaAdsLoader
...
@@ -1746,7 +1762,7 @@ public final class ImaAdsLoader
@Override
@Override
public
void
onAdError
(
AdErrorEvent
adErrorEvent
)
{
public
void
onAdError
(
AdErrorEvent
adErrorEvent
)
{
AdError
error
=
adErrorEvent
.
getError
();
AdError
error
=
adErrorEvent
.
getError
();
if
(
DEBUG
)
{
if
(
configuration
.
debugModeEnabled
)
{
Log
.
d
(
TAG
,
"onAdError"
,
error
);
Log
.
d
(
TAG
,
"onAdError"
,
error
);
}
}
if
(
adsManager
==
null
)
{
if
(
adsManager
==
null
)
{
...
...
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java
View file @
2ada01c1
...
@@ -95,6 +95,7 @@ import java.util.Set;
...
@@ -95,6 +95,7 @@ import java.util.Set;
@Nullable
public
final
AdEvent
.
AdEventListener
applicationAdEventListener
;
@Nullable
public
final
AdEvent
.
AdEventListener
applicationAdEventListener
;
@Nullable
public
final
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
;
@Nullable
public
final
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
;
@Nullable
public
final
ImaSdkSettings
imaSdkSettings
;
@Nullable
public
final
ImaSdkSettings
imaSdkSettings
;
public
final
boolean
debugModeEnabled
;
public
Configuration
(
public
Configuration
(
long
adPreloadTimeoutMs
,
long
adPreloadTimeoutMs
,
...
@@ -109,7 +110,8 @@ import java.util.Set;
...
@@ -109,7 +110,8 @@ import java.util.Set;
@Nullable
AdErrorEvent
.
AdErrorListener
applicationAdErrorListener
,
@Nullable
AdErrorEvent
.
AdErrorListener
applicationAdErrorListener
,
@Nullable
AdEvent
.
AdEventListener
applicationAdEventListener
,
@Nullable
AdEvent
.
AdEventListener
applicationAdEventListener
,
@Nullable
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
,
@Nullable
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
,
@Nullable
ImaSdkSettings
imaSdkSettings
)
{
@Nullable
ImaSdkSettings
imaSdkSettings
,
boolean
debugModeEnabled
)
{
this
.
adPreloadTimeoutMs
=
adPreloadTimeoutMs
;
this
.
adPreloadTimeoutMs
=
adPreloadTimeoutMs
;
this
.
vastLoadTimeoutMs
=
vastLoadTimeoutMs
;
this
.
vastLoadTimeoutMs
=
vastLoadTimeoutMs
;
this
.
mediaLoadTimeoutMs
=
mediaLoadTimeoutMs
;
this
.
mediaLoadTimeoutMs
=
mediaLoadTimeoutMs
;
...
@@ -123,6 +125,7 @@ import java.util.Set;
...
@@ -123,6 +125,7 @@ import java.util.Set;
this
.
applicationAdEventListener
=
applicationAdEventListener
;
this
.
applicationAdEventListener
=
applicationAdEventListener
;
this
.
applicationVideoAdPlayerCallback
=
applicationVideoAdPlayerCallback
;
this
.
applicationVideoAdPlayerCallback
=
applicationVideoAdPlayerCallback
;
this
.
imaSdkSettings
=
imaSdkSettings
;
this
.
imaSdkSettings
=
imaSdkSettings
;
this
.
debugModeEnabled
=
debugModeEnabled
;
}
}
}
}
...
...
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