blob: 94ac2fabf351ee2715ca73ba62ba59edbe96e537 [file] [log] [blame]
pbos@webrtc.org994d0b72014-06-27 08:47:521/*
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;
38 static const uint32_t kSendRtxSsrc;
39 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
61 scoped_ptr<Call> sender_call_;
62 VideoSendStream::Config send_config_;
63 std::vector<VideoStream> video_streams_;
64 VideoSendStream* send_stream_;
65
66 scoped_ptr<Call> receiver_call_;
67 VideoReceiveStream::Config receive_config_;
68 VideoReceiveStream* receive_stream_;
69
70 scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
71 test::FakeEncoder fake_encoder_;
72 test::FakeDecoder fake_decoder_;
73};
74
75class BaseTest : public RtpRtcpObserver {
76 public:
77 explicit BaseTest(unsigned int timeout_ms);
78 BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
79 virtual ~BaseTest();
80
81 virtual void PerformTest() = 0;
82 virtual bool ShouldCreateReceivers() const = 0;
83
84 virtual size_t GetNumStreams() const;
85
86 virtual Call::Config GetSenderCallConfig();
87 virtual Call::Config GetReceiverCallConfig();
88 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
89
90 virtual void ModifyConfigs(VideoSendStream::Config* send_config,
91 VideoReceiveStream::Config* receive_config,
92 std::vector<VideoStream>* video_streams);
93 virtual void OnStreamsCreated(VideoSendStream* send_stream,
94 VideoReceiveStream* receive_stream);
95
96 virtual void OnFrameGeneratorCapturerCreated(
97 FrameGeneratorCapturer* frame_generator_capturer);
98};
99
100class SendTest : public BaseTest {
101 public:
102 explicit SendTest(unsigned int timeout_ms);
103 SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
104
105 virtual bool ShouldCreateReceivers() const OVERRIDE;
106};
107
108class EndToEndTest : public BaseTest {
109 public:
110 explicit EndToEndTest(unsigned int timeout_ms);
111 EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config);
112
113 virtual bool ShouldCreateReceivers() const OVERRIDE;
114};
115
116} // namespace test
117} // namespace webrtc
118
119#endif // WEBRTC_TEST_COMMON_CALL_TEST_H_