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
a9f7b943
authored
Nov 03, 2021
by
olly
Committed by
tonihei
Nov 03, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Prepare for adding ServerSideInsertedAdsMediaSource for IMA
PiperOrigin-RevId: 407274072
parent
7b9b878a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
5 deletions
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java
extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaUtil.java
View file @
a9f7b943
...
...
@@ -41,6 +41,7 @@ import com.google.android.exoplayer2.upstream.DataSchemeDataSource;
import
com.google.android.exoplayer2.upstream.DataSourceUtil
;
import
com.google.android.exoplayer2.upstream.DataSpec
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Collection
;
...
...
@@ -134,6 +135,35 @@ import java.util.Set;
}
}
/** Stores configuration for DAI ad playback. */
static
final
class
DaiConfiguration
{
public
final
AdErrorEvent
.
AdErrorListener
applicationAdErrorListener
;
public
final
boolean
debugModeEnabled
;
@Nullable
public
final
List
<
CompanionAdSlot
>
companionAdSlots
;
@Nullable
public
final
AdEvent
.
AdEventListener
applicationAdEventListener
;
@Nullable
public
final
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
;
@Nullable
public
final
ImaSdkSettings
imaSdkSettings
;
public
DaiConfiguration
(
AdErrorEvent
.
AdErrorListener
applicationAdErrorListener
,
@Nullable
List
<
CompanionAdSlot
>
companionAdSlots
,
@Nullable
AdEvent
.
AdEventListener
applicationAdEventListener
,
@Nullable
VideoAdPlayer
.
VideoAdPlayerCallback
applicationVideoAdPlayerCallback
,
@Nullable
ImaSdkSettings
imaSdkSettings
,
boolean
debugModeEnabled
)
{
this
.
applicationAdErrorListener
=
applicationAdErrorListener
;
this
.
companionAdSlots
=
companionAdSlots
!=
null
?
ImmutableList
.
copyOf
(
companionAdSlots
)
:
null
;
this
.
applicationAdEventListener
=
applicationAdEventListener
;
this
.
applicationVideoAdPlayerCallback
=
applicationVideoAdPlayerCallback
;
this
.
imaSdkSettings
=
imaSdkSettings
;
this
.
debugModeEnabled
=
debugModeEnabled
;
}
}
public
static
final
int
TIMEOUT_UNSET
=
-
1
;
public
static
final
int
BITRATE_UNSET
=
-
1
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
View file @
a9f7b943
...
...
@@ -891,7 +891,8 @@ public final class DownloadHelper {
MediaItem
mediaItem
,
DataSource
.
Factory
dataSourceFactory
,
@Nullable
DrmSessionManager
drmSessionManager
)
{
return
new
DefaultMediaSourceFactory
(
dataSourceFactory
,
ExtractorsFactory
.
EMPTY
)
return
new
DefaultMediaSourceFactory
(
dataSourceFactory
,
ExtractorsFactory
.
EMPTY
,
/* serverSideDaiMediaSourceFactory= */
null
)
.
setDrmSessionManager
(
drmSessionManager
)
.
createMediaSource
(
mediaItem
);
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java
View file @
a9f7b943
...
...
@@ -45,6 +45,7 @@ import com.google.android.exoplayer2.upstream.DataSpec;
import
com.google.android.exoplayer2.upstream.DefaultDataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource
;
import
com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -119,6 +120,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
private
final
DataSource
.
Factory
dataSourceFactory
;
private
final
DelegateFactoryLoader
delegateFactoryLoader
;
@Nullable
private
final
MediaSourceFactory
serverSideDaiMediaSourceFactory
;
@Nullable
private
AdsLoaderProvider
adsLoaderProvider
;
@Nullable
private
AdViewProvider
adViewProvider
;
@Nullable
private
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
...
...
@@ -146,7 +148,10 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* its container.
*/
public
DefaultMediaSourceFactory
(
Context
context
,
ExtractorsFactory
extractorsFactory
)
{
this
(
new
DefaultDataSource
.
Factory
(
context
),
extractorsFactory
);
this
(
new
DefaultDataSource
.
Factory
(
context
),
extractorsFactory
,
/* serverSideDaiMediaSourceFactory= */
null
);
}
/**
...
...
@@ -156,7 +161,10 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* for requesting media data.
*/
public
DefaultMediaSourceFactory
(
DataSource
.
Factory
dataSourceFactory
)
{
this
(
dataSourceFactory
,
new
DefaultExtractorsFactory
());
this
(
dataSourceFactory
,
new
DefaultExtractorsFactory
(),
/* serverSideDaiMediaSourceFactory= */
null
);
}
/**
...
...
@@ -166,10 +174,17 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* for requesting media data.
* @param extractorsFactory An {@link ExtractorsFactory} used to extract progressive media from
* its container.
* @param serverSideDaiMediaSourceFactory A {@link MediaSourceFactory} for creating server side
* inserted ad media sources.
*/
public
DefaultMediaSourceFactory
(
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
)
{
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
,
@Nullable
MediaSourceFactory
serverSideDaiMediaSourceFactory
)
{
this
.
dataSourceFactory
=
dataSourceFactory
;
// Temporary until factory registration is agreed upon.
this
.
serverSideDaiMediaSourceFactory
=
serverSideDaiMediaSourceFactory
;
delegateFactoryLoader
=
new
DelegateFactoryLoader
(
dataSourceFactory
,
extractorsFactory
);
liveTargetOffsetMs
=
C
.
TIME_UNSET
;
liveMinOffsetMs
=
C
.
TIME_UNSET
;
...
...
@@ -333,7 +348,11 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
@Override
public
MediaSource
createMediaSource
(
MediaItem
mediaItem
)
{
checkNotNull
(
mediaItem
.
localConfiguration
);
Assertions
.
checkNotNull
(
mediaItem
.
localConfiguration
);
@Nullable
String
scheme
=
mediaItem
.
localConfiguration
.
uri
.
getScheme
();
if
(
scheme
!=
null
&&
scheme
.
equals
(
"imadai"
))
{
return
checkNotNull
(
serverSideDaiMediaSourceFactory
).
createMediaSource
(
mediaItem
);
}
@C
.
ContentType
int
type
=
Util
.
inferContentTypeForUriAndMimeType
(
...
...
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