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
e486dc60
authored
Jul 14, 2020
by
aquilescanta
Committed by
Oliver Woodman
Jul 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Release Extractor resources in DASH
PiperOrigin-RevId: 321181453
parent
8cd4afcd
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
23 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSource.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java
View file @
e486dc60
...
...
@@ -105,6 +105,11 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
}
@Override
public
void
release
()
{
extractor
.
release
();
}
@Override
public
boolean
read
(
ExtractorInput
input
)
throws
IOException
{
int
result
=
extractor
.
read
(
input
,
POSITION_HOLDER
);
Assertions
.
checkState
(
result
!=
Extractor
.
RESULT_SEEK
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractor.java
View file @
e486dc60
...
...
@@ -74,6 +74,9 @@ public interface ChunkExtractor {
*/
void
init
(
@Nullable
TrackOutputProvider
trackOutputProvider
,
long
startTimeUs
,
long
endTimeUs
);
/** Releases any held resources. */
void
release
();
/**
* Reads from the given {@link ExtractorInput}.
*
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
View file @
e486dc60
...
...
@@ -355,6 +355,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
for
(
SampleQueue
embeddedSampleQueue
:
embeddedSampleQueues
)
{
embeddedSampleQueue
.
release
();
}
chunkSource
.
release
();
if
(
releaseCallback
!=
null
)
{
releaseCallback
.
onSampleStreamReleased
(
this
);
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSource.java
View file @
e486dc60
...
...
@@ -104,4 +104,7 @@ public interface ChunkSource {
* chunk.
*/
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
exclusionDurationMs
);
/** Releases any held resources. */
void
release
();
}
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashUtil.java
View file @
e486dc60
...
...
@@ -114,11 +114,16 @@ public final class DashUtil {
@Nullable
public
static
Format
loadSampleFormat
(
DataSource
dataSource
,
int
trackType
,
Representation
representation
)
throws
IOException
{
ChunkExtractor
chunkExtractor
=
loadInitializationData
(
dataSource
,
trackType
,
representation
,
false
);
return
chunkExtractor
==
null
?
null
:
Assertions
.
checkStateNotNull
(
chunkExtractor
.
getSampleFormats
())[
0
];
if
(
representation
.
getInitializationUri
()
==
null
)
{
return
null
;
}
ChunkExtractor
chunkExtractor
=
newChunkExtractor
(
trackType
,
representation
.
format
);
try
{
loadInitializationData
(
chunkExtractor
,
dataSource
,
representation
,
/* loadIndex= */
false
);
}
finally
{
chunkExtractor
.
release
();
}
return
Assertions
.
checkStateNotNull
(
chunkExtractor
.
getSampleFormats
())[
0
];
}
/**
...
...
@@ -136,39 +141,40 @@ public final class DashUtil {
@Nullable
public
static
ChunkIndex
loadChunkIndex
(
DataSource
dataSource
,
int
trackType
,
Representation
representation
)
throws
IOException
{
@Nullable
ChunkExtractor
chunkExtractor
=
loadInitializationData
(
dataSource
,
trackType
,
representation
,
true
);
return
chunkExtractor
==
null
?
null
:
chunkExtractor
.
getChunkIndex
();
if
(
representation
.
getInitializationUri
()
==
null
)
{
return
null
;
}
ChunkExtractor
chunkExtractor
=
newChunkExtractor
(
trackType
,
representation
.
format
);
try
{
loadInitializationData
(
chunkExtractor
,
dataSource
,
representation
,
/* loadIndex= */
true
);
}
finally
{
chunkExtractor
.
release
();
}
return
chunkExtractor
.
getChunkIndex
();
}
/**
* Loads initialization data for the {@code representation} and optionally index data then returns
* a {@link BundledChunkExtractor} which contains the output.
*
* @param chunkExtractor The {@link ChunkExtractor} to use.
* @param dataSource The source from which the data should be loaded.
* @param trackType The type of the representation. Typically one of the {@link
* com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
* @param representation The representation which initialization chunk belongs to.
* @param loadIndex Whether to load index data too.
* @return A {@link BundledChunkExtractor} for the {@code representation}, or null if no
* initialization or (if requested) index data exists.
* @throws IOException Thrown when there is an error while loading.
*/
@Nullable
private
static
ChunkExtractor
loadInitializationData
(
DataSource
dataSource
,
int
trackType
,
Representation
representation
,
boolean
loadIndex
)
private
static
void
loadInitializationData
(
ChunkExtractor
chunkExtractor
,
DataSource
dataSource
,
Representation
representation
,
boolean
loadIndex
)
throws
IOException
{
RangedUri
initializationUri
=
representation
.
getInitializationUri
();
if
(
initializationUri
==
null
)
{
return
null
;
}
ChunkExtractor
chunkExtractor
=
newChunkExtractor
(
trackType
,
representation
.
format
);
RangedUri
initializationUri
=
Assertions
.
checkNotNull
(
representation
.
getInitializationUri
());
RangedUri
requestUri
;
if
(
loadIndex
)
{
RangedUri
indexUri
=
representation
.
getIndexUri
();
if
(
indexUri
==
null
)
{
return
null
;
return
;
}
// It's common for initialization and index data to be stored adjacently. Attempt to merge
// the two requests together to request both at once.
...
...
@@ -181,7 +187,6 @@ public final class DashUtil {
requestUri
=
initializationUri
;
}
loadInitializationData
(
dataSource
,
representation
,
chunkExtractor
,
requestUri
);
return
chunkExtractor
;
}
private
static
void
loadInitializationData
(
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java
View file @
e486dc60
...
...
@@ -442,6 +442,16 @@ public class DefaultDashChunkSource implements DashChunkSource {
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
exclusionDurationMs
);
}
@Override
public
void
release
()
{
for
(
RepresentationHolder
representationHolder
:
representationHolders
)
{
@Nullable
ChunkExtractor
chunkExtractor
=
representationHolder
.
chunkExtractor
;
if
(
chunkExtractor
!=
null
)
{
chunkExtractor
.
release
();
}
}
}
// Internal methods.
private
long
getSegmentNum
(
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java
View file @
e486dc60
...
...
@@ -271,6 +271,13 @@ public class DefaultSsChunkSource implements SsChunkSource {
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
exclusionDurationMs
);
}
@Override
public
void
release
()
{
for
(
ChunkExtractor
chunkExtractor
:
chunkExtractors
)
{
chunkExtractor
.
release
();
}
}
// Private methods.
private
static
MediaChunk
newMediaChunk
(
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java
View file @
e486dc60
...
...
@@ -150,4 +150,8 @@ public final class FakeChunkSource implements ChunkSource {
return
false
;
}
@Override
public
void
release
()
{
// Do nothing.
}
}
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