Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: media/filters/audio_decoder_unittest.cc

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/decoder_selector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <deque> 5 #include <deque>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 reader_->codec_context_for_testing(), false, &config, false); 154 reader_->codec_context_for_testing(), false, &config, false);
155 155
156 EXPECT_EQ(GetParam().codec, config.codec()); 156 EXPECT_EQ(GetParam().codec, config.codec());
157 EXPECT_EQ(GetParam().samples_per_second, config.samples_per_second()); 157 EXPECT_EQ(GetParam().samples_per_second, config.samples_per_second());
158 EXPECT_EQ(GetParam().channel_layout, config.channel_layout()); 158 EXPECT_EQ(GetParam().channel_layout, config.channel_layout());
159 159
160 InitializeDecoder(config); 160 InitializeDecoder(config);
161 } 161 }
162 162
163 void InitializeDecoder(const AudioDecoderConfig& config) { 163 void InitializeDecoder(const AudioDecoderConfig& config) {
164 InitializeDecoderWithStatus(config, PIPELINE_OK); 164 InitializeDecoderWithResult(config, true);
165 } 165 }
166 166
167 void InitializeDecoderWithStatus(const AudioDecoderConfig& config, 167 void InitializeDecoderWithResult(const AudioDecoderConfig& config,
168 PipelineStatus status) { 168 bool success) {
169 decoder_->Initialize( 169 decoder_->Initialize(
170 config, 170 config, NewExpectedBoolCB(success),
171 NewExpectedStatusCB(status),
172 base::Bind(&AudioDecoderTest::OnDecoderOutput, base::Unretained(this))); 171 base::Bind(&AudioDecoderTest::OnDecoderOutput, base::Unretained(this)));
173 base::RunLoop().RunUntilIdle(); 172 base::RunLoop().RunUntilIdle();
174 } 173 }
175 174
176 void Decode() { 175 void Decode() {
177 AVPacket packet; 176 AVPacket packet;
178 ASSERT_TRUE(reader_->ReadPacketForTesting(&packet)); 177 ASSERT_TRUE(reader_->ReadPacketForTesting(&packet));
179 178
180 // Split out packet metadata before making a copy. 179 // Split out packet metadata before making a copy.
181 av_packet_split_side_data(&packet); 180 av_packet_split_side_data(&packet);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 kSampleFormatF32, 395 kSampleFormatF32,
397 CHANNEL_LAYOUT_STEREO, 396 CHANNEL_LAYOUT_STEREO,
398 48000, 397 48000,
399 kOpusExtraData, 398 kOpusExtraData,
400 arraysize(kOpusExtraData), 399 arraysize(kOpusExtraData),
401 false, 400 false,
402 false, 401 false,
403 base::TimeDelta::FromMilliseconds(80), 402 base::TimeDelta::FromMilliseconds(80),
404 // Use a different codec delay than in the extradata. 403 // Use a different codec delay than in the extradata.
405 100); 404 100);
406 InitializeDecoderWithStatus(decoder_config, DECODER_ERROR_NOT_SUPPORTED); 405 InitializeDecoderWithResult(decoder_config, false);
407 } 406 }
408 407
409 TEST_P(FFmpegAudioDecoderBehavioralTest, InitializeWithBadConfig) { 408 TEST_P(FFmpegAudioDecoderBehavioralTest, InitializeWithBadConfig) {
410 const AudioDecoderConfig decoder_config(kCodecVorbis, 409 const AudioDecoderConfig decoder_config(kCodecVorbis,
411 kSampleFormatF32, 410 kSampleFormatF32,
412 CHANNEL_LAYOUT_STEREO, 411 CHANNEL_LAYOUT_STEREO,
413 // Invalid sample rate of zero. 412 // Invalid sample rate of zero.
414 0, 413 0,
415 NULL, 414 NULL,
416 0, 415 0,
417 false); 416 false);
418 InitializeDecoderWithStatus(decoder_config, DECODER_ERROR_NOT_SUPPORTED); 417 InitializeDecoderWithResult(decoder_config, false);
419 } 418 }
420 419
421 const DecodedBufferExpectations kSfxOpusExpectations[] = { 420 const DecodedBufferExpectations kSfxOpusExpectations[] = {
422 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"}, 421 {0, 13500, "-2.70,-1.41,-0.78,-1.27,-2.56,-3.73,"},
423 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"}, 422 {13500, 20000, "5.48,5.93,6.04,5.83,5.54,5.45,"},
424 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"}, 423 {33500, 20000, "-3.45,-3.35,-3.57,-4.12,-4.74,-5.14,"},
425 }; 424 };
426 425
427 const DecodedBufferExpectations kBearOpusExpectations[] = { 426 const DecodedBufferExpectations kBearOpusExpectations[] = {
428 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"}, 427 {500, 3500, "-0.26,0.87,1.36,0.84,-0.30,-1.22,"},
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 }; 523 };
525 524
526 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest, 525 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderTest,
527 AudioDecoderTest, 526 AudioDecoderTest,
528 testing::ValuesIn(kFFmpegTests)); 527 testing::ValuesIn(kFFmpegTests));
529 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest, 528 INSTANTIATE_TEST_CASE_P(FFmpegAudioDecoderBehavioralTest,
530 FFmpegAudioDecoderBehavioralTest, 529 FFmpegAudioDecoderBehavioralTest,
531 testing::ValuesIn(kFFmpegBehavioralTest)); 530 testing::ValuesIn(kFFmpegBehavioralTest));
532 531
533 } // namespace media 532 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/decoder_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698