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

Side by Side Diff: media/renderers/audio_renderer_impl_unittest.cc

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +pipeline integration tests, +test media, minor fixes Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/renderers/audio_renderer_impl.h" 5 #include "media/renderers/audio_renderer_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ConfigureDecoder(); 146 ConfigureDecoder();
147 ScopedVector<AudioDecoder> decoders; 147 ScopedVector<AudioDecoder> decoders;
148 decoders.push_back(decoder_); 148 decoders.push_back(decoder_);
149 renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(), 149 renderer_.reset(new AudioRendererImpl(message_loop_.task_runner(),
150 sink_.get(), std::move(decoders), 150 sink_.get(), std::move(decoders),
151 new MediaLog())); 151 new MediaLog()));
152 testing::Mock::VerifyAndClearExpectations(&demuxer_stream_); 152 testing::Mock::VerifyAndClearExpectations(&demuxer_stream_);
153 ConfigureDemuxerStream(true); 153 ConfigureDemuxerStream(true);
154 } 154 }
155 155
156 // Reconfigures a demuxer stream using a given config.
157 void ConfigureChangeDemuxerStream(const AudioDecoderConfig& audio_config) {
158 demuxer_stream_.set_audio_decoder_config(audio_config);
159 ConfigureDecoder();
160 ConfigureDemuxerStream(true);
161 }
162
156 void ExpectUnsupportedAudioDecoder() { 163 void ExpectUnsupportedAudioDecoder() {
157 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) 164 EXPECT_CALL(*decoder_, Initialize(_, _, _, _))
158 .WillOnce(DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(false))); 165 .WillOnce(DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(false)));
159 } 166 }
160 167
161 // RendererClient implementation. 168 // RendererClient implementation.
162 MOCK_METHOD1(OnError, void(PipelineStatus)); 169 MOCK_METHOD1(OnError, void(PipelineStatus));
163 void OnEnded() override { 170 void OnEnded() override {
164 CHECK(!ended_); 171 CHECK(!ended_);
165 ended_ = true; 172 ended_ = true;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 DeliverBuffer(DecodeStatus::OK, buffer); 648 DeliverBuffer(DecodeStatus::OK, buffer);
642 649
643 // All channels should now be enabled. 650 // All channels should now be enabled.
644 mask = channel_mask(); 651 mask = channel_mask();
645 EXPECT_FALSE(mask.empty()); 652 EXPECT_FALSE(mask.empty());
646 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels())); 653 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
647 for (int ch = 0; ch < hw_params.channels(); ++ch) 654 for (int ch = 0; ch < hw_params.channels(); ++ch)
648 ASSERT_TRUE(mask[ch]); 655 ASSERT_TRUE(mask[ch]);
649 } 656 }
650 657
658 // Verify that the proper reduced search space is configured for playback rate
659 // changes when downmixing is applied to the input with discrete layout.
660 // The default hardware layout is stereo.
661 TEST_F(AudioRendererImplTest, ChannelMask_DownmixDiscreteLayout) {
662 int audio_channels = 6;
DaleCurtis 2017/03/31 19:06:53 Should be impossible to get discrete + 6 channels
flim-chromium 2017/04/05 18:19:34 Thanks for spotting this. It looks like UpmixDiscr
663 AudioDecoderConfig audio_config(
664 kCodecOpus, kSampleFormat, CHANNEL_LAYOUT_DISCRETE,
665 kInputSamplesPerSecond, EmptyExtraData(), Unencrypted());
666 audio_config.SetChannelsForDiscrete(audio_channels);
667 ConfigureChangeDemuxerStream(audio_config);
668
669 Initialize();
670 std::vector<bool> mask = channel_mask();
671 EXPECT_FALSE(mask.empty());
672 ASSERT_EQ(mask.size(), static_cast<size_t>(audio_channels));
673 for (int ch = 0; ch < audio_channels; ++ch)
674 ASSERT_TRUE(mask[ch]);
675
676 // TODO (flim): channel configuration change?
677 }
678
679 // Verify that the proper reduced search space is configured for playback rate
680 // changes when upmixing is applied to the input with discrete layout.
681 TEST_F(AudioRendererImplTest, ChannelMask_UpmixDiscreteLayout) {
682 AudioParameters hw_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
683 CHANNEL_LAYOUT_7_1, kOutputSamplesPerSecond,
684 SampleFormatToBytesPerChannel(kSampleFormat) * 8,
685 1024);
686 ConfigureConfigChangeRenderer(
687 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
688 CHANNEL_LAYOUT_DISCRETE, kOutputSamplesPerSecond,
689 SampleFormatToBytesPerChannel(kSampleFormat) * 8, 1024),
690 hw_params);
691
692 AudioDecoderConfig audio_config(
693 kCodecOpus, kSampleFormat, CHANNEL_LAYOUT_DISCRETE,
694 kInputSamplesPerSecond, EmptyExtraData(), Unencrypted());
695 audio_config.SetChannelsForDiscrete(4);
696 ConfigureChangeDemuxerStream(audio_config);
697
698 Initialize();
699 std::vector<bool> mask = channel_mask();
700 EXPECT_FALSE(mask.empty());
701 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
702 for (int ch = 0; ch < hw_params.channels(); ++ch) {
703 if (ch > 3)
704 ASSERT_FALSE(mask[ch]);
705 else
706 ASSERT_TRUE(mask[ch]);
707 }
708
709 // TODO (flim): channel configuration change?
710 }
711
651 TEST_F(AudioRendererImplTest, Underflow_Flush) { 712 TEST_F(AudioRendererImplTest, Underflow_Flush) {
652 Initialize(); 713 Initialize();
653 Preroll(); 714 Preroll();
654 StartTicking(); 715 StartTicking();
655 716
656 // Force underflow. 717 // Force underflow.
657 EXPECT_TRUE(ConsumeBufferedData(frames_buffered())); 718 EXPECT_TRUE(ConsumeBufferedData(frames_buffered()));
658 WaitForPendingRead(); 719 WaitForPendingRead();
659 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); 720 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
660 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1))); 721 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1)));
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 // Advance far enough that we shouldn't be clamped to current time (tested 1124 // Advance far enough that we shouldn't be clamped to current time (tested
1064 // already above). 1125 // already above).
1065 tick_clock_->Advance(kOneSecond); 1126 tick_clock_->Advance(kOneSecond);
1066 EXPECT_EQ( 1127 EXPECT_EQ(
1067 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), 1128 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value),
1068 CurrentMediaWallClockTime(&is_time_moving)); 1129 CurrentMediaWallClockTime(&is_time_moving));
1069 EXPECT_TRUE(is_time_moving); 1130 EXPECT_TRUE(is_time_moving);
1070 } 1131 }
1071 1132
1072 } // namespace media 1133 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698