Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: media/base/android/media_source_player_unittest.cc

Issue 185993004: Encrypted Media: Confine UUID code to MediaDrmBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "media/base/android/media_codec_bridge.h" 10 #include "media/base/android/media_codec_bridge.h"
11 #include "media/base/android/media_drm_bridge.h" 11 #include "media/base/android/media_drm_bridge.h"
12 #include "media/base/android/media_player_manager.h" 12 #include "media/base/android/media_player_manager.h"
13 #include "media/base/android/media_source_player.h" 13 #include "media/base/android/media_source_player.h"
14 #include "media/base/bind_to_current_loop.h" 14 #include "media/base/bind_to_current_loop.h"
15 #include "media/base/decoder_buffer.h" 15 #include "media/base/decoder_buffer.h"
16 #include "media/base/test_data_util.h" 16 #include "media/base/test_data_util.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "ui/gl/android/surface_texture.h" 18 #include "ui/gl/android/surface_texture.h"
19 19
20 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
21
20 namespace media { 22 namespace media {
21 23
22 // Helper macro to skip the test if MediaCodecBridge isn't available. 24 // Helper macro to skip the test if MediaCodecBridge isn't available.
23 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ 25 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \
24 do { \ 26 do { \
25 if (!MediaCodecBridge::IsAvailable()) { \ 27 if (!MediaCodecBridge::IsAvailable()) { \
26 VLOG(0) << "Could not run test - not supported on device."; \ 28 VLOG(0) << "Could not run test - not supported on device."; \
27 return; \ 29 return; \
28 } \ 30 } \
29 } while (0) 31 } while (0)
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 EXPECT_EQ(1, demuxer_->num_seek_requests()); 727 EXPECT_EQ(1, demuxer_->num_seek_requests());
726 728
727 player_.OnDemuxerSeekDone(kNoTimestamp()); 729 player_.OnDemuxerSeekDone(kNoTimestamp());
728 EXPECT_FALSE(manager_.playback_completed()); 730 EXPECT_FALSE(manager_.playback_completed());
729 } 731 }
730 732
731 base::TimeTicks StartTimeTicks() { 733 base::TimeTicks StartTimeTicks() {
732 return player_.start_time_ticks_; 734 return player_.start_time_ticks_;
733 } 735 }
734 736
735 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, 737 bool IsTypeSupported(const std::string& key_system,
736 MediaDrmBridge::SecurityLevel security_level, 738 MediaDrmBridge::SecurityLevel security_level,
737 const std::string& container, 739 const std::string& container,
738 const std::vector<std::string>& codecs) { 740 const std::vector<std::string>& codecs) {
739 return MediaSourcePlayer::IsTypeSupported( 741 return MediaSourcePlayer::IsTypeSupported(
740 scheme_uuid, security_level, container, codecs); 742 key_system, security_level, container, codecs);
741 } 743 }
742 744
743 base::MessageLoop message_loop_; 745 base::MessageLoop message_loop_;
744 MockMediaPlayerManager manager_; 746 MockMediaPlayerManager manager_;
745 MockDemuxerAndroid* demuxer_; // Owned by |player_|. 747 MockDemuxerAndroid* demuxer_; // Owned by |player_|.
746 MediaSourcePlayer player_; 748 MediaSourcePlayer player_;
747 749
748 // Track whether a possibly async decoder callback test hook has run. 750 // Track whether a possibly async decoder callback test hook has run.
749 bool decoder_callback_hook_executed_; 751 bool decoder_callback_hook_executed_;
750 752
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 EXPECT_FALSE(GetMediaDecoderJob(false)); 2078 EXPECT_FALSE(GetMediaDecoderJob(false));
2077 } 2079 }
2078 2080
2079 // TODO(xhwang): Enable this test when the test devices are updated. 2081 // TODO(xhwang): Enable this test when the test devices are updated.
2080 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { 2082 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) {
2081 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { 2083 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) {
2082 VLOG(0) << "Could not run test - not supported on device."; 2084 VLOG(0) << "Could not run test - not supported on device.";
2083 return; 2085 return;
2084 } 2086 }
2085 2087
2086 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
2087 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };
2088
2089 std::vector<uint8> widevine_uuid(kWidevineUUID,
2090 kWidevineUUID + arraysize(kWidevineUUID));
2091
2092 // We test "L3" fully. But for "L1" we don't check the result as it depend on 2088 // We test "L3" fully. But for "L1" we don't check the result as it depend on
2093 // whether the test device supports "L1" decoding. 2089 // whether the test device supports "L1" decoding.
2094 2090
2095 std::vector<std::string> codec_avc(1, "avc1"); 2091 std::vector<std::string> codec_avc(1, "avc1");
2096 std::vector<std::string> codec_aac(1, "mp4a"); 2092 std::vector<std::string> codec_aac(1, "mp4a");
2097 std::vector<std::string> codec_avc_aac(1, "avc1"); 2093 std::vector<std::string> codec_avc_aac(1, "avc1");
2098 codec_avc_aac.push_back("mp4a"); 2094 codec_avc_aac.push_back("mp4a");
2099 2095
2100 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoMp4, codec_avc)); 2096 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc));
2101 IsTypeSupported(widevine_uuid, kL1, kVideoMp4, codec_avc); 2097 IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc);
2102 2098
2103 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. 2099 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy.
2104 // Clean this up after we have a solution to specifying decoding mode. 2100 // Clean this up after we have a solution to specifying decoding mode.
2105 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kAudioMp4, codec_aac)); 2101 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kAudioMp4, codec_aac));
2106 IsTypeSupported(widevine_uuid, kL1, kAudioMp4, codec_aac); 2102 IsTypeSupported(kWidevineKeySystem, kL1, kAudioMp4, codec_aac);
2107 2103
2108 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoMp4, codec_avc_aac)); 2104 EXPECT_TRUE(
2109 IsTypeSupported(widevine_uuid, kL1, kVideoMp4, codec_avc_aac); 2105 IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc_aac));
2106 IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc_aac);
2110 2107
2111 std::vector<std::string> codec_vp8(1, "vp8"); 2108 std::vector<std::string> codec_vp8(1, "vp8");
2112 std::vector<std::string> codec_vorbis(1, "vorbis"); 2109 std::vector<std::string> codec_vorbis(1, "vorbis");
2113 std::vector<std::string> codec_vp8_vorbis(1, "vp8"); 2110 std::vector<std::string> codec_vp8_vorbis(1, "vp8");
2114 codec_vp8_vorbis.push_back("vorbis"); 2111 codec_vp8_vorbis.push_back("vorbis");
2115 2112
2116 // TODO(xhwang): WebM is actually not supported but currently 2113 // TODO(xhwang): WebM is actually not supported but currently
2117 // MediaDrmBridge.isCryptoSchemeSupported() doesn't check the container type. 2114 // MediaDrmBridge.IsKeySystemSupported() doesn't check the container type.
2118 // Fix isCryptoSchemeSupported() and update this test as necessary. 2115 // Fix IsKeySystemSupported() and update this test as necessary.
2119 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoWebM, codec_vp8)); 2116 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8));
2120 IsTypeSupported(widevine_uuid, kL1, kVideoWebM, codec_vp8); 2117 IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8);
2121 2118
2122 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. 2119 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy.
2123 // Clean this up after we have a solution to specifying decoding mode. 2120 // Clean this up after we have a solution to specifying decoding mode.
2124 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kAudioWebM, codec_vorbis)); 2121 EXPECT_TRUE(
2125 IsTypeSupported(widevine_uuid, kL1, kAudioWebM, codec_vorbis); 2122 IsTypeSupported(kWidevineKeySystem, kL3, kAudioWebM, codec_vorbis));
2123 IsTypeSupported(kWidevineKeySystem, kL1, kAudioWebM, codec_vorbis);
2126 2124
2127 EXPECT_TRUE( 2125 EXPECT_TRUE(
2128 IsTypeSupported(widevine_uuid, kL3, kVideoWebM, codec_vp8_vorbis)); 2126 IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8_vorbis));
2129 IsTypeSupported(widevine_uuid, kL1, kVideoWebM, codec_vp8_vorbis); 2127 IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8_vorbis);
2130 } 2128 }
2131 2129
2132 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidUUID) { 2130 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidKeySystem) {
2133 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { 2131 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) {
2134 VLOG(0) << "Could not run test - not supported on device."; 2132 VLOG(0) << "Could not run test - not supported on device.";
2135 return; 2133 return;
2136 } 2134 }
2137 2135
2138 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 2136 const char kInvalidKeySystem[] = "invalid.keysystem";
2139 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
2140
2141 std::vector<uint8> invalid_uuid(kInvalidUUID,
2142 kInvalidUUID + arraysize(kInvalidUUID));
2143 2137
2144 std::vector<std::string> codec_avc(1, "avc1"); 2138 std::vector<std::string> codec_avc(1, "avc1");
2145 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL3, kVideoMp4, codec_avc)); 2139 EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL3, kVideoMp4, codec_avc));
2146 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL1, kVideoMp4, codec_avc)); 2140 EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL1, kVideoMp4, codec_avc));
2147 } 2141 }
2148 2142
2149 // TODO(xhwang): Are these IsTypeSupported tests device specific? 2143 // TODO(xhwang): Are these IsTypeSupported tests device specific?
2150 // TODO(xhwang): Add more IsTypeSupported tests. 2144 // TODO(xhwang): Add more IsTypeSupported tests.
2151 2145
2152 } // namespace media 2146 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698