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

Side by Side Diff: webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc

Issue 1607353002: Swap use of CriticalSectionWrapper with rtc::CriticalSection in voice_engine/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/base/criticalsection.h"
11 #include "webrtc/system_wrappers/include/atomic32.h" 12 #include "webrtc/system_wrappers/include/atomic32.h"
12 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
13 #include "webrtc/system_wrappers/include/event_wrapper.h" 13 #include "webrtc/system_wrappers/include/event_wrapper.h"
14 #include "webrtc/test/testsupport/fileutils.h" 14 #include "webrtc/test/testsupport/fileutils.h"
15 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" 15 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h"
16 #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" 16 #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h"
17 17
18 class TestRtpObserver : public webrtc::VoERTPObserver { 18 class TestRtpObserver : public webrtc::VoERTPObserver {
19 public: 19 public:
20 TestRtpObserver() 20 TestRtpObserver() : changed_ssrc_event_(voetest::EventWrapper::Create()) {}
21 : crit_(voetest::CriticalSectionWrapper::CreateCriticalSection()),
22 changed_ssrc_event_(voetest::EventWrapper::Create()) {}
23 virtual ~TestRtpObserver() {} 21 virtual ~TestRtpObserver() {}
24 virtual void OnIncomingCSRCChanged(int channel, 22 virtual void OnIncomingCSRCChanged(int channel,
25 unsigned int CSRC, 23 unsigned int CSRC,
26 bool added) {} 24 bool added) {}
27 virtual void OnIncomingSSRCChanged(int channel, 25 virtual void OnIncomingSSRCChanged(int channel,
28 unsigned int SSRC); 26 unsigned int SSRC);
29 void WaitForChangedSsrc() { 27 void WaitForChangedSsrc() {
30 // 10 seconds should be enough. 28 // 10 seconds should be enough.
31 EXPECT_EQ(voetest::kEventSignaled, changed_ssrc_event_->Wait(10*1000)); 29 EXPECT_EQ(voetest::kEventSignaled, changed_ssrc_event_->Wait(10*1000));
32 } 30 }
33 void SetIncomingSsrc(unsigned int ssrc) { 31 void SetIncomingSsrc(unsigned int ssrc) {
34 voetest::CriticalSectionScoped lock(crit_.get()); 32 rtc::CritScope lock(&crit_);
35 incoming_ssrc_ = ssrc; 33 incoming_ssrc_ = ssrc;
36 } 34 }
37 public: 35 public:
38 rtc::scoped_ptr<voetest::CriticalSectionWrapper> crit_; 36 rtc::CriticalSection crit_;
39 unsigned int incoming_ssrc_; 37 unsigned int incoming_ssrc_;
40 rtc::scoped_ptr<voetest::EventWrapper> changed_ssrc_event_; 38 rtc::scoped_ptr<voetest::EventWrapper> changed_ssrc_event_;
41 }; 39 };
42 40
43 void TestRtpObserver::OnIncomingSSRCChanged(int channel, 41 void TestRtpObserver::OnIncomingSSRCChanged(int channel,
44 unsigned int SSRC) { 42 unsigned int SSRC) {
45 char msg[128]; 43 char msg[128];
46 sprintf(msg, "\n=> OnIncomingSSRCChanged(channel=%d, SSRC=%u)\n", channel, 44 sprintf(msg, "\n=> OnIncomingSSRCChanged(channel=%d, SSRC=%u)\n", channel,
47 SSRC); 45 SSRC);
48 TEST_LOG("%s", msg); 46 TEST_LOG("%s", msg);
49 47
50 { 48 {
51 voetest::CriticalSectionScoped lock(crit_.get()); 49 rtc::CritScope lock(&crit_);
52 if (incoming_ssrc_ == SSRC) 50 if (incoming_ssrc_ == SSRC)
53 changed_ssrc_event_->Set(); 51 changed_ssrc_event_->Set();
54 } 52 }
55 } 53 }
56 54
57 static const char* const RTCP_CNAME = "Whatever"; 55 static const char* const RTCP_CNAME = "Whatever";
58 56
59 class RtpRtcpTest : public AfterStreamingFixture { 57 class RtpRtcpTest : public AfterStreamingFixture {
60 protected: 58 protected:
61 void SetUp() { 59 void SetUp() {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 107
110 Sleep(1000); 108 Sleep(1000);
111 109
112 unsigned int ssrc; 110 unsigned int ssrc;
113 EXPECT_EQ(0, voe_rtp_rtcp_->GetLocalSSRC(channel_, ssrc)); 111 EXPECT_EQ(0, voe_rtp_rtcp_->GetLocalSSRC(channel_, ssrc));
114 EXPECT_EQ(local_ssrc, ssrc); 112 EXPECT_EQ(local_ssrc, ssrc);
115 113
116 EXPECT_EQ(0, voe_rtp_rtcp_->GetRemoteSSRC(channel_, ssrc)); 114 EXPECT_EQ(0, voe_rtp_rtcp_->GetRemoteSSRC(channel_, ssrc));
117 EXPECT_EQ(local_ssrc, ssrc); 115 EXPECT_EQ(local_ssrc, ssrc);
118 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698