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

Side by Side Diff: media/cast/sender/audio_sender_unittest.cc

Issue 2113783002: Refactoring: Merge VideoSenderConfig and AudioSenderConfig. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mek's comment. Created 4 years, 5 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/cast/sender/audio_sender.cc ('k') | media/cast/sender/external_video_encoder.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 "media/cast/sender/audio_sender.h" 5 #include "media/cast/sender/audio_sender.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 AudioSenderTest() { 96 AudioSenderTest() {
97 InitializeMediaLibrary(); 97 InitializeMediaLibrary();
98 testing_clock_ = new base::SimpleTestTickClock(); 98 testing_clock_ = new base::SimpleTestTickClock();
99 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); 99 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks());
100 task_runner_ = new FakeSingleThreadTaskRunner(testing_clock_); 100 task_runner_ = new FakeSingleThreadTaskRunner(testing_clock_);
101 cast_environment_ = 101 cast_environment_ =
102 new CastEnvironment(std::unique_ptr<base::TickClock>(testing_clock_), 102 new CastEnvironment(std::unique_ptr<base::TickClock>(testing_clock_),
103 task_runner_, task_runner_, task_runner_); 103 task_runner_, task_runner_, task_runner_);
104 audio_config_.codec = CODEC_AUDIO_OPUS; 104 audio_config_.codec = CODEC_AUDIO_OPUS;
105 audio_config_.use_external_encoder = false; 105 audio_config_.use_external_encoder = false;
106 audio_config_.frequency = kDefaultAudioSamplingRate; 106 audio_config_.rtp_timebase = kDefaultAudioSamplingRate;
107 audio_config_.channels = 2; 107 audio_config_.channels = 2;
108 audio_config_.bitrate = kDefaultAudioEncoderBitrate; 108 audio_config_.max_bitrate = kDefaultAudioEncoderBitrate;
109 audio_config_.rtp_payload_type = RtpPayloadType::AUDIO_OPUS; 109 audio_config_.rtp_payload_type = RtpPayloadType::AUDIO_OPUS;
110 110
111 transport_ = new TestPacketSender(); 111 transport_ = new TestPacketSender();
112 transport_sender_.reset( 112 transport_sender_.reset(
113 new CastTransportImpl(testing_clock_, base::TimeDelta(), 113 new CastTransportImpl(testing_clock_, base::TimeDelta(),
114 base::WrapUnique(new TransportClient()), 114 base::WrapUnique(new TransportClient()),
115 base::WrapUnique(transport_), task_runner_)); 115 base::WrapUnique(transport_), task_runner_));
116 OperationalStatus operational_status = STATUS_UNINITIALIZED; 116 OperationalStatus operational_status = STATUS_UNINITIALIZED;
117 audio_sender_.reset(new AudioSender( 117 audio_sender_.reset(new AudioSender(
118 cast_environment_, 118 cast_environment_,
119 audio_config_, 119 audio_config_,
120 base::Bind(&SaveOperationalStatus, &operational_status), 120 base::Bind(&SaveOperationalStatus, &operational_status),
121 transport_sender_.get())); 121 transport_sender_.get()));
122 task_runner_->RunTasks(); 122 task_runner_->RunTasks();
123 CHECK_EQ(STATUS_INITIALIZED, operational_status); 123 CHECK_EQ(STATUS_INITIALIZED, operational_status);
124 } 124 }
125 125
126 ~AudioSenderTest() override {} 126 ~AudioSenderTest() override {}
127 127
128 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. 128 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
129 TestPacketSender* transport_; // Owned by CastTransport. 129 TestPacketSender* transport_; // Owned by CastTransport.
130 std::unique_ptr<CastTransportImpl> transport_sender_; 130 std::unique_ptr<CastTransportImpl> transport_sender_;
131 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; 131 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_;
132 std::unique_ptr<AudioSender> audio_sender_; 132 std::unique_ptr<AudioSender> audio_sender_;
133 scoped_refptr<CastEnvironment> cast_environment_; 133 scoped_refptr<CastEnvironment> cast_environment_;
134 AudioSenderConfig audio_config_; 134 FrameSenderConfig audio_config_;
135 }; 135 };
136 136
137 TEST_F(AudioSenderTest, Encode20ms) { 137 TEST_F(AudioSenderTest, Encode20ms) {
138 const base::TimeDelta kDuration = base::TimeDelta::FromMilliseconds(20); 138 const base::TimeDelta kDuration = base::TimeDelta::FromMilliseconds(20);
139 std::unique_ptr<AudioBus> bus( 139 std::unique_ptr<AudioBus> bus(
140 TestAudioBusFactory(audio_config_.channels, audio_config_.frequency, 140 TestAudioBusFactory(audio_config_.channels, audio_config_.rtp_timebase,
141 TestAudioBusFactory::kMiddleANoteFreq, 0.5f) 141 TestAudioBusFactory::kMiddleANoteFreq, 0.5f)
142 .NextAudioBus(kDuration)); 142 .NextAudioBus(kDuration));
143 143
144 audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks()); 144 audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks());
145 task_runner_->RunTasks(); 145 task_runner_->RunTasks();
146 EXPECT_LE(1, transport_->number_of_rtp_packets()); 146 EXPECT_LE(1, transport_->number_of_rtp_packets());
147 EXPECT_LE(1, transport_->number_of_rtcp_packets()); 147 EXPECT_LE(1, transport_->number_of_rtcp_packets());
148 } 148 }
149 149
150 TEST_F(AudioSenderTest, RtcpTimer) { 150 TEST_F(AudioSenderTest, RtcpTimer) {
151 const base::TimeDelta kDuration = base::TimeDelta::FromMilliseconds(20); 151 const base::TimeDelta kDuration = base::TimeDelta::FromMilliseconds(20);
152 std::unique_ptr<AudioBus> bus( 152 std::unique_ptr<AudioBus> bus(
153 TestAudioBusFactory(audio_config_.channels, audio_config_.frequency, 153 TestAudioBusFactory(audio_config_.channels, audio_config_.rtp_timebase,
154 TestAudioBusFactory::kMiddleANoteFreq, 0.5f) 154 TestAudioBusFactory::kMiddleANoteFreq, 0.5f)
155 .NextAudioBus(kDuration)); 155 .NextAudioBus(kDuration));
156 156
157 audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks()); 157 audio_sender_->InsertAudio(std::move(bus), testing_clock_->NowTicks());
158 task_runner_->RunTasks(); 158 task_runner_->RunTasks();
159 159
160 // Make sure that we send at least one RTCP packet. 160 // Make sure that we send at least one RTCP packet.
161 base::TimeDelta max_rtcp_timeout = 161 base::TimeDelta max_rtcp_timeout =
162 base::TimeDelta::FromMilliseconds(1 + kRtcpReportIntervalMs * 3 / 2); 162 base::TimeDelta::FromMilliseconds(1 + kRtcpReportIntervalMs * 3 / 2);
163 testing_clock_->Advance(max_rtcp_timeout); 163 testing_clock_->Advance(max_rtcp_timeout);
164 task_runner_->RunTasks(); 164 task_runner_->RunTasks();
165 EXPECT_LE(1, transport_->number_of_rtp_packets()); 165 EXPECT_LE(1, transport_->number_of_rtp_packets());
166 EXPECT_LE(1, transport_->number_of_rtcp_packets()); 166 EXPECT_LE(1, transport_->number_of_rtcp_packets());
167 } 167 }
168 168
169 } // namespace cast 169 } // namespace cast
170 } // namespace media 170 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender.cc ('k') | media/cast/sender/external_video_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698