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
4c05201a
authored
Feb 21, 2020
by
aquilescanta
Committed by
Oliver Woodman
Feb 25, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make ExtractorHolder a top-level class
PiperOrigin-RevId: 296405881
parent
995682ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
70 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorHolder.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorHolder.java
0 → 100644
View file @
4c05201a
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
source
;
import
android.net.Uri
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.extractor.Extractor
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.EOFException
;
import
java.io.IOException
;
/** Stores a list of extractors and a selected extractor when the format has been detected. */
/* package */
final
class
ExtractorHolder
{
private
final
Extractor
[]
extractors
;
@Nullable
private
Extractor
extractor
;
/**
* Creates a holder that will select an extractor and initialize it using the specified output.
*
* @param extractors One or more extractors to choose from.
*/
public
ExtractorHolder
(
Extractor
[]
extractors
)
{
this
.
extractors
=
extractors
;
}
/**
* Returns an initialized extractor for reading {@code input}, and returns the same extractor on
* later calls.
*
* @param input The {@link ExtractorInput} from which data should be read.
* @param output The {@link ExtractorOutput} that will be used to initialize the selected
* extractor.
* @param uri The {@link Uri} of the data.
* @return An initialized extractor for reading {@code input}.
* @throws UnrecognizedInputFormatException Thrown if the input format could not be detected.
* @throws IOException Thrown if the input could not be read.
* @throws InterruptedException Thrown if the thread was interrupted.
*/
public
Extractor
selectExtractor
(
ExtractorInput
input
,
ExtractorOutput
output
,
Uri
uri
)
throws
IOException
,
InterruptedException
{
if
(
extractor
!=
null
)
{
return
extractor
;
}
if
(
extractors
.
length
==
1
)
{
this
.
extractor
=
extractors
[
0
];
}
else
{
for
(
Extractor
extractor
:
extractors
)
{
try
{
if
(
extractor
.
sniff
(
input
))
{
this
.
extractor
=
extractor
;
break
;
}
}
catch
(
EOFException
e
)
{
// Do nothing.
}
finally
{
input
.
resetPeekPosition
();
}
}
if
(
extractor
==
null
)
{
throw
new
UnrecognizedInputFormatException
(
"None of the available extractors ("
+
Util
.
getCommaDelimitedSimpleClassNames
(
extractors
)
+
") could read the stream."
,
uri
);
}
}
extractor
.
init
(
output
);
return
extractor
;
}
public
void
release
()
{
if
(
extractor
!=
null
)
{
extractor
.
release
();
extractor
=
null
;
}
}
}
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
View file @
4c05201a
...
@@ -53,7 +53,6 @@ import com.google.android.exoplayer2.util.ConditionVariable;
...
@@ -53,7 +53,6 @@ import com.google.android.exoplayer2.util.ConditionVariable;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -1040,75 +1039,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -1040,75 +1039,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
}
}
/** Stores a list of extractors and a selected extractor when the format has been detected. */
private
static
final
class
ExtractorHolder
{
private
final
Extractor
[]
extractors
;
@Nullable
private
Extractor
extractor
;
/**
* Creates a holder that will select an extractor and initialize it using the specified output.
*
* @param extractors One or more extractors to choose from.
*/
public
ExtractorHolder
(
Extractor
[]
extractors
)
{
this
.
extractors
=
extractors
;
}
/**
* Returns an initialized extractor for reading {@code input}, and returns the same extractor on
* later calls.
*
* @param input The {@link ExtractorInput} from which data should be read.
* @param output The {@link ExtractorOutput} that will be used to initialize the selected
* extractor.
* @param uri The {@link Uri} of the data.
* @return An initialized extractor for reading {@code input}.
* @throws UnrecognizedInputFormatException Thrown if the input format could not be detected.
* @throws IOException Thrown if the input could not be read.
* @throws InterruptedException Thrown if the thread was interrupted.
*/
public
Extractor
selectExtractor
(
ExtractorInput
input
,
ExtractorOutput
output
,
Uri
uri
)
throws
IOException
,
InterruptedException
{
if
(
extractor
!=
null
)
{
return
extractor
;
}
if
(
extractors
.
length
==
1
)
{
this
.
extractor
=
extractors
[
0
];
}
else
{
for
(
Extractor
extractor
:
extractors
)
{
try
{
if
(
extractor
.
sniff
(
input
))
{
this
.
extractor
=
extractor
;
break
;
}
}
catch
(
EOFException
e
)
{
// Do nothing.
}
finally
{
input
.
resetPeekPosition
();
}
}
if
(
extractor
==
null
)
{
throw
new
UnrecognizedInputFormatException
(
"None of the available extractors ("
+
Util
.
getCommaDelimitedSimpleClassNames
(
extractors
)
+
") could read the stream."
,
uri
);
}
}
extractor
.
init
(
output
);
return
extractor
;
}
public
void
release
()
{
if
(
extractor
!=
null
)
{
extractor
.
release
();
extractor
=
null
;
}
}
}
/** Stores state that is initialized when preparation completes. */
/** Stores state that is initialized when preparation completes. */
private
static
final
class
PreparedState
{
private
static
final
class
PreparedState
{
...
...
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