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

Side by Side Diff: webrtc/call/call_unittest.cc

Issue 1542653002: Add audio streams to CallTest and a first A/V call test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Create audio devices earlier Created 4 years, 12 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 | « webrtc/call/call_perf_tests.cc ('k') | webrtc/call/packet_injection_tests.cc » ('j') | 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 <list> 11 #include <list>
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #include "webrtc/audio_state.h" 15 #include "webrtc/audio_state.h"
16 #include "webrtc/call.h" 16 #include "webrtc/call.h"
17 #include "webrtc/modules/include/module_common_types.h"
18 #include "webrtc/test/call_test.h"
17 #include "webrtc/test/mock_voice_engine.h" 19 #include "webrtc/test/mock_voice_engine.h"
18 20
19 namespace { 21 namespace {
20 22
21 struct CallHelper { 23 struct CallHelper {
22 CallHelper() { 24 CallHelper() {
23 webrtc::AudioState::Config audio_state_config; 25 webrtc::AudioState::Config audio_state_config;
24 audio_state_config.voice_engine = &voice_engine_; 26 audio_state_config.voice_engine = &voice_engine_;
25 webrtc::Call::Config config; 27 webrtc::Call::Config config;
26 config.audio_state = webrtc::AudioState::Create(audio_state_config); 28 config.audio_state = webrtc::AudioState::Create(audio_state_config);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } else { 101 } else {
100 streams.push_front(stream); 102 streams.push_front(stream);
101 } 103 }
102 } 104 }
103 for (auto s : streams) { 105 for (auto s : streams) {
104 call->DestroyAudioReceiveStream(s); 106 call->DestroyAudioReceiveStream(s);
105 } 107 }
106 streams.clear(); 108 streams.clear();
107 } 109 }
108 } 110 }
111
112 namespace test {
113
114 class MediumCallTest : public CallTest {};
115
116 TEST_F(MediumCallTest, TransportSeqNumOnAudioAndVideo) {
117 class TransportSequenceNumberTest : public test::EndToEndTest {
118 public:
119 TransportSequenceNumberTest()
120 : EndToEndTest(test::CallTest::kDefaultTimeoutMs),
121 video_observed_(false),
122 audio_observed_(false) {
123 parser_->RegisterRtpHeaderExtension(kRtpExtensionTransportSequenceNumber,
124 kExtensionId);
125 }
126
127 size_t GetNumVideoStreams() const override { return 1; }
128 size_t GetNumAudioStreams() const override { return 1; }
129
130 void ModifyVideoConfigs(
131 VideoSendStream::Config* send_config,
132 std::vector<VideoReceiveStream::Config>* receive_configs,
133 VideoEncoderConfig* encoder_config) {
134 send_config->rtp.extensions.clear();
135 send_config->rtp.extensions.push_back(
136 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId));
137 (*receive_configs)[0].rtp.extensions.clear();
138 (*receive_configs)[0].rtp.extensions.push_back(
139 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId));
140 }
141
142 void ModifyAudioConfigs(
143 AudioSendStream::Config* send_config,
144 std::vector<AudioReceiveStream::Config>* receive_configs) {
145 send_config->rtp.extensions.clear();
146 send_config->rtp.extensions.push_back(
147 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId));
148 (*receive_configs)[0].rtp.extensions.clear();
149 (*receive_configs)[0].rtp.extensions.push_back(
150 RtpExtension(RtpExtension::kTransportSequenceNumber, kExtensionId));
151 }
152
153 Action OnSendRtp(const uint8_t* packet, size_t length) override {
154 RTPHeader header;
155 EXPECT_TRUE(parser_->Parse(packet, length, &header));
156 EXPECT_TRUE(header.extension.hasTransportSequenceNumber);
157 // Unwrap packet id and verify uniqueness.
158 int64_t packet_id =
159 unwrapper_.Unwrap(header.extension.transportSequenceNumber);
160 EXPECT_TRUE(received_packet_ids_.insert(packet_id).second);
161
162 if (header.ssrc == kVideoSendSsrcs[0])
163 video_observed_ = true;
164 if (header.ssrc == kAudioSendSsrc)
165 audio_observed_ = true;
166 if (audio_observed_ && video_observed_ &&
167 received_packet_ids_.size() == 50) {
168 size_t packet_id_range =
169 *received_packet_ids_.rbegin() - *received_packet_ids_.begin() + 1;
170 EXPECT_EQ(received_packet_ids_.size(), packet_id_range);
171 observation_complete_.Set();
172 }
173 return SEND_PACKET;
174 }
175
176 void PerformTest() override {
177 EXPECT_TRUE(Wait()) << "Timed out while waiting for audio and video "
178 "packets with transport sequence number.";
179 }
180
181 private:
182 const int kExtensionId = 8;
183 bool video_observed_;
184 bool audio_observed_;
185 SequenceNumberUnwrapper unwrapper_;
186 std::set<int64_t> received_packet_ids_;
187 } test;
188
189 RunBaseTest(&test, FakeNetworkPipe::Config());
pbos-webrtc 2015/12/28 22:22:31 Wondering if this could be confused being put unde
stefan-webrtc 2015/12/29 09:37:06 I moved it in the latest patch set. Still under te
190 }
191 } // namespace test
109 } // namespace webrtc 192 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/call_perf_tests.cc ('k') | webrtc/call/packet_injection_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698