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
61c43c30
authored
Dec 04, 2019
by
aquilescanta
Committed by
Ian Baker
Dec 05, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make DownloadHelper pass DrmSessionManager to MediaSources
PiperOrigin-RevId: 283795201
parent
5ce85602
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
131 additions
and
65 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
61c43c30
...
...
@@ -616,10 +616,21 @@ public class PlayerActivity extends AppCompatActivity
}
MediaSourceFactory
adMediaSourceFactory
=
new
MediaSourceFactory
()
{
private
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
=
DrmSessionManager
.
getDummyDrmSessionManager
();
@Override
@SuppressWarnings
(
"unchecked"
)
// Safe upcasting.
public
MediaSourceFactory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
this
.
drmSessionManager
=
(
DrmSessionManager
<
ExoMediaCrypto
>)
drmSessionManager
;
return
this
;
}
@Override
public
MediaSource
createMediaSource
(
Uri
uri
)
{
return
PlayerActivity
.
this
.
createLeafMediaSource
(
uri
,
/* extension=*/
null
,
DrmSessionManager
.
getDummyDrmSessionManager
()
);
uri
,
/* extension=*/
null
,
drmSessionManager
);
}
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
View file @
61c43c30
...
...
@@ -263,9 +263,13 @@ public final class DownloadHelper {
uri
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
DASH_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
DASH_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
Util
.
getRendererCapabilities
(
renderersFactory
,
drmSessionManager
));
Util
.
getRendererCapabilities
(
renderersFactory
,
/* drmSessionManager= */
null
));
}
/** @deprecated Use {@link #forHls(Context, Uri, Factory, RenderersFactory)} */
...
...
@@ -329,9 +333,13 @@ public final class DownloadHelper {
uri
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
HLS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
HLS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
Util
.
getRendererCapabilities
(
renderersFactory
,
drmSessionManager
));
Util
.
getRendererCapabilities
(
renderersFactory
,
/* drmSessionManager= */
null
));
}
/** @deprecated Use {@link #forSmoothStreaming(Context, Uri, Factory, RenderersFactory)} */
...
...
@@ -395,9 +403,24 @@ public final class DownloadHelper {
uri
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
SS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
SS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
Util
.
getRendererCapabilities
(
renderersFactory
,
drmSessionManager
));
Util
.
getRendererCapabilities
(
renderersFactory
,
/* drmSessionManager= */
null
));
}
/**
* Equivalent to {@link #createMediaSource(DownloadRequest, Factory, DrmSessionManager)
* createMediaSource(downloadRequest, dataSourceFactory,
* DrmSessionManager.getDummyDrmSessionManager())}.
*/
public
static
MediaSource
createMediaSource
(
DownloadRequest
downloadRequest
,
DataSource
.
Factory
dataSourceFactory
)
{
return
createMediaSource
(
downloadRequest
,
dataSourceFactory
,
DrmSessionManager
.
getDummyDrmSessionManager
());
}
/**
...
...
@@ -409,7 +432,9 @@ public final class DownloadHelper {
* @return A MediaSource which only contains the tracks defined in {@code downloadRequest}.
*/
public
static
MediaSource
createMediaSource
(
DownloadRequest
downloadRequest
,
DataSource
.
Factory
dataSourceFactory
)
{
DownloadRequest
downloadRequest
,
DataSource
.
Factory
dataSourceFactory
,
DrmSessionManager
<?>
drmSessionManager
)
{
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
;
switch
(
downloadRequest
.
type
)
{
case
DownloadRequest
.
TYPE_DASH
:
...
...
@@ -428,7 +453,11 @@ public final class DownloadHelper {
throw
new
IllegalStateException
(
"Unsupported type: "
+
downloadRequest
.
type
);
}
return
createMediaSourceInternal
(
constructor
,
downloadRequest
.
uri
,
dataSourceFactory
,
downloadRequest
.
streamKeys
);
constructor
,
downloadRequest
.
uri
,
dataSourceFactory
,
drmSessionManager
,
downloadRequest
.
streamKeys
);
}
private
final
String
downloadType
;
...
...
@@ -888,12 +917,16 @@ public final class DownloadHelper {
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
,
Uri
uri
,
Factory
dataSourceFactory
,
@Nullable
DrmSessionManager
<?>
drmSessionManager
,
@Nullable
List
<
StreamKey
>
streamKeys
)
{
if
(
constructor
==
null
)
{
throw
new
IllegalStateException
(
"Module missing to create media source."
);
}
try
{
MediaSourceFactory
factory
=
constructor
.
newInstance
(
dataSourceFactory
);
if
(
drmSessionManager
!=
null
)
{
factory
.
setDrmSessionManager
(
drmSessionManager
);
}
if
(
streamKeys
!=
null
)
{
factory
.
setStreamKeys
(
streamKeys
);
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
View file @
61c43c30
...
...
@@ -179,6 +179,13 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
return
this
;
}
/** @deprecated Use {@link ProgressiveMediaSource.Factory#setDrmSessionManager} instead. */
@Override
@Deprecated
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
throw
new
UnsupportedOperationException
();
}
/**
* Returns a new {@link ExtractorMediaSource} using the current parameters.
*
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
View file @
61c43c30
...
...
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source;
import
android.net.Uri
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.offline.StreamKey
;
import
java.util.List
;
...
...
@@ -35,6 +37,15 @@ public interface MediaSourceFactory {
}
/**
* Sets the {@link DrmSessionManager} to use for acquiring {@link DrmSession DrmSessions}.
*
* @param drmSessionManager The {@link DrmSessionManager}.
* @return This factory, for convenience.
* @throws IllegalStateException If one of the {@code create} methods has already been called.
*/
MediaSourceFactory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
);
/**
* Creates a new {@link MediaSource} with the specified {@code uri}.
*
* @param uri The URI to play.
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
View file @
61c43c30
...
...
@@ -133,20 +133,6 @@ public final class ProgressiveMediaSource 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 {@link LoadErrorHandlingPolicy}. The default value is created by calling {@link
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
*
...
...
@@ -178,6 +164,21 @@ public final class ProgressiveMediaSource 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.
*/
@Override
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
drmSessionManager
=
drmSessionManager
;
return
this
;
}
/**
* Returns a new {@link ProgressiveMediaSource} using the current parameters.
*
* @param uri The {@link Uri}.
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java
View file @
61c43c30
...
...
@@ -137,20 +137,6 @@ public final class DashMediaSource 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
* #setLoadErrorHandlingPolicy} for the default value.
*
...
...
@@ -311,6 +297,21 @@ public final class DashMediaSource 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.
*/
@Override
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
drmSessionManager
=
drmSessionManager
;
return
this
;
}
/**
* Returns a new {@link DashMediaSource} using the current parameters.
*
* @param manifestUri The manifest {@link Uri}.
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
View file @
61c43c30
...
...
@@ -134,20 +134,6 @@ public final class HlsMediaSource 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 {@link LoadErrorHandlingPolicy}. The default value is created by calling {@link
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
*
...
...
@@ -300,6 +286,21 @@ public final class HlsMediaSource 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.
*/
@Override
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
drmSessionManager
=
drmSessionManager
;
return
this
;
}
/**
* Returns a new {@link HlsMediaSource} using the current parameters.
*
* @return The new {@link HlsMediaSource}.
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java
View file @
61c43c30
...
...
@@ -123,20 +123,6 @@ 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
* #setLoadErrorHandlingPolicy} for the default value.
*
...
...
@@ -278,6 +264,21 @@ 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.
*/
@Override
public
Factory
setDrmSessionManager
(
DrmSessionManager
<?>
drmSessionManager
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
drmSessionManager
=
drmSessionManager
;
return
this
;
}
/**
* Returns a new {@link SsMediaSource} using the current parameters.
*
* @param manifestUri The manifest {@link Uri}.
...
...
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