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
510f1883
authored
Jul 12, 2019
by
aquilescanta
Committed by
Oliver Woodman
Jul 14, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Plumb DrmSessionManager into ProgressiveMediaSource
PiperOrigin-RevId: 257777513
parent
df81bd6a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
13 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
510f1883
...
@@ -486,7 +486,9 @@ public class PlayerActivity extends AppCompatActivity
...
@@ -486,7 +486,9 @@ public class PlayerActivity extends AppCompatActivity
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
:
return
new
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
).
createMediaSource
(
uri
);
return
new
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
)
.
setDrmSessionManager
(
drmSessionManager
)
.
createMediaSource
(
uri
);
default
:
default
:
throw
new
IllegalStateException
(
"Unsupported type: "
+
type
);
throw
new
IllegalStateException
(
"Unsupported type: "
+
type
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java
View file @
510f1883
...
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
...
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.ExtractorsFactory
;
...
@@ -325,6 +326,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
...
@@ -325,6 +326,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
uri
,
uri
,
dataSourceFactory
,
dataSourceFactory
,
extractorsFactory
,
extractorsFactory
,
DrmSessionManager
.
getDummyDrmSessionManager
(),
loadableLoadErrorHandlingPolicy
,
loadableLoadErrorHandlingPolicy
,
customCacheKey
,
customCacheKey
,
continueLoadingCheckIntervalBytes
,
continueLoadingCheckIntervalBytes
,
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
View file @
510f1883
...
@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.FormatHolder;
...
@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.FormatHolder;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorInput
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorInput
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
...
@@ -90,6 +91,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -90,6 +91,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private
final
Uri
uri
;
private
final
Uri
uri
;
private
final
DataSource
dataSource
;
private
final
DataSource
dataSource
;
private
final
DrmSessionManager
<?>
drmSessionManager
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
final
EventDispatcher
eventDispatcher
;
private
final
EventDispatcher
eventDispatcher
;
private
final
Listener
listener
;
private
final
Listener
listener
;
...
@@ -107,6 +109,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -107,6 +109,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Nullable
private
SeekMap
seekMap
;
@Nullable
private
SeekMap
seekMap
;
@Nullable
private
IcyHeaders
icyHeaders
;
@Nullable
private
IcyHeaders
icyHeaders
;
private
SampleQueue
[]
sampleQueues
;
private
SampleQueue
[]
sampleQueues
;
private
DecryptableSampleQueueReader
[]
sampleQueueReaders
;
private
TrackId
[]
sampleQueueTrackIds
;
private
TrackId
[]
sampleQueueTrackIds
;
private
boolean
sampleQueuesBuilt
;
private
boolean
sampleQueuesBuilt
;
private
boolean
prepared
;
private
boolean
prepared
;
...
@@ -152,6 +155,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -152,6 +155,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
Uri
uri
,
Uri
uri
,
DataSource
dataSource
,
DataSource
dataSource
,
Extractor
[]
extractors
,
Extractor
[]
extractors
,
DrmSessionManager
<?>
drmSessionManager
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
,
EventDispatcher
eventDispatcher
,
EventDispatcher
eventDispatcher
,
Listener
listener
,
Listener
listener
,
...
@@ -160,6 +164,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -160,6 +164,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
int
continueLoadingCheckIntervalBytes
)
{
int
continueLoadingCheckIntervalBytes
)
{
this
.
uri
=
uri
;
this
.
uri
=
uri
;
this
.
dataSource
=
dataSource
;
this
.
dataSource
=
dataSource
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
loadErrorHandlingPolicy
=
loadErrorHandlingPolicy
;
this
.
eventDispatcher
=
eventDispatcher
;
this
.
eventDispatcher
=
eventDispatcher
;
this
.
listener
=
listener
;
this
.
listener
=
listener
;
...
@@ -180,6 +185,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -180,6 +185,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
handler
=
new
Handler
();
handler
=
new
Handler
();
sampleQueueTrackIds
=
new
TrackId
[
0
];
sampleQueueTrackIds
=
new
TrackId
[
0
];
sampleQueues
=
new
SampleQueue
[
0
];
sampleQueues
=
new
SampleQueue
[
0
];
sampleQueueReaders
=
new
DecryptableSampleQueueReader
[
0
];
pendingResetPositionUs
=
C
.
TIME_UNSET
;
pendingResetPositionUs
=
C
.
TIME_UNSET
;
length
=
C
.
LENGTH_UNSET
;
length
=
C
.
LENGTH_UNSET
;
durationUs
=
C
.
TIME_UNSET
;
durationUs
=
C
.
TIME_UNSET
;
...
@@ -195,6 +201,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -195,6 +201,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
sampleQueue
.
discardToEnd
();
sampleQueue
.
discardToEnd
();
}
}
}
}
for
(
DecryptableSampleQueueReader
reader
:
sampleQueueReaders
)
{
reader
.
release
();
}
loader
.
release
(
/* callback= */
this
);
loader
.
release
(
/* callback= */
this
);
handler
.
removeCallbacksAndMessages
(
null
);
handler
.
removeCallbacksAndMessages
(
null
);
callback
=
null
;
callback
=
null
;
...
@@ -432,29 +441,32 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -432,29 +441,32 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
// SampleStream methods.
// SampleStream methods.
/* package */
boolean
isReady
(
int
track
)
{
/* package */
boolean
isReady
(
int
track
)
{
return
!
suppressRead
()
&&
(
loadingFinished
||
sampleQueues
[
track
].
hasNextSample
());
return
!
suppressRead
()
&&
sampleQueueReaders
[
track
].
isReady
(
loadingFinished
);
}
/* package */
void
maybeThrowError
(
int
sampleQueueIndex
)
throws
IOException
{
sampleQueueReaders
[
sampleQueueIndex
].
maybeThrowError
();
maybeThrowError
();
}
}
/* package */
void
maybeThrowError
()
throws
IOException
{
/* package */
void
maybeThrowError
()
throws
IOException
{
loader
.
maybeThrowError
(
loadErrorHandlingPolicy
.
getMinimumLoadableRetryCount
(
dataType
));
loader
.
maybeThrowError
(
loadErrorHandlingPolicy
.
getMinimumLoadableRetryCount
(
dataType
));
}
}
/* package */
int
readData
(
int
track
,
FormatHolder
formatHolder
,
DecoderInputBuffer
buffer
,
/* package */
int
readData
(
int
sampleQueueIndex
,
FormatHolder
formatHolder
,
DecoderInputBuffer
buffer
,
boolean
formatRequired
)
{
boolean
formatRequired
)
{
if
(
suppressRead
())
{
if
(
suppressRead
())
{
return
C
.
RESULT_NOTHING_READ
;
return
C
.
RESULT_NOTHING_READ
;
}
}
maybeNotifyDownstreamFormat
(
track
);
maybeNotifyDownstreamFormat
(
sampleQueueIndex
);
int
result
=
int
result
=
sampleQueues
[
track
].
read
(
sampleQueueReaders
[
sampleQueueIndex
].
read
(
formatHolder
,
formatHolder
,
buffer
,
formatRequired
,
loadingFinished
,
lastSeekPositionUs
);
buffer
,
formatRequired
,
/* allowOnlyClearBuffers= */
false
,
loadingFinished
,
lastSeekPositionUs
);
if
(
result
==
C
.
RESULT_NOTHING_READ
)
{
if
(
result
==
C
.
RESULT_NOTHING_READ
)
{
maybeStartDeferredRetry
(
track
);
maybeStartDeferredRetry
(
sampleQueueIndex
);
}
}
return
result
;
return
result
;
}
}
...
@@ -667,6 +679,12 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -667,6 +679,12 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@NullableType
SampleQueue
[]
sampleQueues
=
Arrays
.
copyOf
(
this
.
sampleQueues
,
trackCount
+
1
);
@NullableType
SampleQueue
[]
sampleQueues
=
Arrays
.
copyOf
(
this
.
sampleQueues
,
trackCount
+
1
);
sampleQueues
[
trackCount
]
=
trackOutput
;
sampleQueues
[
trackCount
]
=
trackOutput
;
this
.
sampleQueues
=
Util
.
castNonNullTypeArray
(
sampleQueues
);
this
.
sampleQueues
=
Util
.
castNonNullTypeArray
(
sampleQueues
);
@NullableType
DecryptableSampleQueueReader
[]
sampleQueueReaders
=
Arrays
.
copyOf
(
this
.
sampleQueueReaders
,
trackCount
+
1
);
sampleQueueReaders
[
trackCount
]
=
new
DecryptableSampleQueueReader
(
this
.
sampleQueues
[
trackCount
],
drmSessionManager
);
this
.
sampleQueueReaders
=
Util
.
castNonNullTypeArray
(
sampleQueueReaders
);
return
trackOutput
;
return
trackOutput
;
}
}
...
@@ -868,7 +886,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -868,7 +886,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
void
maybeThrowError
()
throws
IOException
{
public
void
maybeThrowError
()
throws
IOException
{
ProgressiveMediaPeriod
.
this
.
maybeThrowError
();
ProgressiveMediaPeriod
.
this
.
maybeThrowError
(
track
);
}
}
@Override
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java
View file @
510f1883
...
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.source;
...
@@ -18,6 +18,8 @@ package com.google.android.exoplayer2.source;
import
android.net.Uri
;
import
android.net.Uri
;
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.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorsFactory
;
import
com.google.android.exoplayer2.extractor.ExtractorsFactory
;
...
@@ -51,6 +53,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -51,6 +53,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
private
ExtractorsFactory
extractorsFactory
;
private
ExtractorsFactory
extractorsFactory
;
@Nullable
private
String
customCacheKey
;
@Nullable
private
String
customCacheKey
;
@Nullable
private
Object
tag
;
@Nullable
private
Object
tag
;
private
DrmSessionManager
<?>
drmSessionManager
;
private
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
LoadErrorHandlingPolicy
loadErrorHandlingPolicy
;
private
int
continueLoadingCheckIntervalBytes
;
private
int
continueLoadingCheckIntervalBytes
;
private
boolean
isCreateCalled
;
private
boolean
isCreateCalled
;
...
@@ -74,6 +77,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -74,6 +77,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
public
Factory
(
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
)
{
public
Factory
(
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
)
{
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
extractorsFactory
=
extractorsFactory
;
this
.
extractorsFactory
=
extractorsFactory
;
drmSessionManager
=
DrmSessionManager
.
getDummyDrmSessionManager
();
loadErrorHandlingPolicy
=
new
DefaultLoadErrorHandlingPolicy
();
loadErrorHandlingPolicy
=
new
DefaultLoadErrorHandlingPolicy
();
continueLoadingCheckIntervalBytes
=
DEFAULT_LOADING_CHECK_INTERVAL_BYTES
;
continueLoadingCheckIntervalBytes
=
DEFAULT_LOADING_CHECK_INTERVAL_BYTES
;
}
}
...
@@ -129,6 +133,20 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -129,6 +133,20 @@ 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()}.
*
*
...
@@ -172,6 +190,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -172,6 +190,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
uri
,
uri
,
dataSourceFactory
,
dataSourceFactory
,
extractorsFactory
,
extractorsFactory
,
drmSessionManager
,
loadErrorHandlingPolicy
,
loadErrorHandlingPolicy
,
customCacheKey
,
customCacheKey
,
continueLoadingCheckIntervalBytes
,
continueLoadingCheckIntervalBytes
,
...
@@ -193,6 +212,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -193,6 +212,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
private
final
Uri
uri
;
private
final
Uri
uri
;
private
final
DataSource
.
Factory
dataSourceFactory
;
private
final
DataSource
.
Factory
dataSourceFactory
;
private
final
ExtractorsFactory
extractorsFactory
;
private
final
ExtractorsFactory
extractorsFactory
;
private
final
DrmSessionManager
<?>
drmSessionManager
;
private
final
LoadErrorHandlingPolicy
loadableLoadErrorHandlingPolicy
;
private
final
LoadErrorHandlingPolicy
loadableLoadErrorHandlingPolicy
;
@Nullable
private
final
String
customCacheKey
;
@Nullable
private
final
String
customCacheKey
;
private
final
int
continueLoadingCheckIntervalBytes
;
private
final
int
continueLoadingCheckIntervalBytes
;
...
@@ -207,6 +227,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -207,6 +227,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
Uri
uri
,
Uri
uri
,
DataSource
.
Factory
dataSourceFactory
,
DataSource
.
Factory
dataSourceFactory
,
ExtractorsFactory
extractorsFactory
,
ExtractorsFactory
extractorsFactory
,
DrmSessionManager
<?>
drmSessionManager
,
LoadErrorHandlingPolicy
loadableLoadErrorHandlingPolicy
,
LoadErrorHandlingPolicy
loadableLoadErrorHandlingPolicy
,
@Nullable
String
customCacheKey
,
@Nullable
String
customCacheKey
,
int
continueLoadingCheckIntervalBytes
,
int
continueLoadingCheckIntervalBytes
,
...
@@ -214,6 +235,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -214,6 +235,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
this
.
uri
=
uri
;
this
.
uri
=
uri
;
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
extractorsFactory
=
extractorsFactory
;
this
.
extractorsFactory
=
extractorsFactory
;
this
.
drmSessionManager
=
drmSessionManager
;
this
.
loadableLoadErrorHandlingPolicy
=
loadableLoadErrorHandlingPolicy
;
this
.
loadableLoadErrorHandlingPolicy
=
loadableLoadErrorHandlingPolicy
;
this
.
customCacheKey
=
customCacheKey
;
this
.
customCacheKey
=
customCacheKey
;
this
.
continueLoadingCheckIntervalBytes
=
continueLoadingCheckIntervalBytes
;
this
.
continueLoadingCheckIntervalBytes
=
continueLoadingCheckIntervalBytes
;
...
@@ -248,6 +270,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
...
@@ -248,6 +270,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
uri
,
uri
,
dataSource
,
dataSource
,
extractorsFactory
.
createExtractors
(),
extractorsFactory
.
createExtractors
(),
drmSessionManager
,
loadableLoadErrorHandlingPolicy
,
loadableLoadErrorHandlingPolicy
,
createEventDispatcher
(
id
),
createEventDispatcher
(
id
),
this
,
this
,
...
...
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