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" |
Henrik Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 16 | #include "webrtc/system_wrappers/include/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 | |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 34 | static const int kDefaultTimeoutMs; |
| 35 | static const int kLongTimeoutMs; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 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; |
| 46 | |
| 47 | protected: |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 48 | void RunBaseTest(BaseTest* test, const FakeNetworkPipe::Config& config); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 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); |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 54 | void DestroyCalls(); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 55 | |
pbos | 2d56668 | 2015-09-28 09:59:31 -0700 | [diff] [blame] | 56 | void CreateSendConfig(size_t num_streams, Transport* send_transport); |
| 57 | void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 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_; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 69 | rtc::scoped_ptr<PacketTransport> send_transport_; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 70 | VideoSendStream::Config video_send_config_; |
| 71 | VideoEncoderConfig video_encoder_config_; |
| 72 | VideoSendStream* video_send_stream_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 73 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 74 | rtc::scoped_ptr<Call> receiver_call_; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 75 | rtc::scoped_ptr<PacketTransport> receive_transport_; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 76 | std::vector<VideoReceiveStream::Config> video_receive_configs_; |
| 77 | std::vector<VideoReceiveStream*> video_receive_streams_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 78 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 79 | rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 80 | test::FakeEncoder fake_encoder_; |
pbos@webrtc.org | 776e6f2 | 2014-10-29 15:28:39 +0000 | [diff] [blame] | 81 | ScopedVector<VideoDecoder> allocated_decoders_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | class BaseTest : public RtpRtcpObserver { |
| 85 | public: |
| 86 | explicit BaseTest(unsigned int timeout_ms); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 87 | virtual ~BaseTest(); |
| 88 | |
| 89 | virtual void PerformTest() = 0; |
| 90 | virtual bool ShouldCreateReceivers() const = 0; |
| 91 | |
| 92 | virtual size_t GetNumStreams() const; |
| 93 | |
| 94 | virtual Call::Config GetSenderCallConfig(); |
| 95 | virtual Call::Config GetReceiverCallConfig(); |
| 96 | virtual void OnCallsCreated(Call* sender_call, Call* receiver_call); |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 97 | virtual void OnTransportsCreated(PacketTransport* send_transport, |
| 98 | PacketTransport* receive_transport); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 99 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 100 | virtual void ModifyVideoConfigs( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 101 | VideoSendStream::Config* send_config, |
| 102 | std::vector<VideoReceiveStream::Config>* receive_configs, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame] | 103 | VideoEncoderConfig* encoder_config); |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 104 | virtual void OnVideoStreamsCreated( |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 105 | VideoSendStream* send_stream, |
| 106 | const std::vector<VideoReceiveStream*>& receive_streams); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 107 | |
| 108 | virtual void OnFrameGeneratorCapturerCreated( |
| 109 | FrameGeneratorCapturer* frame_generator_capturer); |
| 110 | }; |
| 111 | |
| 112 | class SendTest : public BaseTest { |
| 113 | public: |
| 114 | explicit SendTest(unsigned int timeout_ms); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 115 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 116 | bool ShouldCreateReceivers() const override; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | class EndToEndTest : public BaseTest { |
| 120 | public: |
| 121 | explicit EndToEndTest(unsigned int timeout_ms); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 122 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 123 | bool ShouldCreateReceivers() const override; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | } // namespace test |
| 127 | } // namespace webrtc |
| 128 | |
| 129 | #endif // WEBRTC_TEST_COMMON_CALL_TEST_H_ |