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; | |
sprang_webrtc
2017/03/29 12:24:30
nit: {} for if/else
nisse-webrtc
2017/03/29 12:37:55
Done.
| |
47 } | |
48 return receiver_->DeliverPacket(media_type, packet, length, packet_time); | |
49 } | |
50 | |
29 CallTest::CallTest() | 51 CallTest::CallTest() |
30 : clock_(Clock::GetRealTimeClock()), | 52 : clock_(Clock::GetRealTimeClock()), |
31 video_send_config_(nullptr), | 53 video_send_config_(nullptr), |
32 video_send_stream_(nullptr), | 54 video_send_stream_(nullptr), |
33 audio_send_config_(nullptr), | 55 audio_send_config_(nullptr), |
34 audio_send_stream_(nullptr), | 56 audio_send_stream_(nullptr), |
35 fake_encoder_(clock_), | 57 fake_encoder_(clock_), |
36 num_video_streams_(1), | 58 num_video_streams_(1), |
37 num_audio_streams_(0), | 59 num_audio_streams_(0), |
38 num_flexfec_streams_(0), | 60 num_flexfec_streams_(0), |
(...skipping 29 matching lines...) Expand all Loading... | |
68 audio_state_config.audio_mixer = AudioMixerImpl::Create(); | 90 audio_state_config.audio_mixer = AudioMixerImpl::Create(); |
69 recv_config.audio_state = AudioState::Create(audio_state_config); | 91 recv_config.audio_state = AudioState::Create(audio_state_config); |
70 } | 92 } |
71 CreateReceiverCall(recv_config); | 93 CreateReceiverCall(recv_config); |
72 } | 94 } |
73 test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); | 95 test->OnCallsCreated(sender_call_.get(), receiver_call_.get()); |
74 receive_transport_.reset(test->CreateReceiveTransport()); | 96 receive_transport_.reset(test->CreateReceiveTransport()); |
75 send_transport_.reset(test->CreateSendTransport(sender_call_.get())); | 97 send_transport_.reset(test->CreateSendTransport(sender_call_.get())); |
76 | 98 |
77 if (test->ShouldCreateReceivers()) { | 99 if (test->ShouldCreateReceivers()) { |
78 send_transport_->SetReceiver(receiver_call_->Receiver()); | 100 if (num_video_streams_ > 0 && num_audio_streams_ > 0) { |
79 receive_transport_->SetReceiver(sender_call_->Receiver()); | 101 receive_demuxer_.SetReceiver(receiver_call_->Receiver()); |
102 send_transport_->SetReceiver(&receive_demuxer_); | |
103 send_demuxer_.SetReceiver(sender_call_->Receiver()); | |
104 receive_transport_->SetReceiver(&send_demuxer_); | |
105 } else { | |
stefan-webrtc
2017/03/29 12:27:25
Is there a reason why we don't always use the demu
nisse-webrtc
2017/03/29 12:37:55
I'm afraid it is a bit brittle, so I don't want to
stefan-webrtc
2017/03/30 06:47:11
I'm ok with both options. Maybe good to have one l
nisse-webrtc
2017/03/30 06:56:45
I don't have a strong opinion either. I think I'll
| |
106 send_transport_->SetReceiver(receiver_call_->Receiver()); | |
107 receive_transport_->SetReceiver(sender_call_->Receiver()); | |
108 } | |
80 if (num_video_streams_ > 0) | 109 if (num_video_streams_ > 0) |
81 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); | 110 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); |
82 if (num_audio_streams_ > 0) | 111 if (num_audio_streams_ > 0) |
83 receiver_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp); | 112 receiver_call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp); |
84 } else { | 113 } else { |
85 // Sender-only call delivers to itself. | 114 // Sender-only call delivers to itself. |
86 send_transport_->SetReceiver(sender_call_->Receiver()); | 115 send_transport_->SetReceiver(sender_call_->Receiver()); |
87 receive_transport_->SetReceiver(nullptr); | 116 receive_transport_->SetReceiver(nullptr); |
88 } | 117 } |
89 | 118 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 | 480 |
452 Call::Config BaseTest::GetReceiverCallConfig() { | 481 Call::Config BaseTest::GetReceiverCallConfig() { |
453 return Call::Config(&event_log_); | 482 return Call::Config(&event_log_); |
454 } | 483 } |
455 | 484 |
456 void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { | 485 void BaseTest::OnCallsCreated(Call* sender_call, Call* receiver_call) { |
457 } | 486 } |
458 | 487 |
459 test::PacketTransport* BaseTest::CreateSendTransport(Call* sender_call) { | 488 test::PacketTransport* BaseTest::CreateSendTransport(Call* sender_call) { |
460 return new PacketTransport(sender_call, this, test::PacketTransport::kSender, | 489 return new PacketTransport(sender_call, this, test::PacketTransport::kSender, |
490 MediaType::VIDEO, | |
461 FakeNetworkPipe::Config()); | 491 FakeNetworkPipe::Config()); |
462 } | 492 } |
463 | 493 |
464 test::PacketTransport* BaseTest::CreateReceiveTransport() { | 494 test::PacketTransport* BaseTest::CreateReceiveTransport() { |
465 return new PacketTransport(nullptr, this, test::PacketTransport::kReceiver, | 495 return new PacketTransport(nullptr, this, test::PacketTransport::kReceiver, |
496 MediaType::VIDEO, | |
466 FakeNetworkPipe::Config()); | 497 FakeNetworkPipe::Config()); |
467 } | 498 } |
468 | 499 |
469 size_t BaseTest::GetNumVideoStreams() const { | 500 size_t BaseTest::GetNumVideoStreams() const { |
470 return 1; | 501 return 1; |
471 } | 502 } |
472 | 503 |
473 size_t BaseTest::GetNumAudioStreams() const { | 504 size_t BaseTest::GetNumAudioStreams() const { |
474 return 0; | 505 return 0; |
475 } | 506 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 | 554 |
524 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { | 555 EndToEndTest::EndToEndTest(unsigned int timeout_ms) : BaseTest(timeout_ms) { |
525 } | 556 } |
526 | 557 |
527 bool EndToEndTest::ShouldCreateReceivers() const { | 558 bool EndToEndTest::ShouldCreateReceivers() const { |
528 return true; | 559 return true; |
529 } | 560 } |
530 | 561 |
531 } // namespace test | 562 } // namespace test |
532 } // namespace webrtc | 563 } // namespace webrtc |
OLD | NEW |