mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Reduce the diff between different versions of GTS tests
This means there are fewer changes required when exporting these tests as part of the GTS suite run by device manufacturers. PiperOrigin-RevId: 367230977
This commit is contained in:
parent
d853379b8b
commit
61a5ca480e
@ -20,8 +20,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||
/** Test data for DASH tests. */
|
||||
/* package */ final class DashTestData {
|
||||
|
||||
private static final String BASE_URL =
|
||||
"https://storage.googleapis.com/exoplayer-test-media-1/gen-4/";
|
||||
private static final String BASE_URL = getBaseUrl();
|
||||
|
||||
private static final String BASE_URL_SCREENS = BASE_URL + "screens/dash-vod-single-segment/";
|
||||
private static final String BASE_URL_COMMON_ENCRYPTION = BASE_URL + "common-encryption/";
|
||||
@ -161,6 +160,10 @@ import com.google.android.exoplayer2.util.Util;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getBaseUrl() {
|
||||
return "https://storage.googleapis.com/exoplayer-test-media-1/gen-4/";
|
||||
}
|
||||
|
||||
private DashTestData() {
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import android.view.Surface;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
@ -186,7 +187,9 @@ import java.util.List;
|
||||
|
||||
private DashHostedTest createDashHostedTest(
|
||||
boolean canIncludeAdditionalVideoFormats, boolean isCddLimitedRetry) {
|
||||
MetricsLogger metricsLogger = MetricsLogger.Factory.createDefault(tag);
|
||||
MetricsLogger metricsLogger =
|
||||
MetricsLogger.DEFAULT_FACTORY.create(
|
||||
InstrumentationRegistry.getInstrumentation(), tag, streamName);
|
||||
return new DashHostedTest(tag, streamName, manifestUrl, metricsLogger, fullPlaybackNoSeeking,
|
||||
audioFormat, canIncludeAdditionalVideoFormats, isCddLimitedRetry, actionSchedule,
|
||||
offlineLicenseKeySetId, widevineLicenseUrl, useL1Widevine, dataSourceFactory,
|
||||
@ -344,15 +347,20 @@ import java.util.List;
|
||||
videoCounters.inputBufferCount - 1, videoCounters.inputBufferCount);
|
||||
}
|
||||
try {
|
||||
int droppedFrameLimit = (int) Math.ceil(MAX_DROPPED_VIDEO_FRAME_FRACTION
|
||||
if (!shouldSkipDroppedOutputBufferPerformanceAssertions()) {
|
||||
int droppedFrameLimit =
|
||||
(int)
|
||||
Math.ceil(
|
||||
MAX_DROPPED_VIDEO_FRAME_FRACTION
|
||||
* DecoderCountersUtil.getTotalBufferCount(videoCounters));
|
||||
// Assert that performance is acceptable.
|
||||
// Assert that total dropped frames were within limit.
|
||||
DecoderCountersUtil.assertDroppedBufferLimit(tag + VIDEO_TAG_SUFFIX, videoCounters,
|
||||
droppedFrameLimit);
|
||||
DecoderCountersUtil.assertDroppedBufferLimit(
|
||||
tag + VIDEO_TAG_SUFFIX, videoCounters, droppedFrameLimit);
|
||||
// Assert that consecutive dropped frames were within limit.
|
||||
DecoderCountersUtil.assertConsecutiveDroppedBufferLimit(tag + VIDEO_TAG_SUFFIX,
|
||||
videoCounters, MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES);
|
||||
DecoderCountersUtil.assertConsecutiveDroppedBufferLimit(
|
||||
tag + VIDEO_TAG_SUFFIX, videoCounters, MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES);
|
||||
}
|
||||
} catch (AssertionError e) {
|
||||
if (trackSelector.includedAdditionalVideoFormats) {
|
||||
// Retry limiting to CDD mandated formats (b/28220076).
|
||||
@ -365,6 +373,11 @@ import java.util.List;
|
||||
}
|
||||
}
|
||||
|
||||
/** Provides a hook to skip dropped output buffer assertions in specific circumstances. */
|
||||
private static boolean shouldSkipDroppedOutputBufferPerformanceAssertions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class DashTestTrackSelector extends DefaultTrackSelector {
|
||||
|
||||
private final String tag;
|
||||
|
@ -22,6 +22,7 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||
import android.media.MediaCodecInfo.VideoCapabilities;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
|
||||
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
|
||||
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
|
||||
@ -43,7 +44,11 @@ public class EnumerateDecodersTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
metricsLogger = MetricsLogger.Factory.createDefault(TAG);
|
||||
metricsLogger =
|
||||
MetricsLogger.DEFAULT_FACTORY.create(
|
||||
InstrumentationRegistry.getInstrumentation(),
|
||||
TAG,
|
||||
/* streamName= */ "enumerate-decoders");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -20,6 +20,9 @@ import com.google.android.exoplayer2.util.Log;
|
||||
/** Implementation of {@link MetricsLogger} that prints the metrics to logcat. */
|
||||
/* package */ final class LogcatMetricsLogger implements MetricsLogger {
|
||||
|
||||
public static final Factory FACTORY =
|
||||
(instrumentation, tag, streamName) -> new LogcatMetricsLogger(tag);
|
||||
|
||||
private final String tag;
|
||||
|
||||
public LogcatMetricsLogger(String tag) {
|
||||
|
@ -15,9 +15,17 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.playbacktests.gts;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
|
||||
/** Metric logging interface for playback tests. */
|
||||
/* package */ interface MetricsLogger {
|
||||
|
||||
interface Factory {
|
||||
MetricsLogger create(Instrumentation instrumentation, String tag, String streamName);
|
||||
}
|
||||
|
||||
Factory DEFAULT_FACTORY = LogcatMetricsLogger.FACTORY;
|
||||
|
||||
String KEY_FRAMES_DROPPED_COUNT = "frames_dropped_count";
|
||||
String KEY_FRAMES_RENDERED_COUNT = "frames_rendered_count";
|
||||
String KEY_FRAMES_SKIPPED_COUNT = "frames_skipped_count";
|
||||
@ -53,22 +61,4 @@ package com.google.android.exoplayer2.playbacktests.gts;
|
||||
* Closes the logger.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* A factory for instantiating {@link MetricsLogger} instances.
|
||||
*/
|
||||
final class Factory {
|
||||
|
||||
private Factory() {}
|
||||
|
||||
/**
|
||||
* Obtains a new instance of {@link MetricsLogger}.
|
||||
*
|
||||
* @param tag The tag to be used for logcat logs.
|
||||
*/
|
||||
public static MetricsLogger createDefault(String tag) {
|
||||
return new LogcatMetricsLogger(tag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user