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; |
| 40 | static const uint8_t kUlpfecPayloadType; |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 41 | static const uint32_t kSendRtxSsrcs[kNumSsrcs]; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 42 | static const uint32_t kSendSsrcs[kNumSsrcs]; |
| 43 | static const uint32_t kReceiverLocalSsrc; |
| 44 | static const int kNackRtpHistoryMs; |
| 45 | |
| 46 | protected: |
| 47 | void RunBaseTest(BaseTest* test); |
| 48 | |
| 49 | void CreateCalls(const Call::Config& sender_config, |
| 50 | const Call::Config& receiver_config); |
| 51 | void CreateSenderCall(const Call::Config& config); |
| 52 | void CreateReceiverCall(const Call::Config& config); |
| 53 | |
| 54 | void CreateSendConfig(size_t num_streams); |
| 55 | void CreateMatchingReceiveConfigs(); |
| 56 | |
| 57 | void CreateFrameGeneratorCapturer(); |
| 58 | |
| 59 | void CreateStreams(); |
| 60 | void Start(); |
| 61 | void Stop(); |
| 62 | void DestroyStreams(); |
| 63 | |
pbos@webrtc.org | 2bb1bda | 2014-07-07 13:06:48 +0000 | [diff] [blame] | 64 | Clock* const clock_; |
| 65 | |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 66 | scoped_ptr<Call> sender_call_; |
| 67 | VideoSendStream::Config send_config_; |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame^] | 68 | VideoEncoderConfig encoder_config_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 69 | VideoSendStream* send_stream_; |
| 70 | |
| 71 | scoped_ptr<Call> receiver_call_; |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 72 | std::vector<VideoReceiveStream::Config> receive_configs_; |
| 73 | std::vector<VideoReceiveStream*> receive_streams_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 74 | |
| 75 | scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_; |
| 76 | test::FakeEncoder fake_encoder_; |
andresp@webrtc.org | 7ae9108 | 2014-07-10 10:35:12 +0000 | [diff] [blame] | 77 | ScopedVector<test::FakeDecoder> fake_decoders_; |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | class BaseTest : public RtpRtcpObserver { |
| 81 | public: |
| 82 | explicit BaseTest(unsigned int timeout_ms); |
| 83 | BaseTest(unsigned int timeout_ms, const FakeNetworkPipe::Config& config); |
| 84 | virtual ~BaseTest(); |
| 85 | |
| 86 | virtual void PerformTest() = 0; |
| 87 | virtual bool ShouldCreateReceivers() const = 0; |
| 88 | |
| 89 | virtual size_t GetNumStreams() const; |
| 90 | |
| 91 | virtual Call::Config GetSenderCallConfig(); |
| 92 | virtual Call::Config GetReceiverCallConfig(); |
| 93 | virtual void OnCallsCreated(Call* sender_call, Call* receiver_call); |
| 94 | |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 95 | virtual void ModifyConfigs( |
| 96 | VideoSendStream::Config* send_config, |
| 97 | std::vector<VideoReceiveStream::Config>* receive_configs, |
pbos@webrtc.org | bbe0a85 | 2014-09-19 12:30:25 +0000 | [diff] [blame^] | 98 | VideoEncoderConfig* encoder_config); |
pbos@webrtc.org | be9d2a4 | 2014-06-30 13:19:09 +0000 | [diff] [blame] | 99 | virtual void OnStreamsCreated( |
| 100 | VideoSendStream* send_stream, |
| 101 | const std::vector<VideoReceiveStream*>& receive_streams); |
pbos@webrtc.org | 994d0b7 | 2014-06-27 08:47:52 +0000 | [diff] [blame] | 102 | |
| 103 | virtual void OnFrameGeneratorCapturerCreated( |
| 104 | FrameGeneratorCapturer* frame_generator_capturer); |
| 105 | }; |
| 106 | |
| 107 | class 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 | |
| 115 | class 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_ |