blob: b8d13c4fd94b328ed8b2c1e1f33f625a17855637 [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;
40 static const uint8_t kUlpfecPayloadType;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000041 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000042 static const uint32_t kSendSsrcs[kNumSsrcs];
43 static const uint32_t kReceiverLocalSsrc;
44 static const int kNackRtpHistoryMs;
Erik Språng95261872015-04-10 11:58:49 +020045 static const int kAbsSendTimeExtensionId;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000046
47 protected:
48 void RunBaseTest(BaseTest* test);
49
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);
54
55 void CreateSendConfig(size_t num_streams);
56 void CreateMatchingReceiveConfigs();
57
58 void CreateFrameGeneratorCapturer();
59
60 void CreateStreams();
61 void Start();
62 void Stop();
63 void DestroyStreams();
64
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000065 Clock* const clock_;
66
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000067 rtc::scoped_ptr<Call> sender_call_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000068 VideoSendStream::Config send_config_;
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +000069 VideoEncoderConfig encoder_config_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000070 VideoSendStream* send_stream_;
71
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000072 rtc::scoped_ptr<Call> receiver_call_;
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000073 std::vector<VideoReceiveStream::Config> receive_configs_;
74 std::vector<VideoReceiveStream*> receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000075
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000076 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000077 test::FakeEncoder fake_encoder_;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000078 ScopedVector<VideoDecoder> allocated_decoders_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000079};
80
81class BaseTest : public RtpRtcpObserver {
82 public:
83 explicit BaseTest(unsigned int timeout_ms);
84 BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
85 virtual ~BaseTest();
86
87 virtual void PerformTest() = 0;
88 virtual bool ShouldCreateReceivers() const = 0;
89
90 virtual size_t GetNumStreams() const;
91
92 virtual Call::Config GetSenderCallConfig();
93 virtual Call::Config GetReceiverCallConfig();
94 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
95
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000096 virtual void ModifyConfigs(
97 VideoSendStream::Config* send_config,
98 std::vector<VideoReceiveStream::Config>* receive_configs,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +000099 VideoEncoderConfig* encoder_config);
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000100 virtual void OnStreamsCreated(
101 VideoSendStream* send_stream,
102 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000103
104 virtual void OnFrameGeneratorCapturerCreated(
105 FrameGeneratorCapturer* frame_generator_capturer);
106};
107
108class SendTest : public BaseTest {
109 public:
110 explicit SendTest(unsigned int timeout_ms);
111 SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
112
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000113 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000114};
115
116class EndToEndTest : public BaseTest {
117 public:
118 explicit EndToEndTest(unsigned int timeout_ms);
119 EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
120
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000121 bool ShouldCreateReceivers() const override;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000122};
123
124} // namespace test
125} // namespace webrtc
126
127#endif // WEBRTC_TEST_COMMON_CALL_TEST_H_