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
9974670c
authored
Dec 04, 2019
by
aquilescanta
Committed by
Oliver Woodman
Jan 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make DownloadHelper pass DrmSessionManager to MediaSources
PiperOrigin-RevId: 283795201
parent
9c23888f
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 @
9974670c
...
@@ -615,10 +615,21 @@ public class PlayerActivity extends AppCompatActivity
...
@@ -615,10 +615,21 @@ public class PlayerActivity extends AppCompatActivity
}
}
MediaSourceFactory
adMediaSourceFactory
=
MediaSourceFactory
adMediaSourceFactory
=
new
MediaSourceFactory
()
{
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
@Override
public
MediaSource
createMediaSource
(
Uri
uri
)
{
public
MediaSource
createMediaSource
(
Uri
uri
)
{
return
PlayerActivity
.
this
.
createLeafMediaSource
(
return
PlayerActivity
.
this
.
createLeafMediaSource
(
uri
,
/* extension=*/
null
,
DrmSessionManager
.
getDummyDrmSessionManager
()
);
uri
,
/* extension=*/
null
,
drmSessionManager
);
}
}
@Override
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java
View file @
9974670c
...
@@ -263,9 +263,13 @@ public final class DownloadHelper {
...
@@ -263,9 +263,13 @@ public final class DownloadHelper {
uri
,
uri
,
/* cacheKey= */
null
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
createMediaSourceInternal
(
DASH_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
DASH_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
trackSelectorParameters
,
Util
.
getRendererCapabilities
(
renderersFactory
,
drmSessionManager
));
Util
.
getRendererCapabilities
(
renderersFactory
,
/* drmSessionManager= */
null
));
}
}
/** @deprecated Use {@link #forHls(Context, Uri, Factory, RenderersFactory)} */
/** @deprecated Use {@link #forHls(Context, Uri, Factory, RenderersFactory)} */
...
@@ -329,9 +333,13 @@ public final class DownloadHelper {
...
@@ -329,9 +333,13 @@ public final class DownloadHelper {
uri
,
uri
,
/* cacheKey= */
null
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
createMediaSourceInternal
(
HLS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
HLS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
trackSelectorParameters
,
Util
.
getRendererCapabilities
(
renderersFactory
,
drmSessionManager
));
Util
.
getRendererCapabilities
(
renderersFactory
,
/* drmSessionManager= */
null
));
}
}
/** @deprecated Use {@link #forSmoothStreaming(Context, Uri, Factory, RenderersFactory)} */
/** @deprecated Use {@link #forSmoothStreaming(Context, Uri, Factory, RenderersFactory)} */
...
@@ -395,9 +403,24 @@ public final class DownloadHelper {
...
@@ -395,9 +403,24 @@ public final class DownloadHelper {
uri
,
uri
,
/* cacheKey= */
null
,
/* cacheKey= */
null
,
createMediaSourceInternal
(
createMediaSourceInternal
(
SS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
/* streamKeys= */
null
),
SS_FACTORY_CONSTRUCTOR
,
uri
,
dataSourceFactory
,
drmSessionManager
,
/* streamKeys= */
null
),
trackSelectorParameters
,
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 {
...
@@ -409,7 +432,9 @@ public final class DownloadHelper {
* @return A MediaSource which only contains the tracks defined in {@code downloadRequest}.
* @return A MediaSource which only contains the tracks defined in {@code downloadRequest}.
*/
*/
public
static
MediaSource
createMediaSource
(
public
static
MediaSource
createMediaSource
(
DownloadRequest
downloadRequest
,
DataSource
.
Factory
dataSourceFactory
)
{
DownloadRequest
downloadRequest
,
DataSource
.
Factory
dataSourceFactory
,
DrmSessionManager
<?>
drmSessionManager
)
{
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
;
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
;
switch
(
downloadRequest
.
type
)
{
switch
(
downloadRequest
.
type
)
{
case
DownloadRequest
.
TYPE_DASH
:
case
DownloadRequest
.
TYPE_DASH
:
...
@@ -428,7 +453,11 @@ public final class DownloadHelper {
...
@@ -428,7 +453,11 @@ public final class DownloadHelper {
throw
new
IllegalStateException
(
"Unsupported type: "
+
downloadRequest
.
type
);
throw
new
IllegalStateException
(
"Unsupported type: "
+
downloadRequest
.
type
);
}
}
return
createMediaSourceInternal
(
return
createMediaSourceInternal
(
constructor
,
downloadRequest
.
uri
,
dataSourceFactory
,
downloadRequest
.
streamKeys
);
constructor
,
downloadRequest
.
uri
,
dataSourceFactory
,
drmSessionManager
,
downloadRequest
.
streamKeys
);
}
}
private
final
String
downloadType
;
private
final
String
downloadType
;
...
@@ -888,12 +917,16 @@ public final class DownloadHelper {
...
@@ -888,12 +917,16 @@ public final class DownloadHelper {
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
,
@Nullable
Constructor
<?
extends
MediaSourceFactory
>
constructor
,
Uri
uri
,
Uri
uri
,
Factory
dataSourceFactory
,
Factory
dataSourceFactory
,
@Nullable
DrmSessionManager
<?>
drmSessionManager
,
@Nullable
List
<
StreamKey
>
streamKeys
)
{
@Nullable
List
<
StreamKey
>
streamKeys
)
{
if
(
constructor
==
null
)
{
if
(
constructor
==
null
)
{
throw
new
IllegalStateException
(
"Module missing to create media source."
);
throw
new
IllegalStateException
(
"Module missing to create media source."
);
}
}
try
{
try
{
MediaSourceFactory
factory
=
constructor
.
newInstance
(
dataSourceFactory
);
MediaSourceFactory
factory
=
constructor
.
newInstance
(
dataSourceFactory
);
if
(
drmSessionManager
!=
null
)
{
factory
.
setDrmSessionManager
(
drmSessionManager
);
}
if
(
streamKeys
!=
null
)
{
if
(
streamKeys
!=
null
)
{
factory
.
setStreamKeys
(
streamKeys
);
factory
.
setStreamKeys
(
streamKeys
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
View file @
9974670c
...
@@ -179,6 +179,13 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
...
@@ -179,6 +179,13 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
return
this
;
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.
* Returns a new {@link ExtractorMediaSource} using the current parameters.
*
*
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java
View file @
9974670c
...
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source;
...
@@ -17,6 +17,8 @@ package com.google.android.exoplayer2.source;
import
android.net.Uri
;
import
android.net.Uri
;
import
com.google.android.exoplayer2.C
;
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
com.google.android.exoplayer2.offline.StreamKey
;
import
java.util.List
;
import
java.util.List
;
...
@@ -35,6 +37,15 @@ public interface MediaSourceFactory {
...
@@ -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}.
* Creates a new {@link MediaSource} with the specified {@code uri}.
*
*
* @param uri The URI to play.
* @param uri The URI to play.
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
View file @
9974670c
...
@@ -133,20 +133,6 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -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
* Sets the {@link LoadErrorHandlingPolicy}. The default value is created by calling {@link
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
*
*
...
@@ -178,6 +164,21 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -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.
* Returns a new {@link ProgressiveMediaSource} using the current parameters.
*
*
* @param uri The {@link Uri}.
* @param uri The {@link Uri}.
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java
View file @
9974670c
...
@@ -137,20 +137,6 @@ public final class DashMediaSource extends BaseMediaSource {
...
@@ -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
* 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.
*
*
...
@@ -311,6 +297,21 @@ public final class DashMediaSource extends BaseMediaSource {
...
@@ -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.
* Returns a new {@link DashMediaSource} using the current parameters.
*
*
* @param manifestUri The manifest {@link Uri}.
* @param manifestUri The manifest {@link Uri}.
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
View file @
9974670c
...
@@ -161,20 +161,6 @@ public final class HlsMediaSource extends BaseMediaSource
...
@@ -161,20 +161,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
* Sets the {@link LoadErrorHandlingPolicy}. The default value is created by calling {@link
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
* DefaultLoadErrorHandlingPolicy#DefaultLoadErrorHandlingPolicy()}.
*
*
...
@@ -327,6 +313,21 @@ public final class HlsMediaSource extends BaseMediaSource
...
@@ -327,6 +313,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.
* Returns a new {@link HlsMediaSource} using the current parameters.
*
*
* @return The new {@link HlsMediaSource}.
* @return The new {@link HlsMediaSource}.
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java
View file @
9974670c
...
@@ -122,20 +122,6 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -122,20 +122,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
* 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.
*
*
...
@@ -277,6 +263,21 @@ public final class SsMediaSource extends BaseMediaSource
...
@@ -277,6 +263,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.
* Returns a new {@link SsMediaSource} using the current parameters.
*
*
* @param manifestUri The manifest {@link Uri}.
* @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