blob: e24d83593119a8c85b85a5198441ed165027b21c [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"
16#include "webrtc/test/fake_decoder.h"
17#include "webrtc/test/fake_encoder.h"
18#include "webrtc/test/frame_generator_capturer.h"
19#include "webrtc/test/rtp_rtcp_observer.h"
20
21namespace webrtc {
22namespace test {
23
24class BaseTest;
25
26class CallTest : public ::testing::Test {
27 public:
28 CallTest();
29 ~CallTest();
30
31 static const size_t kNumSsrcs = 3;
32
33 static const unsigned int kDefaultTimeoutMs;
34 static const unsigned int kLongTimeoutMs;
35 static const uint8_t kSendPayloadType;
36 static const uint8_t kSendRtxPayloadType;
37 static const uint8_t kFakeSendPayloadType;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000038 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000039 static const uint32_t kSendSsrcs[kNumSsrcs];
40 static const uint32_t kReceiverLocalSsrc;
41 static const int kNackRtpHistoryMs;
42
43 protected:
44 void RunBaseTest(BaseTest* test);
45
46 void CreateCalls(const Call::Config& sender_config,
47 const Call::Config& receiver_config);
48 void CreateSenderCall(const Call::Config& config);
49 void CreateReceiverCall(const Call::Config& config);
50
51 void CreateSendConfig(size_t num_streams);
52 void CreateMatchingReceiveConfigs();
53
54 void CreateFrameGeneratorCapturer();
55
56 void CreateStreams();
57 void Start();
58 void Stop();
59 void DestroyStreams();
60
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +000061 Clock* const clock_;
62
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000063 scoped_ptr<Call> sender_call_;
64 VideoSendStream::Config send_config_;
65 std::vector<VideoStream> video_streams_;
66 VideoSendStream* send_stream_;
67
68 scoped_ptr<Call> receiver_call_;
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000069 std::vector<VideoReceiveStream::Config> receive_configs_;
70 std::vector<VideoReceiveStream*> receive_streams_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000071
72 scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
73 test::FakeEncoder fake_encoder_;
74 test::FakeDecoder fake_decoder_;
75};
76
77class BaseTest : public RtpRtcpObserver {
78 public:
79 explicit BaseTest(unsigned int timeout_ms);
80 BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
81 virtual ~BaseTest();
82
83 virtual void PerformTest() = 0;
84 virtual bool ShouldCreateReceivers() const = 0;
85
86 virtual size_t GetNumStreams() const;
87
88 virtual Call::Config GetSenderCallConfig();
89 virtual Call::Config GetReceiverCallConfig();
90 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
91
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +000092 virtual void ModifyConfigs(
93 VideoSendStream::Config* send_config,
94 std::vector<VideoReceiveStream::Config>* receive_configs,
95 std::vector<VideoStream>* video_streams);
96 virtual void OnStreamsCreated(
97 VideoSendStream* send_stream,
98 const std::vector<VideoReceiveStream*>& receive_streams);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000099
100 virtual void OnFrameGeneratorCapturerCreated(
101 FrameGeneratorCapturer* frame_generator_capturer);
102};
103
104class SendTest : public BaseTest {
105 public:
106 explicit SendTest(unsigned int timeout_ms);
107 SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
108
109 virtual bool ShouldCreateReceivers() const OVERRIDE;
110};
111
112class EndToEndTest : public BaseTest {
113 public:
114 explicit EndToEndTest(unsigned int timeout_ms);
115 EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
116
117 virtual bool ShouldCreateReceivers() const OVERRIDE;
118};
119
120} // namespace test
121} // namespace webrtc
122
123#endif // WEBRTC_TEST_COMMON_CALL_TEST_H_