1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
/*
* Copyright 2018 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.
*/
#include <memory>
#include "api/test/create_frame_generator.h"
#include "api/test/frame_generator_interface.h"
#include "api/test/simulated_network.h"
#include "call/fake_network_pipe.h"
#include "call/simulated_network.h"
#include "rtc_base/task_queue_for_test.h"
#include "system_wrappers/include/sleep.h"
#include "test/call_test.h"
#include "test/field_trial.h"
#include "test/frame_forwarder.h"
#include "test/gtest.h"
#include "test/null_transport.h"
#include "test/video_test_constants.h"
namespace webrtc {
class CallOperationEndToEndTest : public test::CallTest {};
TEST_F(CallOperationEndToEndTest, ReceiverCanBeStartedTwice) {
CreateCalls();
test::NullTransport transport;
CreateSendConfig(1, 0, 0, &transport);
CreateMatchingReceiveConfigs(&transport);
CreateVideoStreams();
video_receive_streams_[0]->Start();
video_receive_streams_[0]->Start();
DestroyStreams();
}
TEST_F(CallOperationEndToEndTest, ReceiverCanBeStoppedTwice) {
CreateCalls();
test::NullTransport transport;
CreateSendConfig(1, 0, 0, &transport);
CreateMatchingReceiveConfigs(&transport);
CreateVideoStreams();
video_receive_streams_[0]->Stop();
video_receive_streams_[0]->Stop();
DestroyStreams();
}
TEST_F(CallOperationEndToEndTest, ReceiverCanBeStoppedAndRestarted) {
CreateCalls();
test::NullTransport transport;
CreateSendConfig(1, 0, 0, &transport);
CreateMatchingReceiveConfigs(&transport);
CreateVideoStreams();
video_receive_streams_[0]->Stop();
video_receive_streams_[0]->Start();
video_receive_streams_[0]->Stop();
DestroyStreams();
}
TEST_F(CallOperationEndToEndTest, RendersSingleDelayedFrame) {
static const int kWidth = 320;
static const int kHeight = 240;
// This constant is chosen to be higher than the timeout in the video_render
// module. This makes sure that frames aren't dropped if there are no other
// frames in the queue.
static const int kRenderDelayMs = 1000;
class Renderer : public rtc::VideoSinkInterface<VideoFrame> {
public:
void OnFrame(const VideoFrame& video_frame) override {
SleepMs(kRenderDelayMs);
event_.Set();
}
bool Wait() {
return event_.Wait(test::VideoTestConstants::kDefaultTimeout);
}
rtc::Event event_;
} renderer;
test::FrameForwarder frame_forwarder;
SendTask(task_queue(), [this, &renderer, &frame_forwarder]() {
CreateCalls();
CreateSendTransport(BuiltInNetworkBehaviorConfig(),
/*observer=*/nullptr);
CreateReceiveTransport(BuiltInNetworkBehaviorConfig(),
/*observer=*/nullptr);
CreateSendConfig(1, 0, 0);
CreateMatchingReceiveConfigs();
video_receive_configs_[0].renderer = &renderer;
CreateVideoStreams();
Start();
// Create frames that are smaller than the send width/height, this is
// done to check that the callbacks are done after processing video.
std::unique_ptr<test::FrameGeneratorInterface> frame_generator(
test::CreateSquareFrameGenerator(kWidth, kHeight, absl::nullopt,
absl::nullopt));
GetVideoSendStream()->SetSource(&frame_forwarder,
DegradationPreference::MAINTAIN_FRAMERATE);
test::FrameGeneratorInterface::VideoFrameData frame_data =
frame_generator->NextFrame();
VideoFrame frame = VideoFrame::Builder()
.set_video_frame_buffer(frame_data.buffer)
.set_update_rect(frame_data.update_rect)
.build();
frame_forwarder.IncomingCapturedFrame(frame);
});
EXPECT_TRUE(renderer.Wait())
<< "Timed out while waiting for the frame to render.";
SendTask(task_queue(), [this]() {
Stop();
DestroyStreams();
DestroyCalls();
});
}
TEST_F(CallOperationEndToEndTest, TransmitsFirstFrame) {
class Renderer : public rtc::VideoSinkInterface<VideoFrame> {
public:
void OnFrame(const VideoFrame& video_frame) override { event_.Set(); }
bool Wait() {
return event_.Wait(test::VideoTestConstants::kDefaultTimeout);
}
rtc::Event event_;
} renderer;
std::unique_ptr<test::FrameGeneratorInterface> frame_generator;
test::FrameForwarder frame_forwarder;
std::unique_ptr<test::DirectTransport> sender_transport;
std::unique_ptr<test::DirectTransport> receiver_transport;
SendTask(task_queue(), [this, &renderer, &frame_generator,
&frame_forwarder]() {
CreateCalls();
CreateSendTransport(BuiltInNetworkBehaviorConfig(),
/*observer=*/nullptr);
CreateReceiveTransport(BuiltInNetworkBehaviorConfig(),
/*observer=*/nullptr);
CreateSendConfig(1, 0, 0);
CreateMatchingReceiveConfigs();
video_receive_configs_[0].renderer = &renderer;
CreateVideoStreams();
Start();
frame_generator = test::CreateSquareFrameGenerator(
test::VideoTestConstants::kDefaultWidth,
test::VideoTestConstants::kDefaultHeight, absl::nullopt, absl::nullopt);
GetVideoSendStream()->SetSource(&frame_forwarder,
DegradationPreference::MAINTAIN_FRAMERATE);
test::FrameGeneratorInterface::VideoFrameData frame_data =
frame_generator->NextFrame();
VideoFrame frame = VideoFrame::Builder()
.set_video_frame_buffer(frame_data.buffer)
.set_update_rect(frame_data.update_rect)
.build();
frame_forwarder.IncomingCapturedFrame(frame);
});
EXPECT_TRUE(renderer.Wait())
<< "Timed out while waiting for the frame to render.";
SendTask(task_queue(), [this]() {
Stop();
DestroyStreams();
DestroyCalls();
});
}
} // namespace webrtc
|