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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 return ack_params; | 168 return ack_params; |
168 } | 169 } |
169 | 170 |
170 MediaPlayerHostMsg_ReadFromDemuxerAck_Params CreateEOSAck(bool is_audio) { | 171 MediaPlayerHostMsg_ReadFromDemuxerAck_Params CreateEOSAck(bool is_audio) { |
171 MediaPlayerHostMsg_ReadFromDemuxerAck_Params ack_params; | 172 MediaPlayerHostMsg_ReadFromDemuxerAck_Params ack_params; |
172 ack_params.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; | 173 ack_params.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; |
173 ack_params.access_units.resize(1); | 174 ack_params.access_units.resize(1); |
174 ack_params.access_units[0].status = DemuxerStream::kOk; | 175 ack_params.access_units[0].status = DemuxerStream::kOk; |
175 ack_params.access_units[0].end_of_stream = true; | 176 ack_params.access_units[0].end_of_stream = true; |
176 return ack_params; | 177 return ack_params; |
177 } | 178 } |
178 | 179 |
179 base::TimeTicks StartTimeTicks() { | 180 base::TimeTicks StartTimeTicks() { |
180 return player_->start_time_ticks_; | 181 return player_->start_time_ticks_; |
181 } | 182 } |
182 | 183 |
184 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, | |
185 const std::string& security_level, | |
186 const std::string& container, | |
187 const std::vector<std::string>& codecs) { | |
188 return MediaSourcePlayer::IsTypeSupported( | |
ddorwin
2013/08/28 18:41:57
Would a using statement avoid the need for this fu
xhwang
2013/08/30 05:32:38
We can only "using foo_namespace::Func1", not "usi
| |
189 scheme_uuid, security_level, container, codecs); | |
190 } | |
191 | |
183 protected: | 192 protected: |
184 scoped_ptr<MockMediaPlayerManager> manager_; | 193 scoped_ptr<MockMediaPlayerManager> manager_; |
185 scoped_ptr<MediaSourcePlayer> player_; | 194 scoped_ptr<MediaSourcePlayer> player_; |
186 | 195 |
187 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayerTest); | 196 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayerTest); |
188 }; | 197 }; |
189 | 198 |
190 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithValidConfig) { | 199 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithValidConfig) { |
191 if (!MediaCodecBridge::IsAvailable()) | 200 if (!MediaCodecBridge::IsAvailable()) |
192 return; | 201 return; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 manager_->message_loop()->Run(); | 469 manager_->message_loop()->Run(); |
461 EXPECT_EQ(2, manager_->num_requests()); | 470 EXPECT_EQ(2, manager_->num_requests()); |
462 | 471 |
463 // Send EOS. | 472 // Send EOS. |
464 player_->ReadFromDemuxerAck(CreateEOSAck(false)); | 473 player_->ReadFromDemuxerAck(CreateEOSAck(false)); |
465 manager_->message_loop()->Run(); | 474 manager_->message_loop()->Run(); |
466 // No more request for data should be made. | 475 // No more request for data should be made. |
467 EXPECT_EQ(2, manager_->num_requests()); | 476 EXPECT_EQ(2, manager_->num_requests()); |
468 } | 477 } |
469 | 478 |
479 TEST_F(MediaSourcePlayerTest, CanPlayType_Widevine) { | |
480 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) | |
481 return; | |
482 | |
483 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
484 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
485 | |
486 std::vector<uint8> widevine_uuid(kWidevineUUID, | |
487 kWidevineUUID + arraysize(kWidevineUUID)); | |
488 | |
489 std::vector<std::string> codec_avc(1, "avc1"); | |
490 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/mp4", codec_avc)); | |
491 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L1", "video/mp4", codec_avc)); | |
492 | |
493 std::vector<std::string> codec_vp8(1, "vp8"); | |
494 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vp8)); | |
495 EXPECT_FALSE(IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vp8)); | |
496 | |
497 std::vector<std::string> codec_vorbis(1, "vorbis"); | |
498 EXPECT_TRUE(IsTypeSupported(widevine_uuid, "L3", "video/webm", codec_vorbis)); | |
499 EXPECT_FALSE( | |
500 IsTypeSupported(widevine_uuid, "L1", "video/webm", codec_vorbis)); | |
501 } | |
502 | |
503 TEST_F(MediaSourcePlayerTest, CanPlayType_InvalidUUID) { | |
504 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) | |
505 return; | |
506 | |
507 uint8 kInvalidUUID[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, | |
508 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; | |
509 | |
510 std::vector<uint8> invalid_uuid(kInvalidUUID, | |
511 kInvalidUUID + arraysize(kInvalidUUID)); | |
512 | |
513 std::vector<std::string> codec_avc(1, "avc1"); | |
514 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", "video/mp4", codec_avc)); | |
515 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", "video/mp4", codec_avc)); | |
516 } | |
517 | |
518 // TODO(xhwang): Are these IsTypeSupported tests device specific? | |
519 // TODO(xhwang): Add more IsTypeSupported tests. | |
520 | |
470 } // namespace media | 521 } // namespace media |
OLD | NEW |