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
37024ae4
authored
May 28, 2020
by
tonihei
Committed by
Oliver Woodman
May 29, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add named constant for group indices.
PiperOrigin-RevId: 313596831
parent
5c52915f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeter.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultBandwidthMeter.java
View file @
37024ae4
...
@@ -79,6 +79,15 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
...
@@ -79,6 +79,15 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
/** Default maximum weight for the sliding window. */
/** Default maximum weight for the sliding window. */
public
static
final
int
DEFAULT_SLIDING_WINDOW_MAX_WEIGHT
=
2000
;
public
static
final
int
DEFAULT_SLIDING_WINDOW_MAX_WEIGHT
=
2000
;
/** Index for the Wifi group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
private
static
final
int
COUNTRY_GROUP_INDEX_WIFI
=
0
;
/** Index for the 2G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
private
static
final
int
COUNTRY_GROUP_INDEX_2G
=
1
;
/** Index for the 3G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
private
static
final
int
COUNTRY_GROUP_INDEX_3G
=
2
;
/** Index for the 4G group index in {@link #DEFAULT_INITIAL_BITRATE_COUNTRY_GROUPS}. */
private
static
final
int
COUNTRY_GROUP_INDEX_4G
=
3
;
@Nullable
private
static
DefaultBandwidthMeter
singletonInstance
;
@Nullable
private
static
DefaultBandwidthMeter
singletonInstance
;
/** Builder for a bandwidth meter. */
/** Builder for a bandwidth meter. */
...
@@ -199,15 +208,26 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
...
@@ -199,15 +208,26 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
int
[]
groupIndices
=
getCountryGroupIndices
(
countryCode
);
int
[]
groupIndices
=
getCountryGroupIndices
(
countryCode
);
SparseArray
<
Long
>
result
=
new
SparseArray
<>(
/* initialCapacity= */
6
);
SparseArray
<
Long
>
result
=
new
SparseArray
<>(
/* initialCapacity= */
6
);
result
.
append
(
C
.
NETWORK_TYPE_UNKNOWN
,
DEFAULT_INITIAL_BITRATE_ESTIMATE
);
result
.
append
(
C
.
NETWORK_TYPE_UNKNOWN
,
DEFAULT_INITIAL_BITRATE_ESTIMATE
);
result
.
append
(
C
.
NETWORK_TYPE_WIFI
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
[
groupIndices
[
0
]]);
result
.
append
(
result
.
append
(
C
.
NETWORK_TYPE_2G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_2G
[
groupIndices
[
1
]]);
C
.
NETWORK_TYPE_WIFI
,
result
.
append
(
C
.
NETWORK_TYPE_3G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_3G
[
groupIndices
[
2
]]);
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
[
groupIndices
[
COUNTRY_GROUP_INDEX_WIFI
]]);
result
.
append
(
C
.
NETWORK_TYPE_4G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
[
groupIndices
[
3
]]);
result
.
append
(
C
.
NETWORK_TYPE_2G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_2G
[
groupIndices
[
COUNTRY_GROUP_INDEX_2G
]]);
result
.
append
(
C
.
NETWORK_TYPE_3G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_3G
[
groupIndices
[
COUNTRY_GROUP_INDEX_3G
]]);
result
.
append
(
C
.
NETWORK_TYPE_4G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
[
groupIndices
[
COUNTRY_GROUP_INDEX_4G
]]);
// Assume default Wifi and 4G bitrate for Ethernet and 5G, respectively, to prevent using the
// Assume default Wifi and 4G bitrate for Ethernet and 5G, respectively, to prevent using the
// slower fallback.
// slower fallback.
result
.
append
(
result
.
append
(
C
.
NETWORK_TYPE_ETHERNET
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
[
groupIndices
[
0
]]);
C
.
NETWORK_TYPE_ETHERNET
,
result
.
append
(
C
.
NETWORK_TYPE_5G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
[
groupIndices
[
3
]]);
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
[
groupIndices
[
COUNTRY_GROUP_INDEX_WIFI
]]);
result
.
append
(
C
.
NETWORK_TYPE_5G
,
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
[
groupIndices
[
COUNTRY_GROUP_INDEX_4G
]]);
return
result
;
return
result
;
}
}
...
...
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