OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/test/call_test.h" | 11 #include "webrtc/test/call_test.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/config.h" | 17 #include "webrtc/config.h" |
18 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 18 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
20 #include "webrtc/voice_engine/include/voe_base.h" | 20 #include "webrtc/voice_engine/include/voe_base.h" |
21 | 21 |
22 namespace webrtc { | 22 namespace webrtc { |
23 namespace test { | 23 namespace test { |
24 | 24 |
25 namespace { | 25 namespace { |
26 const int kVideoRotationRtpExtensionId = 4; | 26 const int kVideoRotationRtpExtensionId = 4; |
27 } | 27 } |
28 | 28 |
| 29 void CallTest::PayloadDemuxer::SetReceiver(PacketReceiver* receiver) { |
| 30 receiver_ = receiver; |
| 31 } |
| 32 |
| 33 PacketReceiver::DeliveryStatus CallTest::PayloadDemuxer::DeliverPacket( |
| 34 MediaType media_type, |
| 35 const uint8_t* packet, |
| 36 size_t length, |
| 37 const PacketTime& packet_time) { |
| 38 if (media_type == MediaType::ANY) { |
| 39 // This simplistic demux logic will not make much sense for RTCP |
| 40 // packets, but it seems that doesn't matter. |
| 41 RTC_CHECK_GE(length, 2); |
| 42 uint8_t pt = packet[1] & 0x7f; |
| 43 if (pt == kFakeVideoSendPayloadType || pt == kFlexfecPayloadType) { |
| 44 media_type = MediaType::VIDEO; |
| 45 } else { |
| 46 media_type = MediaType::AUDIO; |
| 47 } |
| 48 } |
| 49 return receiver_->DeliverPacket(media_type, packet, length, packet_time); |
| 50 } |
| 51 |
29 CallTest::CallTest() | 52 CallTest::CallTest() |
30 : clock_(Clock::GetRealTimeClock()), | 53 : clock_(Clock::GetRealTimeClock()), |
31 video_send_config_(nullptr), | 54 video_send_config_(nullptr), |
32 video_send_stream_(nullptr), | 55 video_send_stream_(nullptr), |
33 audio_send_config_(nullptr), | 56 audio_send_config_(nullptr), |
34 audio_send_stream_(nullptr), | 57 audio_send_stream_(nullptr), |
35 fake_encoder_(clock_), | 58 fake_encoder_(clock_), |
36 num_video_streams_(1), | 59 num_video_streams_(1), |
37 num_audio_streams_(0), | 60 num_audio_streams_(0), |
38 num_flexfec_streams_(0), | 61 num_flexfec_streams_(0), |
(...skipping 29 matching lines...) Expand all Loading... |
68 audio_state_config.audio_mixer = AudioMixerImpl::Create(); | 91 audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
69 recv_config.audio_state = AudioState::Create(audio_state_config); | 92 recv_config.audio_state = AudioState::Create(audio_state_config); |
70 } | 93 } |
71 CreateReceiverCall(recv_config); | 94 CreateReceiverCall(recv_config); |
72 } | 95 } |
73 test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); | 96 test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); |
74 receive_transport_.reset(test->CreateReceiveTransport()); | 97 receive_transport_.reset(test->CreateReceiveTransport()); |
75 send_transport_.reset(test->CreateSendTransport(sender_call_.get())); | 98 send_transport_.reset(test->CreateSendTransport(sender_call_.get())); |
76 | 99 |
77 if (test->ShouldCreateReceivers()) { | 100 if (test->ShouldCreateReceivers()) { |
78 send_transport_->SetReceiver(receiver_call_->Receiver()); | 101 // For tests using only video or only audio, we rely on each test |
79 receive_transport_->SetReceiver(sender_call_->Receiver()); | 102 // configuring the underlying FakeNetworkPipe with the right media |
| 103 // type. But for tests sending both video and audio over the same |
| 104 // FakeNetworkPipe, we need to "demux", i.e., setting the |
| 105 // MediaType based on RTP payload type. |
| 106 if (num_video_streams_ > 0 && num_audio_streams_ > 0) { |
| 107 receive_demuxer_.SetReceiver(receiver_call_->Receiver()); |
| 108 send_transport_->SetReceiver(&receive_demuxer_); |
| 109 send_demuxer_.SetReceiver(sender_call_->Receiver()); |
| 110 receive_transport_->SetReceiver(&send_demuxer_); |
| 111 } else { |
| 112 send_transport_->SetReceiver(receiver_call_->Receiver()); |
| 113 receive_transport_->SetReceiver(sender_call_->Receiver()); |
| 114 } |
80 if (num_video_streams_ > 0) | 115 if (num_video_streams_ > 0) |
81 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); | 116 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); |
82 if (num_audio_streams_ > 0) | 117 if (num_audio_streams_ > 0) |
83 receiver_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp); | 118 receiver_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp); |
84 } else { | 119 } else { |
85 // Sender-only call delivers to itself. | 120 // Sender-only call delivers to itself. |
86 send_transport_->SetReceiver(sender_call_->Receiver()); | 121 send_transport_->SetReceiver(sender_call_->Receiver()); |
87 receive_transport_->SetReceiver(nullptr); | 122 receive_transport_->SetReceiver(nullptr); |
88 } | 123 } |
89 | 124 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 486 |
452 Call::Config BaseTest::GetReceiverCallConfig() { | 487 Call::Config BaseTest::GetReceiverCallConfig() { |
453 return Call::Config(&event_log_); | 488 return Call::Config(&event_log_); |
454 } | 489 } |
455 | 490 |
456 void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { | 491 void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { |
457 } | 492 } |
458 | 493 |
459 test::PacketTransport* BaseTest::CreateSendTransport(Call* sender_call) { | 494 test::PacketTransport* BaseTest::CreateSendTransport(Call* sender_call) { |
460 return new PacketTransport(sender_call, this, test::PacketTransport::kSender, | 495 return new PacketTransport(sender_call, this, test::PacketTransport::kSender, |
| 496 MediaType::VIDEO, |
461 FakeNetworkPipe::Config()); | 497 FakeNetworkPipe::Config()); |
462 } | 498 } |
463 | 499 |
464 test::PacketTransport* BaseTest::CreateReceiveTransport() { | 500 test::PacketTransport* BaseTest::CreateReceiveTransport() { |
465 return new PacketTransport(nullptr, this, test::PacketTransport::kReceiver, | 501 return new PacketTransport(nullptr, this, test::PacketTransport::kReceiver, |
| 502 MediaType::VIDEO, |
466 FakeNetworkPipe::Config()); | 503 FakeNetworkPipe::Config()); |
467 } | 504 } |
468 | 505 |
469 size_t BaseTest::GetNumVideoStreams() const { | 506 size_t BaseTest::GetNumVideoStreams() const { |
470 return 1; | 507 return 1; |
471 } | 508 } |
472 | 509 |
473 size_t BaseTest::GetNumAudioStreams() const { | 510 size_t BaseTest::GetNumAudioStreams() const { |
474 return 0; | 511 return 0; |
475 } | 512 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 560 |
524 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { | 561 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { |
525 } | 562 } |
526 | 563 |
527 bool EndToEndTest::ShouldCreateReceivers() const { | 564 bool EndToEndTest::ShouldCreateReceivers() const { |
528 return true; | 565 return true; |
529 } | 566 } |
530 | 567 |
531 } // namespace test | 568 } // namespace test |
532 } // namespace webrtc | 569 } // namespace webrtc |
OLD | NEW |