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
cdf19430
authored
Mar 10, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove TrackInfo from the SampleExtractor interface.
parent
fbd0a57e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
35 deletions
library/src/main/java/com/google/android/exoplayer/source/DefaultSampleSource.java
library/src/main/java/com/google/android/exoplayer/source/FrameworkSampleExtractor.java
library/src/main/java/com/google/android/exoplayer/source/SampleExtractor.java
library/src/main/java/com/google/android/exoplayer/source/DefaultSampleSource.java
View file @
cdf19430
...
...
@@ -62,9 +62,14 @@ public final class DefaultSampleSource implements SampleSource {
if
(
sampleExtractor
.
prepare
())
{
prepared
=
true
;
trackInfos
=
sampleExtractor
.
getTrackInfos
();
trackStates
=
new
int
[
trackInfos
.
length
];
pendingDiscontinuities
=
new
boolean
[
trackInfos
.
length
];
int
trackCount
=
sampleExtractor
.
getTrackCount
();
trackStates
=
new
int
[
trackCount
];
pendingDiscontinuities
=
new
boolean
[
trackCount
];
trackInfos
=
new
TrackInfo
[
trackCount
];
for
(
int
track
=
0
;
track
<
trackCount
;
track
++)
{
String
mimeType
=
sampleExtractor
.
getMediaFormat
(
track
).
mimeType
;
trackInfos
[
track
]
=
new
TrackInfo
(
mimeType
,
sampleExtractor
.
getDurationUs
(
track
));
}
}
return
prepared
;
...
...
@@ -119,7 +124,8 @@ public final class DefaultSampleSource implements SampleSource {
return
NOTHING_READ
;
}
if
(
trackStates
[
track
]
!=
TRACK_STATE_FORMAT_SENT
)
{
sampleExtractor
.
getTrackMediaFormat
(
track
,
formatHolder
);
formatHolder
.
format
=
sampleExtractor
.
getMediaFormat
(
track
);
formatHolder
.
drmInitData
=
sampleExtractor
.
getDrmInitData
(
track
);
trackStates
[
track
]
=
TRACK_STATE_FORMAT_SENT
;
return
FORMAT_READ
;
}
...
...
library/src/main/java/com/google/android/exoplayer/source/FrameworkSampleExtractor.java
View file @
cdf19430
...
...
@@ -17,10 +17,8 @@ package com.google.android.exoplayer.source;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.MediaFormatHolder
;
import
com.google.android.exoplayer.SampleHolder
;
import
com.google.android.exoplayer.SampleSource
;
import
com.google.android.exoplayer.TrackInfo
;
import
com.google.android.exoplayer.TrackRenderer
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
...
...
@@ -53,8 +51,6 @@ public final class FrameworkSampleExtractor implements SampleExtractor {
private
final
MediaExtractor
mediaExtractor
;
private
TrackInfo
[]
trackInfos
;
/**
* Instantiates a new sample extractor reading from the specified {@code uri}.
*
...
...
@@ -106,25 +102,10 @@ public final class FrameworkSampleExtractor implements SampleExtractor {
mediaExtractor
.
setDataSource
(
fileDescriptor
,
fileDescriptorOffset
,
fileDescriptorLength
);
}
int
trackCount
=
mediaExtractor
.
getTrackCount
();
trackInfos
=
new
TrackInfo
[
trackCount
];
for
(
int
i
=
0
;
i
<
trackCount
;
i
++)
{
android
.
media
.
MediaFormat
format
=
mediaExtractor
.
getTrackFormat
(
i
);
long
durationUs
=
format
.
containsKey
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
?
format
.
getLong
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
:
C
.
UNKNOWN_TIME_US
;
String
mime
=
format
.
getString
(
android
.
media
.
MediaFormat
.
KEY_MIME
);
trackInfos
[
i
]
=
new
TrackInfo
(
mime
,
durationUs
);
}
return
true
;
}
@Override
public
TrackInfo
[]
getTrackInfos
()
{
return
trackInfos
;
}
@Override
public
void
selectTrack
(
int
index
)
{
mediaExtractor
.
selectTrack
(
index
);
}
...
...
@@ -151,10 +132,25 @@ public final class FrameworkSampleExtractor implements SampleExtractor {
}
@Override
public
void
getTrackMediaFormat
(
int
track
,
MediaFormatHolder
mediaFormatHolder
)
{
mediaFormatHolder
.
format
=
MediaFormat
.
createFromFrameworkMediaFormatV16
(
mediaExtractor
.
getTrackFormat
(
track
));
mediaFormatHolder
.
drmInitData
=
Util
.
SDK_INT
>=
18
?
getPsshInfoV18
()
:
null
;
public
int
getTrackCount
()
{
return
mediaExtractor
.
getTrackCount
();
}
@Override
public
MediaFormat
getMediaFormat
(
int
track
)
{
return
MediaFormat
.
createFromFrameworkMediaFormatV16
(
mediaExtractor
.
getTrackFormat
(
track
));
}
@Override
public
Map
<
UUID
,
byte
[]>
getDrmInitData
(
int
track
)
{
return
Util
.
SDK_INT
>=
18
?
getPsshInfoV18
()
:
null
;
}
@Override
public
long
getDurationUs
(
int
track
)
{
android
.
media
.
MediaFormat
format
=
mediaExtractor
.
getTrackFormat
(
track
);
return
format
.
containsKey
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
?
format
.
getLong
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
:
C
.
UNKNOWN_TIME_US
;
}
@Override
...
...
library/src/main/java/com/google/android/exoplayer/source/SampleExtractor.java
View file @
cdf19430
...
...
@@ -16,19 +16,19 @@
package
com
.
google
.
android
.
exoplayer
.
source
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.MediaFormatHolder
;
import
com.google.android.exoplayer.SampleHolder
;
import
com.google.android.exoplayer.SampleSource
;
import
com.google.android.exoplayer.TrackInfo
;
import
com.google.android.exoplayer.TrackRenderer
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.UUID
;
/**
* Extractor for reading track metadata and samples stored in tracks.
*
* <p>Call {@link #prepare} until it returns {@code true}, then access track metadata via
* {@link #get
TrackInfos} and {@link #getTrack
MediaFormat}.
* {@link #getMediaFormat}.
*
* <p>Pass indices of tracks to read from to {@link #selectTrack}. A track can later be deselected
* by calling {@link #deselectTrack}. It is safe to select/deselect tracks after reading sample
...
...
@@ -46,9 +46,6 @@ public interface SampleExtractor {
*/
boolean
prepare
()
throws
IOException
;
/** Returns track information about all tracks that can be selected. */
TrackInfo
[]
getTrackInfos
();
/** Selects the track at {@code index} for reading sample data. */
void
selectTrack
(
int
index
);
...
...
@@ -75,8 +72,17 @@ public interface SampleExtractor {
*/
void
seekTo
(
long
positionUs
);
/** Stores the {@link MediaFormat} of {@code track}. */
void
getTrackMediaFormat
(
int
track
,
MediaFormatHolder
mediaFormatHolder
);
/** Returns the number of tracks, if {@link #prepare} has returned {@code true}. */
int
getTrackCount
();
/** Returns the {@link MediaFormat} of {@code track}. */
MediaFormat
getMediaFormat
(
int
track
);
/** Returns the DRM initialization data for {@code track}. */
Map
<
UUID
,
byte
[]>
getDrmInitData
(
int
track
);
/** Returns the duration of {@code track} in microseconds. */
long
getDurationUs
(
int
track
);
/**
* Reads the next sample in the track at index {@code track} into {@code sampleHolder}, returning
...
...
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