From e98bee6163a354754fe0b383c3e2160865d754be Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 2 Jun 2017 08:26:13 -0700 Subject: [PATCH] Add surface attach/detach to *WithRendererDisabling tests This will cause the test to exercise the code path of instantiating a DummySurface, rendering to it for 10 seconds, then re-targeting the real surface again. For secure content tests the code path is only exercised if DummySurface.SECURE_SUPPORTED is true. The logic for checking this is within MediaCodecVideoRenderer itself, rather than being part of the test. Issue: #677 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=157833026 --- .../video/MediaCodecVideoRenderer.java | 18 +++-- .../playbacktests/gts/DashStreamingTest.java | 4 ++ .../exoplayer2/playbacktests/util/Action.java | 68 ++++++++++++++++--- .../playbacktests/util/ActionSchedule.java | 46 ++++++++++--- .../playbacktests/util/ExoHostedTest.java | 6 +- 5 files changed, 118 insertions(+), 24 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java index cb248fd142..6a51016dd3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java @@ -653,10 +653,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { } private boolean shouldUseDummySurface(boolean codecIsSecure) { - // TODO: Work out when we can safely uncomment the secure case below. This case is currently - // broken on Galaxy S8 [Internal: b/37197802]. - return Util.SDK_INT >= 23 && !tunneling - && (!codecIsSecure /* || DummySurface.SECURE_SUPPORTED */); + return Util.SDK_INT >= 23 && !tunneling && (!codecIsSecure + || (DummySurface.SECURE_SUPPORTED && !deviceNeedsSecureDummySurfaceWorkaround())); } private void setJoiningDeadlineMs() { @@ -923,6 +921,18 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { codec.setVideoScalingMode(scalingMode); } + /** + * Returns whether the device is known to fail outputting from a secure decoder to a secure + * surface texture. + *

+ * If true is returned then use of {@link DummySurface} is disabled for secure playbacks. + */ + private static boolean deviceNeedsSecureDummySurfaceWorkaround() { + // See [Internal: b/37197802]. + return Util.SDK_INT == 24 + && (Util.MODEL.startsWith("SM-G950") || Util.MODEL.startsWith("SM-G955")); + } + /** * Returns whether the device is known to enable frame-rate conversion logic that negatively * impacts ExoPlayer. diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java index e7441362cf..24f73e9d08 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java @@ -67,6 +67,10 @@ public final class DashStreamingTest extends ActivityInstrumentationTestCase2