Commit 4b1410bc by olly Committed by Oliver Woodman

Simplify + Fix WV encrypted playback tests

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149993442
parent 139252c9
...@@ -135,13 +135,12 @@ public final class DashHostedTest extends ExoHostedTest { ...@@ -135,13 +135,12 @@ public final class DashHostedTest extends ExoHostedTest {
} }
public Builder setManifestUrl(String manifestUrl) { public Builder setManifestUrl(String manifestUrl) {
this.manifestUrl = MANIFEST_URL_PREFIX + manifestUrl; this.manifestUrl = manifestUrl;
return this; return this;
} }
public Builder setManifestUrlForWidevine(String manifestUrl, String videoMimeType) { public Builder setWidevineMimeType(String mimeType) {
this.useL1Widevine = isL1WidevineAvailable(videoMimeType); this.useL1Widevine = isL1WidevineAvailable(mimeType);
this.manifestUrl = getWidevineManifestUrl(manifestUrl, useL1Widevine);
this.widevineLicenseUrl = getWidevineLicenseUrl(useL1Widevine); this.widevineLicenseUrl = getWidevineLicenseUrl(useL1Widevine);
return this; return this;
} }
...@@ -177,13 +176,6 @@ public final class DashHostedTest extends ExoHostedTest { ...@@ -177,13 +176,6 @@ public final class DashHostedTest extends ExoHostedTest {
private static final int MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES = 10; private static final int MAX_CONSECUTIVE_DROPPED_VIDEO_FRAMES = 10;
private static final float MAX_DROPPED_VIDEO_FRAME_FRACTION = 0.01f; private static final float MAX_DROPPED_VIDEO_FRAME_FRACTION = 0.01f;
private static final String MANIFEST_URL_PREFIX = "https://storage.googleapis.com/exoplayer-test-"
+ "media-1/gen-4/screens/dash-vod-single-segment/";
// TODO: Don't need separate suffixes. Clean up.
private static final String WIDEVINE_L1_SUFFIX = ".mpd";
private static final String WIDEVINE_L3_SUFFIX = ".mpd";
private static final String WIDEVINE_LICENSE_URL = private static final String WIDEVINE_LICENSE_URL =
"https://proxy.uat.widevine.com/proxy?provider=widevine_test&video_id="; "https://proxy.uat.widevine.com/proxy?provider=widevine_test&video_id=";
private static final String WIDEVINE_SW_CRYPTO_CONTENT_ID = "exoplayer_test_1"; private static final String WIDEVINE_SW_CRYPTO_CONTENT_ID = "exoplayer_test_1";
...@@ -204,11 +196,6 @@ public final class DashHostedTest extends ExoHostedTest { ...@@ -204,11 +196,6 @@ public final class DashHostedTest extends ExoHostedTest {
boolean needsCddLimitedRetry; boolean needsCddLimitedRetry;
public static String getWidevineManifestUrl(String manifestUrl, boolean useL1Widevine) {
return MANIFEST_URL_PREFIX + manifestUrl
+ (useL1Widevine ? WIDEVINE_L1_SUFFIX : WIDEVINE_L3_SUFFIX);
}
public static String getWidevineLicenseUrl(boolean useL1Widevine) { public static String getWidevineLicenseUrl(boolean useL1Widevine) {
return WIDEVINE_LICENSE_URL return WIDEVINE_LICENSE_URL
+ (useL1Widevine ? WIDEVINE_HW_SECURE_DECODE_CONTENT_ID : WIDEVINE_SW_CRYPTO_CONTENT_ID); + (useL1Widevine ? WIDEVINE_HW_SECURE_DECODE_CONTENT_ID : WIDEVINE_SW_CRYPTO_CONTENT_ID);
...@@ -216,13 +203,12 @@ public final class DashHostedTest extends ExoHostedTest { ...@@ -216,13 +203,12 @@ public final class DashHostedTest extends ExoHostedTest {
@TargetApi(18) @TargetApi(18)
@SuppressWarnings("ResourceType") @SuppressWarnings("ResourceType")
public static boolean isL1WidevineAvailable(String videoMimeType) { public static boolean isL1WidevineAvailable(String mimeType) {
try { try {
// Force L3 if secure decoder is not available. // Force L3 if secure decoder is not available.
if (MediaCodecUtil.getDecoderInfo(videoMimeType, true) == null) { if (MediaCodecUtil.getDecoderInfo(mimeType, true) == null) {
return false; return false;
} }
MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID); MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID);
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY); String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
mediaDrm.release(); mediaDrm.release();
......
...@@ -22,20 +22,22 @@ import com.google.android.exoplayer2.util.Util; ...@@ -22,20 +22,22 @@ import com.google.android.exoplayer2.util.Util;
*/ */
public final class DashTestData { public final class DashTestData {
private static final String BASE_URL = "https://storage.googleapis.com/exoplayer-test-media-1/"
+ "gen-4/screens/dash-vod-single-segment/";
// Clear content manifests. // Clear content manifests.
public static final String H264_MANIFEST = "manifest-h264.mpd"; public static final String H264_MANIFEST = BASE_URL + "manifest-h264.mpd";
public static final String H265_MANIFEST = "manifest-h265.mpd"; public static final String H265_MANIFEST = BASE_URL + "manifest-h265.mpd";
public static final String VP9_MANIFEST = "manifest-vp9.mpd"; public static final String VP9_MANIFEST = BASE_URL + "manifest-vp9.mpd";
public static final String H264_23_MANIFEST = "manifest-h264-23.mpd"; public static final String H264_23_MANIFEST = BASE_URL + "manifest-h264-23.mpd";
public static final String H264_24_MANIFEST = "manifest-h264-24.mpd"; public static final String H264_24_MANIFEST = BASE_URL + "manifest-h264-24.mpd";
public static final String H264_29_MANIFEST = "manifest-h264-29.mpd"; public static final String H264_29_MANIFEST = BASE_URL + "manifest-h264-29.mpd";
// Widevine encrypted content manifests. // Widevine encrypted content manifests.
public static final String WIDEVINE_H264_MANIFEST_PREFIX = "manifest-h264-enc"; public static final String WIDEVINE_H264_MANIFEST = BASE_URL + "manifest-h264-enc.mpd";
public static final String WIDEVINE_H265_MANIFEST_PREFIX = "manifest-h265-enc"; public static final String WIDEVINE_H265_MANIFEST = BASE_URL + "manifest-h265-enc.mpd";
public static final String WIDEVINE_VP9_MANIFEST_PREFIX = "manifest-vp9-enc"; public static final String WIDEVINE_VP9_MANIFEST = BASE_URL + "manifest-vp9-enc.mpd";
public static final String WIDEVINE_H264_23_MANIFEST_PREFIX = "manifest-h264-23-enc"; public static final String WIDEVINE_H264_23_MANIFEST = BASE_URL + "manifest-h264-23-enc.mpd";
public static final String WIDEVINE_H264_24_MANIFEST_PREFIX = "manifest-h264-24-enc"; public static final String WIDEVINE_H264_24_MANIFEST = BASE_URL + "manifest-h264-24-enc.mpd";
public static final String WIDEVINE_H264_29_MANIFEST_PREFIX = "manifest-h264-29-enc"; public static final String WIDEVINE_H264_29_MANIFEST = BASE_URL + "manifest-h264-29-enc.mpd";
public static final String AAC_AUDIO_REPRESENTATION_ID = "141"; public static final String AAC_AUDIO_REPRESENTATION_ID = "141";
public static final String H264_BASELINE_240P_VIDEO_REPRESENTATION_ID = "avc-baseline-240"; public static final String H264_BASELINE_240P_VIDEO_REPRESENTATION_ID = "avc-baseline-240";
...@@ -50,8 +52,8 @@ public final class DashTestData { ...@@ -50,8 +52,8 @@ public final class DashTestData {
// when switching between baseline and main profiles on certain devices. // when switching between baseline and main profiles on certain devices.
public static final String[] H264_CDD_ADAPTIVE = Util.SDK_INT < 24 public static final String[] H264_CDD_ADAPTIVE = Util.SDK_INT < 24
? new String[] { ? new String[] {
H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, H264_BASELINE_240P_VIDEO_REPRESENTATION_ID,
H264_BASELINE_480P_VIDEO_REPRESENTATION_ID} H264_BASELINE_480P_VIDEO_REPRESENTATION_ID}
: new String[] { : new String[] {
H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, H264_BASELINE_240P_VIDEO_REPRESENTATION_ID,
H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, H264_BASELINE_480P_VIDEO_REPRESENTATION_ID,
...@@ -75,7 +77,7 @@ public final class DashTestData { ...@@ -75,7 +77,7 @@ public final class DashTestData {
H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, H265_BASELINE_288P_VIDEO_REPRESENTATION_ID,
H265_BASELINE_360P_VIDEO_REPRESENTATION_ID}; H265_BASELINE_360P_VIDEO_REPRESENTATION_ID};
public static final String VORBIS_AUDIO_REPRESENTATION_ID = "4"; public static final String VP9_VORBIS_AUDIO_REPRESENTATION_ID = "4";
public static final String VP9_180P_VIDEO_REPRESENTATION_ID = "0"; public static final String VP9_180P_VIDEO_REPRESENTATION_ID = "0";
public static final String VP9_360P_VIDEO_REPRESENTATION_ID = "1"; public static final String VP9_360P_VIDEO_REPRESENTATION_ID = "1";
// The highest quality VP9 format mandated by the Android CDD. // The highest quality VP9 format mandated by the Android CDD.
...@@ -101,8 +103,8 @@ public final class DashTestData { ...@@ -101,8 +103,8 @@ public final class DashTestData {
// when switching between baseline and main profiles on certain devices. // when switching between baseline and main profiles on certain devices.
public static final String[] WIDEVINE_H264_CDD_ADAPTIVE = Util.SDK_INT < 24 public static final String[] WIDEVINE_H264_CDD_ADAPTIVE = Util.SDK_INT < 24
? new String[] { ? new String[] {
WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID,
WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID} WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID}
: new String[] { : new String[] {
WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID,
WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID,
...@@ -124,11 +126,11 @@ public final class DashTestData { ...@@ -124,11 +126,11 @@ public final class DashTestData {
WIDEVINE_H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, WIDEVINE_H265_BASELINE_288P_VIDEO_REPRESENTATION_ID,
WIDEVINE_H265_BASELINE_360P_VIDEO_REPRESENTATION_ID}; WIDEVINE_H265_BASELINE_360P_VIDEO_REPRESENTATION_ID};
public static final String WIDEVINE_VORBIS_AUDIO_REPRESENTATION_ID = "0"; public static final String WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID = "0";
public static final String WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID = "1"; public static final String WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID = "2";
public static final String WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID = "2"; public static final String WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID = "3";
// The highest quality VP9 format mandated by the Android CDD. // The highest quality VP9 format mandated by the Android CDD.
public static final String WIDEVINE_VP9_CDD_FIXED = VP9_360P_VIDEO_REPRESENTATION_ID; public static final String WIDEVINE_VP9_CDD_FIXED = WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID;
// Multiple VP9 formats mandated by the Android CDD. // Multiple VP9 formats mandated by the Android CDD.
public static final String[] WIDEVINE_VP9_CDD_ADAPTIVE = public static final String[] WIDEVINE_VP9_CDD_ADAPTIVE =
new String[] { new String[] {
......
...@@ -38,7 +38,6 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -38,7 +38,6 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
private static final String USER_AGENT = "ExoPlayerPlaybackTests"; private static final String USER_AGENT = "ExoPlayerPlaybackTests";
private DashHostedTest.Builder builder; private DashHostedTest.Builder builder;
private String widevineManifestUrl;
private DefaultHttpDataSourceFactory httpDataSourceFactory; private DefaultHttpDataSourceFactory httpDataSourceFactory;
private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper; private OfflineLicenseHelper<FrameworkMediaCrypto> offlineLicenseHelper;
private byte[] offlineLicenseKeySetId; private byte[] offlineLicenseKeySetId;
...@@ -52,18 +51,17 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -52,18 +51,17 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
super.setUp(); super.setUp();
builder = new DashHostedTest.Builder(TAG) builder = new DashHostedTest.Builder(TAG)
.setStreamName("test_widevine_h264_fixed_offline") .setStreamName("test_widevine_h264_fixed_offline")
.setManifestUrlForWidevine(DashTestData.WIDEVINE_H264_MANIFEST_PREFIX, MimeTypes.VIDEO_H264) .setManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST)
.setWidevineMimeType(MimeTypes.VIDEO_H264)
.setFullPlaybackNoSeeking(true) .setFullPlaybackNoSeeking(true)
.setCanIncludeAdditionalVideoFormats(false) .setCanIncludeAdditionalVideoFormats(false)
.setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID,
DashTestData.WIDEVINE_H264_CDD_FIXED); DashTestData.WIDEVINE_H264_CDD_FIXED);
boolean useL1Widevine = DashHostedTest.isL1WidevineAvailable(MimeTypes.VIDEO_H264); boolean useL1Widevine = DashHostedTest.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
widevineManifestUrl = DashHostedTest
.getWidevineManifestUrl(DashTestData.WIDEVINE_H264_MANIFEST_PREFIX, useL1Widevine);
String widevineLicenseUrl = DashHostedTest.getWidevineLicenseUrl(useL1Widevine); String widevineLicenseUrl = DashHostedTest.getWidevineLicenseUrl(useL1Widevine);
httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT); httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT);
offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(widevineLicenseUrl, offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(widevineLicenseUrl,
httpDataSourceFactory); httpDataSourceFactory);
} }
...@@ -125,7 +123,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -125,7 +123,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
downloadLicense(); downloadLicense();
// Wait until the license expires // Wait until the license expires
long licenseDuration = long licenseDuration =
offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId).first; offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId).first;
assertTrue("License duration should be less than 30 sec. " assertTrue("License duration should be less than 30 sec. "
+ "Server settings might have changed.", licenseDuration < 30); + "Server settings might have changed.", licenseDuration < 30);
...@@ -134,7 +132,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -134,7 +132,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
wait(licenseDuration * 1000 + 2000); wait(licenseDuration * 1000 + 2000);
} }
long previousDuration = licenseDuration; long previousDuration = licenseDuration;
licenseDuration = licenseDuration =
offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId).first; offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId).first;
assertTrue("License duration should be decreasing.", previousDuration > licenseDuration); assertTrue("License duration should be decreasing.", previousDuration > licenseDuration);
} }
...@@ -150,7 +148,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -150,7 +148,7 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
downloadLicense(); downloadLicense();
// During playback pause until the license expires then continue playback // During playback pause until the license expires then continue playback
Pair<Long, Long> licenseDurationRemainingSec = Pair<Long, Long> licenseDurationRemainingSec =
offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId); offlineLicenseHelper.getLicenseDurationRemainingSec(offlineLicenseKeySetId);
long licenseDuration = licenseDurationRemainingSec.first; long licenseDuration = licenseDurationRemainingSec.first;
assertTrue("License duration should be less than 30 sec. " assertTrue("License duration should be less than 30 sec. "
...@@ -163,10 +161,10 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa ...@@ -163,10 +161,10 @@ public final class DashWidevineOfflineTest extends ActivityInstrumentationTestCa
.setActionSchedule(schedule) .setActionSchedule(schedule)
.runTest(getActivity(), getInstrumentation()); .runTest(getActivity(), getInstrumentation());
} }
private void downloadLicense() throws InterruptedException, DrmSessionException, IOException { private void downloadLicense() throws InterruptedException, DrmSessionException, IOException {
offlineLicenseKeySetId = offlineLicenseHelper.download( offlineLicenseKeySetId = offlineLicenseHelper.download(
httpDataSourceFactory.createDataSource(), widevineManifestUrl); httpDataSourceFactory.createDataSource(), DashTestData.WIDEVINE_H264_MANIFEST);
Assert.assertNotNull(offlineLicenseKeySetId); Assert.assertNotNull(offlineLicenseKeySetId);
Assert.assertTrue(offlineLicenseKeySetId.length > 0); Assert.assertTrue(offlineLicenseKeySetId.length > 0);
builder.setOfflineLicenseKeySetId(offlineLicenseKeySetId); builder.setOfflineLicenseKeySetId(offlineLicenseKeySetId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment