Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: webrtc/test/call_test.h

Issue 1542653002: Add audio streams to CallTest and a first A/V call test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment addressed Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/packet_injection_tests.cc ('k') | webrtc/test/call_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #ifndef WEBRTC_TEST_COMMON_CALL_TEST_H_ 10 #ifndef WEBRTC_TEST_CALL_TEST_H_
11 #define WEBRTC_TEST_COMMON_CALL_TEST_H_ 11 #define WEBRTC_TEST_CALL_TEST_H_
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/call.h" 15 #include "webrtc/call.h"
16 #include "webrtc/call/transport_adapter.h"
16 #include "webrtc/system_wrappers/include/scoped_vector.h" 17 #include "webrtc/system_wrappers/include/scoped_vector.h"
18 #include "webrtc/test/fake_audio_device.h"
17 #include "webrtc/test/fake_decoder.h" 19 #include "webrtc/test/fake_decoder.h"
18 #include "webrtc/test/fake_encoder.h" 20 #include "webrtc/test/fake_encoder.h"
19 #include "webrtc/test/frame_generator_capturer.h" 21 #include "webrtc/test/frame_generator_capturer.h"
20 #include "webrtc/test/rtp_rtcp_observer.h" 22 #include "webrtc/test/rtp_rtcp_observer.h"
21 23
22 namespace webrtc { 24 namespace webrtc {
25
26 class VoEBase;
27 class VoECodec;
28 class VoENetwork;
29
23 namespace test { 30 namespace test {
24 31
25 class BaseTest; 32 class BaseTest;
26 33
27 class CallTest : public ::testing::Test { 34 class CallTest : public ::testing::Test {
28 public: 35 public:
29 CallTest(); 36 CallTest();
30 ~CallTest(); 37 virtual ~CallTest();
31 38
32 static const size_t kNumSsrcs = 3; 39 static const size_t kNumSsrcs = 3;
33 40
34 static const int kDefaultTimeoutMs; 41 static const int kDefaultTimeoutMs;
35 static const int kLongTimeoutMs; 42 static const int kLongTimeoutMs;
36 static const uint8_t kSendPayloadType; 43 static const uint8_t kVideoSendPayloadType;
37 static const uint8_t kSendRtxPayloadType; 44 static const uint8_t kSendRtxPayloadType;
38 static const uint8_t kFakeSendPayloadType; 45 static const uint8_t kFakeVideoSendPayloadType;
39 static const uint8_t kRedPayloadType; 46 static const uint8_t kRedPayloadType;
40 static const uint8_t kRtxRedPayloadType; 47 static const uint8_t kRtxRedPayloadType;
41 static const uint8_t kUlpfecPayloadType; 48 static const uint8_t kUlpfecPayloadType;
49 static const uint8_t kAudioSendPayloadType;
42 static const uint32_t kSendRtxSsrcs[kNumSsrcs]; 50 static const uint32_t kSendRtxSsrcs[kNumSsrcs];
43 static const uint32_t kSendSsrcs[kNumSsrcs]; 51 static const uint32_t kVideoSendSsrcs[kNumSsrcs];
44 static const uint32_t kReceiverLocalSsrc; 52 static const uint32_t kAudioSendSsrc;
53 static const uint32_t kReceiverLocalVideoSsrc;
54 static const uint32_t kReceiverLocalAudioSsrc;
45 static const int kNackRtpHistoryMs; 55 static const int kNackRtpHistoryMs;
46 56
47 protected: 57 protected:
58 // RunBaseTest overwrites the audio_state and the voice_engine of the send and
59 // receive Call configs to simplify test code and avoid having old VoiceEngine
60 // APIs in the tests.
48 void RunBaseTest(BaseTest* test, const FakeNetworkPipe::Config& config); 61 void RunBaseTest(BaseTest* test, const FakeNetworkPipe::Config& config);
49 62
50 void CreateCalls(const Call::Config& sender_config, 63 void CreateCalls(const Call::Config& sender_config,
51 const Call::Config& receiver_config); 64 const Call::Config& receiver_config);
52 void CreateSenderCall(const Call::Config& config); 65 void CreateSenderCall(const Call::Config& config);
53 void CreateReceiverCall(const Call::Config& config); 66 void CreateReceiverCall(const Call::Config& config);
54 void DestroyCalls(); 67 void DestroyCalls();
55 68
56 void CreateSendConfig(size_t num_streams, Transport* send_transport); 69 void CreateSendConfig(size_t num_video_streams,
70 size_t num_audio_streams,
71 Transport* send_transport);
57 void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport); 72 void CreateMatchingReceiveConfigs(Transport* rtcp_send_transport);
58 73
59 void CreateFrameGeneratorCapturer(); 74 void CreateFrameGeneratorCapturer();
75 void CreateFakeAudioDevices();
60 76
61 void CreateStreams(); 77 void CreateVideoStreams();
78 void CreateAudioStreams();
62 void Start(); 79 void Start();
63 void Stop(); 80 void Stop();
64 void DestroyStreams(); 81 void DestroyStreams();
65 82
66 Clock* const clock_; 83 Clock* const clock_;
67 84
68 rtc::scoped_ptr<Call> sender_call_; 85 rtc::scoped_ptr<Call> sender_call_;
69 rtc::scoped_ptr<PacketTransport> send_transport_; 86 rtc::scoped_ptr<PacketTransport> send_transport_;
70 VideoSendStream::Config video_send_config_; 87 VideoSendStream::Config video_send_config_;
71 VideoEncoderConfig video_encoder_config_; 88 VideoEncoderConfig video_encoder_config_;
72 VideoSendStream* video_send_stream_; 89 VideoSendStream* video_send_stream_;
90 AudioSendStream::Config audio_send_config_;
91 AudioSendStream* audio_send_stream_;
73 92
74 rtc::scoped_ptr<Call> receiver_call_; 93 rtc::scoped_ptr<Call> receiver_call_;
75 rtc::scoped_ptr<PacketTransport> receive_transport_; 94 rtc::scoped_ptr<PacketTransport> receive_transport_;
76 std::vector<VideoReceiveStream::Config> video_receive_configs_; 95 std::vector<VideoReceiveStream::Config> video_receive_configs_;
77 std::vector<VideoReceiveStream*> video_receive_streams_; 96 std::vector<VideoReceiveStream*> video_receive_streams_;
97 std::vector<AudioReceiveStream::Config> audio_receive_configs_;
98 std::vector<AudioReceiveStream*> audio_receive_streams_;
78 99
79 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_; 100 rtc::scoped_ptr<test::FrameGeneratorCapturer> frame_generator_capturer_;
80 test::FakeEncoder fake_encoder_; 101 test::FakeEncoder fake_encoder_;
81 ScopedVector<VideoDecoder> allocated_decoders_; 102 ScopedVector<VideoDecoder> allocated_decoders_;
103 size_t num_video_streams_;
104 size_t num_audio_streams_;
105
106 private:
107 // TODO(holmer): Remove once VoiceEngine is fully refactored to the new API.
108 // These methods are used to set up legacy voice engines and channels which is
109 // necessary while voice engine is being refactored to the new stream API.
110 struct VoiceEngineState {
111 VoiceEngineState()
112 : voice_engine(nullptr),
113 base(nullptr),
114 network(nullptr),
115 codec(nullptr),
116 channel_id(-1),
117 transport_adapter(nullptr) {}
118
119 VoiceEngine* voice_engine;
120 VoEBase* base;
121 VoENetwork* network;
122 VoECodec* codec;
123 int channel_id;
124 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter;
125 };
126
127 void CreateVoiceEngines();
128 void SetupVoiceEngineTransports(PacketTransport* send_transport,
129 PacketTransport* recv_transport);
130 void DestroyVoiceEngines();
131
132 VoiceEngineState voe_send_;
133 VoiceEngineState voe_recv_;
134
135 // The audio devices must outlive the voice engines.
136 rtc::scoped_ptr<test::FakeAudioDevice> fake_send_audio_device_;
137 rtc::scoped_ptr<test::FakeAudioDevice> fake_recv_audio_device_;
82 }; 138 };
83 139
84 class BaseTest : public RtpRtcpObserver { 140 class BaseTest : public RtpRtcpObserver {
85 public: 141 public:
86 explicit BaseTest(unsigned int timeout_ms); 142 explicit BaseTest(unsigned int timeout_ms);
87 virtual ~BaseTest(); 143 virtual ~BaseTest();
88 144
89 virtual void PerformTest() = 0; 145 virtual void PerformTest() = 0;
90 virtual bool ShouldCreateReceivers() const = 0; 146 virtual bool ShouldCreateReceivers() const = 0;
91 147
92 virtual size_t GetNumStreams() const; 148 virtual size_t GetNumVideoStreams() const;
149 virtual size_t GetNumAudioStreams() const;
93 150
94 virtual Call::Config GetSenderCallConfig(); 151 virtual Call::Config GetSenderCallConfig();
95 virtual Call::Config GetReceiverCallConfig(); 152 virtual Call::Config GetReceiverCallConfig();
96 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call); 153 virtual void OnCallsCreated(Call* sender_call, Call* receiver_call);
97 virtual void OnTransportsCreated(PacketTransport* send_transport, 154 virtual void OnTransportsCreated(PacketTransport* send_transport,
98 PacketTransport* receive_transport); 155 PacketTransport* receive_transport);
99 156
100 virtual void ModifyVideoConfigs( 157 virtual void ModifyVideoConfigs(
101 VideoSendStream::Config* send_config, 158 VideoSendStream::Config* send_config,
102 std::vector<VideoReceiveStream::Config>* receive_configs, 159 std::vector<VideoReceiveStream::Config>* receive_configs,
103 VideoEncoderConfig* encoder_config); 160 VideoEncoderConfig* encoder_config);
104 virtual void OnVideoStreamsCreated( 161 virtual void OnVideoStreamsCreated(
105 VideoSendStream* send_stream, 162 VideoSendStream* send_stream,
106 const std::vector<VideoReceiveStream*>& receive_streams); 163 const std::vector<VideoReceiveStream*>& receive_streams);
107 164
165 virtual void ModifyAudioConfigs(
166 AudioSendStream::Config* send_config,
167 std::vector<AudioReceiveStream::Config>* receive_configs);
168 virtual void OnAudioStreamsCreated(
169 AudioSendStream* send_stream,
170 const std::vector<AudioReceiveStream*>& receive_streams);
171
108 virtual void OnFrameGeneratorCapturerCreated( 172 virtual void OnFrameGeneratorCapturerCreated(
109 FrameGeneratorCapturer* frame_generator_capturer); 173 FrameGeneratorCapturer* frame_generator_capturer);
110 }; 174 };
111 175
112 class SendTest : public BaseTest { 176 class SendTest : public BaseTest {
113 public: 177 public:
114 explicit SendTest(unsigned int timeout_ms); 178 explicit SendTest(unsigned int timeout_ms);
115 179
116 bool ShouldCreateReceivers() const override; 180 bool ShouldCreateReceivers() const override;
117 }; 181 };
118 182
119 class EndToEndTest : public BaseTest { 183 class EndToEndTest : public BaseTest {
120 public: 184 public:
121 explicit EndToEndTest(unsigned int timeout_ms); 185 explicit EndToEndTest(unsigned int timeout_ms);
122 186
123 bool ShouldCreateReceivers() const override; 187 bool ShouldCreateReceivers() const override;
124 }; 188 };
125 189
126 } // namespace test 190 } // namespace test
127 } // namespace webrtc 191 } // namespace webrtc
128 192
129 #endif // WEBRTC_TEST_COMMON_CALL_TEST_H_ 193 #endif // WEBRTC_TEST_CALL_TEST_H_
OLDNEW
« no previous file with comments | « webrtc/call/packet_injection_tests.cc ('k') | webrtc/test/call_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698