blob: 4a645b4cfd5de69a8781568b74b027411a529d75 [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"
andresp@webrtc.org7ae91082014-07-10 10:35:12 +000016#include "webrtc/system_wrappers/interface/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
34 static const unsigned int kDefaultTimeoutMs;
35 static const unsigned int kLongTimeoutMs;
36 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;
Erik Språng95261872015-04-10 11:58:49 +020046 static const int kAbsSendTimeExtensionId;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000047
48 protected:
49 void RunBaseTest(BaseTest* test);
50
51 void CreateCalls(const Call::Config& sender_config,
52 const Call::Config& receiver_config);
53 void CreateSenderCall(const Call::Config& config);
54 void CreateReceiverCall(const Call::Config& config);
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020055 void DestroyCalls();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000056
pbos2d566682015-09-28 09:59:31 -070057 void CreateSendConfig(size_t num_streams, Transport* send_transport);
58 void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000059
60 void CreateFrameGeneratorCapturer();
61
62 void CreateStreams();
63 void Start();
64 void Stop();
65 void DestroyStreams();
66
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000067 Clock* const clock_;
68
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000069 rtc::scoped_ptr<Call> sender_call_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000070 VideoSendStream::Config send_config_;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +000071 VideoEncoderConfig encoder_config_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000072 VideoSendStream* send_stream_;
73
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000074 rtc::scoped_ptr<Call> receiver_call_;
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000075 std::vector<VideoReceiveStream::Config> receive_configs_;
76 std::vector<VideoReceiveStream*> receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000077
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000078 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000079 test::FakeEncoder fake_encoder_;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000080 ScopedVector<VideoDecoder> allocated_decoders_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000081};
82
83class BaseTest : public RtpRtcpObserver {
84 public:
85 explicit BaseTest(unsigned int timeout_ms);
86 BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
87 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);
97
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000098 virtual void ModifyConfigs(
99 VideoSendStream::Config* send_config,
100 std::vector<VideoReceiveStream::Config>* receive_configs,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +0000101 VideoEncoderConfig* encoder_config);
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000102 virtual void OnStreamsCreated(
103 VideoSendStream* send_stream,
104 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000105
106 virtual void OnFrameGeneratorCapturerCreated(
107 FrameGeneratorCapturer* frame_generator_capturer);
108};
109
110class SendTest : public BaseTest {
111 public:
112 explicit SendTest(unsigned int timeout_ms);
113 SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
114
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000115 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000116};
117
118class EndToEndTest : public BaseTest {
119 public:
120 explicit EndToEndTest(unsigned int timeout_ms);
121 EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
122
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_