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_player_manager.h" | 12 #include "media/base/android/media_player_manager.h" |
12 #include "media/base/android/media_source_player.h" | 13 #include "media/base/android/media_source_player.h" |
13 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
14 #include "media/base/test_data_util.h" | 15 #include "media/base/test_data_util.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "ui/gl/android/surface_texture.h" | 17 #include "ui/gl/android/surface_texture.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 static const int kDefaultDurationInMs = 10000; | 21 static const int kDefaultDurationInMs = 10000; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 data.access_units.resize(1); | 172 data.access_units.resize(1); |
172 data.access_units[0].status = DemuxerStream::kOk; | 173 data.access_units[0].status = DemuxerStream::kOk; |
173 data.access_units[0].end_of_stream = true; | 174 data.access_units[0].end_of_stream = true; |
174 return data; | 175 return data; |
175 } | 176 } |
176 | 177 |
177 base::TimeTicks StartTimeTicks() { | 178 base::TimeTicks StartTimeTicks() { |
178 return player_->start_time_ticks_; | 179 return player_->start_time_ticks_; |
179 } | 180 } |
180 | 181 |
| 182 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, |
| 183 const std::string& security_level, |
| 184 const std::string& container, |
| 185 const std::vector<std::string>& codecs) { |
| 186 return MediaSourcePlayer::IsTypeSupported( |
| 187 scheme_uuid, security_level, container, codecs); |
| 188 } |
| 189 |
181 protected: | 190 protected: |
182 scoped_ptr<MockMediaPlayerManager> manager_; | 191 scoped_ptr<MockMediaPlayerManager> manager_; |
183 scoped_ptr<MediaSourcePlayer> player_; | 192 scoped_ptr<MediaSourcePlayer> player_; |
184 | 193 |
185 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayerTest); | 194 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayerTest); |
186 }; | 195 }; |
187 | 196 |
188 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithValidConfig) { | 197 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithValidConfig) { |
189 if (!MediaCodecBridge::IsAvailable()) | 198 if (!MediaCodecBridge::IsAvailable()) |
190 return; | 199 return; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 manager_->message_loop()->Run(); | 467 manager_->message_loop()->Run(); |
459 EXPECT_EQ(2, manager_->num_requests()); | 468 EXPECT_EQ(2, manager_->num_requests()); |
460 | 469 |
461 // Send EOS. | 470 // Send EOS. |
462 player_->ReadFromDemuxerAck(CreateEOSAck(false)); | 471 player_->ReadFromDemuxerAck(CreateEOSAck(false)); |
463 manager_->message_loop()->Run(); | 472 manager_->message_loop()->Run(); |
464 // No more request for data should be made. | 473 // No more request for data should be made. |
465 EXPECT_EQ(2, manager_->num_requests()); | 474 EXPECT_EQ(2, manager_->num_requests()); |
466 } | 475 } |
467 | 476 |
| 477 TEST_F(MediaSourcePlayerTest, CanPlayType_Widevine) { |
| 478 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| 479 return; |
| 480 |
| 481 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
| 482 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| 483 |
| 484 std::vector<uint8> widevine_uuid(kWidevineUUID, |
| 485 kWidevineUUID + arraysize(kWidevineUUID)); |
| 486 |
| 487 std::vector<std::string> codec_avc(1, "avc1"); |
| 488 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/mp4", codec_avc)); |
| 489 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L1", "video/mp4", codec_avc)); |
| 490 |
| 491 std::vector<std::string> codec_vp8(1, "vp8"); |
| 492 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vp8)); |
| 493 EXPECT_FALSE(IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vp8)); |
| 494 |
| 495 std::vector<std::string> codec_vorbis(1, "vorbis"); |
| 496 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vorbis)); |
| 497 EXPECT_FALSE( |
| 498 IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vorbis)); |
| 499 } |
| 500 |
| 501 TEST_F(MediaSourcePlayerTest, CanPlayType_InvalidUUID) { |
| 502 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| 503 return; |
| 504 |
| 505 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, |
| 506 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; |
| 507 |
| 508 std::vector<uint8> invalid_uuid(kInvalidUUID, |
| 509 kInvalidUUID + arraysize(kInvalidUUID)); |
| 510 |
| 511 std::vector<std::string> codec_avc(1, "avc1"); |
| 512 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", "video/mp4", codec_avc)); |
| 513 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", "video/mp4", codec_avc)); |
| 514 } |
| 515 |
| 516 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
| 517 // TODO(xhwang): Add more IsTypeSupported tests. |
| 518 |
468 } // namespace media | 519 } // namespace media |
OLD | NEW |