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
cbceb2a2
authored
Nov 22, 2021
by
bachinger
Committed by
kim-vde
Nov 26, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Rename ServerSideInsertedAdMediaSource et al
PiperOrigin-RevId: 411657479
parent
92c971ec
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
34 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsMediaSource.java → library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideAdInsertionMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtil.java → library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideAdInsertionUtil.java
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdMediaSourceTest.java → library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideAdInsertionMediaSourceTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtilTest.java → library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideAdInsertionUtilTest.java
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSide
InsertedAds
MediaSource.java
→
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSide
AdInsertion
MediaSource.java
View file @
cbceb2a2
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
source
.
ads
;
package
com
.
google
.
android
.
exoplayer2
.
source
.
ads
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getAdCountInGroup
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getAdCountInGroup
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getMediaPeriodPositionUs
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getMediaPeriodPositionUs
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getMediaPeriodPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getMediaPeriodPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getMediaPeriodPositionUsForContent
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getMediaPeriodPositionUsForContent
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getStreamPositionUs
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getStreamPositionUs
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Util
.
castNonNull
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Util
.
castNonNull
;
...
@@ -76,7 +76,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -76,7 +76,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* <p>The ad breaks need to be specified using {@link #setAdPlaybackState} and can be updated during
* <p>The ad breaks need to be specified using {@link #setAdPlaybackState} and can be updated during
* playback.
* playback.
*/
*/
public
final
class
ServerSide
InsertedAds
MediaSource
extends
BaseMediaSource
public
final
class
ServerSide
AdInsertion
MediaSource
extends
BaseMediaSource
implements
MediaSource
.
MediaSourceCaller
,
MediaSourceEventListener
,
DrmSessionEventListener
{
implements
MediaSource
.
MediaSourceCaller
,
MediaSourceEventListener
,
DrmSessionEventListener
{
private
final
MediaSource
mediaSource
;
private
final
MediaSource
mediaSource
;
...
@@ -99,7 +99,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
...
@@ -99,7 +99,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
*/
*/
// Calling BaseMediaSource.createEventDispatcher from the constructor.
// Calling BaseMediaSource.createEventDispatcher from the constructor.
@SuppressWarnings
(
"nullness:method.invocation"
)
@SuppressWarnings
(
"nullness:method.invocation"
)
public
ServerSide
InsertedAds
MediaSource
(
MediaSource
mediaSource
)
{
public
ServerSide
AdInsertion
MediaSource
(
MediaSource
mediaSource
)
{
this
.
mediaSource
=
mediaSource
;
this
.
mediaSource
=
mediaSource
;
mediaPeriods
=
ArrayListMultimap
.
create
();
mediaPeriods
=
ArrayListMultimap
.
create
();
adPlaybackState
=
AdPlaybackState
.
NONE
;
adPlaybackState
=
AdPlaybackState
.
NONE
;
...
@@ -148,7 +148,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
...
@@ -148,7 +148,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
this
.
adPlaybackState
=
adPlaybackState
;
this
.
adPlaybackState
=
adPlaybackState
;
if
(
contentTimeline
!=
null
)
{
if
(
contentTimeline
!=
null
)
{
refreshSourceInfo
(
refreshSourceInfo
(
new
ServerSide
InsertedAds
Timeline
(
contentTimeline
,
adPlaybackState
));
new
ServerSide
AdInsertion
Timeline
(
contentTimeline
,
adPlaybackState
));
}
}
});
});
}
}
...
@@ -193,7 +193,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
...
@@ -193,7 +193,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
if
(
AdPlaybackState
.
NONE
.
equals
(
adPlaybackState
))
{
if
(
AdPlaybackState
.
NONE
.
equals
(
adPlaybackState
))
{
return
;
return
;
}
}
refreshSourceInfo
(
new
ServerSide
InsertedAds
Timeline
(
timeline
,
adPlaybackState
));
refreshSourceInfo
(
new
ServerSide
AdInsertion
Timeline
(
timeline
,
adPlaybackState
));
}
}
@Override
@Override
...
@@ -899,11 +899,11 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
...
@@ -899,11 +899,11 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
}
}
}
}
private
static
final
class
ServerSide
InsertedAds
Timeline
extends
ForwardingTimeline
{
private
static
final
class
ServerSide
AdInsertion
Timeline
extends
ForwardingTimeline
{
private
final
AdPlaybackState
adPlaybackState
;
private
final
AdPlaybackState
adPlaybackState
;
public
ServerSide
InsertedAds
Timeline
(
public
ServerSide
AdInsertion
Timeline
(
Timeline
contentTimeline
,
AdPlaybackState
adPlaybackState
)
{
Timeline
contentTimeline
,
AdPlaybackState
adPlaybackState
)
{
super
(
contentTimeline
);
super
(
contentTimeline
);
Assertions
.
checkState
(
contentTimeline
.
getPeriodCount
()
==
1
);
Assertions
.
checkState
(
contentTimeline
.
getPeriodCount
()
==
1
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSide
InsertedAds
Util.java
→
library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSide
AdInsertion
Util.java
View file @
cbceb2a2
...
@@ -26,9 +26,9 @@ import com.google.android.exoplayer2.source.MediaPeriodId;
...
@@ -26,9 +26,9 @@ import com.google.android.exoplayer2.source.MediaPeriodId;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
/** A static utility class with methods to work with server-side inserted ads. */
/** A static utility class with methods to work with server-side inserted ads. */
public
final
class
ServerSide
InsertedAds
Util
{
public
final
class
ServerSide
AdInsertion
Util
{
private
ServerSide
InsertedAds
Util
()
{}
private
ServerSide
AdInsertion
Util
()
{}
/**
/**
* Adds a new server-side inserted ad group to an {@link AdPlaybackState}.
* Adds a new server-side inserted ad group to an {@link AdPlaybackState}.
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSide
InsertedAd
MediaSourceTest.java
→
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSide
AdInsertion
MediaSourceTest.java
View file @
cbceb2a2
...
@@ -19,7 +19,7 @@ import static com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainL
...
@@ -19,7 +19,7 @@ import static com.google.android.exoplayer2.robolectric.RobolectricUtil.runMainL
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
playUntilPosition
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
playUntilPosition
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
runUntilPendingCommandsAreFullyHandled
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
runUntilPendingCommandsAreFullyHandled
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
runUntilPlaybackState
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
runUntilPlaybackState
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
addAdGroupToAdPlaybackState
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
addAdGroupToAdPlaybackState
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyInt
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyInt
;
...
@@ -54,9 +54,9 @@ import org.junit.Rule;
...
@@ -54,9 +54,9 @@ import org.junit.Rule;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
/** Unit test for {@link ServerSide
InsertedAds
MediaSource}. */
/** Unit test for {@link ServerSide
AdInsertion
MediaSource}. */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
ServerSide
InsertedAd
MediaSourceTest
{
public
final
class
ServerSide
AdInsertion
MediaSourceTest
{
@Rule
@Rule
public
ShadowMediaCodecConfig
mediaCodecConfig
=
public
ShadowMediaCodecConfig
mediaCodecConfig
=
...
@@ -80,8 +80,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
...
@@ -80,8 +80,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
/* defaultPositionUs= */
3_000_000
,
/* defaultPositionUs= */
3_000_000
,
/* windowOffsetInFirstPeriodUs= */
42_000_000L
,
/* windowOffsetInFirstPeriodUs= */
42_000_000L
,
AdPlaybackState
.
NONE
));
AdPlaybackState
.
NONE
));
ServerSide
InsertedAds
MediaSource
mediaSource
=
ServerSide
AdInsertion
MediaSource
mediaSource
=
new
ServerSide
InsertedAds
MediaSource
(
new
FakeMediaSource
(
wrappedTimeline
));
new
ServerSide
AdInsertion
MediaSource
(
new
FakeMediaSource
(
wrappedTimeline
));
// Test with one ad group before the window, and the window starting within the second ad group.
// Test with one ad group before the window, and the window starting within the second ad group.
AdPlaybackState
adPlaybackState
=
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
new
AdPlaybackState
(
...
@@ -152,8 +152,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
...
@@ -152,8 +152,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
ServerSide
InsertedAds
MediaSource
mediaSource
=
ServerSide
AdInsertion
MediaSource
mediaSource
=
new
ServerSide
InsertedAds
MediaSource
(
new
ServerSide
AdInsertion
MediaSource
(
new
DefaultMediaSourceFactory
(
context
)
new
DefaultMediaSourceFactory
(
context
)
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
...
@@ -211,8 +211,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
...
@@ -211,8 +211,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
ServerSide
InsertedAds
MediaSource
mediaSource
=
ServerSide
AdInsertion
MediaSource
mediaSource
=
new
ServerSide
InsertedAds
MediaSource
(
new
ServerSide
AdInsertion
MediaSource
(
new
DefaultMediaSourceFactory
(
context
)
new
DefaultMediaSourceFactory
(
context
)
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
...
@@ -271,8 +271,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
...
@@ -271,8 +271,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
renderersFactory
);
ServerSide
InsertedAds
MediaSource
mediaSource
=
ServerSide
AdInsertion
MediaSource
mediaSource
=
new
ServerSide
InsertedAds
MediaSource
(
new
ServerSide
AdInsertion
MediaSource
(
new
DefaultMediaSourceFactory
(
context
)
new
DefaultMediaSourceFactory
(
context
)
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
...
@@ -325,8 +325,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
...
@@ -325,8 +325,8 @@ public final class ServerSideInsertedAdMediaSourceTest {
new
ExoPlayer
.
Builder
(
context
).
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
)).
build
();
new
ExoPlayer
.
Builder
(
context
).
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
)).
build
();
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
ServerSide
InsertedAds
MediaSource
mediaSource
=
ServerSide
AdInsertion
MediaSource
mediaSource
=
new
ServerSide
InsertedAds
MediaSource
(
new
ServerSide
AdInsertion
MediaSource
(
new
DefaultMediaSourceFactory
(
context
)
new
DefaultMediaSourceFactory
(
context
)
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
.
createMediaSource
(
MediaItem
.
fromUri
(
TEST_ASSET
)));
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
());
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSide
InsertedAds
UtilTest.java
→
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSide
AdInsertion
UtilTest.java
View file @
cbceb2a2
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
source
.
ads
;
package
com
.
google
.
android
.
exoplayer2
.
source
.
ads
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
addAdGroupToAdPlaybackState
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
addAdGroupToAdPlaybackState
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getAdCountInGroup
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getAdCountInGroup
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getMediaPeriodPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getMediaPeriodPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getMediaPeriodPositionUsForContent
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getMediaPeriodPositionUsForContent
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getStreamPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getStreamPositionUsForAd
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
InsertedAds
Util
.
getStreamPositionUsForContent
;
import
static
com
.
google
.
android
.
exoplayer2
.
source
.
ads
.
ServerSide
AdInsertion
Util
.
getStreamPositionUsForContent
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
...
@@ -28,9 +28,9 @@ import com.google.android.exoplayer2.C;
...
@@ -28,9 +28,9 @@ import com.google.android.exoplayer2.C;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
/** Unit tests for {@link ServerSide
InsertedAds
Util}. */
/** Unit tests for {@link ServerSide
AdInsertion
Util}. */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
ServerSide
InsertedAds
UtilTest
{
public
final
class
ServerSide
AdInsertion
UtilTest
{
private
static
final
Object
ADS_ID
=
new
Object
();
private
static
final
Object
ADS_ID
=
new
Object
();
...
...
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