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

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

Issue 1347793005: Replace Atomic32 with webrtc/base/atomicops.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix typo Created 5 years, 2 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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/atomicops.h"
11 #include "webrtc/modules/interface/module_common_types.h" 12 #include "webrtc/modules/interface/module_common_types.h"
12 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" 13 #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
13 #include "webrtc/system_wrappers/interface/atomic32.h"
14 #include "webrtc/system_wrappers/interface/sleep.h" 14 #include "webrtc/system_wrappers/interface/sleep.h"
15 #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h " 15 #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h "
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::AtLeast; 18 using ::testing::AtLeast;
19 using ::testing::Eq; 19 using ::testing::Eq;
20 using ::testing::Field; 20 using ::testing::Field;
21 21
22 class ExtensionVerifyTransport : public webrtc::Transport { 22 class ExtensionVerifyTransport : public webrtc::Transport {
23 public: 23 public:
(...skipping 12 matching lines...) Expand all
36 !header.extension.hasAudioLevel) { 36 !header.extension.hasAudioLevel) {
37 ok = false; 37 ok = false;
38 } 38 }
39 if (absolute_sender_time_id_ >= 0 && 39 if (absolute_sender_time_id_ >= 0 &&
40 !header.extension.hasAbsoluteSendTime) { 40 !header.extension.hasAbsoluteSendTime) {
41 ok = false; 41 ok = false;
42 } 42 }
43 if (!ok) { 43 if (!ok) {
44 // bad_packets_ count packets we expected to have an extension but 44 // bad_packets_ count packets we expected to have an extension but
45 // didn't have one. 45 // didn't have one.
46 ++bad_packets_; 46 rtc::AtomicOps::Increment(&bad_packets_);
47 } 47 }
48 } 48 }
49 // received_packets_ count all packets we receive. 49 // received_packets_ count all packets we receive.
50 ++received_packets_; 50 rtc::AtomicOps::Increment(&received_packets_);
51 return static_cast<int>(len); 51 return static_cast<int>(len);
52 } 52 }
53 53
54 int SendRTCPPacket(const void* data, size_t len) override { 54 int SendRTCPPacket(const void* data, size_t len) override {
55 return static_cast<int>(len); 55 return static_cast<int>(len);
56 } 56 }
57 57
58 void SetAudioLevelId(int id) { 58 void SetAudioLevelId(int id) {
59 audio_level_id_ = id; 59 audio_level_id_ = id;
60 parser_->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel, id); 60 parser_->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAudioLevel, id);
61 } 61 }
62 62
63 void SetAbsoluteSenderTimeId(int id) { 63 void SetAbsoluteSenderTimeId(int id) {
64 absolute_sender_time_id_ = id; 64 absolute_sender_time_id_ = id;
65 parser_->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAbsoluteSendTime, 65 parser_->RegisterRtpHeaderExtension(webrtc::kRtpExtensionAbsoluteSendTime,
66 id); 66 id);
67 } 67 }
68 68
69 bool Wait() { 69 bool Wait() {
70 // Wait until we've received to specified number of packets. 70 // Wait until we've received to specified number of packets.
71 while (received_packets_.Value() < kPacketsExpected) { 71 while (rtc::AtomicOps::AcquireLoad(&received_packets_) < kPacketsExpected) {
72 webrtc::SleepMs(kSleepIntervalMs); 72 webrtc::SleepMs(kSleepIntervalMs);
73 } 73 }
74 // Check whether any were 'bad' (didn't contain an extension when they 74 // Check whether any were 'bad' (didn't contain an extension when they
75 // where supposed to). 75 // where supposed to).
76 return bad_packets_.Value() == 0; 76 return rtc::AtomicOps::AcquireLoad(&bad_packets_) == 0;
77 } 77 }
78 78
79 private: 79 private:
80 enum { 80 enum {
81 kPacketsExpected = 10, 81 kPacketsExpected = 10,
82 kSleepIntervalMs = 10 82 kSleepIntervalMs = 10
83 }; 83 };
84 rtc::scoped_ptr<webrtc::RtpHeaderParser> parser_; 84 rtc::scoped_ptr<webrtc::RtpHeaderParser> parser_;
85 webrtc::Atomic32 received_packets_; 85 volatile int received_packets_;
86 webrtc::Atomic32 bad_packets_; 86 volatile int bad_packets_;
87 int audio_level_id_; 87 int audio_level_id_;
88 int absolute_sender_time_id_; 88 int absolute_sender_time_id_;
89 }; 89 };
90 90
91 class SendRtpRtcpHeaderExtensionsTest : public BeforeStreamingFixture { 91 class SendRtpRtcpHeaderExtensionsTest : public BeforeStreamingFixture {
92 protected: 92 protected:
93 void SetUp() override { 93 void SetUp() override {
94 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(channel_)); 94 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(channel_));
95 EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel_, 95 EXPECT_EQ(0, voe_network_->RegisterExternalTransport(channel_,
96 verifying_transport_)); 96 verifying_transport_));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_EQ(0, voe_rtp_rtcp_->SetSendAbsoluteSenderTimeStatus(channel_, true, 144 EXPECT_EQ(0, voe_rtp_rtcp_->SetSendAbsoluteSenderTimeStatus(channel_, true,
145 3)); 145 3));
146 EXPECT_EQ(0, voe_rtp_rtcp_->SetSendAudioLevelIndicationStatus(channel_, true, 146 EXPECT_EQ(0, voe_rtp_rtcp_->SetSendAudioLevelIndicationStatus(channel_, true,
147 9)); 147 9));
148 verifying_transport_.SetAbsoluteSenderTimeId(3); 148 verifying_transport_.SetAbsoluteSenderTimeId(3);
149 // Don't register audio level with header parser - unknown extensions should 149 // Don't register audio level with header parser - unknown extensions should
150 // be ignored when parsing. 150 // be ignored when parsing.
151 ResumePlaying(); 151 ResumePlaying();
152 EXPECT_TRUE(verifying_transport_.Wait()); 152 EXPECT_TRUE(verifying_transport_.Wait());
153 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698