Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initial network type #384

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 91,7 @@ private NetworkTypeObserver(Context context) {
mainHandler = new Handler(Looper.getMainLooper());
listeners = new CopyOnWriteArrayList<>();
networkTypeLock = new Object();
networkType = C.NETWORK_TYPE_UNKNOWN;
networkType = getNetworkTypeFromConnectivityManager(context);
IntentFilter filter = new IntentFilter();
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(new Receiver(), filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 249,9 @@ public FallbackSelection getFallbackSelectionFor(
}
assertThat(Lists.transform(chunks, (chunk) -> chunk.dataSpec.uri.toString()))
.containsExactly(
"http://video.com/baseUrl/a/video/video_0_700000.m4s",
"http://video.com/baseUrl/a/video/video_0_452000.m4s",
"http://video.com/baseUrl/a/video/video_0_250000.m4s",
"http://video.com/baseUrl/a/video/video_0_700000.m4s",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test errors a chunk download, excludes the respective track, picks another track and downloads the chunk in a loop until a replacement track is not available and then validates the order of the tracks.

As the initial network type was C.NETWORK_TYPE_UNKNOWN, It was picking a track closer to 700 Kbps (1 Mbps x 0.7 BANDWIDTH_FRACTION) and the order was 700 Kbps, 452 Kbps, 250 Kbps and 1.3 Mbps.

After the change, we use the default network type (2G) from robolectric for which exo's default bandwidth estimate is 574 Kbps (820Kbps x 0.7 BANDWIDTH_FRACTION) and so the order changed to 452 Kbps, 250 Kbps, 700 Kbps and 1.3 Mbps.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jfyi, Default Locale from robolectric is en_US.

"http://video.com/baseUrl/a/video/video_0_1300000.m4s")
.inOrder();
}
Expand Down