OLD | NEW |
---|---|
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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 702 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
701 | 703 |
702 player_.OnDemuxerSeekDone(kNoTimestamp()); | 704 player_.OnDemuxerSeekDone(kNoTimestamp()); |
703 EXPECT_FALSE(manager_.playback_completed()); | 705 EXPECT_FALSE(manager_.playback_completed()); |
704 } | 706 } |
705 | 707 |
706 base::TimeTicks StartTimeTicks() { | 708 base::TimeTicks StartTimeTicks() { |
707 return player_.start_time_ticks_; | 709 return player_.start_time_ticks_; |
708 } | 710 } |
709 | 711 |
710 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, | 712 bool IsTypeSupported(const std::string& key_system, |
711 MediaDrmBridge::SecurityLevel security_level, | 713 MediaDrmBridge::SecurityLevel security_level, |
712 const std::string& container, | 714 const std::string& container, |
713 const std::vector<std::string>& codecs) { | 715 const std::vector<std::string>& codecs) { |
714 return MediaSourcePlayer::IsTypeSupported( | 716 return MediaSourcePlayer::IsTypeSupported( |
715 scheme_uuid, security_level, container, codecs); | 717 key_system, security_level, container, codecs); |
716 } | 718 } |
717 | 719 |
718 base::MessageLoop message_loop_; | 720 base::MessageLoop message_loop_; |
719 MockMediaPlayerManager manager_; | 721 MockMediaPlayerManager manager_; |
720 MockDemuxerAndroid* demuxer_; // Owned by |player_|. | 722 MockDemuxerAndroid* demuxer_; // Owned by |player_|. |
721 MediaSourcePlayer player_; | 723 MediaSourcePlayer player_; |
722 | 724 |
723 // Track whether a possibly async decoder callback test hook has run. | 725 // Track whether a possibly async decoder callback test hook has run. |
724 bool decoder_callback_hook_executed_; | 726 bool decoder_callback_hook_executed_; |
725 | 727 |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2026 EXPECT_FALSE(GetMediaDecoderJob(false)); | 2028 EXPECT_FALSE(GetMediaDecoderJob(false)); |
2027 } | 2029 } |
2028 | 2030 |
2029 // TODO(xhwang): Enable this test when the test devices are updated. | 2031 // TODO(xhwang): Enable this test when the test devices are updated. |
2030 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { | 2032 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { |
2031 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { | 2033 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { |
2032 VLOG(0) << "Could not run test - not supported on device."; | 2034 VLOG(0) << "Could not run test - not supported on device."; |
2033 return; | 2035 return; |
2034 } | 2036 } |
2035 | 2037 |
2036 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
2037 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
2038 | |
2039 std::vector<uint8> widevine_uuid(kWidevineUUID, | |
2040 kWidevineUUID + arraysize(kWidevineUUID)); | |
2041 | |
2042 // We test "L3" fully. But for "L1" we don't check the result as it depend on | 2038 // We test "L3" fully. But for "L1" we don't check the result as it depend on |
2043 // whether the test device supports "L1" decoding. | 2039 // whether the test device supports "L1" decoding. |
2044 | 2040 |
2045 std::vector<std::string> codec_avc(1, "avc1"); | 2041 std::vector<std::string> codec_avc(1, "avc1"); |
2046 std::vector<std::string> codec_aac(1, "mp4a"); | 2042 std::vector<std::string> codec_aac(1, "mp4a"); |
2047 std::vector<std::string> codec_avc_aac(1, "avc1"); | 2043 std::vector<std::string> codec_avc_aac(1, "avc1"); |
2048 codec_avc_aac.push_back("mp4a"); | 2044 codec_avc_aac.push_back("mp4a"); |
2049 | 2045 |
2050 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoMp4, codec_avc)); | 2046 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc)); |
2051 IsTypeSupported(widevine_uuid, kL1, kVideoMp4, codec_avc); | 2047 IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc); |
2052 | 2048 |
2053 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. | 2049 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. |
2054 // Clean this up after we have a solution to specifying decoding mode. | 2050 // Clean this up after we have a solution to specifying decoding mode. |
2055 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kAudioMp4, codec_aac)); | 2051 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kAudioMp4, codec_aac)); |
2056 IsTypeSupported(widevine_uuid, kL1, kAudioMp4, codec_aac); | 2052 IsTypeSupported(kWidevineKeySystem, kL1, kAudioMp4, codec_aac); |
2057 | 2053 |
2058 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoMp4, codec_avc_aac)); | 2054 EXPECT_TRUE( |
2059 IsTypeSupported(widevine_uuid, kL1, kVideoMp4, codec_avc_aac); | 2055 IsTypeSupported(kWidevineKeySystem, kL3, kVideoMp4, codec_avc_aac)); |
2056 IsTypeSupported(kWidevineKeySystem, kL1, kVideoMp4, codec_avc_aac); | |
2060 | 2057 |
2061 std::vector<std::string> codec_vp8(1, "vp8"); | 2058 std::vector<std::string> codec_vp8(1, "vp8"); |
2062 std::vector<std::string> codec_vorbis(1, "vorbis"); | 2059 std::vector<std::string> codec_vorbis(1, "vorbis"); |
2063 std::vector<std::string> codec_vp8_vorbis(1, "vp8"); | 2060 std::vector<std::string> codec_vp8_vorbis(1, "vp8"); |
2064 codec_vp8_vorbis.push_back("vorbis"); | 2061 codec_vp8_vorbis.push_back("vorbis"); |
2065 | 2062 |
2066 // TODO(xhwang): WebM is actually not supported but currently | 2063 // TODO(xhwang): WebM is actually not supported but currently |
2067 // MediaDrmBridge.isCryptoSchemeSupported() doesn't check the container type. | 2064 // MediaDrmBridge.isCryptoSchemeSupported() doesn't check the container type. |
2068 // Fix isCryptoSchemeSupported() and update this test as necessary. | 2065 // Fix isCryptoSchemeSupported() and update this test as necessary. |
2069 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kVideoWebM, codec_vp8)); | 2066 EXPECT_TRUE(IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8)); |
2070 IsTypeSupported(widevine_uuid, kL1, kVideoWebM, codec_vp8); | 2067 IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8); |
2071 | 2068 |
2072 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. | 2069 // TODO(xhwang): L1/L3 doesn't apply to audio, so the result is messy. |
2073 // Clean this up after we have a solution to specifying decoding mode. | 2070 // Clean this up after we have a solution to specifying decoding mode. |
2074 EXPECT_TRUE(IsTypeSupported(widevine_uuid, kL3, kAudioWebM, codec_vorbis)); | 2071 EXPECT_TRUE( |
2075 IsTypeSupported(widevine_uuid, kL1, kAudioWebM, codec_vorbis); | 2072 IsTypeSupported(kWidevineKeySystem, kL3, kAudioWebM, codec_vorbis)); |
2073 IsTypeSupported(kWidevineKeySystem, kL1, kAudioWebM, codec_vorbis); | |
2076 | 2074 |
2077 EXPECT_TRUE( | 2075 EXPECT_TRUE( |
2078 IsTypeSupported(widevine_uuid, kL3, kVideoWebM, codec_vp8_vorbis)); | 2076 IsTypeSupported(kWidevineKeySystem, kL3, kVideoWebM, codec_vp8_vorbis)); |
2079 IsTypeSupported(widevine_uuid, kL1, kVideoWebM, codec_vp8_vorbis); | 2077 IsTypeSupported(kWidevineKeySystem, kL1, kVideoWebM, codec_vp8_vorbis); |
2080 } | 2078 } |
2081 | 2079 |
2082 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidUUID) { | 2080 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidKeySystem) { |
2083 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { | 2081 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { |
ddorwin
2014/03/04 20:00:56
Do we need these checks for an invalid key system?
xhwang
2014/03/05 21:52:33
In the current implementation, we should always ca
| |
2084 VLOG(0) << "Could not run test - not supported on device."; | 2082 VLOG(0) << "Could not run test - not supported on device."; |
2085 return; | 2083 return; |
2086 } | 2084 } |
2087 | 2085 |
2088 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, | 2086 const char kInvalidKeySystem[] = "invalid.keysystem"; |
2089 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; | |
2090 | |
2091 std::vector<uint8> invalid_uuid(kInvalidUUID, | |
2092 kInvalidUUID + arraysize(kInvalidUUID)); | |
2093 | 2087 |
2094 std::vector<std::string> codec_avc(1, "avc1"); | 2088 std::vector<std::string> codec_avc(1, "avc1"); |
2095 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL3, kVideoMp4, codec_avc)); | 2089 EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL3, kVideoMp4, codec_avc)); |
2096 EXPECT_FALSE(IsTypeSupported(invalid_uuid, kL1, kVideoMp4, codec_avc)); | 2090 EXPECT_FALSE(IsTypeSupported(kInvalidKeySystem, kL1, kVideoMp4, codec_avc)); |
2097 } | 2091 } |
2098 | 2092 |
2099 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 2093 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
2100 // TODO(xhwang): Add more IsTypeSupported tests. | 2094 // TODO(xhwang): Add more IsTypeSupported tests. |
2101 | 2095 |
2102 } // namespace media | 2096 } // namespace media |
OLD | NEW |