pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 10 | #include "webrtc/base/checks.h" |
| 11 | #include "webrtc/common.h" |
| 12 | #include "webrtc/config.h" |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 13 | #include "webrtc/test/call_test.h" |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 14 | #include "webrtc/test/encoder_settings.h" |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 15 | #include "webrtc/test/testsupport/fileutils.h" |
| 16 | #include "webrtc/voice_engine/include/voe_base.h" |
| 17 | #include "webrtc/voice_engine/include/voe_codec.h" |
| 18 | #include "webrtc/voice_engine/include/voe_network.h" |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | namespace test { |
| 22 | |
Guo-wei Shieh | 2c37078 | 2015-04-08 20:00:10 | [diff] [blame] | 23 | namespace { |
| 24 | const int kVideoRotationRtpExtensionId = 4; |
| 25 | } |
| 26 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 27 | CallTest::CallTest() |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 | [diff] [blame] | 28 | : clock_(Clock::GetRealTimeClock()), |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 29 | video_send_config_(nullptr), |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 30 | video_send_stream_(nullptr), |
| 31 | audio_send_config_(nullptr), |
| 32 | audio_send_stream_(nullptr), |
| 33 | fake_encoder_(clock_), |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 34 | num_video_streams_(1), |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 35 | num_audio_streams_(0), |
| 36 | fake_send_audio_device_(nullptr), |
| 37 | fake_recv_audio_device_(nullptr) {} |
pbos@webrtc.org | 32452b2 | 2014-10-22 12:15:24 | [diff] [blame] | 38 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 39 | CallTest::~CallTest() { |
| 40 | } |
| 41 | |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 42 | void CallTest::RunBaseTest(BaseTest* test) { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 43 | num_video_streams_ = test->GetNumVideoStreams(); |
| 44 | num_audio_streams_ = test->GetNumAudioStreams(); |
| 45 | RTC_DCHECK(num_video_streams_ > 0 || num_audio_streams_ > 0); |
| 46 | Call::Config send_config(test->GetSenderCallConfig()); |
| 47 | if (num_audio_streams_ > 0) { |
| 48 | CreateVoiceEngines(); |
| 49 | AudioState::Config audio_state_config; |
| 50 | audio_state_config.voice_engine = voe_send_.voice_engine; |
| 51 | send_config.audio_state = AudioState::Create(audio_state_config); |
| 52 | } |
| 53 | CreateSenderCall(send_config); |
| 54 | if (test->ShouldCreateReceivers()) { |
| 55 | Call::Config recv_config(test->GetReceiverCallConfig()); |
| 56 | if (num_audio_streams_ > 0) { |
| 57 | AudioState::Config audio_state_config; |
| 58 | audio_state_config.voice_engine = voe_recv_.voice_engine; |
| 59 | recv_config.audio_state = AudioState::Create(audio_state_config); |
| 60 | } |
| 61 | CreateReceiverCall(recv_config); |
| 62 | } |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 63 | test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 64 | send_transport_.reset(test->CreateSendTransport(sender_call_.get())); |
| 65 | receive_transport_.reset(test->CreateReceiveTransport()); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 66 | |
| 67 | if (test->ShouldCreateReceivers()) { |
stefan | f116bd0 | 2015-10-27 15:29:42 | [diff] [blame] | 68 | send_transport_->SetReceiver(receiver_call_->Receiver()); |
| 69 | receive_transport_->SetReceiver(sender_call_->Receiver()); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 70 | } else { |
| 71 | // Sender-only call delivers to itself. |
stefan | f116bd0 | 2015-10-27 15:29:42 | [diff] [blame] | 72 | send_transport_->SetReceiver(sender_call_->Receiver()); |
| 73 | receive_transport_->SetReceiver(nullptr); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 74 | } |
| 75 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 76 | CreateSendConfig(num_video_streams_, num_audio_streams_, |
| 77 | send_transport_.get()); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 78 | if (test->ShouldCreateReceivers()) { |
stefan | f116bd0 | 2015-10-27 15:29:42 | [diff] [blame] | 79 | CreateMatchingReceiveConfigs(receive_transport_.get()); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 80 | } |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 81 | if (num_audio_streams_ > 0) |
| 82 | SetupVoiceEngineTransports(send_transport_.get(), receive_transport_.get()); |
| 83 | |
| 84 | if (num_video_streams_ > 0) { |
| 85 | test->ModifyVideoConfigs(&video_send_config_, &video_receive_configs_, |
| 86 | &video_encoder_config_); |
| 87 | } |
| 88 | if (num_audio_streams_ > 0) |
| 89 | test->ModifyAudioConfigs(&audio_send_config_, &audio_receive_configs_); |
| 90 | |
| 91 | if (num_video_streams_ > 0) { |
| 92 | CreateVideoStreams(); |
| 93 | test->OnVideoStreamsCreated(video_send_stream_, video_receive_streams_); |
| 94 | } |
| 95 | if (num_audio_streams_ > 0) { |
| 96 | CreateAudioStreams(); |
| 97 | test->OnAudioStreamsCreated(audio_send_stream_, audio_receive_streams_); |
| 98 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 99 | |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 100 | if (num_video_streams_ > 0) { |
| 101 | CreateFrameGeneratorCapturer(); |
| 102 | test->OnFrameGeneratorCapturerCreated(frame_generator_capturer_.get()); |
| 103 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 104 | |
| 105 | Start(); |
| 106 | test->PerformTest(); |
stefan | f116bd0 | 2015-10-27 15:29:42 | [diff] [blame] | 107 | send_transport_->StopSending(); |
| 108 | receive_transport_->StopSending(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 109 | Stop(); |
| 110 | |
| 111 | DestroyStreams(); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 112 | DestroyCalls(); |
| 113 | if (num_audio_streams_ > 0) |
| 114 | DestroyVoiceEngines(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | void CallTest::Start() { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 118 | if (video_send_stream_) |
| 119 | video_send_stream_->Start(); |
| 120 | for (VideoReceiveStream* video_recv_stream : video_receive_streams_) |
| 121 | video_recv_stream->Start(); |
| 122 | if (audio_send_stream_) { |
| 123 | fake_send_audio_device_->Start(); |
| 124 | audio_send_stream_->Start(); |
| 125 | EXPECT_EQ(0, voe_send_.base->StartSend(voe_send_.channel_id)); |
| 126 | } |
| 127 | for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) |
| 128 | audio_recv_stream->Start(); |
| 129 | if (!audio_receive_streams_.empty()) { |
| 130 | fake_recv_audio_device_->Start(); |
| 131 | EXPECT_EQ(0, voe_recv_.base->StartPlayout(voe_recv_.channel_id)); |
| 132 | EXPECT_EQ(0, voe_recv_.base->StartReceive(voe_recv_.channel_id)); |
| 133 | } |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 134 | if (frame_generator_capturer_.get() != NULL) |
| 135 | frame_generator_capturer_->Start(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | void CallTest::Stop() { |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 139 | if (frame_generator_capturer_.get() != NULL) |
| 140 | frame_generator_capturer_->Stop(); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 141 | if (!audio_receive_streams_.empty()) { |
| 142 | fake_recv_audio_device_->Stop(); |
| 143 | EXPECT_EQ(0, voe_recv_.base->StopReceive(voe_recv_.channel_id)); |
| 144 | EXPECT_EQ(0, voe_recv_.base->StopPlayout(voe_recv_.channel_id)); |
| 145 | } |
| 146 | for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) |
| 147 | audio_recv_stream->Stop(); |
| 148 | if (audio_send_stream_) { |
| 149 | fake_send_audio_device_->Stop(); |
| 150 | EXPECT_EQ(0, voe_send_.base->StopSend(voe_send_.channel_id)); |
| 151 | audio_send_stream_->Stop(); |
| 152 | } |
| 153 | for (VideoReceiveStream* video_recv_stream : video_receive_streams_) |
| 154 | video_recv_stream->Stop(); |
| 155 | if (video_send_stream_) |
| 156 | video_send_stream_->Stop(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | void CallTest::CreateCalls(const Call::Config& sender_config, |
| 160 | const Call::Config& receiver_config) { |
| 161 | CreateSenderCall(sender_config); |
| 162 | CreateReceiverCall(receiver_config); |
| 163 | } |
| 164 | |
| 165 | void CallTest::CreateSenderCall(const Call::Config& config) { |
| 166 | sender_call_.reset(Call::Create(config)); |
| 167 | } |
| 168 | |
| 169 | void CallTest::CreateReceiverCall(const Call::Config& config) { |
| 170 | receiver_call_.reset(Call::Create(config)); |
| 171 | } |
| 172 | |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 08:49:27 | [diff] [blame] | 173 | void CallTest::DestroyCalls() { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 174 | sender_call_.reset(); |
| 175 | receiver_call_.reset(); |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 08:49:27 | [diff] [blame] | 176 | } |
| 177 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 178 | void CallTest::CreateSendConfig(size_t num_video_streams, |
| 179 | size_t num_audio_streams, |
pbos | 2d56668 | 2015-09-28 16:59:31 | [diff] [blame] | 180 | Transport* send_transport) { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 181 | RTC_DCHECK(num_video_streams <= kNumSsrcs); |
| 182 | RTC_DCHECK_LE(num_audio_streams, 1u); |
| 183 | RTC_DCHECK(num_audio_streams == 0 || voe_send_.channel_id >= 0); |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 184 | if (num_video_streams > 0) { |
| 185 | video_send_config_ = VideoSendStream::Config(send_transport); |
| 186 | video_send_config_.encoder_settings.encoder = &fake_encoder_; |
| 187 | video_send_config_.encoder_settings.payload_name = "FAKE"; |
| 188 | video_send_config_.encoder_settings.payload_type = |
| 189 | kFakeVideoSendPayloadType; |
| 190 | video_send_config_.rtp.extensions.push_back( |
| 191 | RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeExtensionId)); |
| 192 | video_encoder_config_.streams = test::CreateVideoStreams(num_video_streams); |
| 193 | for (size_t i = 0; i < num_video_streams; ++i) |
| 194 | video_send_config_.rtp.ssrcs.push_back(kVideoSendSsrcs[i]); |
| 195 | video_send_config_.rtp.extensions.push_back(RtpExtension( |
| 196 | RtpExtension::kVideoRotation, kVideoRotationRtpExtensionId)); |
| 197 | } |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 198 | |
| 199 | if (num_audio_streams > 0) { |
| 200 | audio_send_config_ = AudioSendStream::Config(send_transport); |
| 201 | audio_send_config_.voe_channel_id = voe_send_.channel_id; |
| 202 | audio_send_config_.rtp.ssrc = kAudioSendSsrc; |
| 203 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 204 | } |
| 205 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 206 | void CallTest::CreateMatchingReceiveConfigs(Transport* rtcp_send_transport) { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 207 | RTC_DCHECK(video_receive_configs_.empty()); |
| 208 | RTC_DCHECK(allocated_decoders_.empty()); |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 209 | if (num_video_streams_ > 0) { |
| 210 | RTC_DCHECK(!video_send_config_.rtp.ssrcs.empty()); |
| 211 | VideoReceiveStream::Config video_config(rtcp_send_transport); |
| 212 | video_config.rtp.remb = true; |
| 213 | video_config.rtp.local_ssrc = kReceiverLocalVideoSsrc; |
| 214 | for (const RtpExtension& extension : video_send_config_.rtp.extensions) |
| 215 | video_config.rtp.extensions.push_back(extension); |
| 216 | for (size_t i = 0; i < video_send_config_.rtp.ssrcs.size(); ++i) { |
| 217 | VideoReceiveStream::Decoder decoder = |
| 218 | test::CreateMatchingDecoder(video_send_config_.encoder_settings); |
| 219 | allocated_decoders_.push_back(decoder.decoder); |
| 220 | video_config.decoders.clear(); |
| 221 | video_config.decoders.push_back(decoder); |
| 222 | video_config.rtp.remote_ssrc = video_send_config_.rtp.ssrcs[i]; |
| 223 | video_receive_configs_.push_back(video_config); |
| 224 | } |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | RTC_DCHECK(num_audio_streams_ <= 1); |
| 228 | if (num_audio_streams_ == 1) { |
Stefan Holmer | 04cb763 | 2016-01-14 19:34:30 | [diff] [blame] | 229 | RTC_DCHECK(voe_send_.channel_id >= 0); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 230 | AudioReceiveStream::Config audio_config; |
| 231 | audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; |
| 232 | audio_config.rtcp_send_transport = rtcp_send_transport; |
| 233 | audio_config.voe_channel_id = voe_recv_.channel_id; |
| 234 | audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; |
| 235 | audio_receive_configs_.push_back(audio_config); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 236 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 237 | } |
| 238 | |
danilchap | 9c6a0c7 | 2016-02-10 18:54:47 | [diff] [blame^] | 239 | void CallTest::CreateFrameGeneratorCapturerWithDrift(Clock* clock, |
| 240 | float speed) { |
| 241 | VideoStream stream = video_encoder_config_.streams.back(); |
| 242 | frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( |
| 243 | video_send_stream_->Input(), stream.width, stream.height, |
| 244 | stream.max_framerate * speed, clock)); |
| 245 | } |
| 246 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 247 | void CallTest::CreateFrameGeneratorCapturer() { |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 248 | VideoStream stream = video_encoder_config_.streams.back(); |
| 249 | frame_generator_capturer_.reset(test::FrameGeneratorCapturer::Create( |
| 250 | video_send_stream_->Input(), stream.width, stream.height, |
| 251 | stream.max_framerate, clock_)); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 252 | } |
pbos | f1828e8 | 2015-07-28 15:20:59 | [diff] [blame] | 253 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 254 | void CallTest::CreateFakeAudioDevices() { |
| 255 | fake_send_audio_device_.reset(new FakeAudioDevice( |
danilchap | 9c6a0c7 | 2016-02-10 18:54:47 | [diff] [blame^] | 256 | clock_, test::ResourcePath("voice_engine/audio_long16", "pcm"), |
| 257 | DriftingClock::kNoDrift)); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 258 | fake_recv_audio_device_.reset(new FakeAudioDevice( |
danilchap | 9c6a0c7 | 2016-02-10 18:54:47 | [diff] [blame^] | 259 | clock_, test::ResourcePath("voice_engine/audio_long16", "pcm"), |
| 260 | DriftingClock::kNoDrift)); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void CallTest::CreateVideoStreams() { |
| 264 | RTC_DCHECK(video_send_stream_ == nullptr); |
| 265 | RTC_DCHECK(video_receive_streams_.empty()); |
| 266 | RTC_DCHECK(audio_send_stream_ == nullptr); |
| 267 | RTC_DCHECK(audio_receive_streams_.empty()); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 268 | |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 269 | video_send_stream_ = sender_call_->CreateVideoSendStream( |
| 270 | video_send_config_, video_encoder_config_); |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 271 | for (size_t i = 0; i < video_receive_configs_.size(); ++i) { |
| 272 | video_receive_streams_.push_back( |
| 273 | receiver_call_->CreateVideoReceiveStream(video_receive_configs_[i])); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 274 | } |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 275 | } |
| 276 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 277 | void CallTest::CreateAudioStreams() { |
| 278 | audio_send_stream_ = sender_call_->CreateAudioSendStream(audio_send_config_); |
| 279 | for (size_t i = 0; i < audio_receive_configs_.size(); ++i) { |
| 280 | audio_receive_streams_.push_back( |
| 281 | receiver_call_->CreateAudioReceiveStream(audio_receive_configs_[i])); |
| 282 | } |
| 283 | CodecInst isac = {kAudioSendPayloadType, "ISAC", 16000, 480, 1, 32000}; |
| 284 | EXPECT_EQ(0, voe_send_.codec->SetSendCodec(voe_send_.channel_id, isac)); |
| 285 | } |
| 286 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 287 | void CallTest::DestroyStreams() { |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 288 | if (video_send_stream_) |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 289 | sender_call_->DestroyVideoSendStream(video_send_stream_); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 290 | video_send_stream_ = nullptr; |
| 291 | for (VideoReceiveStream* video_recv_stream : video_receive_streams_) |
| 292 | receiver_call_->DestroyVideoReceiveStream(video_recv_stream); |
| 293 | |
| 294 | if (audio_send_stream_) |
| 295 | sender_call_->DestroyAudioSendStream(audio_send_stream_); |
| 296 | audio_send_stream_ = nullptr; |
| 297 | for (AudioReceiveStream* audio_recv_stream : audio_receive_streams_) |
| 298 | receiver_call_->DestroyAudioReceiveStream(audio_recv_stream); |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 299 | video_receive_streams_.clear(); |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 300 | |
pbos@webrtc.org | 776e6f2 | 2014-10-29 15:28:39 | [diff] [blame] | 301 | allocated_decoders_.clear(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 302 | } |
| 303 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 304 | void CallTest::CreateVoiceEngines() { |
| 305 | CreateFakeAudioDevices(); |
| 306 | voe_send_.voice_engine = VoiceEngine::Create(); |
| 307 | voe_send_.base = VoEBase::GetInterface(voe_send_.voice_engine); |
| 308 | voe_send_.network = VoENetwork::GetInterface(voe_send_.voice_engine); |
| 309 | voe_send_.codec = VoECodec::GetInterface(voe_send_.voice_engine); |
| 310 | EXPECT_EQ(0, voe_send_.base->Init(fake_send_audio_device_.get(), nullptr)); |
| 311 | Config voe_config; |
| 312 | voe_config.Set<VoicePacing>(new VoicePacing(true)); |
| 313 | voe_send_.channel_id = voe_send_.base->CreateChannel(voe_config); |
| 314 | EXPECT_GE(voe_send_.channel_id, 0); |
| 315 | |
| 316 | voe_recv_.voice_engine = VoiceEngine::Create(); |
| 317 | voe_recv_.base = VoEBase::GetInterface(voe_recv_.voice_engine); |
| 318 | voe_recv_.network = VoENetwork::GetInterface(voe_recv_.voice_engine); |
| 319 | voe_recv_.codec = VoECodec::GetInterface(voe_recv_.voice_engine); |
| 320 | EXPECT_EQ(0, voe_recv_.base->Init(fake_recv_audio_device_.get(), nullptr)); |
| 321 | voe_recv_.channel_id = voe_recv_.base->CreateChannel(); |
| 322 | EXPECT_GE(voe_recv_.channel_id, 0); |
| 323 | } |
| 324 | |
| 325 | void CallTest::SetupVoiceEngineTransports(PacketTransport* send_transport, |
| 326 | PacketTransport* recv_transport) { |
| 327 | voe_send_.transport_adapter.reset( |
| 328 | new internal::TransportAdapter(send_transport)); |
| 329 | voe_send_.transport_adapter->Enable(); |
| 330 | EXPECT_EQ(0, voe_send_.network->RegisterExternalTransport( |
| 331 | voe_send_.channel_id, *voe_send_.transport_adapter.get())); |
| 332 | |
| 333 | voe_recv_.transport_adapter.reset( |
| 334 | new internal::TransportAdapter(recv_transport)); |
| 335 | voe_recv_.transport_adapter->Enable(); |
| 336 | EXPECT_EQ(0, voe_recv_.network->RegisterExternalTransport( |
| 337 | voe_recv_.channel_id, *voe_recv_.transport_adapter.get())); |
| 338 | } |
| 339 | |
| 340 | void CallTest::DestroyVoiceEngines() { |
| 341 | voe_recv_.base->DeleteChannel(voe_recv_.channel_id); |
| 342 | voe_recv_.channel_id = -1; |
| 343 | voe_recv_.base->Release(); |
| 344 | voe_recv_.base = nullptr; |
| 345 | voe_recv_.network->Release(); |
| 346 | voe_recv_.network = nullptr; |
| 347 | voe_recv_.codec->Release(); |
| 348 | voe_recv_.codec = nullptr; |
| 349 | |
| 350 | voe_send_.base->DeleteChannel(voe_send_.channel_id); |
| 351 | voe_send_.channel_id = -1; |
| 352 | voe_send_.base->Release(); |
| 353 | voe_send_.base = nullptr; |
| 354 | voe_send_.network->Release(); |
| 355 | voe_send_.network = nullptr; |
| 356 | voe_send_.codec->Release(); |
| 357 | voe_send_.codec = nullptr; |
| 358 | |
| 359 | VoiceEngine::Delete(voe_send_.voice_engine); |
| 360 | voe_send_.voice_engine = nullptr; |
| 361 | VoiceEngine::Delete(voe_recv_.voice_engine); |
| 362 | voe_recv_.voice_engine = nullptr; |
| 363 | } |
| 364 | |
Peter Boström | 5811a39 | 2015-12-10 12:02:50 | [diff] [blame] | 365 | const int CallTest::kDefaultTimeoutMs = 30 * 1000; |
| 366 | const int CallTest::kLongTimeoutMs = 120 * 1000; |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 367 | const uint8_t CallTest::kVideoSendPayloadType = 100; |
| 368 | const uint8_t CallTest::kFakeVideoSendPayloadType = 125; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 369 | const uint8_t CallTest::kSendRtxPayloadType = 98; |
stefan@webrtc.org | 01581da | 2014-09-04 06:48:14 | [diff] [blame] | 370 | const uint8_t CallTest::kRedPayloadType = 118; |
Shao Changbin | e62202f | 2015-04-21 12:24:50 | [diff] [blame] | 371 | const uint8_t CallTest::kRtxRedPayloadType = 99; |
stefan@webrtc.org | 01581da | 2014-09-04 06:48:14 | [diff] [blame] | 372 | const uint8_t CallTest::kUlpfecPayloadType = 119; |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 373 | const uint8_t CallTest::kAudioSendPayloadType = 103; |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 | [diff] [blame] | 374 | const uint32_t CallTest::kSendRtxSsrcs[kNumSsrcs] = {0xBADCAFD, 0xBADCAFE, |
| 375 | 0xBADCAFF}; |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 376 | const uint32_t CallTest::kVideoSendSsrcs[kNumSsrcs] = {0xC0FFED, 0xC0FFEE, |
| 377 | 0xC0FFEF}; |
| 378 | const uint32_t CallTest::kAudioSendSsrc = 0xDEADBEEF; |
| 379 | const uint32_t CallTest::kReceiverLocalVideoSsrc = 0x123456; |
| 380 | const uint32_t CallTest::kReceiverLocalAudioSsrc = 0x1234567; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 381 | const int CallTest::kNackRtpHistoryMs = 1000; |
| 382 | |
| 383 | BaseTest::BaseTest(unsigned int timeout_ms) : RtpRtcpObserver(timeout_ms) { |
| 384 | } |
| 385 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 386 | BaseTest::~BaseTest() { |
| 387 | } |
| 388 | |
| 389 | Call::Config BaseTest::GetSenderCallConfig() { |
solenberg | 4fbae2b | 2015-08-28 11:07:10 | [diff] [blame] | 390 | return Call::Config(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | Call::Config BaseTest::GetReceiverCallConfig() { |
solenberg | 4fbae2b | 2015-08-28 11:07:10 | [diff] [blame] | 394 | return Call::Config(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { |
| 398 | } |
| 399 | |
stefan | e74eef1 | 2016-01-08 14:47:13 | [diff] [blame] | 400 | test::PacketTransport* BaseTest::CreateSendTransport(Call* sender_call) { |
| 401 | return new PacketTransport(sender_call, this, test::PacketTransport::kSender, |
| 402 | FakeNetworkPipe::Config()); |
| 403 | } |
| 404 | |
| 405 | test::PacketTransport* BaseTest::CreateReceiveTransport() { |
| 406 | return new PacketTransport(nullptr, this, test::PacketTransport::kReceiver, |
| 407 | FakeNetworkPipe::Config()); |
| 408 | } |
stefan | f116bd0 | 2015-10-27 15:29:42 | [diff] [blame] | 409 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 410 | size_t BaseTest::GetNumVideoStreams() const { |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 411 | return 1; |
| 412 | } |
| 413 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 414 | size_t BaseTest::GetNumAudioStreams() const { |
| 415 | return 0; |
| 416 | } |
| 417 | |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 418 | void BaseTest::ModifyVideoConfigs( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 419 | VideoSendStream::Config* send_config, |
| 420 | std::vector<VideoReceiveStream::Config>* receive_configs, |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 421 | VideoEncoderConfig* encoder_config) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 422 | |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 423 | void BaseTest::OnVideoStreamsCreated( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 | [diff] [blame] | 424 | VideoSendStream* send_stream, |
stefan | ff48361 | 2015-12-21 11:14:00 | [diff] [blame] | 425 | const std::vector<VideoReceiveStream*>& receive_streams) {} |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 426 | |
Stefan Holmer | 9fea80f | 2016-01-07 16:43:18 | [diff] [blame] | 427 | void BaseTest::ModifyAudioConfigs( |
| 428 | AudioSendStream::Config* send_config, |
| 429 | std::vector<AudioReceiveStream::Config>* receive_configs) {} |
| 430 | |
| 431 | void BaseTest::OnAudioStreamsCreated( |
| 432 | AudioSendStream* send_stream, |
| 433 | const std::vector<AudioReceiveStream*>& receive_streams) {} |
| 434 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 435 | void BaseTest::OnFrameGeneratorCapturerCreated( |
| 436 | FrameGeneratorCapturer* frame_generator_capturer) { |
| 437 | } |
| 438 | |
| 439 | SendTest::SendTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { |
| 440 | } |
| 441 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 442 | bool SendTest::ShouldCreateReceivers() const { |
| 443 | return false; |
| 444 | } |
| 445 | |
| 446 | EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { |
| 447 | } |
| 448 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 | [diff] [blame] | 449 | bool EndToEndTest::ShouldCreateReceivers() const { |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | } // namespace test |
| 454 | } // namespace webrtc |