blob: 4d8e1179567b25c7e2c5a55e0034a6de97c80993 [file] [log] [blame]
pbos@webrtc.org994d0b72014-06-27 08:47:521/*
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 Holmer9fea80f2016-01-07 16:43:1810#ifndef WEBRTC_TEST_CALL_TEST_H_
11#define WEBRTC_TEST_CALL_TEST_H_
pbos@webrtc.org994d0b72014-06-27 08:47:5212
kwiberg4a206a92016-03-31 17:24:2613#include <memory>
pbos@webrtc.org994d0b72014-06-27 08:47:5214#include <vector>
15
16#include "webrtc/call.h"
Stefan Holmer9fea80f2016-01-07 16:43:1817#include "webrtc/call/transport_adapter.h"
Stefan Holmer9fea80f2016-01-07 16:43:1818#include "webrtc/test/fake_audio_device.h"
pbos@webrtc.org994d0b72014-06-27 08:47:5219#include "webrtc/test/fake_decoder.h"
20#include "webrtc/test/fake_encoder.h"
21#include "webrtc/test/frame_generator_capturer.h"
22#include "webrtc/test/rtp_rtcp_observer.h"
23
24namespace webrtc {
Stefan Holmer9fea80f2016-01-07 16:43:1825
26class VoEBase;
27class VoECodec;
28class VoENetwork;
29
pbos@webrtc.org994d0b72014-06-27 08:47:5230namespace test {
31
32class BaseTest;
33
34class CallTest : public ::testing::Test {
35 public:
36 CallTest();
Stefan Holmer9fea80f2016-01-07 16:43:1837 virtual ~CallTest();
pbos@webrtc.org994d0b72014-06-27 08:47:5238
39 static const size_t kNumSsrcs = 3;
40
Peter Boström5811a392015-12-10 12:02:5041 static const int kDefaultTimeoutMs;
42 static const int kLongTimeoutMs;
Stefan Holmer9fea80f2016-01-07 16:43:1843 static const uint8_t kVideoSendPayloadType;
pbos@webrtc.org994d0b72014-06-27 08:47:5244 static const uint8_t kSendRtxPayloadType;
Stefan Holmer9fea80f2016-01-07 16:43:1845 static const uint8_t kFakeVideoSendPayloadType;
stefan@webrtc.org01581da2014-09-04 06:48:1446 static const uint8_t kRedPayloadType;
Shao Changbine62202f2015-04-21 12:24:5047 static const uint8_t kRtxRedPayloadType;
stefan@webrtc.org01581da2014-09-04 06:48:1448 static const uint8_t kUlpfecPayloadType;
Stefan Holmer9fea80f2016-01-07 16:43:1849 static const uint8_t kAudioSendPayloadType;
pbos@webrtc.org2bb1bda2014-07-07 13:06:4850 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
Stefan Holmer9fea80f2016-01-07 16:43:1851 static const uint32_t kVideoSendSsrcs[kNumSsrcs];
52 static const uint32_t kAudioSendSsrc;
53 static const uint32_t kReceiverLocalVideoSsrc;
54 static const uint32_t kReceiverLocalAudioSsrc;
pbos@webrtc.org994d0b72014-06-27 08:47:5255 static const int kNackRtpHistoryMs;
56
57 protected:
Stefan Holmer9fea80f2016-01-07 16:43:1858 // RunBaseTest overwrites the audio_state and the voice_engine of the send and
59 // receive Call configs to simplify test code and avoid having old VoiceEngine
60 // APIs in the tests.
stefane74eef12016-01-08 14:47:1361 void RunBaseTest(BaseTest* test);
pbos@webrtc.org994d0b72014-06-27 08:47:5262
63 void CreateCalls(const Call::Config& sender_config,
64 const Call::Config& receiver_config);
65 void CreateSenderCall(const Call::Config& config);
66 void CreateReceiverCall(const Call::Config& config);
Fredrik Solenberg4f4ec0a2015-10-22 08:49:2767 void DestroyCalls();
pbos@webrtc.org994d0b72014-06-27 08:47:5268
Stefan Holmer9fea80f2016-01-07 16:43:1869 void CreateSendConfig(size_t num_video_streams,
70 size_t num_audio_streams,
71 Transport* send_transport);
pbos2d566682015-09-28 16:59:3172 void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport);
pbos@webrtc.org994d0b72014-06-27 08:47:5273
danilchap9c6a0c72016-02-10 18:54:4774 void CreateFrameGeneratorCapturerWithDrift(Clock* drift_clock, float speed);
pbos@webrtc.org994d0b72014-06-27 08:47:5275 void CreateFrameGeneratorCapturer();
Stefan Holmer9fea80f2016-01-07 16:43:1876 void CreateFakeAudioDevices();
pbos@webrtc.org994d0b72014-06-27 08:47:5277
Stefan Holmer9fea80f2016-01-07 16:43:1878 void CreateVideoStreams();
79 void CreateAudioStreams();
pbos@webrtc.org994d0b72014-06-27 08:47:5280 void Start();
81 void Stop();
82 void DestroyStreams();
Perba7dc722016-04-19 13:01:2383 void SetFakeVideoCaptureRotation(VideoRotation rotation);
pbos@webrtc.org994d0b72014-06-27 08:47:5284
pbos@webrtc.org2bb1bda2014-07-07 13:06:4885 Clock* const clock_;
86
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:5587 rtc::scoped_ptr<Call> sender_call_;
stefanf116bd02015-10-27 15:29:4288 rtc::scoped_ptr<PacketTransport> send_transport_;
stefanff483612015-12-21 11:14:0089 VideoSendStream::Config video_send_config_;
90 VideoEncoderConfig video_encoder_config_;
91 VideoSendStream* video_send_stream_;
Stefan Holmer9fea80f2016-01-07 16:43:1892 AudioSendStream::Config audio_send_config_;
93 AudioSendStream* audio_send_stream_;
pbos@webrtc.org994d0b72014-06-27 08:47:5294
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:5595 rtc::scoped_ptr<Call> receiver_call_;
stefanf116bd02015-10-27 15:29:4296 rtc::scoped_ptr<PacketTransport> receive_transport_;
stefanff483612015-12-21 11:14:0097 std::vector<VideoReceiveStream::Config> video_receive_configs_;
98 std::vector<VideoReceiveStream*> video_receive_streams_;
Stefan Holmer9fea80f2016-01-07 16:43:1899 std::vector<AudioReceiveStream::Config> audio_receive_configs_;
100 std::vector<AudioReceiveStream*> audio_receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52101
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55102 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
pbos@webrtc.org994d0b72014-06-27 08:47:52103 test::FakeEncoder fake_encoder_;
kwiberg4a206a92016-03-31 17:24:26104 std::vector<std::unique_ptr<VideoDecoder>> allocated_decoders_;
Stefan Holmer9fea80f2016-01-07 16:43:18105 size_t num_video_streams_;
106 size_t num_audio_streams_;
107
108 private:
109 // TODO(holmer): Remove once VoiceEngine is fully refactored to the new API.
110 // These methods are used to set up legacy voice engines and channels which is
111 // necessary while voice engine is being refactored to the new stream API.
112 struct VoiceEngineState {
113 VoiceEngineState()
114 : voice_engine(nullptr),
115 base(nullptr),
116 network(nullptr),
117 codec(nullptr),
118 channel_id(-1),
119 transport_adapter(nullptr) {}
120
121 VoiceEngine* voice_engine;
122 VoEBase* base;
123 VoENetwork* network;
124 VoECodec* codec;
125 int channel_id;
126 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter;
127 };
128
129 void CreateVoiceEngines();
130 void SetupVoiceEngineTransports(PacketTransport* send_transport,
131 PacketTransport* recv_transport);
132 void DestroyVoiceEngines();
133
134 VoiceEngineState voe_send_;
135 VoiceEngineState voe_recv_;
136
137 // The audio devices must outlive the voice engines.
138 rtc::scoped_ptr<test::FakeAudioDevice> fake_send_audio_device_;
139 rtc::scoped_ptr<test::FakeAudioDevice> fake_recv_audio_device_;
pbos@webrtc.org994d0b72014-06-27 08:47:52140};
141
142class BaseTest : public RtpRtcpObserver {
143 public:
144 explicit BaseTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52145 virtual ~BaseTest();
146
147 virtual void PerformTest() = 0;
148 virtual bool ShouldCreateReceivers() const = 0;
149
Stefan Holmer9fea80f2016-01-07 16:43:18150 virtual size_t GetNumVideoStreams() const;
151 virtual size_t GetNumAudioStreams() const;
pbos@webrtc.org994d0b72014-06-27 08:47:52152
153 virtual Call::Config GetSenderCallConfig();
154 virtual Call::Config GetReceiverCallConfig();
155 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
stefane74eef12016-01-08 14:47:13156
157 virtual test::PacketTransport* CreateSendTransport(Call* sender_call);
158 virtual test::PacketTransport* CreateReceiveTransport();
pbos@webrtc.org994d0b72014-06-27 08:47:52159
stefanff483612015-12-21 11:14:00160 virtual void ModifyVideoConfigs(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09161 VideoSendStream::Config* send_config,
162 std::vector<VideoReceiveStream::Config>* receive_configs,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25163 VideoEncoderConfig* encoder_config);
stefanff483612015-12-21 11:14:00164 virtual void OnVideoStreamsCreated(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09165 VideoSendStream* send_stream,
166 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52167
Stefan Holmer9fea80f2016-01-07 16:43:18168 virtual void ModifyAudioConfigs(
169 AudioSendStream::Config* send_config,
170 std::vector<AudioReceiveStream::Config>* receive_configs);
171 virtual void OnAudioStreamsCreated(
172 AudioSendStream* send_stream,
173 const std::vector<AudioReceiveStream*>& receive_streams);
174
pbos@webrtc.org994d0b72014-06-27 08:47:52175 virtual void OnFrameGeneratorCapturerCreated(
176 FrameGeneratorCapturer* frame_generator_capturer);
177};
178
179class SendTest : public BaseTest {
180 public:
181 explicit SendTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52182
kjellander@webrtc.org14665ff2015-03-04 12:58:35183 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52184};
185
186class EndToEndTest : public BaseTest {
187 public:
188 explicit EndToEndTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52189
kjellander@webrtc.org14665ff2015-03-04 12:58:35190 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52191};
192
193} // namespace test
194} // namespace webrtc
195
Stefan Holmer9fea80f2016-01-07 16:43:18196#endif // WEBRTC_TEST_CALL_TEST_H_