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
c90745d9
authored
Feb 14, 2022
by
olly
Committed by
Ian Baker
Feb 17, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add getFormat and length to TrackGroupInfo
PiperOrigin-RevId: 428520090
parent
11f1ebb3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
16 deletions
docs/track-selection.md
library/common/src/main/java/com/google/android/exoplayer2/TracksInfo.java
library/core/src/main/java/com/google/android/exoplayer2/analytics/MediaMetricsListener.java
library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java
docs/track-selection.md
View file @
c90745d9
...
...
@@ -40,12 +40,11 @@ for (TrackGroupInfo groupInfo : tracksInfo.getTrackGroupInfos()) {
@C.TrackType int trackType = groupInfo.getTrackType();
boolean trackInGroupIsSelected = groupInfo.isSelected();
boolean trackInGroupIsSupported = groupInfo.isSupported();
TrackGroup group = groupInfo.getTrackGroup();
for (int i = 0; i < group.length; i++) {
for (int i = 0; i < groupInfo.length; i++) {
// Individual track information.
boolean isSupported = groupInfo.isTrackSupported(i);
boolean isSelected = groupInfo.isTrackSelected(i);
Format trackFormat = group
.get
Format(i);
Format trackFormat = group
Info.getTrack
Format(i);
}
}
~~~
...
...
library/common/src/main/java/com/google/android/exoplayer2/TracksInfo.java
View file @
c90745d9
...
...
@@ -38,12 +38,17 @@ import java.util.List;
/** Information about groups of tracks. */
public
final
class
TracksInfo
implements
Bundleable
{
/**
* Information about a single group of tracks, including the underlying {@link TrackGroup}, the
* {@link C.TrackType type} of tracks it contains, and the level to which each track is supported
* by the player.
*/
public
static
final
class
TrackGroupInfo
implements
Bundleable
{
/** The number of tracks in the group. */
public
final
int
length
;
private
final
TrackGroup
trackGroup
;
private
final
@C
.
FormatSupport
int
[]
trackSupport
;
private
final
@C
.
TrackType
int
trackType
;
...
...
@@ -62,7 +67,7 @@ public final class TracksInfo implements Bundleable {
@C
.
FormatSupport
int
[]
trackSupport
,
@C
.
TrackType
int
trackType
,
boolean
[]
tracksSelected
)
{
int
length
=
trackGroup
.
length
;
length
=
trackGroup
.
length
;
checkArgument
(
length
==
trackSupport
.
length
&&
length
==
tracksSelected
.
length
);
this
.
trackGroup
=
trackGroup
;
this
.
trackSupport
=
trackSupport
.
clone
();
...
...
@@ -70,12 +75,22 @@ public final class TracksInfo implements Bundleable {
this
.
trackSelected
=
tracksSelected
.
clone
();
}
/** Returns the
{@link TrackGroup} described by this {@code TrackGroupInfo
}. */
/** Returns the
underlying {@link TrackGroup
}. */
public
TrackGroup
getTrackGroup
()
{
return
trackGroup
;
}
/**
* Returns the {@link Format} for a specified track.
*
* @param trackIndex The index of the track in the {@link TrackGroup}.
* @return The {@link Format} of the track.
*/
public
Format
getTrackFormat
(
int
trackIndex
)
{
return
trackGroup
.
getFormat
(
trackIndex
);
}
/**
* Returns the level of support for a specified track.
*
* @param trackIndex The index of the track in the {@link TrackGroup}.
...
...
library/core/src/main/java/com/google/android/exoplayer2/analytics/MediaMetricsListener.java
View file @
c90745d9
...
...
@@ -62,7 +62,6 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer;
import
com.google.android.exoplayer2.source.LoadEventInfo
;
import
com.google.android.exoplayer2.source.MediaLoadData
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.source.TrackGroup
;
import
com.google.android.exoplayer2.upstream.FileDataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource
;
import
com.google.android.exoplayer2.upstream.UdpDataSource
;
...
...
@@ -823,10 +822,9 @@ public final class MediaMetricsListener
@Nullable
private
static
DrmInitData
getDrmInitData
(
ImmutableList
<
TrackGroupInfo
>
trackGroupInfos
)
{
for
(
TrackGroupInfo
trackGroupInfo
:
trackGroupInfos
)
{
TrackGroup
trackGroup
=
trackGroupInfo
.
getTrackGroup
();
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroup
.
length
;
trackIndex
++)
{
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroupInfo
.
length
;
trackIndex
++)
{
if
(
trackGroupInfo
.
isTrackSelected
(
trackIndex
))
{
@Nullable
DrmInitData
drmInitData
=
trackGroup
.
get
Format
(
trackIndex
).
drmInitData
;
@Nullable
DrmInitData
drmInitData
=
trackGroup
Info
.
getTrack
Format
(
trackIndex
).
drmInitData
;
if
(
drmInitData
!=
null
)
{
return
drmInitData
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java
View file @
c90745d9
...
...
@@ -265,9 +265,8 @@ public class EventLogger implements AnalyticsListener {
ImmutableList
<
TracksInfo
.
TrackGroupInfo
>
trackGroupInfos
=
tracksInfo
.
getTrackGroupInfos
();
for
(
int
groupIndex
=
0
;
groupIndex
<
trackGroupInfos
.
size
();
groupIndex
++)
{
TracksInfo
.
TrackGroupInfo
trackGroupInfo
=
trackGroupInfos
.
get
(
groupIndex
);
TrackGroup
trackGroup
=
trackGroupInfo
.
getTrackGroup
();
logd
(
" group ["
);
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroup
.
length
;
trackIndex
++)
{
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroup
Info
.
length
;
trackIndex
++)
{
String
status
=
getTrackStatusString
(
trackGroupInfo
.
isTrackSelected
(
trackIndex
));
String
formatSupport
=
getFormatSupportString
(
trackGroupInfo
.
getTrackSupport
(
trackIndex
));
logd
(
...
...
@@ -276,7 +275,7 @@ public class EventLogger implements AnalyticsListener {
+
" Track:"
+
trackIndex
+
", "
+
Format
.
toLogString
(
trackGroup
.
get
Format
(
trackIndex
))
+
Format
.
toLogString
(
trackGroup
Info
.
getTrack
Format
(
trackIndex
))
+
", supported="
+
formatSupport
);
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
c90745d9
...
...
@@ -7974,7 +7974,7 @@ public final class ExoPlayerTest {
assertThat
(
timelineAfterError
.
get
().
getWindowCount
()).
isEqualTo
(
1
);
assertThat
(
mediaItemIndexAfterError
.
get
()).
isEqualTo
(
0
);
assertThat
(
trackInfosAfterError
.
get
().
getTrackGroupInfos
()).
hasSize
(
1
);
assertThat
(
trackInfosAfterError
.
get
().
getTrackGroupInfos
().
get
(
0
).
getTrack
Group
().
get
Format
(
0
))
assertThat
(
trackInfosAfterError
.
get
().
getTrackGroupInfos
().
get
(
0
).
getTrackFormat
(
0
))
.
isEqualTo
(
ExoPlayerTestRunner
.
AUDIO_FORMAT
);
assertThat
(
trackSelectionsAfterError
.
get
().
get
(
0
)).
isNull
();
// Video renderer.
assertThat
(
trackSelectionsAfterError
.
get
().
get
(
1
)).
isNotNull
();
// Audio renderer.
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java
View file @
c90745d9
...
...
@@ -1130,12 +1130,12 @@ public class StyledPlayerControlView extends FrameLayout {
if
(
trackGroupInfo
.
getTrackType
()
!=
trackType
)
{
continue
;
}
TrackGroup
trackGroup
=
trackGroupInfo
.
getTrackGroup
();
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroup
.
length
;
trackIndex
++)
{
for
(
int
trackIndex
=
0
;
trackIndex
<
trackGroupInfo
.
length
;
trackIndex
++)
{
if
(!
trackGroupInfo
.
isTrackSupported
(
trackIndex
))
{
continue
;
}
String
trackName
=
trackNameProvider
.
getTrackName
(
trackGroup
.
getFormat
(
trackIndex
));
String
trackName
=
trackNameProvider
.
getTrackName
(
trackGroupInfo
.
getTrackFormat
(
trackIndex
));
tracks
.
add
(
new
TrackInformation
(
tracksInfo
,
trackGroupIndex
,
trackIndex
,
trackName
));
}
}
...
...
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