2014-06-27 08:47:52 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2016-01-07 17:43:18 +01:00
|
|
|
#ifndef WEBRTC_TEST_CALL_TEST_H_
|
|
|
|
|
#define WEBRTC_TEST_CALL_TEST_H_
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-03-31 10:24:26 -07:00
|
|
|
#include <memory>
|
2014-06-27 08:47:52 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2016-12-07 04:52:58 -08:00
|
|
|
#include "webrtc/call/call.h"
|
2016-10-07 11:53:05 -07:00
|
|
|
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
2016-10-02 23:45:26 -07:00
|
|
|
#include "webrtc/test/encoder_settings.h"
|
2016-01-07 17:43:18 +01:00
|
|
|
#include "webrtc/test/fake_audio_device.h"
|
2014-06-27 08:47:52 +00:00
|
|
|
#include "webrtc/test/fake_decoder.h"
|
|
|
|
|
#include "webrtc/test/fake_encoder.h"
|
2016-09-30 06:19:08 -07:00
|
|
|
#include "webrtc/test/fake_videorenderer.h"
|
2014-06-27 08:47:52 +00:00
|
|
|
#include "webrtc/test/frame_generator_capturer.h"
|
|
|
|
|
#include "webrtc/test/rtp_rtcp_observer.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2016-01-07 17:43:18 +01:00
|
|
|
|
|
|
|
|
class VoEBase;
|
|
|
|
|
|
2014-06-27 08:47:52 +00:00
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
class BaseTest;
|
|
|
|
|
|
|
|
|
|
class CallTest : public ::testing::Test {
|
|
|
|
|
public:
|
|
|
|
|
CallTest();
|
2016-01-07 17:43:18 +01:00
|
|
|
virtual ~CallTest();
|
2014-06-27 08:47:52 +00:00
|
|
|
|
|
|
|
|
static const size_t kNumSsrcs = 3;
|
2016-10-02 23:45:26 -07:00
|
|
|
static const int kDefaultWidth = 320;
|
|
|
|
|
static const int kDefaultHeight = 180;
|
|
|
|
|
static const int kDefaultFramerate = 30;
|
2015-12-10 13:02:50 +01:00
|
|
|
static const int kDefaultTimeoutMs;
|
|
|
|
|
static const int kLongTimeoutMs;
|
2016-01-07 17:43:18 +01:00
|
|
|
static const uint8_t kVideoSendPayloadType;
|
2014-06-27 08:47:52 +00:00
|
|
|
static const uint8_t kSendRtxPayloadType;
|
2016-01-07 17:43:18 +01:00
|
|
|
static const uint8_t kFakeVideoSendPayloadType;
|
2014-09-04 06:48:14 +00:00
|
|
|
static const uint8_t kRedPayloadType;
|
2015-04-21 20:24:50 +08:00
|
|
|
static const uint8_t kRtxRedPayloadType;
|
2014-09-04 06:48:14 +00:00
|
|
|
static const uint8_t kUlpfecPayloadType;
|
2016-11-15 07:10:52 -08:00
|
|
|
static const uint8_t kFlexfecPayloadType;
|
2016-01-07 17:43:18 +01:00
|
|
|
static const uint8_t kAudioSendPayloadType;
|
2014-07-07 13:06:48 +00:00
|
|
|
static const uint32_t kSendRtxSsrcs[kNumSsrcs];
|
2016-01-07 17:43:18 +01:00
|
|
|
static const uint32_t kVideoSendSsrcs[kNumSsrcs];
|
|
|
|
|
static const uint32_t kAudioSendSsrc;
|
2016-11-15 07:10:52 -08:00
|
|
|
static const uint32_t kFlexfecSendSsrc;
|
2016-01-07 17:43:18 +01:00
|
|
|
static const uint32_t kReceiverLocalVideoSsrc;
|
|
|
|
|
static const uint32_t kReceiverLocalAudioSsrc;
|
2014-06-27 08:47:52 +00:00
|
|
|
static const int kNackRtpHistoryMs;
|
2017-04-10 16:57:57 -07:00
|
|
|
static const std::map<uint8_t, MediaType> payload_type_map_;
|
2014-06-27 08:47:52 +00:00
|
|
|
|
|
|
|
|
protected:
|
2016-01-07 17:43:18 +01:00
|
|
|
// RunBaseTest overwrites the audio_state and the voice_engine of the send and
|
|
|
|
|
// receive Call configs to simplify test code and avoid having old VoiceEngine
|
|
|
|
|
// APIs in the tests.
|
2016-01-08 06:47:13 -08:00
|
|
|
void RunBaseTest(BaseTest* test);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
|
|
|
|
void CreateCalls(const Call::Config& sender_config,
|
|
|
|
|
const Call::Config& receiver_config);
|
|
|
|
|
void CreateSenderCall(const Call::Config& config);
|
|
|
|
|
void CreateReceiverCall(const Call::Config& config);
|
2015-10-22 10:49:27 +02:00
|
|
|
void DestroyCalls();
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-01-07 17:43:18 +01:00
|
|
|
void CreateSendConfig(size_t num_video_streams,
|
|
|
|
|
size_t num_audio_streams,
|
2016-11-15 07:10:52 -08:00
|
|
|
size_t num_flexfec_streams,
|
2016-01-07 17:43:18 +01:00
|
|
|
Transport* send_transport);
|
2017-03-07 04:21:04 -08:00
|
|
|
|
2015-09-28 09:59:31 -07:00
|
|
|
void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-10-02 23:45:26 -07:00
|
|
|
void CreateFrameGeneratorCapturerWithDrift(Clock* drift_clock,
|
|
|
|
|
float speed,
|
|
|
|
|
int framerate,
|
|
|
|
|
int width,
|
|
|
|
|
int height);
|
|
|
|
|
void CreateFrameGeneratorCapturer(int framerate, int width, int height);
|
2017-03-23 03:40:03 -07:00
|
|
|
void CreateFakeAudioDevices(
|
|
|
|
|
std::unique_ptr<FakeAudioDevice::Capturer> capturer,
|
|
|
|
|
std::unique_ptr<FakeAudioDevice::Renderer> renderer);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-01-07 17:43:18 +01:00
|
|
|
void CreateVideoStreams();
|
|
|
|
|
void CreateAudioStreams();
|
2016-11-15 07:10:52 -08:00
|
|
|
void CreateFlexfecStreams();
|
2014-06-27 08:47:52 +00:00
|
|
|
void Start();
|
|
|
|
|
void Stop();
|
|
|
|
|
void DestroyStreams();
|
2016-04-19 15:01:23 +02:00
|
|
|
void SetFakeVideoCaptureRotation(VideoRotation rotation);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2014-07-07 13:06:48 +00:00
|
|
|
Clock* const clock_;
|
|
|
|
|
|
2017-04-10 03:54:05 -07:00
|
|
|
std::unique_ptr<webrtc::RtcEventLog> event_log_;
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<Call> sender_call_;
|
|
|
|
|
std::unique_ptr<PacketTransport> send_transport_;
|
2015-12-21 03:14:00 -08:00
|
|
|
VideoSendStream::Config video_send_config_;
|
|
|
|
|
VideoEncoderConfig video_encoder_config_;
|
|
|
|
|
VideoSendStream* video_send_stream_;
|
2016-01-07 17:43:18 +01:00
|
|
|
AudioSendStream::Config audio_send_config_;
|
|
|
|
|
AudioSendStream* audio_send_stream_;
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<Call> receiver_call_;
|
|
|
|
|
std::unique_ptr<PacketTransport> receive_transport_;
|
2015-12-21 03:14:00 -08:00
|
|
|
std::vector<VideoReceiveStream::Config> video_receive_configs_;
|
|
|
|
|
std::vector<VideoReceiveStream*> video_receive_streams_;
|
2016-01-07 17:43:18 +01:00
|
|
|
std::vector<AudioReceiveStream::Config> audio_receive_configs_;
|
|
|
|
|
std::vector<AudioReceiveStream*> audio_receive_streams_;
|
2016-11-15 07:10:52 -08:00
|
|
|
std::vector<FlexfecReceiveStream::Config> flexfec_receive_configs_;
|
|
|
|
|
std::vector<FlexfecReceiveStream*> flexfec_receive_streams_;
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
|
2014-06-27 08:47:52 +00:00
|
|
|
test::FakeEncoder fake_encoder_;
|
2016-03-31 10:24:26 -07:00
|
|
|
std::vector<std::unique_ptr<VideoDecoder>> allocated_decoders_;
|
2016-01-07 17:43:18 +01:00
|
|
|
size_t num_video_streams_;
|
|
|
|
|
size_t num_audio_streams_;
|
2016-11-15 07:10:52 -08:00
|
|
|
size_t num_flexfec_streams_;
|
2016-06-13 07:34:51 -07:00
|
|
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
2017-04-27 02:08:52 -07:00
|
|
|
rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
2016-09-30 06:19:08 -07:00
|
|
|
test::FakeVideoRenderer fake_renderer_;
|
2016-01-07 17:43:18 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// TODO(holmer): Remove once VoiceEngine is fully refactored to the new API.
|
|
|
|
|
// These methods are used to set up legacy voice engines and channels which is
|
|
|
|
|
// necessary while voice engine is being refactored to the new stream API.
|
|
|
|
|
struct VoiceEngineState {
|
|
|
|
|
VoiceEngineState()
|
|
|
|
|
: voice_engine(nullptr),
|
|
|
|
|
base(nullptr),
|
2016-04-29 00:57:13 -07:00
|
|
|
channel_id(-1) {}
|
2016-01-07 17:43:18 +01:00
|
|
|
|
|
|
|
|
VoiceEngine* voice_engine;
|
|
|
|
|
VoEBase* base;
|
|
|
|
|
int channel_id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void CreateVoiceEngines();
|
|
|
|
|
void DestroyVoiceEngines();
|
|
|
|
|
|
|
|
|
|
VoiceEngineState voe_send_;
|
|
|
|
|
VoiceEngineState voe_recv_;
|
2017-06-29 08:32:09 -07:00
|
|
|
rtc::scoped_refptr<AudioProcessing> apm_send_;
|
|
|
|
|
rtc::scoped_refptr<AudioProcessing> apm_recv_;
|
2016-01-07 17:43:18 +01:00
|
|
|
|
|
|
|
|
// The audio devices must outlive the voice engines.
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<test::FakeAudioDevice> fake_send_audio_device_;
|
|
|
|
|
std::unique_ptr<test::FakeAudioDevice> fake_recv_audio_device_;
|
2014-06-27 08:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class BaseTest : public RtpRtcpObserver {
|
|
|
|
|
public:
|
2017-03-21 03:24:27 -07:00
|
|
|
BaseTest();
|
2014-06-27 08:47:52 +00:00
|
|
|
explicit BaseTest(unsigned int timeout_ms);
|
|
|
|
|
virtual ~BaseTest();
|
|
|
|
|
|
|
|
|
|
virtual void PerformTest() = 0;
|
|
|
|
|
virtual bool ShouldCreateReceivers() const = 0;
|
|
|
|
|
|
2016-01-07 17:43:18 +01:00
|
|
|
virtual size_t GetNumVideoStreams() const;
|
|
|
|
|
virtual size_t GetNumAudioStreams() const;
|
2016-11-15 07:10:52 -08:00
|
|
|
virtual size_t GetNumFlexfecStreams() const;
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2017-03-23 03:40:03 -07:00
|
|
|
virtual std::unique_ptr<FakeAudioDevice::Capturer> CreateCapturer();
|
|
|
|
|
virtual std::unique_ptr<FakeAudioDevice::Renderer> CreateRenderer();
|
|
|
|
|
virtual void OnFakeAudioDevicesCreated(FakeAudioDevice* send_audio_device,
|
|
|
|
|
FakeAudioDevice* recv_audio_device);
|
|
|
|
|
|
2014-06-27 08:47:52 +00:00
|
|
|
virtual Call::Config GetSenderCallConfig();
|
|
|
|
|
virtual Call::Config GetReceiverCallConfig();
|
|
|
|
|
virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
|
2016-01-08 06:47:13 -08:00
|
|
|
|
|
|
|
|
virtual test::PacketTransport* CreateSendTransport(Call* sender_call);
|
|
|
|
|
virtual test::PacketTransport* CreateReceiveTransport();
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2015-12-21 03:14:00 -08:00
|
|
|
virtual void ModifyVideoConfigs(
|
2014-06-30 13:19:09 +00:00
|
|
|
VideoSendStream::Config* send_config,
|
|
|
|
|
std::vector<VideoReceiveStream::Config>* receive_configs,
|
2014-09-19 12:30:25 +00:00
|
|
|
VideoEncoderConfig* encoder_config);
|
2016-10-02 23:45:26 -07:00
|
|
|
virtual void ModifyVideoCaptureStartResolution(int* width,
|
|
|
|
|
int* heigt,
|
|
|
|
|
int* frame_rate);
|
2015-12-21 03:14:00 -08:00
|
|
|
virtual void OnVideoStreamsCreated(
|
2014-06-30 13:19:09 +00:00
|
|
|
VideoSendStream* send_stream,
|
|
|
|
|
const std::vector<VideoReceiveStream*>& receive_streams);
|
2014-06-27 08:47:52 +00:00
|
|
|
|
2016-01-07 17:43:18 +01:00
|
|
|
virtual void ModifyAudioConfigs(
|
|
|
|
|
AudioSendStream::Config* send_config,
|
|
|
|
|
std::vector<AudioReceiveStream::Config>* receive_configs);
|
|
|
|
|
virtual void OnAudioStreamsCreated(
|
|
|
|
|
AudioSendStream* send_stream,
|
|
|
|
|
const std::vector<AudioReceiveStream*>& receive_streams);
|
|
|
|
|
|
2016-11-15 07:10:52 -08:00
|
|
|
virtual void ModifyFlexfecConfigs(
|
|
|
|
|
std::vector<FlexfecReceiveStream::Config>* receive_configs);
|
|
|
|
|
virtual void OnFlexfecStreamsCreated(
|
|
|
|
|
const std::vector<FlexfecReceiveStream*>& receive_streams);
|
|
|
|
|
|
2014-06-27 08:47:52 +00:00
|
|
|
virtual void OnFrameGeneratorCapturerCreated(
|
|
|
|
|
FrameGeneratorCapturer* frame_generator_capturer);
|
2016-10-07 11:53:05 -07:00
|
|
|
|
2017-03-23 03:40:03 -07:00
|
|
|
virtual void OnTestFinished();
|
|
|
|
|
|
2017-04-10 03:54:05 -07:00
|
|
|
std::unique_ptr<webrtc::RtcEventLog> event_log_;
|
2014-06-27 08:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SendTest : public BaseTest {
|
|
|
|
|
public:
|
|
|
|
|
explicit SendTest(unsigned int timeout_ms);
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool ShouldCreateReceivers() const override;
|
2014-06-27 08:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class EndToEndTest : public BaseTest {
|
|
|
|
|
public:
|
2017-03-21 03:24:27 -07:00
|
|
|
EndToEndTest();
|
2014-06-27 08:47:52 +00:00
|
|
|
explicit EndToEndTest(unsigned int timeout_ms);
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
bool ShouldCreateReceivers() const override;
|
2014-06-27 08:47:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2016-01-07 17:43:18 +01:00
|
|
|
#endif // WEBRTC_TEST_CALL_TEST_H_
|