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
5941882d
authored
Jan 21, 2015
by
ojw28
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #254 from SongArc/dev
FrameworkSampleSource with FileDescriptor
parents
a879819d
8547f0c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java
View file @
5941882d
...
...
@@ -23,6 +23,7 @@ import android.content.Context;
import
android.media.MediaExtractor
;
import
android.net.Uri
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.UUID
;
...
...
@@ -43,6 +44,10 @@ public final class FrameworkSampleSource implements SampleSource {
private
final
Uri
uri
;
private
final
Map
<
String
,
String
>
headers
;
private
final
FileDescriptor
fileDescriptor
;
private
final
long
fdOffset
;
private
final
long
fdLength
;
private
MediaExtractor
extractor
;
private
TrackInfo
[]
trackInfos
;
private
boolean
prepared
;
...
...
@@ -59,13 +64,36 @@ public final class FrameworkSampleSource implements SampleSource {
this
.
uri
=
uri
;
this
.
headers
=
headers
;
this
.
remainingReleaseCount
=
downstreamRendererCount
;
this
.
fileDescriptor
=
null
;
this
.
fdOffset
=
0
;
this
.
fdLength
=
0
;
}
public
FrameworkSampleSource
(
FileDescriptor
fileDescriptor
,
long
offset
,
long
length
,
int
downstreamRendererCount
)
{
Assertions
.
checkState
(
Util
.
SDK_INT
>=
16
);
this
.
fileDescriptor
=
fileDescriptor
;
this
.
fdOffset
=
offset
;
this
.
fdLength
=
length
;
this
.
remainingReleaseCount
=
downstreamRendererCount
;
this
.
context
=
null
;
this
.
uri
=
null
;
this
.
headers
=
null
;
}
@Override
public
boolean
prepare
()
throws
IOException
{
if
(!
prepared
)
{
extractor
=
new
MediaExtractor
();
if
(
context
!=
null
)
extractor
.
setDataSource
(
context
,
uri
,
headers
);
else
extractor
.
setDataSource
(
fileDescriptor
,
fdOffset
,
fdLength
);
trackStates
=
new
int
[
extractor
.
getTrackCount
()];
pendingDiscontinuities
=
new
boolean
[
trackStates
.
length
];
trackInfos
=
new
TrackInfo
[
trackStates
.
length
];
...
...
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