OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 #ifndef SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ | 11 #ifndef SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ |
12 #define SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ | 12 #define SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ |
13 | 13 |
14 #include <deque> | 14 #include <deque> |
15 | 15 |
| 16 #include "webrtc/base/atomicops.h" |
16 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 19 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
19 #include "webrtc/system_wrappers/interface/atomic32.h" | |
20 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 20 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
21 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 21 #include "webrtc/system_wrappers/interface/event_wrapper.h" |
22 #include "webrtc/system_wrappers/interface/sleep.h" | 22 #include "webrtc/system_wrappers/interface/sleep.h" |
23 #include "webrtc/system_wrappers/interface/thread_wrapper.h" | 23 #include "webrtc/system_wrappers/interface/thread_wrapper.h" |
24 #include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixt
ure.h" | 24 #include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixt
ure.h" |
25 | 25 |
26 class TestErrorObserver; | 26 class TestErrorObserver; |
27 | 27 |
28 class LoopBackTransport : public webrtc::Transport { | 28 class LoopBackTransport : public webrtc::Transport { |
29 public: | 29 public: |
(...skipping 18 matching lines...) Expand all Loading... |
48 | 48 |
49 int SendRTCPPacket(const void* data, size_t len) override { | 49 int SendRTCPPacket(const void* data, size_t len) override { |
50 StorePacket(Packet::Rtcp, data, len); | 50 StorePacket(Packet::Rtcp, data, len); |
51 return static_cast<int>(len); | 51 return static_cast<int>(len); |
52 } | 52 } |
53 | 53 |
54 void WaitForTransmittedPackets(int32_t packet_count) { | 54 void WaitForTransmittedPackets(int32_t packet_count) { |
55 enum { | 55 enum { |
56 kSleepIntervalMs = 10 | 56 kSleepIntervalMs = 10 |
57 }; | 57 }; |
58 int32_t limit = transmitted_packets_.Value() + packet_count; | 58 int32_t limit = |
59 while (transmitted_packets_.Value() < limit) { | 59 rtc::AtomicOps::AcquireLoad(&transmitted_packets_) + packet_count; |
| 60 while (rtc::AtomicOps::AcquireLoad(&transmitted_packets_) < limit) { |
60 webrtc::SleepMs(kSleepIntervalMs); | 61 webrtc::SleepMs(kSleepIntervalMs); |
61 } | 62 } |
62 } | 63 } |
63 | 64 |
64 void AddChannel(uint32_t ssrc, int channel) { | 65 void AddChannel(uint32_t ssrc, int channel) { |
65 webrtc::CriticalSectionScoped lock(crit_.get()); | 66 webrtc::CriticalSectionScoped lock(crit_.get()); |
66 channels_[ssrc] = channel; | 67 channels_[ssrc] = channel; |
67 } | 68 } |
68 | 69 |
69 private: | 70 private: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 132 |
132 switch (p.type) { | 133 switch (p.type) { |
133 case Packet::Rtp: | 134 case Packet::Rtp: |
134 voe_network_->ReceivedRTPPacket(channel, p.data, p.len, | 135 voe_network_->ReceivedRTPPacket(channel, p.data, p.len, |
135 webrtc::PacketTime()); | 136 webrtc::PacketTime()); |
136 break; | 137 break; |
137 case Packet::Rtcp: | 138 case Packet::Rtcp: |
138 voe_network_->ReceivedRTCPPacket(channel, p.data, p.len); | 139 voe_network_->ReceivedRTCPPacket(channel, p.data, p.len); |
139 break; | 140 break; |
140 } | 141 } |
141 ++transmitted_packets_; | 142 rtc::AtomicOps::Increment(&transmitted_packets_); |
142 } | 143 } |
143 return true; | 144 return true; |
144 } | 145 } |
145 | 146 |
146 const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_; | 147 const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_; |
147 const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_; | 148 const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_; |
148 const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_; | 149 const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_; |
149 std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get()); | 150 std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get()); |
150 const int channel_; | 151 const int channel_; |
151 std::map<uint32_t, int> channels_ GUARDED_BY(crit_.get()); | 152 std::map<uint32_t, int> channels_ GUARDED_BY(crit_.get()); |
152 webrtc::VoENetwork* const voe_network_; | 153 webrtc::VoENetwork* const voe_network_; |
153 webrtc::Atomic32 transmitted_packets_; | 154 volatile int transmitted_packets_; |
154 }; | 155 }; |
155 | 156 |
156 // This fixture initializes the voice engine in addition to the work | 157 // This fixture initializes the voice engine in addition to the work |
157 // done by the before-initialization fixture. It also registers an error | 158 // done by the before-initialization fixture. It also registers an error |
158 // observer which will fail tests on error callbacks. This fixture is | 159 // observer which will fail tests on error callbacks. This fixture is |
159 // useful to tests that want to run before we have started any form of | 160 // useful to tests that want to run before we have started any form of |
160 // streaming through the voice engine. | 161 // streaming through the voice engine. |
161 class AfterInitializationFixture : public BeforeInitializationFixture { | 162 class AfterInitializationFixture : public BeforeInitializationFixture { |
162 public: | 163 public: |
163 AfterInitializationFixture(); | 164 AfterInitializationFixture(); |
164 virtual ~AfterInitializationFixture(); | 165 virtual ~AfterInitializationFixture(); |
165 | 166 |
166 protected: | 167 protected: |
167 rtc::scoped_ptr<TestErrorObserver> error_observer_; | 168 rtc::scoped_ptr<TestErrorObserver> error_observer_; |
168 }; | 169 }; |
169 | 170 |
170 #endif // SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ | 171 #endif // SRC_VOICE_ENGINE_MAIN_TEST_AUTO_TEST_STANDARD_TEST_BASE_AFTER_INIT_H_ |
OLD | NEW |