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_bridge.h" | 17 #include "ui/gl/android/surface_texture_bridge.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 static const int kDefaultDurationInMs = 10000; | 21 static const int kDefaultDurationInMs = 10000; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 manager_->message_loop()->Run(); | 461 manager_->message_loop()->Run(); |
461 EXPECT_EQ(2, manager_->num_requests()); | 462 EXPECT_EQ(2, manager_->num_requests()); |
462 | 463 |
463 // Send EOS. | 464 // Send EOS. |
464 player_->ReadFromDemuxerAck(CreateEOSAck(false)); | 465 player_->ReadFromDemuxerAck(CreateEOSAck(false)); |
465 manager_->message_loop()->Run(); | 466 manager_->message_loop()->Run(); |
466 // No more request for data should be made. | 467 // No more request for data should be made. |
467 EXPECT_EQ(2, manager_->num_requests()); | 468 EXPECT_EQ(2, manager_->num_requests()); |
468 } | 469 } |
469 | 470 |
| 471 TEST_F(MediaSourcePlayerTest, CanPlayType_Widevine) { |
| 472 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| 473 return; |
| 474 |
| 475 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
| 476 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
| 477 |
| 478 std::vector<uint8> widevine_uuid(kWidevineUUID, |
| 479 kWidevineUUID + arraysize(kWidevineUUID)); |
| 480 |
| 481 std::vector<std::string> codecs_avc(1, "video/avc"); |
| 482 EXPECT_TRUE(MediaSourcePlayer::CanPlayType( |
| 483 widevine_uuid, "L3", "video/webm", codecs_avc)); |
| 484 EXPECT_TRUE(MediaSourcePlayer::CanPlayType( |
| 485 widevine_uuid, "L1", "video/webm", codecs_avc)); |
| 486 |
| 487 std::vector<std::string> codecs_vp8(1, "video/x-vnd.on2.vp8"); |
| 488 EXPECT_TRUE(MediaSourcePlayer::CanPlayType( |
| 489 widevine_uuid, "L3", "video/webm", codecs_vp8)); |
| 490 EXPECT_FALSE(MediaSourcePlayer::CanPlayType( |
| 491 widevine_uuid, "L1", "video/webm", codecs_vp8)); |
| 492 |
| 493 std::vector<std::string> codecs_vorbis(1, "audio/vorbis"); |
| 494 EXPECT_TRUE(MediaSourcePlayer::CanPlayType( |
| 495 widevine_uuid, "L3", "video/webm", codecs_vorbis)); |
| 496 EXPECT_FALSE(MediaSourcePlayer::CanPlayType( |
| 497 widevine_uuid, "L1", "video/webm", codecs_vorbis)); |
| 498 } |
| 499 |
| 500 TEST_F(MediaSourcePlayerTest, CanPlayType_InvalidUUID) { |
| 501 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) |
| 502 return; |
| 503 |
| 504 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, |
| 505 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; |
| 506 |
| 507 std::vector<uint8> invalid_uuid(kInvalidUUID, |
| 508 kInvalidUUID + arraysize(kInvalidUUID)); |
| 509 |
| 510 std::vector<std::string> codecs_avc(1, "video/avc"); |
| 511 EXPECT_FALSE(MediaSourcePlayer::CanPlayType( |
| 512 invalid_uuid, "L3", "video/webm", codecs_avc)); |
| 513 EXPECT_FALSE(MediaSourcePlayer::CanPlayType( |
| 514 invalid_uuid, "L1", "video/webm", codecs_avc)); |
| 515 } |
| 516 |
| 517 TODO(xhwang): Are these CanPlayType tests device specific? |
| 518 TODO(xhwang): Add more CanPlayType tests. |
| 519 |
470 } // namespace media | 520 } // namespace media |
OLD | NEW |