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

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

Issue 1757683002: Make the audio channel communicate network state changes to the call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added handling for the case where the enum class value is outside of the valid range 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/fakewebrtccall.h ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 receiving_ = false; 226 receiving_ = false;
227 } 227 }
228 228
229 void FakeVideoReceiveStream::SetStats( 229 void FakeVideoReceiveStream::SetStats(
230 const webrtc::VideoReceiveStream::Stats& stats) { 230 const webrtc::VideoReceiveStream::Stats& stats) {
231 stats_ = stats; 231 stats_ = stats;
232 } 232 }
233 233
234 FakeCall::FakeCall(const webrtc::Call::Config& config) 234 FakeCall::FakeCall(const webrtc::Call::Config& config)
235 : config_(config), 235 : config_(config),
236 network_state_(webrtc::kNetworkUp), 236 audio_network_state_(webrtc::kNetworkUp),
237 video_network_state_(webrtc::kNetworkUp),
237 num_created_send_streams_(0), 238 num_created_send_streams_(0),
238 num_created_receive_streams_(0) {} 239 num_created_receive_streams_(0) {}
239 240
240 FakeCall::~FakeCall() { 241 FakeCall::~FakeCall() {
241 EXPECT_EQ(0u, video_send_streams_.size()); 242 EXPECT_EQ(0u, video_send_streams_.size());
242 EXPECT_EQ(0u, audio_send_streams_.size()); 243 EXPECT_EQ(0u, audio_send_streams_.size());
243 EXPECT_EQ(0u, video_receive_streams_.size()); 244 EXPECT_EQ(0u, video_receive_streams_.size());
244 EXPECT_EQ(0u, audio_receive_streams_.size()); 245 EXPECT_EQ(0u, audio_receive_streams_.size());
245 } 246 }
246 247
(...skipping 28 matching lines...) Expand all
275 276
276 const FakeAudioReceiveStream* FakeCall::GetAudioReceiveStream(uint32_t ssrc) { 277 const FakeAudioReceiveStream* FakeCall::GetAudioReceiveStream(uint32_t ssrc) {
277 for (const auto* p : GetAudioReceiveStreams()) { 278 for (const auto* p : GetAudioReceiveStreams()) {
278 if (p->GetConfig().rtp.remote_ssrc == ssrc) { 279 if (p->GetConfig().rtp.remote_ssrc == ssrc) {
279 return p; 280 return p;
280 } 281 }
281 } 282 }
282 return nullptr; 283 return nullptr;
283 } 284 }
284 285
285 webrtc::NetworkState FakeCall::GetNetworkState() const { 286 webrtc::NetworkState FakeCall::GetNetworkState(webrtc::MediaType media) const {
286 return network_state_; 287 switch (media) {
288 case webrtc::MediaType::AUDIO:
289 return audio_network_state_;
290 case webrtc::MediaType::VIDEO:
291 return video_network_state_;
292 case webrtc::MediaType::DATA:
293 case webrtc::MediaType::ANY:
294 ADD_FAILURE() << "GetNetworkState called with unknown parameter.";
295 return webrtc::kNetworkDown;
296 }
297 // Even though all the values for the enum class are listed above,the compiler
298 // will emit a warning as the method may be called with a value outside of the
299 // valid enum range, unless this case is also handled.
300 ADD_FAILURE() << "GetNetworkState called with unknown parameter.";
301 return webrtc::kNetworkDown;
287 } 302 }
288 303
289 webrtc::AudioSendStream* FakeCall::CreateAudioSendStream( 304 webrtc::AudioSendStream* FakeCall::CreateAudioSendStream(
290 const webrtc::AudioSendStream::Config& config) { 305 const webrtc::AudioSendStream::Config& config) {
291 FakeAudioSendStream* fake_stream = new FakeAudioSendStream(config); 306 FakeAudioSendStream* fake_stream = new FakeAudioSendStream(config);
292 audio_send_streams_.push_back(fake_stream); 307 audio_send_streams_.push_back(fake_stream);
293 ++num_created_send_streams_; 308 ++num_created_send_streams_;
294 return fake_stream; 309 return fake_stream;
295 } 310 }
296 311
297 void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { 312 void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
298 auto it = std::find(audio_send_streams_.begin(), 313 auto it = std::find(audio_send_streams_.begin(),
299 audio_send_streams_.end(), 314 audio_send_streams_.end(),
300 static_cast<FakeAudioSendStream*>(send_stream)); 315 static_cast<FakeAudioSendStream*>(send_stream));
301 if (it == audio_send_streams_.end()) { 316 if (it == audio_send_streams_.end()) {
302 ADD_FAILURE() << "DestroyAudioSendStream called with unknown paramter."; 317 ADD_FAILURE() << "DestroyAudioSendStream called with unknown parameter.";
303 } else { 318 } else {
304 delete *it; 319 delete *it;
305 audio_send_streams_.erase(it); 320 audio_send_streams_.erase(it);
306 } 321 }
307 } 322 }
308 323
309 webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream( 324 webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream(
310 const webrtc::AudioReceiveStream::Config& config) { 325 const webrtc::AudioReceiveStream::Config& config) {
311 audio_receive_streams_.push_back(new FakeAudioReceiveStream(config)); 326 audio_receive_streams_.push_back(new FakeAudioReceiveStream(config));
312 ++num_created_receive_streams_; 327 ++num_created_receive_streams_;
313 return audio_receive_streams_.back(); 328 return audio_receive_streams_.back();
314 } 329 }
315 330
316 void FakeCall::DestroyAudioReceiveStream( 331 void FakeCall::DestroyAudioReceiveStream(
317 webrtc::AudioReceiveStream* receive_stream) { 332 webrtc::AudioReceiveStream* receive_stream) {
318 auto it = std::find(audio_receive_streams_.begin(), 333 auto it = std::find(audio_receive_streams_.begin(),
319 audio_receive_streams_.end(), 334 audio_receive_streams_.end(),
320 static_cast<FakeAudioReceiveStream*>(receive_stream)); 335 static_cast<FakeAudioReceiveStream*>(receive_stream));
321 if (it == audio_receive_streams_.end()) { 336 if (it == audio_receive_streams_.end()) {
322 ADD_FAILURE() << "DestroyAudioReceiveStream called with unknown paramter."; 337 ADD_FAILURE() << "DestroyAudioReceiveStream called with unknown parameter.";
323 } else { 338 } else {
324 delete *it; 339 delete *it;
325 audio_receive_streams_.erase(it); 340 audio_receive_streams_.erase(it);
326 } 341 }
327 } 342 }
328 343
329 webrtc::VideoSendStream* FakeCall::CreateVideoSendStream( 344 webrtc::VideoSendStream* FakeCall::CreateVideoSendStream(
330 const webrtc::VideoSendStream::Config& config, 345 const webrtc::VideoSendStream::Config& config,
331 const webrtc::VideoEncoderConfig& encoder_config) { 346 const webrtc::VideoEncoderConfig& encoder_config) {
332 FakeVideoSendStream* fake_stream = 347 FakeVideoSendStream* fake_stream =
333 new FakeVideoSendStream(config, encoder_config); 348 new FakeVideoSendStream(config, encoder_config);
334 video_send_streams_.push_back(fake_stream); 349 video_send_streams_.push_back(fake_stream);
335 ++num_created_send_streams_; 350 ++num_created_send_streams_;
336 return fake_stream; 351 return fake_stream;
337 } 352 }
338 353
339 void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { 354 void FakeCall::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
340 auto it = std::find(video_send_streams_.begin(), 355 auto it = std::find(video_send_streams_.begin(),
341 video_send_streams_.end(), 356 video_send_streams_.end(),
342 static_cast<FakeVideoSendStream*>(send_stream)); 357 static_cast<FakeVideoSendStream*>(send_stream));
343 if (it == video_send_streams_.end()) { 358 if (it == video_send_streams_.end()) {
344 ADD_FAILURE() << "DestroyVideoSendStream called with unknown paramter."; 359 ADD_FAILURE() << "DestroyVideoSendStream called with unknown parameter.";
345 } else { 360 } else {
346 delete *it; 361 delete *it;
347 video_send_streams_.erase(it); 362 video_send_streams_.erase(it);
348 } 363 }
349 } 364 }
350 365
351 webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream( 366 webrtc::VideoReceiveStream* FakeCall::CreateVideoReceiveStream(
352 const webrtc::VideoReceiveStream::Config& config) { 367 const webrtc::VideoReceiveStream::Config& config) {
353 video_receive_streams_.push_back(new FakeVideoReceiveStream(config)); 368 video_receive_streams_.push_back(new FakeVideoReceiveStream(config));
354 ++num_created_receive_streams_; 369 ++num_created_receive_streams_;
355 return video_receive_streams_.back(); 370 return video_receive_streams_.back();
356 } 371 }
357 372
358 void FakeCall::DestroyVideoReceiveStream( 373 void FakeCall::DestroyVideoReceiveStream(
359 webrtc::VideoReceiveStream* receive_stream) { 374 webrtc::VideoReceiveStream* receive_stream) {
360 auto it = std::find(video_receive_streams_.begin(), 375 auto it = std::find(video_receive_streams_.begin(),
361 video_receive_streams_.end(), 376 video_receive_streams_.end(),
362 static_cast<FakeVideoReceiveStream*>(receive_stream)); 377 static_cast<FakeVideoReceiveStream*>(receive_stream));
363 if (it == video_receive_streams_.end()) { 378 if (it == video_receive_streams_.end()) {
364 ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown paramter."; 379 ADD_FAILURE() << "DestroyVideoReceiveStream called with unknown parameter.";
365 } else { 380 } else {
366 delete *it; 381 delete *it;
367 video_receive_streams_.erase(it); 382 video_receive_streams_.erase(it);
368 } 383 }
369 } 384 }
370 385
371 webrtc::PacketReceiver* FakeCall::Receiver() { 386 webrtc::PacketReceiver* FakeCall::Receiver() {
372 return this; 387 return this;
373 } 388 }
374 389
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 430
416 webrtc::Call::Stats FakeCall::GetStats() const { 431 webrtc::Call::Stats FakeCall::GetStats() const {
417 return stats_; 432 return stats_;
418 } 433 }
419 434
420 void FakeCall::SetBitrateConfig( 435 void FakeCall::SetBitrateConfig(
421 const webrtc::Call::Config::BitrateConfig& bitrate_config) { 436 const webrtc::Call::Config::BitrateConfig& bitrate_config) {
422 config_.bitrate_config = bitrate_config; 437 config_.bitrate_config = bitrate_config;
423 } 438 }
424 439
425 void FakeCall::SignalNetworkState(webrtc::NetworkState state) { 440 void FakeCall::SignalChannelNetworkState(webrtc::MediaType media,
426 network_state_ = state; 441 webrtc::NetworkState state) {
442 switch (media) {
443 case webrtc::MediaType::AUDIO:
444 audio_network_state_ = state;
445 break;
446 case webrtc::MediaType::VIDEO:
447 video_network_state_ = state;
448 break;
449 case webrtc::MediaType::DATA:
450 case webrtc::MediaType::ANY:
451 ADD_FAILURE()
452 << "SignalChannelNetworkState called with unknown parameter.";
453 }
427 } 454 }
428 455
429 void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) { 456 void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) {
430 last_sent_packet_ = sent_packet; 457 last_sent_packet_ = sent_packet;
431 } 458 }
432 } // namespace cricket 459 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/fakewebrtccall.h ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698