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_loop.h" | 14 #include "media/base/bind_to_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 namespace media { | 20 namespace media { |
21 | 21 |
22 // Helper macro to skip the test if MediaCodecBridge isn't available. | 22 // Helper macro to skip the test if MediaCodecBridge isn't available. |
23 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ | 23 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ |
24 do { \ | 24 do { \ |
25 if (!MediaCodecBridge::IsAvailable()) { \ | 25 if (!MediaCodecBridge::IsAvailable()) { \ |
26 LOG(INFO) << "Could not run test - not supported on device."; \ | 26 VLOG(0) << "Could not run test - not supported on device."; \ |
27 return; \ | 27 return; \ |
28 } \ | 28 } \ |
29 } while (0) \ | 29 } while (0) |
30 | 30 |
31 static const int kDefaultDurationInMs = 10000; | 31 static const int kDefaultDurationInMs = 10000; |
32 | 32 |
33 static const char kAudioMp4[] = "audio/mp4"; | 33 static const char kAudioMp4[] = "audio/mp4"; |
34 static const char kVideoMp4[] = "video/mp4"; | 34 static const char kVideoMp4[] = "video/mp4"; |
35 static const char kAudioWebM[] = "audio/webm"; | 35 static const char kAudioWebM[] = "audio/webm"; |
36 static const char kVideoWebM[] = "video/webm"; | 36 static const char kVideoWebM[] = "video/webm"; |
37 | 37 |
38 // Mock of MediaPlayerManager for testing purpose | 38 // Mock of MediaPlayerManager for testing purpose |
39 class MockMediaPlayerManager : public MediaPlayerManager { | 39 class MockMediaPlayerManager : public MediaPlayerManager { |
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 | 1829 |
1830 player_.OnDemuxerConfigsAvailable(configs); | 1830 player_.OnDemuxerConfigsAvailable(configs); |
1831 CreateNextTextureAndSetVideoSurface(); | 1831 CreateNextTextureAndSetVideoSurface(); |
1832 EXPECT_FALSE(IsPendingSurfaceChange()); | 1832 EXPECT_FALSE(IsPendingSurfaceChange()); |
1833 EXPECT_FALSE(GetMediaDecoderJob(false)); | 1833 EXPECT_FALSE(GetMediaDecoderJob(false)); |
1834 } | 1834 } |
1835 | 1835 |
1836 // TODO(xhwang): Enable this test when the test devices are updated. | 1836 // TODO(xhwang): Enable this test when the test devices are updated. |
1837 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { | 1837 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { |
1838 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { | 1838 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { |
1839 LOG(INFO) << "Could not run test - not supported on device."; | 1839 VLOG(0) << "Could not run test - not supported on device."; |
1840 return; | 1840 return; |
1841 } | 1841 } |
1842 | 1842 |
1843 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | 1843 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
1844 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | 1844 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
1845 | 1845 |
1846 std::vector<uint8> widevine_uuid(kWidevineUUID, | 1846 std::vector<uint8> widevine_uuid(kWidevineUUID, |
1847 kWidevineUUID + arraysize(kWidevineUUID)); | 1847 kWidevineUUID + arraysize(kWidevineUUID)); |
1848 | 1848 |
1849 // We test "L3" fully. But for "L1" we don't check the result as it depend on | 1849 // We test "L3" fully. But for "L1" we don't check the result as it depend on |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", kAudioWebM, codec_vorbis)); | 1881 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", kAudioWebM, codec_vorbis)); |
1882 IsTypeSupported(widevine_uuid, "L1", kAudioWebM, codec_vorbis); | 1882 IsTypeSupported(widevine_uuid, "L1", kAudioWebM, codec_vorbis); |
1883 | 1883 |
1884 EXPECT_TRUE( | 1884 EXPECT_TRUE( |
1885 IsTypeSupported(widevine_uuid, "L3", kVideoWebM, codec_vp8_vorbis)); | 1885 IsTypeSupported(widevine_uuid, "L3", kVideoWebM, codec_vp8_vorbis)); |
1886 IsTypeSupported(widevine_uuid, "L1", kVideoWebM, codec_vp8_vorbis); | 1886 IsTypeSupported(widevine_uuid, "L1", kVideoWebM, codec_vp8_vorbis); |
1887 } | 1887 } |
1888 | 1888 |
1889 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidUUID) { | 1889 TEST_F(MediaSourcePlayerTest, IsTypeSupported_InvalidUUID) { |
1890 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { | 1890 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { |
1891 LOG(INFO) << "Could not run test - not supported on device."; | 1891 VLOG(0) << "Could not run test - not supported on device."; |
1892 return; | 1892 return; |
1893 } | 1893 } |
1894 | 1894 |
1895 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, | 1895 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, |
1896 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; | 1896 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; |
1897 | 1897 |
1898 std::vector<uint8> invalid_uuid(kInvalidUUID, | 1898 std::vector<uint8> invalid_uuid(kInvalidUUID, |
1899 kInvalidUUID + arraysize(kInvalidUUID)); | 1899 kInvalidUUID + arraysize(kInvalidUUID)); |
1900 | 1900 |
1901 std::vector<std::string> codec_avc(1, "avc1"); | 1901 std::vector<std::string> codec_avc(1, "avc1"); |
1902 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 1902 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
1903 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 1903 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
1904 } | 1904 } |
1905 | 1905 |
1906 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 1906 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
1907 // TODO(xhwang): Add more IsTypeSupported tests. | 1907 // TODO(xhwang): Add more IsTypeSupported tests. |
1908 | 1908 |
1909 } // namespace media | 1909 } // namespace media |
OLD | NEW |