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

Side by Side Diff: talk/app/webrtc/peerconnectioninterface_unittest.cc

Issue 1670153003: Introduce struct MediaConfig, with construction-time settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed Per's comments. Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp, 2348 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp,
2349 nullptr)); 2349 nullptr));
2350 2350
2351 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); 2351 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release()));
2352 senders = pc_->GetSenders(); 2352 senders = pc_->GetSenders();
2353 EXPECT_EQ(2u, senders.size()); 2353 EXPECT_EQ(2u, senders.size());
2354 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); 2354 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0]));
2355 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); 2355 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0]));
2356 } 2356 }
2357 2357
2358 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
2359 public:
2360 webrtc::MediaControllerInterface* CreateMediaController(
2361 const cricket::MediaConfig &config) const override {
2362 create_media_controller_called_ = true;
2363 create_media_controller_config_ = config;
2364
2365 webrtc::MediaControllerInterface* mc =
2366 PeerConnectionFactory::CreateMediaController(config);
2367 EXPECT_TRUE(mc != nullptr);
2368 return mc;
2369 }
2370
2371 mutable bool create_media_controller_called_ = false;
2372 mutable cricket::MediaConfig create_media_controller_config_;
2373 };
2374
2375 // This test verifies that configuration and constraints are
2376 // propagated into the MediaConfig passed to CreateMediaController.
2377 // These settings are intended for MediaChannel constructors, but that
2378 // is not exercised by this unittest.
2379 TEST(PeerConnection, TestSettingOfMediaConfig) {
perkj_webrtc 2016/02/10 10:41:26 please split into separate tests. 1. Test constri
nisse-webrtc 2016/02/10 13:42:01 Done.
2380 struct OneTest{
2381 bool disable_prerenderer_smoothing;
2382 rtc::Optional<bool> input_enable_dscp;
2383 bool output_enable_dscp;
2384 rtc::Optional<bool> input_enable_cpu_overuse_detection;
2385 bool output_enable_cpu_overuse_detection;
2386 };
2387
2388 const std::vector<OneTest> tests = {
2389 // No disable_prerenderer_smoothing, no constraints
2390 { false,
2391 rtc::Optional<bool>(), false,
2392 rtc::Optional<bool>(), true },
2393 // Non-default constraints
2394 { true,
2395 rtc::Optional<bool>(true), true,
2396 rtc::Optional<bool>(false), false },
2397 // Explicit constraints implying default settings
2398 { false,
2399 rtc::Optional<bool>(false), false,
2400 rtc::Optional<bool>(true), true },
2401 };
2402
2403 scoped_refptr<PeerConnectionFactoryForTest> pcf(
2404 new rtc::RefCountedObject<PeerConnectionFactoryForTest>());
2405
2406 pcf->Initialize();
2407
2408 for (auto test : tests) {
2409 FakeConstraints constraints;
2410 if (test.input_enable_dscp) {
2411 constraints.AddOptional(
2412 webrtc::MediaConstraintsInterface::kEnableDscp,
2413 *test.input_enable_dscp);
2414 }
2415 if (test.input_enable_cpu_overuse_detection) {
2416 constraints.AddOptional(
2417 webrtc::MediaConstraintsInterface::kCpuOveruseDetection,
2418 *test.input_enable_cpu_overuse_detection);
2419 }
2420 PeerConnectionInterface::RTCConfiguration config;
2421 config.disable_prerenderer_smoothing = test.disable_prerenderer_smoothing;
2422
2423 pcf->create_media_controller_called_ = false;
2424
2425 MockPeerConnectionObserver observer;
2426 scoped_refptr<PeerConnectionInterface> pc =
2427 pcf->CreatePeerConnection(config, &constraints,
2428 nullptr, nullptr, &observer);
2429 EXPECT_TRUE(pc.get() != nullptr);
2430 EXPECT_TRUE(pcf->create_media_controller_called_);
2431 EXPECT_EQ(
2432 test.disable_prerenderer_smoothing,
2433 pcf->create_media_controller_config_.disable_prerenderer_smoothing);
2434 EXPECT_EQ(
2435 test.output_enable_dscp,
2436 pcf->create_media_controller_config_.enable_dscp);
2437 EXPECT_EQ(
2438 test.output_enable_cpu_overuse_detection,
2439 pcf->create_media_controller_config_.enable_cpu_overuse_detection);
2440 }
2441 }
2442
2358 // The following tests verify that session options are created correctly. 2443 // The following tests verify that session options are created correctly.
2359 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of 2444 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of
2360 // "verify options are converted correctly", should be "pass options into 2445 // "verify options are converted correctly", should be "pass options into
2361 // CreateOffer and verify the correct offer is produced." 2446 // CreateOffer and verify the correct offer is produced."
2362 2447
2363 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { 2448 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) {
2364 RTCOfferAnswerOptions rtc_options; 2449 RTCOfferAnswerOptions rtc_options;
2365 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; 2450 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1;
2366 2451
2367 cricket::MediaSessionOptions options; 2452 cricket::MediaSessionOptions options;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 FakeConstraints updated_answer_c; 2601 FakeConstraints updated_answer_c;
2517 answer_c.SetMandatoryReceiveAudio(false); 2602 answer_c.SetMandatoryReceiveAudio(false);
2518 answer_c.SetMandatoryReceiveVideo(false); 2603 answer_c.SetMandatoryReceiveVideo(false);
2519 2604
2520 cricket::MediaSessionOptions updated_answer_options; 2605 cricket::MediaSessionOptions updated_answer_options;
2521 EXPECT_TRUE( 2606 EXPECT_TRUE(
2522 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2607 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2523 EXPECT_TRUE(updated_answer_options.has_audio()); 2608 EXPECT_TRUE(updated_answer_options.has_audio());
2524 EXPECT_TRUE(updated_answer_options.has_video()); 2609 EXPECT_TRUE(updated_answer_options.has_video());
2525 } 2610 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698