OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "media/filters/in_memory_url_protocol.h" | 31 #include "media/filters/in_memory_url_protocol.h" |
32 #include "media/filters/opus_audio_decoder.h" | 32 #include "media/filters/opus_audio_decoder.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 | 34 |
35 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
36 #include "base/android/build_info.h" | 36 #include "base/android/build_info.h" |
37 #include "media/base/android/media_codec_util.h" | 37 #include "media/base/android/media_codec_util.h" |
38 #include "media/filters/android/media_codec_audio_decoder.h" | 38 #include "media/filters/android/media_codec_audio_decoder.h" |
39 | 39 |
40 #if defined(USE_PROPRIETARY_CODECS) | 40 #if defined(USE_PROPRIETARY_CODECS) |
41 #include "media/formats/mpeg/adts_header_parser.h" | 41 #include "media/formats/mpeg/adts_stream_parser.h" |
42 #endif | 42 #endif |
43 | 43 |
44 // Helper macro to skip the test if MediaCodec is not available. | 44 // Helper macro to skip the test if MediaCodec is not available. |
45 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \ | 45 #define SKIP_TEST_IF_NO_MEDIA_CODEC() \ |
46 do { \ | 46 do { \ |
47 if (GetParam().decoder_type == MEDIA_CODEC) { \ | 47 if (GetParam().decoder_type == MEDIA_CODEC) { \ |
48 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ | 48 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ |
49 VLOG(0) << "Could not run test - no MediaCodec on device."; \ | 49 VLOG(0) << "Could not run test - no MediaCodec on device."; \ |
50 return; \ | 50 return; \ |
51 } \ | 51 } \ |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 AudioDecoderConfig config; | 198 AudioDecoderConfig config; |
199 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig( | 199 ASSERT_TRUE(AVCodecContextToAudioDecoderConfig( |
200 reader_->codec_context_for_testing(), Unencrypted(), &config)); | 200 reader_->codec_context_for_testing(), Unencrypted(), &config)); |
201 | 201 |
202 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) | 202 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) |
203 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS | 203 // MEDIA_CODEC type requires config->extra_data() for AAC codec. For ADTS |
204 // streams we need to extract it with a separate procedure. | 204 // streams we need to extract it with a separate procedure. |
205 if (GetParam().decoder_type == MEDIA_CODEC && | 205 if (GetParam().decoder_type == MEDIA_CODEC && |
206 GetParam().codec == kCodecAAC && config.extra_data().empty()) { | 206 GetParam().codec == kCodecAAC && config.extra_data().empty()) { |
207 size_t ignore_orig_sample_rate; | 207 int sample_rate; |
208 ASSERT_TRUE(ParseAdtsHeader(packet.data, false, &config, | 208 ChannelLayout channel_layout; |
209 &ignore_orig_sample_rate)); | 209 std::vector<uint8_t> extra_data; |
| 210 ASSERT_GT(ADTSStreamParser().ParseFrameHeader( |
| 211 packet.data, packet.size, nullptr, &sample_rate, |
| 212 &channel_layout, nullptr, nullptr, &extra_data), |
| 213 0); |
| 214 config.Initialize(kCodecAAC, kSampleFormatS16, channel_layout, |
| 215 sample_rate, extra_data, Unencrypted(), |
| 216 base::TimeDelta(), 0); |
210 ASSERT_FALSE(config.extra_data().empty()); | 217 ASSERT_FALSE(config.extra_data().empty()); |
211 } | 218 } |
212 #endif | 219 #endif |
213 | 220 |
214 av_packet_unref(&packet); | 221 av_packet_unref(&packet); |
215 | 222 |
216 EXPECT_EQ(GetParam().codec, config.codec()); | 223 EXPECT_EQ(GetParam().codec, config.codec()); |
217 EXPECT_EQ(GetParam().samples_per_second, config.samples_per_second()); | 224 EXPECT_EQ(GetParam().samples_per_second, config.samples_per_second()); |
218 EXPECT_EQ(GetParam().channel_layout, config.channel_layout()); | 225 EXPECT_EQ(GetParam().channel_layout, config.channel_layout()); |
219 | 226 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 }; | 635 }; |
629 | 636 |
630 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, | 637 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, |
631 AudioDecoderTest, | 638 AudioDecoderTest, |
632 testing::ValuesIn(kFFmpegTests)); | 639 testing::ValuesIn(kFFmpegTests)); |
633 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, | 640 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, |
634 FFmpegAudioDecoderBehavioralTest, | 641 FFmpegAudioDecoderBehavioralTest, |
635 testing::ValuesIn(kFFmpegBehavioralTest)); | 642 testing::ValuesIn(kFFmpegBehavioralTest)); |
636 | 643 |
637 } // namespace media | 644 } // namespace media |
OLD | NEW |