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" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 // |is_audio|. Caller must guard against NPE if the player's job is NULL. | 160 // |is_audio|. Caller must guard against NPE if the player's job is NULL. |
161 bool IsPrerolling(bool is_audio) { | 161 bool IsPrerolling(bool is_audio) { |
162 return GetMediaDecoderJob(is_audio)->prerolling(); | 162 return GetMediaDecoderJob(is_audio)->prerolling(); |
163 } | 163 } |
164 | 164 |
165 // Get the preroll timestamp from the MediaSourcePlayer. | 165 // Get the preroll timestamp from the MediaSourcePlayer. |
166 base::TimeDelta GetPrerollTimestamp() { | 166 base::TimeDelta GetPrerollTimestamp() { |
167 return player_.preroll_timestamp_; | 167 return player_.preroll_timestamp_; |
168 } | 168 } |
169 | 169 |
170 // Inspect internal pending_event_ state of |player_|. This is for infrequent | |
171 // use by tests, only where required. | |
172 bool IsPendingSurfaceChange() { | |
173 return player_.IsEventPending(player_.SURFACE_CHANGE_EVENT_PENDING); | |
174 } | |
175 | |
170 DemuxerConfigs CreateAudioDemuxerConfigs() { | 176 DemuxerConfigs CreateAudioDemuxerConfigs() { |
171 DemuxerConfigs configs; | 177 DemuxerConfigs configs; |
172 configs.audio_codec = kCodecVorbis; | 178 configs.audio_codec = kCodecVorbis; |
173 configs.audio_channels = 2; | 179 configs.audio_channels = 2; |
174 configs.audio_sampling_rate = 44100; | 180 configs.audio_sampling_rate = 44100; |
175 configs.is_audio_encrypted = false; | 181 configs.is_audio_encrypted = false; |
176 configs.duration_ms = kDefaultDurationInMs; | 182 configs.duration_ms = kDefaultDurationInMs; |
177 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("vorbis-extradata"); | 183 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("vorbis-extradata"); |
178 configs.audio_extra_data = std::vector<uint8>( | 184 configs.audio_extra_data = std::vector<uint8>( |
179 buffer->data(), | 185 buffer->data(), |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1372 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs()); | 1378 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs()); |
1373 MediaDecoderJob* second_job = GetMediaDecoderJob(false); | 1379 MediaDecoderJob* second_job = GetMediaDecoderJob(false); |
1374 EXPECT_NE(first_job, second_job); | 1380 EXPECT_NE(first_job, second_job); |
1375 EXPECT_TRUE(second_job); | 1381 EXPECT_TRUE(second_job); |
1376 | 1382 |
1377 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1383 EXPECT_EQ(3, demuxer_->num_data_requests()); |
1378 EXPECT_EQ(1, demuxer_->num_config_requests()); | 1384 EXPECT_EQ(1, demuxer_->num_config_requests()); |
1379 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1385 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
1380 } | 1386 } |
1381 | 1387 |
1388 // TODO(xhwang): Once we add tests to cover DrmBridge, update this test to | |
wolenetz
2013/10/31 20:34:25
From chat with qinmin@, MSP should be able to crea
wolenetz
2013/10/31 21:19:17
Actually, MSP::GetMediaCrypto() requires previous
| |
1389 // also verify that the job is successfully created if SetDrmBridge(), Start() | |
1390 // and eventually OnMediaCrypto() occur. This would increase test coverage of | |
1391 // http://crbug.com/313470 and allow us to remove inspection of internal player | |
1392 // pending event state. | |
1393 TEST_F(MediaSourcePlayerTest, SurfaceChangeClearedEvenIfMediaCryptoAbsent) { | |
1394 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1395 | |
1396 // Test that |SURFACE_CHANGE_EVENT_PENDING| is not pending after | |
1397 // SetVideoSurface() for a player configured for encrypted video, when the | |
1398 // player has not yet received media crypto. | |
1399 DemuxerConfigs configs = CreateVideoDemuxerConfigs(); | |
1400 configs.is_video_encrypted = true; | |
1401 | |
1402 player_.OnDemuxerConfigsAvailable(configs); | |
1403 CreateNextTextureAndSetVideoSurface(); | |
1404 EXPECT_FALSE(IsPendingSurfaceChange()); | |
1405 EXPECT_FALSE(GetMediaDecoderJob(false)); | |
1406 } | |
1407 | |
1382 // TODO(xhwang): Enable this test when the test devices are updated. | 1408 // TODO(xhwang): Enable this test when the test devices are updated. |
1383 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { | 1409 TEST_F(MediaSourcePlayerTest, DISABLED_IsTypeSupported_Widevine) { |
1384 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { | 1410 if (!MediaCodecBridge::IsAvailable() || !MediaDrmBridge::IsAvailable()) { |
1385 LOG(INFO) << "Could not run test - not supported on device."; | 1411 LOG(INFO) << "Could not run test - not supported on device."; |
1386 return; | 1412 return; |
1387 } | 1413 } |
1388 | 1414 |
1389 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | 1415 uint8 kWidevineUUID[] = { 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, |
1390 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | 1416 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; |
1391 | 1417 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 | 1472 |
1447 std::vector<std::string> codec_avc(1, "avc1"); | 1473 std::vector<std::string> codec_avc(1, "avc1"); |
1448 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 1474 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
1449 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 1475 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
1450 } | 1476 } |
1451 | 1477 |
1452 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 1478 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
1453 // TODO(xhwang): Add more IsTypeSupported tests. | 1479 // TODO(xhwang): Add more IsTypeSupported tests. |
1454 | 1480 |
1455 } // namespace media | 1481 } // namespace media |
OLD | NEW |