use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method selectBaseUrl_samePriority_choiceIsRandom.
@Test
public void selectBaseUrl_samePriority_choiceIsRandom() {
List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
"a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
99), new BaseUrl(/* url= */
"b", /* serviceLocation= */
"b", /* priority= */
1, /* weight= */
1));
Random mockRandom = mock(Random.class);
when(mockRandom.nextInt(anyInt())).thenReturn(99);
assertThat(new BaseUrlExclusionList(mockRandom).selectBaseUrl(baseUrls)).isEqualTo(baseUrls.get(1));
// Random is used for random choice.
verify(mockRandom).nextInt(/* bound= */
100);
verifyNoMoreInteractions(mockRandom);
}
use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method reset_dropsAllExclusions.
@Test
public void reset_dropsAllExclusions() {
BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList();
ImmutableList<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl("a", "a", DEFAULT_DVB_PRIORITY, DEFAULT_WEIGHT));
baseUrlExclusionList.exclude(baseUrls.get(0), 5000);
baseUrlExclusionList.reset();
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrls).url).isEqualTo("a");
}
use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method getPriorityCount_correctPriorityCount.
@Test
public void getPriorityCount_correctPriorityCount() {
List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
"a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
1), new BaseUrl(/* url= */
"b", /* serviceLocation= */
"b", /* priority= */
2, /* weight= */
1), new BaseUrl(/* url= */
"c", /* serviceLocation= */
"c", /* priority= */
2, /* weight= */
1), new BaseUrl(/* url= */
"d", /* serviceLocation= */
"d", /* priority= */
3, /* weight= */
1));
assertThat(BaseUrlExclusionList.getPriorityCount(baseUrls)).isEqualTo(3);
assertThat(BaseUrlExclusionList.getPriorityCount(ImmutableList.of())).isEqualTo(0);
}
use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method getPriorityCountAfterExclusion_correctPriorityCount.
@Test
public void getPriorityCountAfterExclusion_correctPriorityCount() {
List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
"a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
1), new BaseUrl(/* url= */
"b", /* serviceLocation= */
"b", /* priority= */
2, /* weight= */
1), new BaseUrl(/* url= */
"c", /* serviceLocation= */
"c", /* priority= */
2, /* weight= */
1), new BaseUrl(/* url= */
"d", /* serviceLocation= */
"d", /* priority= */
3, /* weight= */
1), new BaseUrl(/* url= */
"e", /* serviceLocation= */
"e", /* priority= */
3, /* weight= */
1));
BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList();
// Empty base URL list.
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(ImmutableList.of())).isEqualTo(0);
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3);
// Exclude base urls.
baseUrlExclusionList.exclude(baseUrls.get(0), DEFAULT_LOCATION_EXCLUSION_MS);
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(2);
baseUrlExclusionList.exclude(baseUrls.get(1), 2 * DEFAULT_LOCATION_EXCLUSION_MS);
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(1);
baseUrlExclusionList.exclude(baseUrls.get(3), 3 * DEFAULT_LOCATION_EXCLUSION_MS);
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(0);
// Time passes.
ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(1);
ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(2);
ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3);
}
use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method selectBaseUrl_excludeByServiceLocation_excludesAllBaseUrlOfSameServiceLocation.
@Test
public void selectBaseUrl_excludeByServiceLocation_excludesAllBaseUrlOfSameServiceLocation() {
BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList();
List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
"a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
1), new BaseUrl(/* url= */
"b", /* serviceLocation= */
"a", /* priority= */
2, /* weight= */
1), new BaseUrl(/* url= */
"c", /* serviceLocation= */
"c", /* priority= */
3, /* weight= */
1));
baseUrlExclusionList.exclude(baseUrls.get(0), 5000);
ShadowSystemClock.advanceBy(Duration.ofMillis(4999));
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrls).url).isEqualTo("c");
ShadowSystemClock.advanceBy(Duration.ofMillis(1));
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrls).url).isEqualTo("a");
}
Aggregations