blob: 32820edea625d87128d2a8e66f7fda8e85ef68fc [file] [log] [blame]
pbos@webrtc.org994d0b72014-06-27 08:47:52 +00001/*
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 */
10#ifndef WEBRTC_TEST_COMMON_CALL_TEST_H_
11#define WEBRTC_TEST_COMMON_CALL_TEST_H_
12
13#include <vector>
14
15#include "webrtc/call.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010016#include "webrtc/system_wrappers/include/scoped_vector.h"
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000017#include "webrtc/test/fake_decoder.h"
18#include "webrtc/test/fake_encoder.h"
19#include "webrtc/test/frame_generator_capturer.h"
20#include "webrtc/test/rtp_rtcp_observer.h"
21
22namespace webrtc {
23namespace test {
24
25class BaseTest;
26
27class CallTest : public ::testing::Test {
28 public:
29 CallTest();
30 ~CallTest();
31
32 static const size_t kNumSsrcs = 3;
33
Peter Boström5811a392015-12-10 13:02:50 +010034 static const int kDefaultTimeoutMs;
35 static const int kLongTimeoutMs;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000036 static const uint8_t kSendPayloadType;
37 static const uint8_t kSendRtxPayloadType;
38 static const uint8_t kFakeSendPayloadType;
stefan@webrtc.org01581da2014-09-04 06:48:14 +000039 static const uint8_t kRedPayloadType;
Shao Changbine62202f2015-04-21 20:24:50 +080040 static const uint8_t kRtxRedPayloadType;
stefan@webrtc.org01581da2014-09-04 06:48:14 +000041 static const uint8_t kUlpfecPayloadType;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000042 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000043 static const uint32_t kSendSsrcs[kNumSsrcs];
44 static const uint32_t kReceiverLocalSsrc;
45 static const int kNackRtpHistoryMs;
46
47 protected:
stefanf116bd02015-10-27 08:29:42 -070048 void RunBaseTest(BaseTest* test, const FakeNetworkPipe::Config& config);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000049
50 void CreateCalls(const Call::Config& sender_config,
51 const Call::Config& receiver_config);
52 void CreateSenderCall(const Call::Config& config);
53 void CreateReceiverCall(const Call::Config& config);
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020054 void DestroyCalls();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000055
pbos2d566682015-09-28 09:59:31 -070056 void CreateSendConfig(size_t num_streams, Transport* send_transport);
57 void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000058
59 void CreateFrameGeneratorCapturer();
60
61 void CreateStreams();
62 void Start();
63 void Stop();
64 void DestroyStreams();
65
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000066 Clock* const clock_;
67
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000068 rtc::scoped_ptr<Call> sender_call_;
stefanf116bd02015-10-27 08:29:42 -070069 rtc::scoped_ptr<PacketTransport> send_transport_;
stefanff483612015-12-21 03:14:00 -080070 VideoSendStream::Config video_send_config_;
71 VideoEncoderConfig video_encoder_config_;
72 VideoSendStream* video_send_stream_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000073
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000074 rtc::scoped_ptr<Call> receiver_call_;
stefanf116bd02015-10-27 08:29:42 -070075 rtc::scoped_ptr<PacketTransport> receive_transport_;
stefanff483612015-12-21 03:14:00 -080076 std::vector<VideoReceiveStream::Config> video_receive_configs_;
77 std::vector<VideoReceiveStream*> video_receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000078
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000079 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000080 test::FakeEncoder fake_encoder_;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000081 ScopedVector<VideoDecoder> allocated_decoders_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000082};
83
84class BaseTest : public RtpRtcpObserver {
85 public:
86 explicit BaseTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000087 virtual ~BaseTest();
88
89 virtual void PerformTest() = 0;
90 virtual bool ShouldCreateReceivers() const = 0;
91
92 virtual size_t GetNumStreams() const;
93
94 virtual Call::Config GetSenderCallConfig();
95 virtual Call::Config GetReceiverCallConfig();
96 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
stefanf116bd02015-10-27 08:29:42 -070097 virtual void OnTransportsCreated(PacketTransport* send_transport,
98 PacketTransport* receive_transport);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000099
stefanff483612015-12-21 03:14:00 -0800100 virtual void ModifyVideoConfigs(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000101 VideoSendStream::Config* send_config,
102 std::vector<VideoReceiveStream::Config>* receive_configs,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000103 VideoEncoderConfig* encoder_config);
stefanff483612015-12-21 03:14:00 -0800104 virtual void OnVideoStreamsCreated(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000105 VideoSendStream* send_stream,
106 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000107
108 virtual void OnFrameGeneratorCapturerCreated(
109 FrameGeneratorCapturer* frame_generator_capturer);
110};
111
112class SendTest : public BaseTest {
113 public:
114 explicit SendTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000115
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000116 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000117};
118
119class EndToEndTest : public BaseTest {
120 public:
121 explicit EndToEndTest(unsigned int timeout_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000122
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000123 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000124};
125
126} // namespace test
127} // namespace webrtc
128
129#endif // WEBRTC_TEST_COMMON_CALL_TEST_H_