Search in sources :

Example 1 with FakeAdaptiveDataSet

use of com.google.android.exoplayer2.testutil.FakeAdaptiveDataSet in project ExoPlayer by google.

the class FakeAdaptiveDataSetTest method testAdaptiveDataSetChunkSizeDistribution.

@Test
public void testAdaptiveDataSetChunkSizeDistribution() {
    double expectedStdDev = 4.0;
    FakeAdaptiveDataSet dataSet = new FakeAdaptiveDataSet(TRACK_GROUP, 100000 * C.MICROS_PER_SECOND, C.MICROS_PER_SECOND, expectedStdDev, new Random(0));
    for (int i = 0; i < TEST_FORMATS.length; i++) {
        FakeData data = dataSet.getData(dataSet.getUri(i));
        double mean = computeSegmentSizeMean(data.getSegments());
        double stddev = computeSegmentSizeStdDev(data.getSegments(), mean);
        double relativePercentStdDev = stddev / mean * 100.0;
        assertThat(relativePercentStdDev).isWithin(0.02).of(expectedStdDev);
        assertThat(mean * 8 / TEST_FORMATS[i].bitrate).isWithin(0.01).of(1.0);
    }
}
Also used : Random(java.util.Random) FakeData(com.google.android.exoplayer2.testutil.FakeDataSet.FakeData) Test(org.junit.Test)

Example 2 with FakeAdaptiveDataSet

use of com.google.android.exoplayer2.testutil.FakeAdaptiveDataSet in project ExoPlayer by google.

the class FakeAdaptiveDataSetTest method assertChunkData.

private void assertChunkData(FakeAdaptiveDataSet dataSet, long chunkDuration) {
    for (int i = 0; i < dataSet.getChunkCount(); i++) {
        assertThat(dataSet.getStartTime(i)).isEqualTo(chunkDuration * i);
    }
    for (int s = 0; s < TEST_FORMATS.length; s++) {
        FakeData data = dataSet.getData(dataSet.getUri(s));
        assertThat(data.getSegments().size()).isEqualTo(dataSet.getChunkCount());
        for (int i = 0; i < data.getSegments().size(); i++) {
            long expectedLength = TEST_FORMATS[s].bitrate * dataSet.getChunkDuration(i) / (8 * C.MICROS_PER_SECOND);
            assertThat(data.getSegments().get(i).length).isEqualTo(expectedLength);
        }
    }
}
Also used : FakeData(com.google.android.exoplayer2.testutil.FakeDataSet.FakeData)

Aggregations

FakeData (com.google.android.exoplayer2.testutil.FakeDataSet.FakeData)2 Random (java.util.Random)1 Test (org.junit.Test)1