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" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
11 #include "media/base/android/audio_decoder_job.h" | 10 #include "media/base/android/audio_decoder_job.h" |
12 #include "media/base/android/media_codec_util.h" | 11 #include "media/base/android/media_codec_util.h" |
13 #include "media/base/android/media_drm_bridge.h" | 12 #include "media/base/android/media_drm_bridge.h" |
14 #include "media/base/android/media_player_manager.h" | 13 #include "media/base/android/media_player_manager.h" |
15 #include "media/base/android/media_source_player.h" | 14 #include "media/base/android/media_source_player.h" |
16 #include "media/base/android/media_url_interceptor.h" | 15 #include "media/base/android/media_url_interceptor.h" |
17 #include "media/base/android/sdk_media_codec_bridge.h" | 16 #include "media/base/android/sdk_media_codec_bridge.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 DemuxerConfigs configs; | 239 DemuxerConfigs configs; |
241 configs.audio_codec = audio_codec; | 240 configs.audio_codec = audio_codec; |
242 configs.audio_channels = 2; | 241 configs.audio_channels = 2; |
243 configs.is_audio_encrypted = false; | 242 configs.is_audio_encrypted = false; |
244 configs.duration = kDefaultDuration; | 243 configs.duration = kDefaultDuration; |
245 | 244 |
246 if (audio_codec == kCodecVorbis) { | 245 if (audio_codec == kCodecVorbis) { |
247 configs.audio_sampling_rate = use_low_sample_rate ? 11025 : 44100; | 246 configs.audio_sampling_rate = use_low_sample_rate ? 11025 : 44100; |
248 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile( | 247 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile( |
249 "vorbis-extradata"); | 248 "vorbis-extradata"); |
250 configs.audio_extra_data = std::vector<uint8>( | 249 configs.audio_extra_data = std::vector<uint8_t>( |
251 buffer->data(), | 250 buffer->data(), buffer->data() + buffer->data_size()); |
252 buffer->data() + buffer->data_size()); | |
253 return configs; | 251 return configs; |
254 } | 252 } |
255 | 253 |
256 // Other codecs are not yet supported by this helper. | 254 // Other codecs are not yet supported by this helper. |
257 EXPECT_EQ(audio_codec, kCodecAAC); | 255 EXPECT_EQ(audio_codec, kCodecAAC); |
258 | 256 |
259 configs.audio_sampling_rate = 48000; | 257 configs.audio_sampling_rate = 48000; |
260 uint8 aac_extra_data[] = { 0x13, 0x10 }; | 258 uint8_t aac_extra_data[] = {0x13, 0x10}; |
261 configs.audio_extra_data = std::vector<uint8>( | 259 configs.audio_extra_data = |
262 aac_extra_data, | 260 std::vector<uint8_t>(aac_extra_data, aac_extra_data + 2); |
263 aac_extra_data + 2); | |
264 return configs; | 261 return configs; |
265 } | 262 } |
266 | 263 |
267 DemuxerConfigs CreateVideoDemuxerConfigs(bool use_larger_size) { | 264 DemuxerConfigs CreateVideoDemuxerConfigs(bool use_larger_size) { |
268 DemuxerConfigs configs; | 265 DemuxerConfigs configs; |
269 configs.video_codec = kCodecVP8; | 266 configs.video_codec = kCodecVP8; |
270 configs.video_size = | 267 configs.video_size = |
271 use_larger_size ? gfx::Size(640, 240) : gfx::Size(320, 240); | 268 use_larger_size ? gfx::Size(640, 240) : gfx::Size(320, 240); |
272 configs.is_video_encrypted = false; | 269 configs.is_video_encrypted = false; |
273 configs.duration = kDefaultDuration; | 270 configs.duration = kDefaultDuration; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 365 |
369 unit.status = DemuxerStream::kOk; | 366 unit.status = DemuxerStream::kOk; |
370 scoped_refptr<DecoderBuffer> buffer; | 367 scoped_refptr<DecoderBuffer> buffer; |
371 if (is_audio) { | 368 if (is_audio) { |
372 buffer = ReadTestDataFile( | 369 buffer = ReadTestDataFile( |
373 base::StringPrintf("vorbis-packet-%d", audio_packet_id)); | 370 base::StringPrintf("vorbis-packet-%d", audio_packet_id)); |
374 } else { | 371 } else { |
375 buffer = ReadTestDataFile( | 372 buffer = ReadTestDataFile( |
376 use_large_size_video ? "vp8-I-frame-640x240" : "vp8-I-frame-320x240"); | 373 use_large_size_video ? "vp8-I-frame-640x240" : "vp8-I-frame-320x240"); |
377 } | 374 } |
378 unit.data = std::vector<uint8>( | 375 unit.data = std::vector<uint8_t>(buffer->data(), |
379 buffer->data(), buffer->data() + buffer->data_size()); | 376 buffer->data() + buffer->data_size()); |
380 | 377 |
381 if (is_audio) { | 378 if (is_audio) { |
382 // Vorbis needs 4 extra bytes padding on Android to decode properly. Check | 379 // Vorbis needs 4 extra bytes padding on Android to decode properly. Check |
383 // NuMediaExtractor.cpp in Android source code. | 380 // NuMediaExtractor.cpp in Android source code. |
384 uint8 padding[4] = { 0xff , 0xff , 0xff , 0xff }; | 381 uint8_t padding[4] = {0xff, 0xff, 0xff, 0xff}; |
385 unit.data.insert(unit.data.end(), padding, padding + 4); | 382 unit.data.insert(unit.data.end(), padding, padding + 4); |
386 } | 383 } |
387 | 384 |
388 return unit; | 385 return unit; |
389 } | 386 } |
390 | 387 |
391 DemuxerData CreateReadFromDemuxerAckForAudio(int packet_id) { | 388 DemuxerData CreateReadFromDemuxerAckForAudio(int packet_id) { |
392 DemuxerData data; | 389 DemuxerData data; |
393 data.type = DemuxerStream::AUDIO; | 390 data.type = DemuxerStream::AUDIO; |
394 data.access_units.resize(1); | 391 data.access_units.resize(1); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 EXPECT_TRUE(GetMediaCodecBridge(true)); | 862 EXPECT_TRUE(GetMediaCodecBridge(true)); |
866 } | 863 } |
867 | 864 |
868 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithInvalidConfig) { | 865 TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithInvalidConfig) { |
869 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 866 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
870 | 867 |
871 // Test audio decoder job will not be created when failed to start the codec. | 868 // Test audio decoder job will not be created when failed to start the codec. |
872 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, false); | 869 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, false); |
873 // Replace with invalid |audio_extra_data| | 870 // Replace with invalid |audio_extra_data| |
874 configs.audio_extra_data.clear(); | 871 configs.audio_extra_data.clear(); |
875 uint8 invalid_codec_data[] = { 0x00, 0xff, 0xff, 0xff, 0xff }; | 872 uint8_t invalid_codec_data[] = {0x00, 0xff, 0xff, 0xff, 0xff}; |
876 configs.audio_extra_data.insert(configs.audio_extra_data.begin(), | 873 configs.audio_extra_data.insert(configs.audio_extra_data.begin(), |
877 invalid_codec_data, invalid_codec_data + 4); | 874 invalid_codec_data, invalid_codec_data + 4); |
878 Start(configs); | 875 Start(configs); |
879 | 876 |
880 // Decoder is not created after data is received. | 877 // Decoder is not created after data is received. |
881 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 878 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
882 EXPECT_FALSE(GetMediaCodecBridge(true)); | 879 EXPECT_FALSE(GetMediaCodecBridge(true)); |
883 } | 880 } |
884 | 881 |
885 TEST_F(MediaSourcePlayerTest, StartVideoCodecWithValidSurface) { | 882 TEST_F(MediaSourcePlayerTest, StartVideoCodecWithValidSurface) { |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 | 2375 |
2379 EXPECT_EQ(demuxer_->num_data_requests(), 0); | 2376 EXPECT_EQ(demuxer_->num_data_requests(), 0); |
2380 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true)); | 2377 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true)); |
2381 | 2378 |
2382 manager_.set_allow_play(true); | 2379 manager_.set_allow_play(true); |
2383 player_.Start(); | 2380 player_.Start(); |
2384 EXPECT_TRUE(player_.IsPlaying()); | 2381 EXPECT_TRUE(player_.IsPlaying()); |
2385 } | 2382 } |
2386 | 2383 |
2387 } // namespace media | 2384 } // namespace media |
OLD | NEW |