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

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

Issue 2752323002: Support Opus Ambisonics playback (Closed)
Patch Set: +tests Created 3 years, 9 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;
663 AudioDecoderConfig audio_config(kCodecOpus, kSampleFormat,
664 CHANNEL_LAYOUT_DISCRETE,
665 kInputSamplesPerSecond, EmptyExtraData(),
666 Unencrypted());
667 audio_config.set_channels_for_discrete(audio_channels);
668 ConfigureChangeDemuxerStream(audio_config);
669
670 Initialize();
671 std::vector<bool> mask = channel_mask();
672 EXPECT_FALSE(mask.empty());
673 ASSERT_EQ(mask.size(), static_cast<size_t>(audio_channels));
674 for (int ch = 0; ch < audio_channels; ++ch)
675 ASSERT_TRUE(mask[ch]);
676
677 // TODO (flim): channel configuration change?
678 }
679
680 // Verify that the proper reduced search space is configured for playback rate
681 // changes when upmixing is applied to the input with discrete layout.
682 TEST_F(AudioRendererImplTest, ChannelMask_UpmixDiscreteLayout) {
683 AudioParameters hw_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
684 CHANNEL_LAYOUT_7_1, kOutputSamplesPerSecond,
685 SampleFormatToBytesPerChannel(kSampleFormat) * 8,
686 1024);
687 ConfigureConfigChangeRenderer(
688 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
689 CHANNEL_LAYOUT_DISCRETE, kOutputSamplesPerSecond,
690 SampleFormatToBytesPerChannel(kSampleFormat) * 8, 1024),
691 hw_params);
692
693 AudioDecoderConfig audio_config(kCodecOpus, kSampleFormat,
694 CHANNEL_LAYOUT_DISCRETE,
695 kInputSamplesPerSecond, EmptyExtraData(),
696 Unencrypted());
697 audio_config.set_channels_for_discrete(4);
698 ConfigureChangeDemuxerStream(audio_config);
699
700 Initialize();
701 std::vector<bool> mask = channel_mask();
702 EXPECT_FALSE(mask.empty());
703 ASSERT_EQ(mask.size(), static_cast<size_t>(hw_params.channels()));
704 for (int ch = 0; ch < hw_params.channels(); ++ch) {
705 if (ch > 3)
706 ASSERT_FALSE(mask[ch]);
707 else
708 ASSERT_TRUE(mask[ch]);
709 }
710
711 // TODO (flim): channel configuration change?
712 }
713
651 TEST_F(AudioRendererImplTest, Underflow_Flush) { 714 TEST_F(AudioRendererImplTest, Underflow_Flush) {
652 Initialize(); 715 Initialize();
653 Preroll(); 716 Preroll();
654 StartTicking(); 717 StartTicking();
655 718
656 // Force underflow. 719 // Force underflow.
657 EXPECT_TRUE(ConsumeBufferedData(frames_buffered())); 720 EXPECT_TRUE(ConsumeBufferedData(frames_buffered()));
658 WaitForPendingRead(); 721 WaitForPendingRead();
659 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)); 722 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
660 EXPECT_FALSE(ConsumeBufferedData(OutputFrames(1))); 723 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 1126 // Advance far enough that we shouldn't be clamped to current time (tested
1064 // already above). 1127 // already above).
1065 tick_clock_->Advance(kOneSecond); 1128 tick_clock_->Advance(kOneSecond);
1066 EXPECT_EQ( 1129 EXPECT_EQ(
1067 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value), 1130 current_time + timestamp_helper.GetFrameDuration(frames_to_consume.value),
1068 CurrentMediaWallClockTime(&is_time_moving)); 1131 CurrentMediaWallClockTime(&is_time_moving));
1069 EXPECT_TRUE(is_time_moving); 1132 EXPECT_TRUE(is_time_moving);
1070 } 1133 }
1071 1134
1072 } // namespace media 1135 } // namespace media
OLDNEW
« media/renderers/audio_renderer_impl.cc ('K') | « media/renderers/audio_renderer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698