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

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2708573003: Fix race condition in VideoSendStreamTest.ChangingTransportOverhead (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <algorithm> // max 10 #include <algorithm> // max
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 call_(nullptr), 1466 call_(nullptr),
1467 packets_sent_(0), 1467 packets_sent_(0),
1468 transport_overhead_(0) {} 1468 transport_overhead_(0) {}
1469 1469
1470 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { 1470 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
1471 call_ = sender_call; 1471 call_ = sender_call;
1472 } 1472 }
1473 1473
1474 Action OnSendRtp(const uint8_t* packet, size_t length) override { 1474 Action OnSendRtp(const uint8_t* packet, size_t length) override {
1475 EXPECT_LE(length, kMaxRtpPacketSize); 1475 EXPECT_LE(length, kMaxRtpPacketSize);
1476 rtc::CritScope cs(&lock_);
1476 if (++packets_sent_ < 100) 1477 if (++packets_sent_ < 100)
1477 return SEND_PACKET; 1478 return SEND_PACKET;
1478 observation_complete_.Set(); 1479 observation_complete_.Set();
1479 return SEND_PACKET; 1480 return SEND_PACKET;
1480 } 1481 }
1481 1482
1482 void ModifyVideoConfigs( 1483 void ModifyVideoConfigs(
1483 VideoSendStream::Config* send_config, 1484 VideoSendStream::Config* send_config,
1484 std::vector<VideoReceiveStream::Config>* receive_configs, 1485 std::vector<VideoReceiveStream::Config>* receive_configs,
1485 VideoEncoderConfig* encoder_config) override { 1486 VideoEncoderConfig* encoder_config) override {
1486 send_config->rtp.max_packet_size = kMaxRtpPacketSize; 1487 send_config->rtp.max_packet_size = kMaxRtpPacketSize;
1487 } 1488 }
1488 1489
1489 void PerformTest() override { 1490 void PerformTest() override {
1490 transport_overhead_ = 100; 1491 transport_overhead_ = 100;
1491 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 1492 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO,
1492 transport_overhead_); 1493 transport_overhead_);
1493 EXPECT_TRUE(Wait()); 1494 EXPECT_TRUE(Wait());
1494 packets_sent_ = 0; 1495 {
1496 rtc::CritScope cs(&lock_);
1497 packets_sent_ = 0;
1498 }
1495 transport_overhead_ = 500; 1499 transport_overhead_ = 500;
1496 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 1500 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO,
1497 transport_overhead_); 1501 transport_overhead_);
1498 EXPECT_TRUE(Wait()); 1502 EXPECT_TRUE(Wait());
1499 } 1503 }
1500 1504
1501 private: 1505 private:
1502 Call* call_; 1506 Call* call_;
1503 int packets_sent_; 1507 rtc::CriticalSection lock_;
1508 int packets_sent_ GUARDED_BY(lock_);
1504 int transport_overhead_; 1509 int transport_overhead_;
1505 const size_t kMaxRtpPacketSize = 1000; 1510 const size_t kMaxRtpPacketSize = 1000;
1506 } test; 1511 } test;
1507 1512
1508 RunBaseTest(&test); 1513 RunBaseTest(&test);
1509 } 1514 }
1510 1515
1511 class MaxPaddingSetTest : public test::SendTest { 1516 class MaxPaddingSetTest : public test::SendTest {
1512 public: 1517 public:
1513 static const uint32_t kMinTransmitBitrateBps = 400000; 1518 static const uint32_t kMinTransmitBitrateBps = 400000;
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 rtc::CriticalSection crit_; 3235 rtc::CriticalSection crit_;
3231 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); 3236 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_);
3232 bool first_packet_sent_ GUARDED_BY(&crit_); 3237 bool first_packet_sent_ GUARDED_BY(&crit_);
3233 rtc::Event bitrate_changed_event_; 3238 rtc::Event bitrate_changed_event_;
3234 } test; 3239 } test;
3235 3240
3236 RunBaseTest(&test); 3241 RunBaseTest(&test);
3237 } 3242 }
3238 3243
3239 } // namespace webrtc 3244 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698