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

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

Issue 1454073002: Move some receive stream configuration into webrtc::AudioReceiveStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 delete channel_; 137 delete channel_;
138 engine_.Terminate(); 138 engine_.Terminate();
139 } 139 }
140 140
141 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) { 141 const webrtc::AudioSendStream::Config& GetSendStreamConfig(uint32_t ssrc) {
142 const auto* send_stream = call_.GetAudioSendStream(ssrc); 142 const auto* send_stream = call_.GetAudioSendStream(ssrc);
143 EXPECT_TRUE(send_stream); 143 EXPECT_TRUE(send_stream);
144 return send_stream->GetConfig(); 144 return send_stream->GetConfig();
145 } 145 }
146 146
147 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) {
148 const auto* recv_stream = call_.GetAudioReceiveStream(ssrc);
149 EXPECT_TRUE(recv_stream);
150 return recv_stream->GetConfig();
151 }
152
147 void TestInsertDtmf(uint32_t ssrc, bool caller) { 153 void TestInsertDtmf(uint32_t ssrc, bool caller) {
148 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 154 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
149 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 155 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
150 EXPECT_TRUE(channel_ != nullptr); 156 EXPECT_TRUE(channel_ != nullptr);
151 if (caller) { 157 if (caller) {
152 // If this is a caller, local description will be applied and add the 158 // If this is a caller, local description will be applied and add the
153 // send stream. 159 // send stream.
154 EXPECT_TRUE(channel_->AddSendStream( 160 EXPECT_TRUE(channel_->AddSendStream(
155 cricket::StreamParams::CreateLegacy(kSsrc1))); 161 cricket::StreamParams::CreateLegacy(kSsrc1)));
156 } 162 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Ensure all extensions go back off with an empty list. 257 // Ensure all extensions go back off with an empty list.
252 send_parameters_.codecs.push_back(kPcmuCodec); 258 send_parameters_.codecs.push_back(kPcmuCodec);
253 send_parameters_.extensions.clear(); 259 send_parameters_.extensions.clear();
254 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 260 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
255 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size()); 261 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size());
256 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc2).rtp.extensions.size()); 262 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc2).rtp.extensions.size());
257 } 263 }
258 264
259 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { 265 void TestSetRecvRtpHeaderExtensions(const std::string& ext) {
260 EXPECT_TRUE(SetupEngineWithRecvStream()); 266 EXPECT_TRUE(SetupEngineWithRecvStream());
261 int channel_num = voe_.GetLastChannel();
262 267
263 // Ensure extensions are off by default. 268 // Ensure extensions are off by default.
264 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 269 EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size());
265 270
266 cricket::AudioRecvParameters parameters;
267 // Ensure unknown extensions won't cause an error. 271 // Ensure unknown extensions won't cause an error.
268 parameters.extensions.push_back(cricket::RtpHeaderExtension( 272 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension(
269 "urn:ietf:params:unknownextention", 1)); 273 "urn:ietf:params:unknownextention", 1));
270 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 274 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
271 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 275 EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size());
272 276
273 // Ensure extensions stay off with an empty list of headers. 277 // Ensure extensions stay off with an empty list of headers.
274 parameters.extensions.clear(); 278 recv_parameters_.extensions.clear();
275 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 279 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
276 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 280 EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size());
277 281
278 // Ensure extension is set properly. 282 // Ensure extension is set properly.
279 const int id = 2; 283 const int id = 2;
280 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); 284 recv_parameters_.extensions.push_back(cricket::RtpHeaderExtension(ext, id));
281 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 285 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
282 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 286 EXPECT_EQ(1u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size());
287 EXPECT_EQ(ext, GetRecvStreamConfig(kSsrc1).rtp.extensions[0].name);
288 EXPECT_EQ(id, GetRecvStreamConfig(kSsrc1).rtp.extensions[0].id);
283 289
284 // Ensure extension is set properly on new channel. 290 // Ensure extension is set properly on new channel.
hlundin-webrtc 2015/11/20 12:59:21 channel -> stream
the sun 2015/11/20 14:24:09 Done.
285 // The first stream to occupy the default channel.
286 EXPECT_TRUE(channel_->AddRecvStream( 291 EXPECT_TRUE(channel_->AddRecvStream(
287 cricket::StreamParams::CreateLegacy(kSsrc2))); 292 cricket::StreamParams::CreateLegacy(kSsrc2)));
288 int new_channel_num = voe_.GetLastChannel(); 293 EXPECT_NE(call_.GetAudioReceiveStream(kSsrc1),
289 EXPECT_NE(channel_num, new_channel_num); 294 call_.GetAudioReceiveStream(kSsrc2));
290 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 295 EXPECT_EQ(1u, GetRecvStreamConfig(kSsrc2).rtp.extensions.size());
296 EXPECT_EQ(ext, GetRecvStreamConfig(kSsrc2).rtp.extensions[0].name);
297 EXPECT_EQ(id, GetRecvStreamConfig(kSsrc2).rtp.extensions[0].id);
291 298
292 // Ensure all extensions go back off with an empty list. 299 // Ensure all extensions go back off with an empty list.
293 parameters.extensions.clear(); 300 recv_parameters_.extensions.clear();
294 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 301 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
295 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 302 EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc1).rtp.extensions.size());
296 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 303 EXPECT_EQ(0u, GetRecvStreamConfig(kSsrc2).rtp.extensions.size());
297 } 304 }
298 305
299 webrtc::AudioSendStream::Stats GetAudioSendStreamStats() const { 306 webrtc::AudioSendStream::Stats GetAudioSendStreamStats() const {
300 webrtc::AudioSendStream::Stats stats; 307 webrtc::AudioSendStream::Stats stats;
301 stats.local_ssrc = 12; 308 stats.local_ssrc = 12;
302 stats.bytes_sent = 345; 309 stats.bytes_sent = 345;
303 stats.packets_sent = 678; 310 stats.packets_sent = 678;
304 stats.packets_lost = 9012; 311 stats.packets_lost = 9012;
305 stats.fraction_lost = 34.56f; 312 stats.fraction_lost = 34.56f;
306 stats.codec_name = "codec_name_send"; 313 stats.codec_name = "codec_name_send";
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 EXPECT_EQ(1u, info.receivers.size()); 2402 EXPECT_EQ(1u, info.receivers.size());
2396 VerifyVoiceReceiverInfo(info.receivers[0]); 2403 VerifyVoiceReceiverInfo(info.receivers[0]);
2397 } 2404 }
2398 } 2405 }
2399 2406
2400 // Test that we can set the outgoing SSRC properly with multiple streams. 2407 // Test that we can set the outgoing SSRC properly with multiple streams.
2401 // SSRC is set in SetupEngine by calling AddSendStream. 2408 // SSRC is set in SetupEngine by calling AddSendStream.
2402 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { 2409 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) {
2403 EXPECT_TRUE(SetupEngineWithSendStream()); 2410 EXPECT_TRUE(SetupEngineWithSendStream());
2404 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1)); 2411 EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1));
2405 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2412 EXPECT_TRUE(channel_->AddRecvStream(
2406 EXPECT_EQ(kSsrc1, voe_.GetLocalSSRC(voe_.GetLastChannel())); 2413 cricket::StreamParams::CreateLegacy(kSsrc2)));
2414 EXPECT_EQ(kSsrc1, GetRecvStreamConfig(kSsrc2).rtp.local_ssrc);
2407 } 2415 }
2408 2416
2409 // Test that the local SSRC is the same on sending and receiving channels if the 2417 // Test that the local SSRC is the same on sending and receiving channels if the
2410 // receive channel is created before the send channel. 2418 // receive channel is created before the send channel.
2411 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { 2419 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
2412 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 2420 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
2413 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 2421 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
2414 2422
2415 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2423 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2416 int receive_channel_num = voe_.GetLastChannel(); 2424 int receive_channel_num = voe_.GetLastChannel();
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 cricket::WebRtcVoiceEngine engine; 3328 cricket::WebRtcVoiceEngine engine;
3321 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3329 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3322 rtc::scoped_ptr<webrtc::Call> call( 3330 rtc::scoped_ptr<webrtc::Call> call(
3323 webrtc::Call::Create(webrtc::Call::Config())); 3331 webrtc::Call::Create(webrtc::Call::Config()));
3324 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3332 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3325 call.get()); 3333 call.get());
3326 cricket::AudioRecvParameters parameters; 3334 cricket::AudioRecvParameters parameters;
3327 parameters.codecs = engine.codecs(); 3335 parameters.codecs = engine.codecs();
3328 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3336 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3329 } 3337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698