blob: b390329efc3ef735903dd5cfd5cbb82db1f2e528 [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;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000039 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000040 static const uint32_t kSendSsrcs[kNumSsrcs];
41 static const uint32_t kReceiverLocalSsrc;
42 static const int kNackRtpHistoryMs;
43
44 protected:
45 void RunBaseTest(BaseTest* test);
46
47 void CreateCalls(const Call::Config& sender_config,
48 const Call::Config& receiver_config);
49 void CreateSenderCall(const Call::Config& config);
50 void CreateReceiverCall(const Call::Config& config);
51
52 void CreateSendConfig(size_t num_streams);
53 void CreateMatchingReceiveConfigs();
54
55 void CreateFrameGeneratorCapturer();
56
57 void CreateStreams();
58 void Start();
59 void Stop();
60 void DestroyStreams();
61
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000062 Clock* const clock_;
63
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000064 scoped_ptr<Call> sender_call_;
65 VideoSendStream::Config send_config_;
66 std::vector<VideoStream> video_streams_;
pbos@webrtc.org91f17522014-07-10 10:13:37 +000067 const void* encoder_settings_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000068 VideoSendStream* send_stream_;
69
70 scoped_ptr<Call> receiver_call_;
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000071 std::vector<VideoReceiveStream::Config> receive_configs_;
72 std::vector<VideoReceiveStream*> receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000073
74 scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
75 test::FakeEncoder fake_encoder_;
andresp@webrtc.org7ae91082014-07-10 10:35:12 +000076 ScopedVector<test::FakeDecoder> fake_decoders_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000077};
78
79class BaseTest : public RtpRtcpObserver {
80 public:
81 explicit BaseTest(unsigned int timeout_ms);
82 BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
83 virtual ~BaseTest();
84
85 virtual void PerformTest() = 0;
86 virtual bool ShouldCreateReceivers() const = 0;
87
88 virtual size_t GetNumStreams() const;
89
90 virtual Call::Config GetSenderCallConfig();
91 virtual Call::Config GetReceiverCallConfig();
92 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
93
pbos@webrtc.org91f17522014-07-10 10:13:37 +000094 virtual const void* GetEncoderSettings();
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000095 virtual void ModifyConfigs(
96 VideoSendStream::Config* send_config,
97 std::vector<VideoReceiveStream::Config>* receive_configs,
98 std::vector<VideoStream>* video_streams);
99 virtual void OnStreamsCreated(
100 VideoSendStream* send_stream,
101 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000102
103 virtual void OnFrameGeneratorCapturerCreated(
104 FrameGeneratorCapturer* frame_generator_capturer);
105};
106
107class SendTest : public BaseTest {
108 public:
109 explicit SendTest(unsigned int timeout_ms);
110 SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
111
112 virtual bool ShouldCreateReceivers() const OVERRIDE;
113};
114
115class EndToEndTest : public BaseTest {
116 public:
117 explicit EndToEndTest(unsigned int timeout_ms);
118 EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
119
120 virtual bool ShouldCreateReceivers() const OVERRIDE;
121};
122
123} // namespace test
124} // namespace webrtc
125
126#endif // WEBRTC_TEST_COMMON_CALL_TEST_H_