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
b9ab0cf1
authored
Jul 11, 2019
by
aquilescanta
Committed by
Oliver Woodman
Jul 14, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Plumb DrmSessionManager into SsMediaSource
PiperOrigin-RevId: 257624043
parent
bbcd46e9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
5 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriod.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
b9ab0cf1
...
@@ -480,7 +480,9 @@ public class PlayerActivity extends AppCompatActivity
...
@@ -480,7 +480,9 @@ public class PlayerActivity extends AppCompatActivity
.
setDrmSessionManager
(
drmSessionManager
)
.
setDrmSessionManager
(
drmSessionManager
)
.
createMediaSource
(
uri
);
.
createMediaSource
(
uri
);
case
C
.
TYPE_SS
:
case
C
.
TYPE_SS
:
return
new
SsMediaSource
.
Factory
(
dataSourceFactory
).
createMediaSource
(
uri
);
return
new
SsMediaSource
.
Factory
(
dataSourceFactory
)
.
setDrmSessionManager
(
drmSessionManager
)
.
createMediaSource
(
uri
);
case
C
.
TYPE_HLS
:
case
C
.
TYPE_HLS
:
return
new
HlsMediaSource
.
Factory
(
dataSourceFactory
).
createMediaSource
(
uri
);
return
new
HlsMediaSource
.
Factory
(
dataSourceFactory
).
createMediaSource
(
uri
);
case
C
.
TYPE_OTHER
:
case
C
.
TYPE_OTHER
:
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriod.java
View file @
b9ab0cf1
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.smoothstreaming;
...
@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.smoothstreaming;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.offline.StreamKey
;
import
com.google.android.exoplayer2.offline.StreamKey
;
...
@@ -45,6 +46,7 @@ import java.util.List;
...
@@ -45,6 +46,7 @@ import java.util.List;
private
final
SsChunkSource
.
Factory
chunkSourceFactory
;
private
final
SsChunkSource
.
Factory
chunkSourceFactory
;
@Nullable
private
final
TransferListener
transferListener
;
@Nullable
private
final
TransferListener
transferListener
;
private
final
LoaderErrorThrower
manifestLoaderErrorThrower
;
private
final
LoaderErrorThrower
manifestLoaderErrorThrower
;
private
final
DrmSessionManager
<?>
drmSessionManager
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
EventDispatcher
eventDispatcher
;
private
final
EventDispatcher
eventDispatcher
;
private
final
Allocator
allocator
;
private
final
Allocator
allocator
;
...
@@ -62,6 +64,7 @@ import java.util.List;
...
@@ -62,6 +64,7 @@ import java.util.List;
SsChunkSource
.
Factory
chunkSourceFactory
,
SsChunkSource
.
Factory
chunkSourceFactory
,
@Nullable
TransferListener
transferListener
,
@Nullable
TransferListener
transferListener
,
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
,
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
,
DrmSessionManager
<?>
drmSessionManager
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
EventDispatcher
eventDispatcher
,
EventDispatcher
eventDispatcher
,
LoaderErrorThrower
manifestLoaderErrorThrower
,
LoaderErrorThrower
manifestLoaderErrorThrower
,
...
@@ -70,11 +73,12 @@ import java.util.List;
...
@@ -70,11 +73,12 @@ import java.util.List;
this
.
chunkSourceFactory
=
chunkSourceFactory
;
this
.
chunkSourceFactory
=
chunkSourceFactory
;
this
.
transferListener
=
transferListener
;
this
.
transferListener
=
transferListener
;
this
.
manifestLoaderErrorThrower
=
manifestLoaderErrorThrower
;
this
.
manifestLoaderErrorThrower
=
manifestLoaderErrorThrower
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
eventDispatcher
=
eventDispatcher
;
this
.
eventDispatcher
=
eventDispatcher
;
this
.
allocator
=
allocator
;
this
.
allocator
=
allocator
;
this
.
compositeSequenceableLoaderFactory
=
compositeSequenceableLoaderFactory
;
this
.
compositeSequenceableLoaderFactory
=
compositeSequenceableLoaderFactory
;
trackGroups
=
buildTrackGroups
(
manifest
);
trackGroups
=
buildTrackGroups
(
manifest
,
drmSessionManager
);
sampleStreams
=
newSampleStreamArray
(
0
);
sampleStreams
=
newSampleStreamArray
(
0
);
compositeSequenceableLoader
=
compositeSequenceableLoader
=
compositeSequenceableLoaderFactory
.
createCompositeSequenceableLoader
(
sampleStreams
);
compositeSequenceableLoaderFactory
.
createCompositeSequenceableLoader
(
sampleStreams
);
...
@@ -238,15 +242,26 @@ import java.util.List;
...
@@ -238,15 +242,26 @@ import java.util.List;
this
,
this
,
allocator
,
allocator
,
positionUs
,
positionUs
,
DrmSessionManager
.
getDummyDrmSessionManager
()
,
drmSessionManager
,
loadErrorHandlingPolicy
,
loadErrorHandlingPolicy
,
eventDispatcher
);
eventDispatcher
);
}
}
private
static
TrackGroupArray
buildTrackGroups
(
SsManifest
manifest
)
{
private
static
TrackGroupArray
buildTrackGroups
(
SsManifest
manifest
,
DrmSessionManager
<?>
drmSessionManager
)
{
TrackGroup
[]
trackGroups
=
new
TrackGroup
[
manifest
.
streamElements
.
length
];
TrackGroup
[]
trackGroups
=
new
TrackGroup
[
manifest
.
streamElements
.
length
];
for
(
int
i
=
0
;
i
<
manifest
.
streamElements
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
manifest
.
streamElements
.
length
;
i
++)
{
trackGroups
[
i
]
=
new
TrackGroup
(
manifest
.
streamElements
[
i
].
formats
);
Format
[]
manifestFormats
=
manifest
.
streamElements
[
i
].
formats
;
Format
[]
exposedFormats
=
new
Format
[
manifestFormats
.
length
];
for
(
int
j
=
0
;
j
<
manifestFormats
.
length
;
j
++)
{
Format
manifestFormat
=
manifestFormats
[
j
];
exposedFormats
[
j
]
=
manifestFormat
.
drmInitData
!=
null
?
manifestFormat
.
copyWithExoMediaCryptoType
(
drmSessionManager
.
getExoMediaCryptoType
(
manifestFormat
.
drmInitData
))
:
manifestFormat
;
}
trackGroups
[
i
]
=
new
TrackGroup
(
exposedFormats
);
}
}
return
new
TrackGroupArray
(
trackGroups
);
return
new
TrackGroupArray
(
trackGroups
);
}
}
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java
View file @
b9ab0cf1
...
@@ -22,6 +22,8 @@ import androidx.annotation.Nullable;
...
@@ -22,6 +22,8 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.ExoPlayerLibraryInfo
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.offline.FilteringManifestParser
;
import
com.google.android.exoplayer2.offline.FilteringManifestParser
;
import
com.google.android.exoplayer2.offline.StreamKey
;
import
com.google.android.exoplayer2.offline.StreamKey
;
import
com.google.android.exoplayer2.source.BaseMediaSource
;
import
com.google.android.exoplayer2.source.BaseMediaSource
;
...
@@ -69,6 +71,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -69,6 +71,7 @@ public final class SsMediaSource extends BaseMediaSource
@Nullable
private
ParsingLoadable
.
Parser
<?
extends
SsManifest
>
manifestParser
;
@Nullable
private
ParsingLoadable
.
Parser
<?
extends
SsManifest
>
manifestParser
;
@Nullable
private
List
<
StreamKey
>
streamKeys
;
@Nullable
private
List
<
StreamKey
>
streamKeys
;
private
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
;
private
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
;
private
DrmSessionManager
<?>
drmSessionManager
;
private
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
long
livePresentationDelayMs
;
private
long
livePresentationDelayMs
;
private
boolean
isCreateCalled
;
private
boolean
isCreateCalled
;
...
@@ -98,6 +101,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -98,6 +101,7 @@ public final class SsMediaSource extends BaseMediaSource
@Nullable
DataSource
.
Factory
manifestDataSourceFactory
)
{
@Nullable
DataSource
.
Factory
manifestDataSourceFactory
)
{
this
.
chunkSourceFactory
=
Assertions
.
checkNotNull
(
chunkSourceFactory
);
this
.
chunkSourceFactory
=
Assertions
.
checkNotNull
(
chunkSourceFactory
);
this
.
manifestDataSourceFactory
=
manifestDataSourceFactory
;
this
.
manifestDataSourceFactory
=
manifestDataSourceFactory
;
drmSessionManager
=
DrmSessionManager
.
getDummyDrmSessionManager
();
loadErrorHandlingPolicy
=
new
DefaultLoadErrorHandlingPolicy
();
loadErrorHandlingPolicy
=
new
DefaultLoadErrorHandlingPolicy
();
livePresentationDelayMs
=
DEFAULT_LIVE_PRESENTATION_DELAY_MS
;
livePresentationDelayMs
=
DEFAULT_LIVE_PRESENTATION_DELAY_MS
;
compositeSequenceableLoaderFactory
=
new
DefaultCompositeSequenceableLoaderFactory
();
compositeSequenceableLoaderFactory
=
new
DefaultCompositeSequenceableLoaderFactory
();
...
@@ -118,6 +122,20 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -118,6 +122,20 @@ public final class SsMediaSource extends BaseMediaSource
}
}
/**
/**
* Sets the {@link DrmSessionManager} to use for acquiring {@link DrmSession DrmSessions}. The
* default value is {@link DrmSessionManager#DUMMY}.
*
* @param drmSessionManager The {@link DrmSessionManager}.
* @return This factory, for convenience.
* @throws IllegalStateException If one of the {@code create} methods has already been called.
*/
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
drmSessionManager
=
drmSessionManager
;
return
this
;
}
/**
* Sets the minimum number of times to retry if a loading error occurs. See {@link
* Sets the minimum number of times to retry if a loading error occurs. See {@link
* #setLoadErrorHandlingPolicy} for the default value.
* #setLoadErrorHandlingPolicy} for the default value.
*
*
...
@@ -220,6 +238,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -220,6 +238,7 @@ public final class SsMediaSource extends BaseMediaSource
/* manifestParser= */
null
,
/* manifestParser= */
null
,
chunkSourceFactory
,
chunkSourceFactory
,
compositeSequenceableLoaderFactory
,
compositeSequenceableLoaderFactory
,
drmSessionManager
,
loadErrorHandlingPolicy
,
loadErrorHandlingPolicy
,
livePresentationDelayMs
,
livePresentationDelayMs
,
tag
);
tag
);
...
@@ -279,6 +298,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -279,6 +298,7 @@ public final class SsMediaSource extends BaseMediaSource
manifestParser
,
manifestParser
,
chunkSourceFactory
,
chunkSourceFactory
,
compositeSequenceableLoaderFactory
,
compositeSequenceableLoaderFactory
,
drmSessionManager
,
loadErrorHandlingPolicy
,
loadErrorHandlingPolicy
,
livePresentationDelayMs
,
livePresentationDelayMs
,
tag
);
tag
);
...
@@ -318,6 +338,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -318,6 +338,7 @@ public final class SsMediaSource extends BaseMediaSource
private
final
DataSource
.
Factory
manifestDataSourceFactory
;
private
final
DataSource
.
Factory
manifestDataSourceFactory
;
private
final
SsChunkSource
.
Factory
chunkSourceFactory
;
private
final
SsChunkSource
.
Factory
chunkSourceFactory
;
private
final
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
;
private
final
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
;
private
final
DrmSessionManager
<?>
drmSessionManager
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
long
livePresentationDelayMs
;
private
final
long
livePresentationDelayMs
;
private
final
EventDispatcher
manifestEventDispatcher
;
private
final
EventDispatcher
manifestEventDispatcher
;
...
@@ -383,6 +404,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -383,6 +404,7 @@ public final class SsMediaSource extends BaseMediaSource
/* manifestParser= */
null
,
/* manifestParser= */
null
,
chunkSourceFactory
,
chunkSourceFactory
,
new
DefaultCompositeSequenceableLoaderFactory
(),
new
DefaultCompositeSequenceableLoaderFactory
(),
DrmSessionManager
.
getDummyDrmSessionManager
(),
new
DefaultLoadErrorHandlingPolicy
(
minLoadableRetryCount
),
new
DefaultLoadErrorHandlingPolicy
(
minLoadableRetryCount
),
DEFAULT_LIVE_PRESENTATION_DELAY_MS
,
DEFAULT_LIVE_PRESENTATION_DELAY_MS
,
/* tag= */
null
);
/* tag= */
null
);
...
@@ -483,6 +505,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -483,6 +505,7 @@ public final class SsMediaSource extends BaseMediaSource
manifestParser
,
manifestParser
,
chunkSourceFactory
,
chunkSourceFactory
,
new
DefaultCompositeSequenceableLoaderFactory
(),
new
DefaultCompositeSequenceableLoaderFactory
(),
DrmSessionManager
.
getDummyDrmSessionManager
(),
new
DefaultLoadErrorHandlingPolicy
(
minLoadableRetryCount
),
new
DefaultLoadErrorHandlingPolicy
(
minLoadableRetryCount
),
livePresentationDelayMs
,
livePresentationDelayMs
,
/* tag= */
null
);
/* tag= */
null
);
...
@@ -498,6 +521,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -498,6 +521,7 @@ public final class SsMediaSource extends BaseMediaSource
ParsingLoadable
.
Parser
<?
extends
SsManifest
>
manifestParser
,
ParsingLoadable
.
Parser
<?
extends
SsManifest
>
manifestParser
,
SsChunkSource
.
Factory
chunkSourceFactory
,
SsChunkSource
.
Factory
chunkSourceFactory
,
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
,
CompositeSequenceableLoaderFactory
compositeSequenceableLoaderFactory
,
DrmSessionManager
<?>
drmSessionManager
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
long
livePresentationDelayMs
,
long
livePresentationDelayMs
,
@Nullable
Object
tag
)
{
@Nullable
Object
tag
)
{
...
@@ -508,6 +532,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -508,6 +532,7 @@ public final class SsMediaSource extends BaseMediaSource
this
.
manifestParser
=
manifestParser
;
this
.
manifestParser
=
manifestParser
;
this
.
chunkSourceFactory
=
chunkSourceFactory
;
this
.
chunkSourceFactory
=
chunkSourceFactory
;
this
.
compositeSequenceableLoaderFactory
=
compositeSequenceableLoaderFactory
;
this
.
compositeSequenceableLoaderFactory
=
compositeSequenceableLoaderFactory
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
livePresentationDelayMs
=
livePresentationDelayMs
;
this
.
livePresentationDelayMs
=
livePresentationDelayMs
;
this
.
manifestEventDispatcher
=
createEventDispatcher
(
/* mediaPeriodId= */
null
);
this
.
manifestEventDispatcher
=
createEventDispatcher
(
/* mediaPeriodId= */
null
);
...
@@ -553,6 +578,7 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -553,6 +578,7 @@ public final class SsMediaSource extends BaseMediaSource
chunkSourceFactory
,
chunkSourceFactory
,
mediaTransferListener
,
mediaTransferListener
,
compositeSequenceableLoaderFactory
,
compositeSequenceableLoaderFactory
,
drmSessionManager
,
loadErrorHandlingPolicy
,
loadErrorHandlingPolicy
,
eventDispatcher
,
eventDispatcher
,
manifestLoaderErrorThrower
,
manifestLoaderErrorThrower
,
...
...
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
View file @
b9ab0cf1
...
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
...
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory
;
import
com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
import
com.google.android.exoplayer2.source.MediaSource.MediaPeriodId
;
import
com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher
;
import
com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher
;
...
@@ -66,6 +67,7 @@ public class SsMediaPeriodTest {
...
@@ -66,6 +67,7 @@ public class SsMediaPeriodTest {
mock
(
SsChunkSource
.
Factory
.
class
),
mock
(
SsChunkSource
.
Factory
.
class
),
mock
(
TransferListener
.
class
),
mock
(
TransferListener
.
class
),
mock
(
CompositeSequenceableLoaderFactory
.
class
),
mock
(
CompositeSequenceableLoaderFactory
.
class
),
mock
(
DrmSessionManager
.
class
),
mock
(
LoadErrorHandlingPolicy
.
class
),
mock
(
LoadErrorHandlingPolicy
.
class
),
new
EventDispatcher
()
new
EventDispatcher
()
.
withParameters
(
.
withParameters
(
...
...
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