OLD | NEW |
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 "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h" | 11 #include "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h" |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "webrtc/base/byteorder.h" | 15 #include "webrtc/base/byteorder.h" |
16 #include "webrtc/base/timeutils.h" | 16 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/system_wrappers/include/sleep.h" | 17 #include "webrtc/system_wrappers/include/sleep.h" |
18 #include "webrtc/voice_engine/channel_proxy.h" | |
19 #include "webrtc/voice_engine/voice_engine_impl.h" | |
20 | 18 |
21 namespace { | 19 namespace { |
22 static const unsigned int kReflectorSsrc = 0x0000; | 20 static const unsigned int kReflectorSsrc = 0x0000; |
23 static const unsigned int kLocalSsrc = 0x0001; | 21 static const unsigned int kLocalSsrc = 0x0001; |
24 static const unsigned int kFirstRemoteSsrc = 0x0002; | 22 static const unsigned int kFirstRemoteSsrc = 0x0002; |
25 static const webrtc::CodecInst kCodecInst = | 23 static const webrtc::CodecInst kCodecInst = |
26 {120, "opus", 48000, 960, 2, 64000}; | 24 {120, "opus", 48000, 960, 2, 64000}; |
27 static const int kAudioLevelHeaderId = 1; | 25 static const int kAudioLevelHeaderId = 1; |
28 | 26 |
29 static unsigned int ParseRtcpSsrc(const void* data, size_t len) { | 27 static unsigned int ParseRtcpSsrc(const void* data, size_t len) { |
(...skipping 27 matching lines...) Expand all Loading... |
57 // here, we use two engines to make it more like reality. | 55 // here, we use two engines to make it more like reality. |
58 remote_voe_ = webrtc::VoiceEngine::Create(); | 56 remote_voe_ = webrtc::VoiceEngine::Create(); |
59 remote_base_ = webrtc::VoEBase::GetInterface(remote_voe_); | 57 remote_base_ = webrtc::VoEBase::GetInterface(remote_voe_); |
60 remote_codec_ = webrtc::VoECodec::GetInterface(remote_voe_); | 58 remote_codec_ = webrtc::VoECodec::GetInterface(remote_voe_); |
61 remote_network_ = webrtc::VoENetwork::GetInterface(remote_voe_); | 59 remote_network_ = webrtc::VoENetwork::GetInterface(remote_voe_); |
62 remote_rtp_rtcp_ = webrtc::VoERTP_RTCP::GetInterface(remote_voe_); | 60 remote_rtp_rtcp_ = webrtc::VoERTP_RTCP::GetInterface(remote_voe_); |
63 remote_file_ = webrtc::VoEFile::GetInterface(remote_voe_); | 61 remote_file_ = webrtc::VoEFile::GetInterface(remote_voe_); |
64 | 62 |
65 EXPECT_EQ(0, local_base_->Init()); | 63 EXPECT_EQ(0, local_base_->Init()); |
66 local_sender_ = local_base_->CreateChannel(); | 64 local_sender_ = local_base_->CreateChannel(); |
67 static_cast<webrtc::VoiceEngineImpl*>(local_voe_) | |
68 ->GetChannelProxy(local_sender_) | |
69 ->RegisterLegacyCodecs(); | |
70 EXPECT_EQ(0, local_network_->RegisterExternalTransport(local_sender_, *this)); | 65 EXPECT_EQ(0, local_network_->RegisterExternalTransport(local_sender_, *this)); |
71 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(local_sender_, kLocalSsrc)); | 66 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(local_sender_, kLocalSsrc)); |
72 EXPECT_EQ(0, local_rtp_rtcp_-> | 67 EXPECT_EQ(0, local_rtp_rtcp_-> |
73 SetSendAudioLevelIndicationStatus(local_sender_, true, | 68 SetSendAudioLevelIndicationStatus(local_sender_, true, |
74 kAudioLevelHeaderId)); | 69 kAudioLevelHeaderId)); |
75 | 70 |
76 EXPECT_EQ(0, local_base_->StartSend(local_sender_)); | 71 EXPECT_EQ(0, local_base_->StartSend(local_sender_)); |
77 | 72 |
78 EXPECT_EQ(0, remote_base_->Init()); | 73 EXPECT_EQ(0, remote_base_->Init()); |
79 reflector_ = remote_base_->CreateChannel(); | 74 reflector_ = remote_base_->CreateChannel(); |
80 static_cast<webrtc::VoiceEngineImpl*>(remote_voe_) | |
81 ->GetChannelProxy(reflector_) | |
82 ->RegisterLegacyCodecs(); | |
83 EXPECT_EQ(0, remote_network_->RegisterExternalTransport(reflector_, *this)); | 75 EXPECT_EQ(0, remote_network_->RegisterExternalTransport(reflector_, *this)); |
84 EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(reflector_, kReflectorSsrc)); | 76 EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(reflector_, kReflectorSsrc)); |
85 | 77 |
86 thread_.Start(); | 78 thread_.Start(); |
87 thread_.SetPriority(rtc::kHighPriority); | 79 thread_.SetPriority(rtc::kHighPriority); |
88 } | 80 } |
89 | 81 |
90 ConferenceTransport::~ConferenceTransport() { | 82 ConferenceTransport::~ConferenceTransport() { |
91 // Must stop sending, otherwise DispatchPackets() cannot quit. | 83 // Must stop sending, otherwise DispatchPackets() cannot quit. |
92 EXPECT_EQ(0, remote_network_->DeRegisterExternalTransport(reflector_)); | 84 EXPECT_EQ(0, remote_network_->DeRegisterExternalTransport(reflector_)); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return true; | 215 return true; |
224 } | 216 } |
225 | 217 |
226 void ConferenceTransport::SetRtt(unsigned int rtt_ms) { | 218 void ConferenceTransport::SetRtt(unsigned int rtt_ms) { |
227 rtt_ms_ = rtt_ms; | 219 rtt_ms_ = rtt_ms; |
228 } | 220 } |
229 | 221 |
230 unsigned int ConferenceTransport::AddStream(std::string file_name, | 222 unsigned int ConferenceTransport::AddStream(std::string file_name, |
231 webrtc::FileFormats format) { | 223 webrtc::FileFormats format) { |
232 const int new_sender = remote_base_->CreateChannel(); | 224 const int new_sender = remote_base_->CreateChannel(); |
233 static_cast<webrtc::VoiceEngineImpl*>(remote_voe_) | |
234 ->GetChannelProxy(new_sender) | |
235 ->RegisterLegacyCodecs(); | |
236 EXPECT_EQ(0, remote_network_->RegisterExternalTransport(new_sender, *this)); | 225 EXPECT_EQ(0, remote_network_->RegisterExternalTransport(new_sender, *this)); |
237 | 226 |
238 const unsigned int remote_ssrc = kFirstRemoteSsrc + stream_count_++; | 227 const unsigned int remote_ssrc = kFirstRemoteSsrc + stream_count_++; |
239 EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(new_sender, remote_ssrc)); | 228 EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(new_sender, remote_ssrc)); |
240 EXPECT_EQ(0, remote_rtp_rtcp_-> | 229 EXPECT_EQ(0, remote_rtp_rtcp_-> |
241 SetSendAudioLevelIndicationStatus(new_sender, true, kAudioLevelHeaderId)); | 230 SetSendAudioLevelIndicationStatus(new_sender, true, kAudioLevelHeaderId)); |
242 | 231 |
243 EXPECT_EQ(0, remote_codec_->SetSendCodec(new_sender, kCodecInst)); | 232 EXPECT_EQ(0, remote_codec_->SetSendCodec(new_sender, kCodecInst)); |
244 EXPECT_EQ(0, remote_base_->StartSend(new_sender)); | 233 EXPECT_EQ(0, remote_base_->StartSend(new_sender)); |
245 EXPECT_EQ(0, remote_file_->StartPlayingFileAsMicrophone( | 234 EXPECT_EQ(0, remote_file_->StartPlayingFileAsMicrophone( |
246 new_sender, file_name.c_str(), true, false, format, 1.0)); | 235 new_sender, file_name.c_str(), true, false, format, 1.0)); |
247 | 236 |
248 const int new_receiver = local_base_->CreateChannel(); | 237 const int new_receiver = local_base_->CreateChannel(); |
249 static_cast<webrtc::VoiceEngineImpl*>(local_voe_) | |
250 ->GetChannelProxy(new_receiver) | |
251 ->RegisterLegacyCodecs(); | |
252 EXPECT_EQ(0, local_base_->AssociateSendChannel(new_receiver, local_sender_)); | 238 EXPECT_EQ(0, local_base_->AssociateSendChannel(new_receiver, local_sender_)); |
253 | 239 |
254 EXPECT_EQ(0, local_network_->RegisterExternalTransport(new_receiver, *this)); | 240 EXPECT_EQ(0, local_network_->RegisterExternalTransport(new_receiver, *this)); |
255 // Receive channels have to have the same SSRC in order to send receiver | 241 // Receive channels have to have the same SSRC in order to send receiver |
256 // reports with this SSRC. | 242 // reports with this SSRC. |
257 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(new_receiver, kLocalSsrc)); | 243 EXPECT_EQ(0, local_rtp_rtcp_->SetLocalSSRC(new_receiver, kLocalSsrc)); |
258 | 244 |
259 { | 245 { |
260 rtc::CritScope lock(&stream_crit_); | 246 rtc::CritScope lock(&stream_crit_); |
261 streams_[remote_ssrc] = std::make_pair(new_sender, new_receiver); | 247 streams_[remote_ssrc] = std::make_pair(new_sender, new_receiver); |
(...skipping 29 matching lines...) Expand all Loading... |
291 bool ConferenceTransport::GetReceiverStatistics(unsigned int id, | 277 bool ConferenceTransport::GetReceiverStatistics(unsigned int id, |
292 webrtc::CallStatistics* stats) { | 278 webrtc::CallStatistics* stats) { |
293 int dst = GetReceiverChannelForSsrc(id); | 279 int dst = GetReceiverChannelForSsrc(id); |
294 if (dst == -1) { | 280 if (dst == -1) { |
295 return false; | 281 return false; |
296 } | 282 } |
297 EXPECT_EQ(0, local_rtp_rtcp_->GetRTCPStatistics(dst, *stats)); | 283 EXPECT_EQ(0, local_rtp_rtcp_->GetRTCPStatistics(dst, *stats)); |
298 return true; | 284 return true; |
299 } | 285 } |
300 } // namespace voetest | 286 } // namespace voetest |
OLD | NEW |