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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 1741933002: Prevent a voice channel from sending data before a renderer is set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modifying copyright header to satisfy presubmit bot. Created 4 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
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 23 matching lines...) Expand all
34 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); 34 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0);
35 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); 35 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0);
36 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); 36 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0);
37 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); 37 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0);
38 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); 38 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
39 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); 39 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
40 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); 40 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0);
41 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, 41 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0,
42 1, 0); 42 1, 0);
43 const uint32_t kSsrc1 = 0x99; 43 const uint32_t kSsrc1 = 0x99;
44 const uint32_t kSsrc2 = 0x98; 44 const uint32_t kSsrc2 = 2;
45 const uint32_t kSsrc3 = 3;
45 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; 46 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 };
46 47
47 class FakeVoEWrapper : public cricket::VoEWrapper { 48 class FakeVoEWrapper : public cricket::VoEWrapper {
48 public: 49 public:
49 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) 50 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine)
50 : cricket::VoEWrapper(engine, // processing 51 : cricket::VoEWrapper(engine, // processing
51 engine, // base 52 engine, // base
52 engine, // codec 53 engine, // codec
53 engine, // hw 54 engine, // hw
54 engine, // network 55 engine, // network
55 engine, // rtp 56 engine, // rtp
56 engine) { // volume 57 engine) { // volume
57 } 58 }
58 }; 59 };
59 } // namespace 60 } // namespace
60 61
61 class FakeAudioSink : public webrtc::AudioSinkInterface { 62 class FakeAudioSink : public webrtc::AudioSinkInterface {
62 public: 63 public:
63 void OnData(const Data& audio) override {} 64 void OnData(const Data& audio) override {}
64 }; 65 };
65 66
67 class FakeAudioSource : public cricket::AudioSource {
68 void SetSink(Sink* sink) override {}
69 };
70
66 class WebRtcVoiceEngineTestFake : public testing::Test { 71 class WebRtcVoiceEngineTestFake : public testing::Test {
67 public: 72 public:
68 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} 73 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {}
69 74
70 explicit WebRtcVoiceEngineTestFake(const char* field_trials) 75 explicit WebRtcVoiceEngineTestFake(const char* field_trials)
71 : call_(webrtc::Call::Config()), 76 : call_(webrtc::Call::Config()),
72 engine_(new FakeVoEWrapper(&voe_)), 77 engine_(new FakeVoEWrapper(&voe_)),
73 channel_(nullptr), 78 channel_(nullptr),
74 override_field_trials_(field_trials) { 79 override_field_trials_(field_trials) {
75 send_parameters_.codecs.push_back(kPcmuCodec); 80 send_parameters_.codecs.push_back(kPcmuCodec);
(...skipping 11 matching lines...) Expand all
87 if (!SetupEngine()) { 92 if (!SetupEngine()) {
88 return false; 93 return false;
89 } 94 }
90 return channel_->AddRecvStream( 95 return channel_->AddRecvStream(
91 cricket::StreamParams::CreateLegacy(kSsrc1)); 96 cricket::StreamParams::CreateLegacy(kSsrc1));
92 } 97 }
93 bool SetupEngineWithSendStream() { 98 bool SetupEngineWithSendStream() {
94 if (!SetupEngine()) { 99 if (!SetupEngine()) {
95 return false; 100 return false;
96 } 101 }
97 return channel_->AddSendStream( 102 if (!channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc1))) {
98 cricket::StreamParams::CreateLegacy(kSsrc1)); 103 return false;
104 }
105 return channel_->SetAudioSend(kSsrc1, true, nullptr, &fake_source_);
99 } 106 }
100 void SetupForMultiSendStream() { 107 void SetupForMultiSendStream() {
101 EXPECT_TRUE(SetupEngineWithSendStream()); 108 EXPECT_TRUE(SetupEngineWithSendStream());
102 // Remove stream added in Setup. 109 // Remove stream added in Setup.
103 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); 110 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1));
104 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); 111 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1));
105 // Verify the channel does not exist. 112 // Verify the channel does not exist.
106 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1)); 113 EXPECT_FALSE(call_.GetAudioSendStream(kSsrc1));
107 } 114 }
108 void DeliverPacket(const void* data, int len) { 115 void DeliverPacket(const void* data, int len) {
(...skipping 11 matching lines...) Expand all
120 return *send_stream; 127 return *send_stream;
121 } 128 }
122 129
123 const cricket::FakeAudioReceiveStream& GetRecvStream(uint32_t ssrc) { 130 const cricket::FakeAudioReceiveStream& GetRecvStream(uint32_t ssrc) {
124 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc); 131 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc);
125 EXPECT_TRUE(recv_stream); 132 EXPECT_TRUE(recv_stream);
126 return *recv_stream; 133 return *recv_stream;
127 } 134 }
128 135
129 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) { 136 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) {
130 const auto* send_stream = call_.GetAudioSendStream(ssrc); 137 return GetSendStream(ssrc).GetConfig();
131 EXPECT_TRUE(send_stream);
132 return send_stream->GetConfig();
133 } 138 }
134 139
135 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) { 140 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) {
136 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc); 141 return GetRecvStream(ssrc).GetConfig();
137 EXPECT_TRUE(recv_stream);
138 return recv_stream->GetConfig();
139 } 142 }
140 143
141 void TestInsertDtmf(uint32_t ssrc, bool caller) { 144 void TestInsertDtmf(uint32_t ssrc, bool caller) {
142 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 145 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
143 channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), 146 channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(),
144 cricket::AudioOptions()); 147 cricket::AudioOptions());
145 EXPECT_TRUE(channel_ != nullptr); 148 EXPECT_TRUE(channel_ != nullptr);
146 if (caller) { 149 if (caller) {
147 // If this is a caller, local description will be applied and add the 150 // If this is a caller, local description will be applied and add the
148 // send stream. 151 // send stream.
149 EXPECT_TRUE(channel_->AddSendStream( 152 EXPECT_TRUE(channel_->AddSendStream(
150 cricket::StreamParams::CreateLegacy(kSsrc1))); 153 cricket::StreamParams::CreateLegacy(kSsrc1)));
151 } 154 }
152 155
153 // Test we can only InsertDtmf when the other side supports telephone-event. 156 // Test we can only InsertDtmf when the other side supports telephone-event.
154 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 157 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
155 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 158 channel_->SetSend(true);
156 EXPECT_FALSE(channel_->CanInsertDtmf()); 159 EXPECT_FALSE(channel_->CanInsertDtmf());
157 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); 160 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111));
158 send_parameters_.codecs.push_back(kTelephoneEventCodec); 161 send_parameters_.codecs.push_back(kTelephoneEventCodec);
159 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 162 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
160 EXPECT_TRUE(channel_->CanInsertDtmf()); 163 EXPECT_TRUE(channel_->CanInsertDtmf());
161 164
162 if (!caller) { 165 if (!caller) {
163 // If this is callee, there's no active send channel yet. 166 // If this is callee, there's no active send channel yet.
164 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); 167 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123));
165 EXPECT_TRUE(channel_->AddSendStream( 168 EXPECT_TRUE(channel_->AddSendStream(
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms); 397 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms);
395 } 398 }
396 399
397 protected: 400 protected:
398 cricket::FakeCall call_; 401 cricket::FakeCall call_;
399 cricket::FakeWebRtcVoiceEngine voe_; 402 cricket::FakeWebRtcVoiceEngine voe_;
400 cricket::WebRtcVoiceEngine engine_; 403 cricket::WebRtcVoiceEngine engine_;
401 cricket::VoiceMediaChannel* channel_; 404 cricket::VoiceMediaChannel* channel_;
402 cricket::AudioSendParameters send_parameters_; 405 cricket::AudioSendParameters send_parameters_;
403 cricket::AudioRecvParameters recv_parameters_; 406 cricket::AudioRecvParameters recv_parameters_;
407 FakeAudioSource fake_source_;
404 408
405 private: 409 private:
406 webrtc::test::ScopedFieldTrials override_field_trials_; 410 webrtc::test::ScopedFieldTrials override_field_trials_;
407 }; 411 };
408 412
409 // Tests that our stub library "works". 413 // Tests that our stub library "works".
410 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { 414 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) {
411 EXPECT_FALSE(voe_.IsInited()); 415 EXPECT_FALSE(voe_.IsInited());
412 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 416 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
413 EXPECT_TRUE(voe_.IsInited()); 417 EXPECT_TRUE(voe_.IsInited());
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { 1998 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) {
1995 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); 1999 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
1996 } 2000 }
1997 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { 2001 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) {
1998 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); 2002 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
1999 } 2003 }
2000 2004
2001 // Test that we can create a channel and start sending on it. 2005 // Test that we can create a channel and start sending on it.
2002 TEST_F(WebRtcVoiceEngineTestFake, Send) { 2006 TEST_F(WebRtcVoiceEngineTestFake, Send) {
2003 EXPECT_TRUE(SetupEngineWithSendStream()); 2007 EXPECT_TRUE(SetupEngineWithSendStream());
2004 int channel_num = voe_.GetLastChannel();
2005 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2008 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2006 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2009 channel_->SetSend(true);
2007 EXPECT_TRUE(voe_.GetSend(channel_num)); 2010 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
2008 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 2011 channel_->SetSend(false);
2009 EXPECT_FALSE(voe_.GetSend(channel_num)); 2012 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
2013 }
2014
2015 // Test that a channel will send if and only if it has a source and is enabled
2016 // for sending.
2017 TEST_F(WebRtcVoiceEngineTestFake, SendStateWithAndWithoutSource) {
2018 EXPECT_TRUE(SetupEngineWithSendStream());
2019 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2020 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2021 channel_->SetSend(true);
2022 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
2023 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, nullptr, &fake_source_));
2024 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
2025 EXPECT_TRUE(channel_->SetAudioSend(kSsrc1, true, nullptr, nullptr));
2026 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
2010 } 2027 }
2011 2028
2012 // Test that we can create a channel and start playing out on it. 2029 // Test that we can create a channel and start playing out on it.
2013 TEST_F(WebRtcVoiceEngineTestFake, Playout) { 2030 TEST_F(WebRtcVoiceEngineTestFake, Playout) {
2014 EXPECT_TRUE(SetupEngineWithRecvStream()); 2031 EXPECT_TRUE(SetupEngineWithRecvStream());
2015 int channel_num = voe_.GetLastChannel(); 2032 int channel_num = voe_.GetLastChannel();
2016 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 2033 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2017 EXPECT_TRUE(channel_->SetPlayout(true)); 2034 EXPECT_TRUE(channel_->SetPlayout(true));
2018 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 2035 EXPECT_TRUE(voe_.GetPlayout(channel_num));
2019 EXPECT_TRUE(channel_->SetPlayout(false)); 2036 EXPECT_TRUE(channel_->SetPlayout(false));
2020 EXPECT_FALSE(voe_.GetPlayout(channel_num)); 2037 EXPECT_FALSE(voe_.GetPlayout(channel_num));
2021 } 2038 }
2022 2039
2023 // Test that we can add and remove send streams. 2040 // Test that we can add and remove send streams.
2024 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { 2041 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) {
2025 SetupForMultiSendStream(); 2042 SetupForMultiSendStream();
2026 2043
2027 // Set the global state for sending. 2044 // Set the global state for sending.
2028 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2045 channel_->SetSend(true);
2029 2046
2030 for (uint32_t ssrc : kSsrcs4) { 2047 for (uint32_t ssrc : kSsrcs4) {
2031 EXPECT_TRUE(channel_->AddSendStream( 2048 EXPECT_TRUE(channel_->AddSendStream(
2032 cricket::StreamParams::CreateLegacy(ssrc))); 2049 cricket::StreamParams::CreateLegacy(ssrc)));
2050 EXPECT_TRUE(channel_->SetAudioSend(ssrc, true, nullptr, &fake_source_));
2033 // Verify that we are in a sending state for all the created streams. 2051 // Verify that we are in a sending state for all the created streams.
2034 EXPECT_TRUE(voe_.GetSend(GetSendStreamConfig(ssrc).voe_channel_id)); 2052 EXPECT_TRUE(GetSendStream(ssrc).IsSending());
2035 } 2053 }
2036 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size()); 2054 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size());
2037 2055
2038 // Delete the send streams. 2056 // Delete the send streams.
2039 for (uint32_t ssrc : kSsrcs4) { 2057 for (uint32_t ssrc : kSsrcs4) {
2040 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); 2058 EXPECT_TRUE(channel_->RemoveSendStream(ssrc));
2041 EXPECT_FALSE(call_.GetAudioSendStream(ssrc)); 2059 EXPECT_FALSE(call_.GetAudioSendStream(ssrc));
2042 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); 2060 EXPECT_FALSE(channel_->RemoveSendStream(ssrc));
2043 } 2061 }
2044 EXPECT_EQ(0u, call_.GetAudioSendStreams().size()); 2062 EXPECT_EQ(0u, call_.GetAudioSendStreams().size());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 2097 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2080 EXPECT_STREQ("PCMU", gcodec.plname); 2098 EXPECT_STREQ("PCMU", gcodec.plname);
2081 EXPECT_FALSE(voe_.GetVAD(channel_num)); 2099 EXPECT_FALSE(voe_.GetVAD(channel_num));
2082 } 2100 }
2083 } 2101 }
2084 2102
2085 // Test we can SetSend on all send streams correctly. 2103 // Test we can SetSend on all send streams correctly.
2086 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { 2104 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) {
2087 SetupForMultiSendStream(); 2105 SetupForMultiSendStream();
2088 2106
2089 // Create the send channels and they should be a SEND_NOTHING date. 2107 // Create the send channels and they should be a "not sending" date.
2090 for (uint32_t ssrc : kSsrcs4) { 2108 for (uint32_t ssrc : kSsrcs4) {
2091 EXPECT_TRUE(channel_->AddSendStream( 2109 EXPECT_TRUE(channel_->AddSendStream(
2092 cricket::StreamParams::CreateLegacy(ssrc))); 2110 cricket::StreamParams::CreateLegacy(ssrc)));
2093 int channel_num = voe_.GetLastChannel(); 2111 EXPECT_TRUE(channel_->SetAudioSend(ssrc, true, nullptr, &fake_source_));
2094 EXPECT_FALSE(voe_.GetSend(channel_num)); 2112 EXPECT_FALSE(GetSendStream(ssrc).IsSending());
2095 } 2113 }
2096 2114
2097 // Set the global state for starting sending. 2115 // Set the global state for starting sending.
2098 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2116 channel_->SetSend(true);
2099 for (uint32_t ssrc : kSsrcs4) { 2117 for (uint32_t ssrc : kSsrcs4) {
2100 // Verify that we are in a sending state for all the send streams. 2118 // Verify that we are in a sending state for all the send streams.
2101 int channel_num = GetSendStreamConfig(ssrc).voe_channel_id; 2119 EXPECT_TRUE(GetSendStream(ssrc).IsSending());
2102 EXPECT_TRUE(voe_.GetSend(channel_num));
2103 } 2120 }
2104 2121
2105 // Set the global state for stopping sending. 2122 // Set the global state for stopping sending.
2106 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 2123 channel_->SetSend(false);
2107 for (uint32_t ssrc : kSsrcs4) { 2124 for (uint32_t ssrc : kSsrcs4) {
2108 // Verify that we are in a stop state for all the send streams. 2125 // Verify that we are in a stop state for all the send streams.
2109 int channel_num = GetSendStreamConfig(ssrc).voe_channel_id; 2126 EXPECT_FALSE(GetSendStream(ssrc).IsSending());
2110 EXPECT_FALSE(voe_.GetSend(channel_num));
2111 } 2127 }
2112 } 2128 }
2113 2129
2114 // Test we can set the correct statistics on all send streams. 2130 // Test we can set the correct statistics on all send streams.
2115 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { 2131 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
2116 SetupForMultiSendStream(); 2132 SetupForMultiSendStream();
2117 2133
2118 // Create send streams. 2134 // Create send streams.
2119 for (uint32_t ssrc : kSsrcs4) { 2135 for (uint32_t ssrc : kSsrcs4) {
2120 EXPECT_TRUE(channel_->AddSendStream( 2136 EXPECT_TRUE(channel_->AddSendStream(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { 2189 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
2174 EXPECT_TRUE(SetupEngineWithSendStream()); 2190 EXPECT_TRUE(SetupEngineWithSendStream());
2175 int channel_num1 = voe_.GetLastChannel(); 2191 int channel_num1 = voe_.GetLastChannel();
2176 2192
2177 // Start playout without a receive stream. 2193 // Start playout without a receive stream.
2178 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2194 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2179 EXPECT_TRUE(channel_->SetPlayout(true)); 2195 EXPECT_TRUE(channel_->SetPlayout(true));
2180 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2196 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2181 2197
2182 // Adding another stream should enable playout on the new stream only. 2198 // Adding another stream should enable playout on the new stream only.
2183 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2199 EXPECT_TRUE(
2200 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc2)));
2184 int channel_num2 = voe_.GetLastChannel(); 2201 int channel_num2 = voe_.GetLastChannel();
2185 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2202 channel_->SetSend(true);
2186 EXPECT_TRUE(voe_.GetSend(channel_num1)); 2203 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
2187 EXPECT_FALSE(voe_.GetSend(channel_num2));
2188 2204
2189 // Make sure only the new stream is played out. 2205 // Make sure only the new stream is played out.
2190 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2206 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2191 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); 2207 EXPECT_TRUE(voe_.GetPlayout(channel_num2));
2192 2208
2193 // Adding yet another stream should have stream 2 and 3 enabled for playout. 2209 // Adding yet another stream should have stream 2 and 3 enabled for playout.
2194 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2210 EXPECT_TRUE(
2211 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc3)));
2195 int channel_num3 = voe_.GetLastChannel(); 2212 int channel_num3 = voe_.GetLastChannel();
2196 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2213 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2197 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); 2214 EXPECT_TRUE(voe_.GetPlayout(channel_num2));
2198 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); 2215 EXPECT_TRUE(voe_.GetPlayout(channel_num3));
2199 EXPECT_FALSE(voe_.GetSend(channel_num3));
2200 2216
2201 // Stop sending. 2217 // Stop sending.
2202 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 2218 channel_->SetSend(false);
2203 EXPECT_FALSE(voe_.GetSend(channel_num1)); 2219 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
2204 EXPECT_FALSE(voe_.GetSend(channel_num2));
2205 EXPECT_FALSE(voe_.GetSend(channel_num3));
2206 2220
2207 // Stop playout. 2221 // Stop playout.
2208 EXPECT_TRUE(channel_->SetPlayout(false)); 2222 EXPECT_TRUE(channel_->SetPlayout(false));
2209 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2223 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2210 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); 2224 EXPECT_FALSE(voe_.GetPlayout(channel_num2));
2211 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); 2225 EXPECT_FALSE(voe_.GetPlayout(channel_num3));
2212 2226
2213 // Restart playout and make sure only recv streams are played out. 2227 // Restart playout and make sure only recv streams are played out.
2214 EXPECT_TRUE(channel_->SetPlayout(true)); 2228 EXPECT_TRUE(channel_->SetPlayout(true));
2215 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2229 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2216 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); 2230 EXPECT_TRUE(voe_.GetPlayout(channel_num2));
2217 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); 2231 EXPECT_TRUE(voe_.GetPlayout(channel_num3));
2218 2232
2219 // Now remove the recv streams and verify that the send stream doesn't play. 2233 // Now remove the recv streams and verify that the send stream doesn't play.
2220 EXPECT_TRUE(channel_->RemoveRecvStream(3)); 2234 EXPECT_TRUE(channel_->RemoveRecvStream(3));
2221 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 2235 EXPECT_TRUE(channel_->RemoveRecvStream(2));
2222 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2236 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2223 } 2237 }
2224 2238
2225 // Test that we can create a channel configured for Codian bridges, 2239 // Test that we can create a channel configured for Codian bridges,
2226 // and start sending on it. 2240 // and start sending on it.
2227 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { 2241 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) {
2228 EXPECT_TRUE(SetupEngineWithSendStream()); 2242 EXPECT_TRUE(SetupEngineWithSendStream());
2229 cricket::AudioOptions options_adjust_agc; 2243 cricket::AudioOptions options_adjust_agc;
2230 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); 2244 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10);
2231 int channel_num = voe_.GetLastChannel();
2232 webrtc::AgcConfig agc_config; 2245 webrtc::AgcConfig agc_config;
2233 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2246 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2234 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2247 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2235 send_parameters_.options = options_adjust_agc; 2248 send_parameters_.options = options_adjust_agc;
2236 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2249 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2237 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2250 channel_->SetSend(true);
2238 EXPECT_TRUE(voe_.GetSend(channel_num)); 2251 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
2239 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2252 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2240 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated 2253 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated
2241 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 2254 channel_->SetSend(false);
2242 EXPECT_FALSE(voe_.GetSend(channel_num)); 2255 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
2243 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2256 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2244 } 2257 }
2245 2258
2246 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { 2259 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) {
2247 EXPECT_TRUE(SetupEngineWithSendStream()); 2260 EXPECT_TRUE(SetupEngineWithSendStream());
2248 webrtc::AgcConfig agc_config; 2261 webrtc::AgcConfig agc_config;
2249 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2262 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2250 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2263 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2251 send_parameters_.options.tx_agc_target_dbov = rtc::Optional<uint16_t>(3); 2264 send_parameters_.options.tx_agc_target_dbov = rtc::Optional<uint16_t>(3);
2252 send_parameters_.options.tx_agc_digital_compression_gain = 2265 send_parameters_.options.tx_agc_digital_compression_gain =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 EXPECT_EQ(1u, info.senders.size()); 2321 EXPECT_EQ(1u, info.senders.size());
2309 VerifyVoiceSenderInfo(info.senders[0], false); 2322 VerifyVoiceSenderInfo(info.senders[0], false);
2310 // We have added one receive stream. We should see empty stats. 2323 // We have added one receive stream. We should see empty stats.
2311 EXPECT_EQ(info.receivers.size(), 1u); 2324 EXPECT_EQ(info.receivers.size(), 1u);
2312 EXPECT_EQ(info.receivers[0].ssrc(), 0); 2325 EXPECT_EQ(info.receivers[0].ssrc(), 0);
2313 } 2326 }
2314 2327
2315 // Start sending - this affects some reported stats. 2328 // Start sending - this affects some reported stats.
2316 { 2329 {
2317 cricket::VoiceMediaInfo info; 2330 cricket::VoiceMediaInfo info;
2318 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2331 channel_->SetSend(true);
2319 EXPECT_EQ(true, channel_->GetStats(&info)); 2332 EXPECT_EQ(true, channel_->GetStats(&info));
2320 VerifyVoiceSenderInfo(info.senders[0], true); 2333 VerifyVoiceSenderInfo(info.senders[0], true);
2321 } 2334 }
2322 2335
2323 // Remove the kSsrc2 stream. No receiver stats. 2336 // Remove the kSsrc2 stream. No receiver stats.
2324 { 2337 {
2325 cricket::VoiceMediaInfo info; 2338 cricket::VoiceMediaInfo info;
2326 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); 2339 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
2327 EXPECT_EQ(true, channel_->GetStats(&info)); 2340 EXPECT_EQ(true, channel_->GetStats(&info));
2328 EXPECT_EQ(1u, info.senders.size()); 2341 EXPECT_EQ(1u, info.senders.size());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 } 2580 }
2568 2581
2569 // Test the InsertDtmf on specified send stream as callee. 2582 // Test the InsertDtmf on specified send stream as callee.
2570 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { 2583 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
2571 TestInsertDtmf(kSsrc1, false); 2584 TestInsertDtmf(kSsrc1, false);
2572 } 2585 }
2573 2586
2574 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { 2587 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
2575 EXPECT_TRUE(SetupEngineWithSendStream()); 2588 EXPECT_TRUE(SetupEngineWithSendStream());
2576 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2589 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2577 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2590 channel_->SetSend(true);
2578 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2591 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2579 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2592 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
2580 EXPECT_TRUE(channel_->SetPlayout(true)); 2593 EXPECT_TRUE(channel_->SetPlayout(true));
2581 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); 2594 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1);
2582 EXPECT_TRUE(channel_->SetPlayout(false)); 2595 EXPECT_TRUE(channel_->SetPlayout(false));
2583 EXPECT_FALSE(channel_->SetPlayout(true)); 2596 EXPECT_FALSE(channel_->SetPlayout(true));
2584 } 2597 }
2585 2598
2586 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { 2599 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
2587 EXPECT_TRUE(SetupEngineWithSendStream()); 2600 EXPECT_TRUE(SetupEngineWithSendStream());
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 webrtc::AgcModes agc_mode; 2850 webrtc::AgcModes agc_mode;
2838 bool ns_enabled; 2851 bool ns_enabled;
2839 webrtc::NsModes ns_mode; 2852 webrtc::NsModes ns_mode;
2840 voe_.GetEcStatus(ec_enabled, ec_mode); 2853 voe_.GetEcStatus(ec_enabled, ec_mode);
2841 voe_.GetAgcStatus(agc_enabled, agc_mode); 2854 voe_.GetAgcStatus(agc_enabled, agc_mode);
2842 voe_.GetNsStatus(ns_enabled, ns_mode); 2855 voe_.GetNsStatus(ns_enabled, ns_mode);
2843 EXPECT_TRUE(ec_enabled); 2856 EXPECT_TRUE(ec_enabled);
2844 EXPECT_TRUE(agc_enabled); 2857 EXPECT_TRUE(agc_enabled);
2845 EXPECT_TRUE(ns_enabled); 2858 EXPECT_TRUE(ns_enabled);
2846 2859
2847 channel1->SetSend(cricket::SEND_MICROPHONE); 2860 channel1->SetSend(true);
2848 voe_.GetEcStatus(ec_enabled, ec_mode); 2861 voe_.GetEcStatus(ec_enabled, ec_mode);
2849 voe_.GetAgcStatus(agc_enabled, agc_mode); 2862 voe_.GetAgcStatus(agc_enabled, agc_mode);
2850 voe_.GetNsStatus(ns_enabled, ns_mode); 2863 voe_.GetNsStatus(ns_enabled, ns_mode);
2851 EXPECT_TRUE(ec_enabled); 2864 EXPECT_TRUE(ec_enabled);
2852 EXPECT_TRUE(agc_enabled); 2865 EXPECT_TRUE(agc_enabled);
2853 EXPECT_FALSE(ns_enabled); 2866 EXPECT_FALSE(ns_enabled);
2854 2867
2855 channel2->SetSend(cricket::SEND_MICROPHONE); 2868 channel2->SetSend(true);
2856 voe_.GetEcStatus(ec_enabled, ec_mode); 2869 voe_.GetEcStatus(ec_enabled, ec_mode);
2857 voe_.GetAgcStatus(agc_enabled, agc_mode); 2870 voe_.GetAgcStatus(agc_enabled, agc_mode);
2858 voe_.GetNsStatus(ns_enabled, ns_mode); 2871 voe_.GetNsStatus(ns_enabled, ns_mode);
2859 EXPECT_TRUE(ec_enabled); 2872 EXPECT_TRUE(ec_enabled);
2860 EXPECT_FALSE(agc_enabled); 2873 EXPECT_FALSE(agc_enabled);
2861 EXPECT_TRUE(ns_enabled); 2874 EXPECT_TRUE(ns_enabled);
2862 2875
2863 // Make sure settings take effect while we are sending. 2876 // Make sure settings take effect while we are sending.
2864 ASSERT_TRUE(channel_->SetSendParameters(parameters_options_all)); 2877 ASSERT_TRUE(channel_->SetSendParameters(parameters_options_all));
2865 cricket::AudioSendParameters parameters_options_no_agc_nor_ns = 2878 cricket::AudioSendParameters parameters_options_no_agc_nor_ns =
2866 send_parameters_; 2879 send_parameters_;
2867 parameters_options_no_agc_nor_ns.options.auto_gain_control = 2880 parameters_options_no_agc_nor_ns.options.auto_gain_control =
2868 rtc::Optional<bool>(false); 2881 rtc::Optional<bool>(false);
2869 parameters_options_no_agc_nor_ns.options.noise_suppression = 2882 parameters_options_no_agc_nor_ns.options.noise_suppression =
2870 rtc::Optional<bool>(false); 2883 rtc::Optional<bool>(false);
2871 channel2->SetSend(cricket::SEND_MICROPHONE); 2884 channel2->SetSend(true);
2872 channel2->SetSendParameters(parameters_options_no_agc_nor_ns); 2885 channel2->SetSendParameters(parameters_options_no_agc_nor_ns);
2873 expected_options.echo_cancellation = rtc::Optional<bool>(true); 2886 expected_options.echo_cancellation = rtc::Optional<bool>(true);
2874 expected_options.auto_gain_control = rtc::Optional<bool>(false); 2887 expected_options.auto_gain_control = rtc::Optional<bool>(false);
2875 expected_options.noise_suppression = rtc::Optional<bool>(false); 2888 expected_options.noise_suppression = rtc::Optional<bool>(false);
2876 EXPECT_EQ(expected_options, channel2->options()); 2889 EXPECT_EQ(expected_options, channel2->options());
2877 voe_.GetEcStatus(ec_enabled, ec_mode); 2890 voe_.GetEcStatus(ec_enabled, ec_mode);
2878 voe_.GetAgcStatus(agc_enabled, agc_mode); 2891 voe_.GetAgcStatus(agc_enabled, agc_mode);
2879 voe_.GetNsStatus(ns_enabled, ns_mode); 2892 voe_.GetNsStatus(ns_enabled, ns_mode);
2880 EXPECT_TRUE(ec_enabled); 2893 EXPECT_TRUE(ec_enabled);
2881 EXPECT_FALSE(agc_enabled); 2894 EXPECT_FALSE(agc_enabled);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 cricket::WebRtcVoiceEngine engine; 3305 cricket::WebRtcVoiceEngine engine;
3293 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3306 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3294 std::unique_ptr<webrtc::Call> call( 3307 std::unique_ptr<webrtc::Call> call(
3295 webrtc::Call::Create(webrtc::Call::Config())); 3308 webrtc::Call::Create(webrtc::Call::Config()));
3296 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3309 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3297 cricket::AudioOptions(), call.get()); 3310 cricket::AudioOptions(), call.get());
3298 cricket::AudioRecvParameters parameters; 3311 cricket::AudioRecvParameters parameters;
3299 parameters.codecs = engine.codecs(); 3312 parameters.codecs = engine.codecs();
3300 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3313 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3301 } 3314 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698