pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 7ae9108 | 2014-07-10 10:35:12 +0000 | [diff] [blame] | 16 | #include "webrtc/system_wrappers/interface/scoped_vector.h" |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 17 | #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 | |
| 22 | namespace webrtc { |
| 23 | namespace test { |
| 24 | |
| 25 | class BaseTest; |
| 26 | |
| 27 | class 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.org | 01581da | 2014-09-04 06:48:14 +0000 | [diff] [blame] | 39 | static const uint8_t kRedPayloadType; |
Shao Changbin | e62202f | 2015-04-21 20:24:50 +0800 | [diff] [blame] | 40 | static const uint8_t kRtxRedPayloadType; |
stefan@webrtc.org | 01581da | 2014-09-04 06:48:14 +0000 | [diff] [blame] | 41 | static const uint8_t kUlpfecPayloadType; |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 42 | static const uint32_t kSendRtxSsrcs[kNumSsrcs]; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 43 | static const uint32_t kSendSsrcs[kNumSsrcs]; |
| 44 | static const uint32_t kReceiverLocalSsrc; |
| 45 | static const int kNackRtpHistoryMs; |
Erik Språng | 9526187 | 2015-04-10 11:58:49 +0200 | [diff] [blame] | 46 | static const int kAbsSendTimeExtensionId; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 47 | |
| 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); |
| 55 | |
| 56 | void CreateSendConfig(size_t num_streams); |
| 57 | void CreateMatchingReceiveConfigs(); |
| 58 | |
| 59 | void CreateFrameGeneratorCapturer(); |
| 60 | |
| 61 | void CreateStreams(); |
| 62 | void Start(); |
| 63 | void Stop(); |
| 64 | void DestroyStreams(); |
| 65 | |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 66 | Clock* const clock_; |
| 67 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 68 | rtc::scoped_ptr<Call> sender_call_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 69 | VideoSendStream::Config send_config_; |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 70 | VideoEncoderConfig encoder_config_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 71 | VideoSendStream* send_stream_; |
| 72 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 73 | rtc::scoped_ptr<Call> receiver_call_; |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 74 | std::vector<VideoReceiveStream::Config> receive_configs_; |
| 75 | std::vector<VideoReceiveStream*> receive_streams_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 76 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 77 | rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 78 | test::FakeEncoder fake_encoder_; |
pbos@webrtc.org | 776e6f2 | 2014-10-29 15:28:39 +0000 | [diff] [blame] | 79 | ScopedVector<VideoDecoder> allocated_decoders_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | class BaseTest : public RtpRtcpObserver { |
| 83 | public: |
| 84 | explicit BaseTest(unsigned int timeout_ms); |
| 85 | BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config); |
| 86 | virtual ~BaseTest(); |
| 87 | |
| 88 | virtual void PerformTest() = 0; |
| 89 | virtual bool ShouldCreateReceivers() const = 0; |
| 90 | |
| 91 | virtual size_t GetNumStreams() const; |
| 92 | |
| 93 | virtual Call::Config GetSenderCallConfig(); |
| 94 | virtual Call::Config GetReceiverCallConfig(); |
| 95 | virtual void OnCallsCreated(Call* sender_call, Call* receiver_call); |
| 96 | |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 97 | virtual void ModifyConfigs( |
| 98 | VideoSendStream::Config* send_config, |
| 99 | std::vector<VideoReceiveStream::Config>* receive_configs, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 100 | VideoEncoderConfig* encoder_config); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 101 | virtual void OnStreamsCreated( |
| 102 | VideoSendStream* send_stream, |
| 103 | const std::vector<VideoReceiveStream*>& receive_streams); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 104 | |
| 105 | virtual void OnFrameGeneratorCapturerCreated( |
| 106 | FrameGeneratorCapturer* frame_generator_capturer); |
| 107 | }; |
| 108 | |
| 109 | class SendTest : public BaseTest { |
| 110 | public: |
| 111 | explicit SendTest(unsigned int timeout_ms); |
| 112 | SendTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config); |
| 113 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 114 | bool ShouldCreateReceivers() const override; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | class EndToEndTest : public BaseTest { |
| 118 | public: |
| 119 | explicit EndToEndTest(unsigned int timeout_ms); |
| 120 | EndToEndTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config); |
| 121 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 122 | bool ShouldCreateReceivers() const override; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | } // namespace test |
| 126 | } // namespace webrtc |
| 127 | |
| 128 | #endif // WEBRTC_TEST_COMMON_CALL_TEST_H_ |