| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "webrtc/voice_engine/include/voe_base.h" | 37 #include "webrtc/voice_engine/include/voe_base.h" |
| 38 #include "webrtc/voice_engine/include/voe_codec.h" | 38 #include "webrtc/voice_engine/include/voe_codec.h" |
| 39 #include "webrtc/voice_engine/include/voe_network.h" | 39 #include "webrtc/voice_engine/include/voe_network.h" |
| 40 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 40 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 41 #include "webrtc/voice_engine/include/voe_video_sync.h" | 41 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 42 | 42 |
| 43 namespace webrtc { | 43 namespace webrtc { |
| 44 | 44 |
| 45 class CallPerfTest : public test::CallTest { | 45 class CallPerfTest : public test::CallTest { |
| 46 protected: | 46 protected: |
| 47 void TestAudioVideoSync(bool fec); | 47 void TestAudioVideoSync(bool fec, bool create_audio_first); |
| 48 | 48 |
| 49 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); | 49 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); |
| 50 | 50 |
| 51 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 51 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
| 52 | 52 |
| 53 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 53 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 54 int threshold_ms, | 54 int threshold_ms, |
| 55 int start_time_ms, | 55 int start_time_ms, |
| 56 int run_time_ms); | 56 int run_time_ms); |
| 57 }; | 57 }; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 private: | 183 private: |
| 184 Clock* const clock_; | 184 Clock* const clock_; |
| 185 int voe_channel_; | 185 int voe_channel_; |
| 186 VoEVideoSync* voe_sync_; | 186 VoEVideoSync* voe_sync_; |
| 187 SyncRtcpObserver* audio_observer_; | 187 SyncRtcpObserver* audio_observer_; |
| 188 int64_t creation_time_ms_; | 188 int64_t creation_time_ms_; |
| 189 int64_t first_time_in_sync_; | 189 int64_t first_time_in_sync_; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 void CallPerfTest::TestAudioVideoSync(bool fec) { | 192 void CallPerfTest::TestAudioVideoSync(bool fec, bool create_audio_first) { |
| 193 const char* kSyncGroup = "av_sync"; |
| 193 class AudioPacketReceiver : public PacketReceiver { | 194 class AudioPacketReceiver : public PacketReceiver { |
| 194 public: | 195 public: |
| 195 AudioPacketReceiver(int channel, VoENetwork* voe_network) | 196 AudioPacketReceiver(int channel, VoENetwork* voe_network) |
| 196 : channel_(channel), | 197 : channel_(channel), |
| 197 voe_network_(voe_network), | 198 voe_network_(voe_network), |
| 198 parser_(RtpHeaderParser::Create()) {} | 199 parser_(RtpHeaderParser::Create()) {} |
| 199 DeliveryStatus DeliverPacket(MediaType media_type, const uint8_t* packet, | 200 DeliveryStatus DeliverPacket(MediaType media_type, const uint8_t* packet, |
| 200 size_t length) override { | 201 size_t length) override { |
| 201 EXPECT_TRUE(media_type == MediaType::ANY || | 202 EXPECT_TRUE(media_type == MediaType::ANY || |
| 202 media_type == MediaType::AUDIO); | 203 media_type == MediaType::AUDIO); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 263 |
| 263 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 264 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 264 if (fec) { | 265 if (fec) { |
| 265 send_config_.rtp.fec.red_payload_type = kRedPayloadType; | 266 send_config_.rtp.fec.red_payload_type = kRedPayloadType; |
| 266 send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 267 send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
| 267 receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; | 268 receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; |
| 268 receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 269 receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
| 269 } | 270 } |
| 270 receive_configs_[0].rtp.nack.rtp_history_ms = 1000; | 271 receive_configs_[0].rtp.nack.rtp_history_ms = 1000; |
| 271 receive_configs_[0].renderer = &observer; | 272 receive_configs_[0].renderer = &observer; |
| 272 receive_configs_[0].audio_channel_id = channel; | 273 receive_configs_[0].sync_group = kSyncGroup; |
| 274 |
| 275 AudioReceiveStream::Config audio_config; |
| 276 audio_config.voe_channel_id = channel; |
| 277 audio_config.sync_group = kSyncGroup; |
| 278 |
| 279 AudioReceiveStream* audio_receive_stream = nullptr; |
| 280 |
| 281 if (create_audio_first) { |
| 282 audio_receive_stream = |
| 283 receiver_call_->CreateAudioReceiveStream(audio_config); |
| 284 } |
| 273 | 285 |
| 274 CreateStreams(); | 286 CreateStreams(); |
| 275 | 287 |
| 288 if (!create_audio_first) { |
| 289 audio_receive_stream = |
| 290 receiver_call_->CreateAudioReceiveStream(audio_config); |
| 291 } |
| 292 |
| 276 CreateFrameGeneratorCapturer(); | 293 CreateFrameGeneratorCapturer(); |
| 277 | 294 |
| 278 Start(); | 295 Start(); |
| 279 | 296 |
| 280 fake_audio_device.Start(); | 297 fake_audio_device.Start(); |
| 281 EXPECT_EQ(0, voe_base->StartPlayout(channel)); | 298 EXPECT_EQ(0, voe_base->StartPlayout(channel)); |
| 282 EXPECT_EQ(0, voe_base->StartReceive(channel)); | 299 EXPECT_EQ(0, voe_base->StartReceive(channel)); |
| 283 EXPECT_EQ(0, voe_base->StartSend(channel)); | 300 EXPECT_EQ(0, voe_base->StartSend(channel)); |
| 284 | 301 |
| 285 EXPECT_EQ(kEventSignaled, observer.Wait()) | 302 EXPECT_EQ(kEventSignaled, observer.Wait()) |
| 286 << "Timed out while waiting for audio and video to be synchronized."; | 303 << "Timed out while waiting for audio and video to be synchronized."; |
| 287 | 304 |
| 288 EXPECT_EQ(0, voe_base->StopSend(channel)); | 305 EXPECT_EQ(0, voe_base->StopSend(channel)); |
| 289 EXPECT_EQ(0, voe_base->StopReceive(channel)); | 306 EXPECT_EQ(0, voe_base->StopReceive(channel)); |
| 290 EXPECT_EQ(0, voe_base->StopPlayout(channel)); | 307 EXPECT_EQ(0, voe_base->StopPlayout(channel)); |
| 291 fake_audio_device.Stop(); | 308 fake_audio_device.Stop(); |
| 292 | 309 |
| 293 Stop(); | 310 Stop(); |
| 294 observer.StopSending(); | 311 observer.StopSending(); |
| 295 audio_observer.StopSending(); | 312 audio_observer.StopSending(); |
| 296 | 313 |
| 297 voe_base->DeleteChannel(channel); | 314 voe_base->DeleteChannel(channel); |
| 298 voe_base->Release(); | 315 voe_base->Release(); |
| 299 voe_codec->Release(); | 316 voe_codec->Release(); |
| 300 voe_network->Release(); | 317 voe_network->Release(); |
| 301 voe_sync->Release(); | 318 voe_sync->Release(); |
| 302 | 319 |
| 303 DestroyStreams(); | 320 DestroyStreams(); |
| 304 | 321 |
| 322 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); |
| 323 |
| 305 VoiceEngine::Delete(voice_engine); | 324 VoiceEngine::Delete(voice_engine); |
| 306 } | 325 } |
| 307 | 326 |
| 308 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { | 327 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { |
| 309 TestAudioVideoSync(false); | 328 TestAudioVideoSync(false, true); |
| 329 } |
| 330 |
| 331 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { |
| 332 TestAudioVideoSync(false, false); |
| 310 } | 333 } |
| 311 | 334 |
| 312 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { | 335 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { |
| 313 TestAudioVideoSync(true); | 336 TestAudioVideoSync(true, false); |
| 314 } | 337 } |
| 315 | 338 |
| 316 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 339 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 317 int threshold_ms, | 340 int threshold_ms, |
| 318 int start_time_ms, | 341 int start_time_ms, |
| 319 int run_time_ms) { | 342 int run_time_ms) { |
| 320 class CaptureNtpTimeObserver : public test::EndToEndTest, | 343 class CaptureNtpTimeObserver : public test::EndToEndTest, |
| 321 public VideoRenderer { | 344 public VideoRenderer { |
| 322 public: | 345 public: |
| 323 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& config, | 346 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& config, |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 int encoder_inits_; | 701 int encoder_inits_; |
| 679 uint32_t last_set_bitrate_; | 702 uint32_t last_set_bitrate_; |
| 680 VideoSendStream* send_stream_; | 703 VideoSendStream* send_stream_; |
| 681 VideoEncoderConfig encoder_config_; | 704 VideoEncoderConfig encoder_config_; |
| 682 } test; | 705 } test; |
| 683 | 706 |
| 684 RunBaseTest(&test); | 707 RunBaseTest(&test); |
| 685 } | 708 } |
| 686 | 709 |
| 687 } // namespace webrtc | 710 } // namespace webrtc |
| OLD | NEW |