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

Unified Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 2880323002: Move ownership of RtpTransportControllerSendInterface from Call to PeerConnection.
Patch Set: Delete shadowing member variables in BitrateEstimatorTest. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/ortc/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvoiceengine_unittest.cc
diff --git a/webrtc/media/engine/webrtcvoiceengine_unittest.cc b/webrtc/media/engine/webrtcvoiceengine_unittest.cc
index 98a9101811fa7b90bbda8acbe4e24e06ac673ae3..5f3288c3b7622b4cb62316724a57ed1b5bded99a 100644
--- a/webrtc/media/engine/webrtcvoiceengine_unittest.cc
+++ b/webrtc/media/engine/webrtcvoiceengine_unittest.cc
@@ -14,8 +14,10 @@
#include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/byteorder.h"
+#include "webrtc/base/ptr_util.h"
#include "webrtc/base/safe_conversions.h"
#include "webrtc/call/call.h"
+#include "webrtc/call/rtp_transport_controller_send.h"
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
#include "webrtc/media/base/fakemediaengine.h"
#include "webrtc/media/base/fakenetworkinterface.h"
@@ -115,6 +117,29 @@ void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) {
EXPECT_CALL(*adm, BuiltInNSIsAvailable()).WillOnce(Return(false));
EXPECT_CALL(*adm, SetAGC(true)).WillOnce(Return(0));
}
+
+// Helper class to construct and own Call and the RtcEventLog and
+// RtpTransportControllerSend it depends on.
+class CallHelper {
+ public:
+ CallHelper()
+ : rtp_transport_controller_send_(
+ rtc::MakeUnique<webrtc::RtpTransportControllerSend>(
+ webrtc::Clock::GetRealTimeClock(), &event_log_)) {
+ webrtc::Call::Config call_config(&event_log_);
+ call_config.audio_rtp_transport_send = rtp_transport_controller_send_.get();
+ call_config.video_rtp_transport_send = rtp_transport_controller_send_.get();
+ call_config.send_side_cc = rtp_transport_controller_send_->send_side_cc();
+ call_ = rtc::WrapUnique(webrtc::Call::Create(call_config));
+ }
+ webrtc::Call* call() { return call_.get(); }
+ private:
+ webrtc::RtcEventLogNullImpl event_log_;
+ const std::unique_ptr<webrtc::RtpTransportControllerSendInterface>
+ rtp_transport_controller_send_;
+ std::unique_ptr<webrtc::Call> call_;
+};
+
} // namespace
// Tests that our stub library "works".
@@ -3263,11 +3288,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) {
cricket::WebRtcVoiceEngine engine(
nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(),
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr);
- webrtc::RtcEventLogNullImpl event_log;
- std::unique_ptr<webrtc::Call> call(
- webrtc::Call::Create(webrtc::Call::Config(&event_log)));
+ CallHelper call_helper;
cricket::VoiceMediaChannel* channel = engine.CreateChannel(
- call.get(), cricket::MediaConfig(), cricket::AudioOptions());
+ call_helper.call(), cricket::MediaConfig(), cricket::AudioOptions());
EXPECT_TRUE(channel != nullptr);
delete channel;
}
@@ -3284,11 +3307,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
cricket::WebRtcVoiceEngine engine(
&adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(),
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr);
- webrtc::RtcEventLogNullImpl event_log;
- std::unique_ptr<webrtc::Call> call(
- webrtc::Call::Create(webrtc::Call::Config(&event_log)));
+ CallHelper call_helper;
cricket::VoiceMediaChannel* channel = engine.CreateChannel(
- call.get(), cricket::MediaConfig(), cricket::AudioOptions());
+ call_helper.call(), cricket::MediaConfig(), cricket::AudioOptions());
EXPECT_TRUE(channel != nullptr);
delete channel;
}
@@ -3342,15 +3363,13 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
cricket::WebRtcVoiceEngine engine(
nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(),
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr);
- webrtc::RtcEventLogNullImpl event_log;
- std::unique_ptr<webrtc::Call> call(
- webrtc::Call::Create(webrtc::Call::Config(&event_log)));
+ CallHelper call_helper;
cricket::VoiceMediaChannel* channels[32];
int num_channels = 0;
while (num_channels < arraysize(channels)) {
cricket::VoiceMediaChannel* channel = engine.CreateChannel(
- call.get(), cricket::MediaConfig(), cricket::AudioOptions());
+ call_helper.call(), cricket::MediaConfig(), cricket::AudioOptions());
if (!channel)
break;
channels[num_channels++] = channel;
@@ -3376,11 +3395,10 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
cricket::WebRtcVoiceEngine engine(
nullptr, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(),
webrtc::CreateBuiltinAudioDecoderFactory(), nullptr);
- webrtc::RtcEventLogNullImpl event_log;
- std::unique_ptr<webrtc::Call> call(
- webrtc::Call::Create(webrtc::Call::Config(&event_log)));
+ CallHelper call_helper;
cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
- cricket::AudioOptions(), call.get());
+ cricket::AudioOptions(),
+ call_helper.call());
cricket::AudioRecvParameters parameters;
parameters.codecs = engine.recv_codecs();
EXPECT_TRUE(channel.SetRecvParameters(parameters));
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/ortc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698