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

Side by Side Diff: remoting/protocol/connection_unittest.cc

Issue 2035803002: Fix WebRtcFrameScheduler to wait for first key frame request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 class TestScreenCapturer : public webrtc::DesktopCapturer { 64 class TestScreenCapturer : public webrtc::DesktopCapturer {
65 public: 65 public:
66 TestScreenCapturer() {} 66 TestScreenCapturer() {}
67 ~TestScreenCapturer() override {} 67 ~TestScreenCapturer() override {}
68 68
69 // webrtc::DesktopCapturer interface. 69 // webrtc::DesktopCapturer interface.
70 void Start(Callback* callback) override { 70 void Start(Callback* callback) override {
71 callback_ = callback; 71 callback_ = callback;
72 } 72 }
73 void Capture(const webrtc::DesktopRegion& region) override { 73 void Capture(const webrtc::DesktopRegion& region) override {
74 // Return black 10x10 frame. 74 // Return black 10x10 frame.
Irfan 2016/06/02 19:06:00 Is this 10x10 comment right ?
Sergey Ulanov 2016/06/03 06:01:23 Done.
75 std::unique_ptr<webrtc::DesktopFrame> frame( 75 std::unique_ptr<webrtc::DesktopFrame> frame(
76 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(100, 100))); 76 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(100, 100)));
77 memset(frame->data(), 0, frame->stride() * frame->size().height()); 77 memset(frame->data(), 0, frame->stride() * frame->size().height());
78 frame->mutable_updated_region()->SetRect( 78 if (!first_frame_sent_) {
79 webrtc::DesktopRect::MakeSize(frame->size())); 79 first_frame_sent_ = true;
Irfan 2016/06/02 19:06:00 Can you please explain what this does ?
Sergey Ulanov 2016/06/03 06:01:23 added a comment.
80 frame->mutable_updated_region()->SetRect(
81 webrtc::DesktopRect::MakeSize(frame->size()));
82 }
80 callback_->OnCaptureCompleted(frame.release()); 83 callback_->OnCaptureCompleted(frame.release());
81 } 84 }
82 85
83 private: 86 private:
84 Callback* callback_ = nullptr; 87 Callback* callback_ = nullptr;
88 bool first_frame_sent_ = false;
85 }; 89 };
86 90
87 } // namespace 91 } // namespace
88 92
89 class ConnectionTest : public testing::Test, 93 class ConnectionTest : public testing::Test,
90 public testing::WithParamInterface<bool> { 94 public testing::WithParamInterface<bool> {
91 public: 95 public:
92 ConnectionTest() {} 96 ConnectionTest() {}
93 97
94 protected: 98 protected:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (client_connected_ && run_loop_) 185 if (client_connected_ && run_loop_)
182 run_loop_->Quit(); 186 run_loop_->Quit();
183 } 187 }
184 188
185 void OnClientConnected() { 189 void OnClientConnected() {
186 client_connected_ = true; 190 client_connected_ = true;
187 if (host_connected_ && run_loop_) 191 if (host_connected_ && run_loop_)
188 run_loop_->Quit(); 192 run_loop_->Quit();
189 } 193 }
190 194
195 void WaitFirstVideoFrame() {
196 base::RunLoop run_loop;
197
198 // Expect frames to be passed to FrameConsumer when WebRTC is used, or to
199 // VideoStub otherwise.
200 if (is_using_webrtc()) {
201 client_video_renderer_.GetFrameConsumer()->set_on_frame_callback(
202 base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
203 } else {
204 client_video_renderer_.GetVideoStub()->set_on_frame_callback(
205 base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
206 }
207
208 run_loop.Run();
209
210 if (is_using_webrtc()) {
211 EXPECT_EQ(
212 client_video_renderer_.GetFrameConsumer()->received_frames().size(),
213 1U);
214 EXPECT_EQ(
215 client_video_renderer_.GetVideoStub()->received_packets().size(), 0U);
216 } else {
217 EXPECT_EQ(
218 client_video_renderer_.GetFrameConsumer()->received_frames().size(),
219 0U);
220 EXPECT_EQ(
221 client_video_renderer_.GetVideoStub()->received_packets().size(), 1U);
222 }
223 }
224
191 base::MessageLoopForIO message_loop_; 225 base::MessageLoopForIO message_loop_;
192 std::unique_ptr<base::RunLoop> run_loop_; 226 std::unique_ptr<base::RunLoop> run_loop_;
193 227
194 MockConnectionToClientEventHandler host_event_handler_; 228 MockConnectionToClientEventHandler host_event_handler_;
195 MockClipboardStub host_clipboard_stub_; 229 MockClipboardStub host_clipboard_stub_;
196 MockHostStub host_stub_; 230 MockHostStub host_stub_;
197 MockInputStub host_input_stub_; 231 MockInputStub host_input_stub_;
198 std::unique_ptr<ConnectionToClient> host_connection_; 232 std::unique_ptr<ConnectionToClient> host_connection_;
199 FakeSession* host_session_; // Owned by |host_connection_|. 233 FakeSession* host_session_; // Owned by |host_connection_|.
200 bool host_connected_ = false; 234 bool host_connected_ = false;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 run_loop.Run(); 312 run_loop.Run();
279 } 313 }
280 314
281 TEST_P(ConnectionTest, Video) { 315 TEST_P(ConnectionTest, Video) {
282 Connect(); 316 Connect();
283 317
284 std::unique_ptr<VideoStream> video_stream = 318 std::unique_ptr<VideoStream> video_stream =
285 host_connection_->StartVideoStream( 319 host_connection_->StartVideoStream(
286 base::WrapUnique(new TestScreenCapturer())); 320 base::WrapUnique(new TestScreenCapturer()));
287 321
288 base::RunLoop run_loop; 322 WaitFirstVideoFrame();
323 }
289 324
290 // Expect frames to be passed to FrameConsumer when WebRTC is used, or to 325 TEST_P(ConnectionTest, VideoAfterIceDelay) {
291 // VideoStub otherwise. 326 // Add signaling delay to slow down ICE.
292 if (is_using_webrtc()) { 327 host_session_->set_signaling_delay(base::TimeDelta::FromMilliseconds(200));
Irfan 2016/06/02 19:06:00 Comment seems to indicate this is ICE specific, bu
Sergey Ulanov 2016/06/03 06:01:23 ICE is used internally it WebRTC too. But this com
293 client_video_renderer_.GetFrameConsumer()->set_on_frame_callback( 328 client_session_->set_signaling_delay(base::TimeDelta::FromMilliseconds(200));
294 base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
295 } else {
296 client_video_renderer_.GetVideoStub()->set_on_frame_callback(
297 base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
298 }
299 329
300 run_loop.Run(); 330 Connect();
301 331
302 if (is_using_webrtc()) { 332 std::unique_ptr<VideoStream> video_stream =
303 EXPECT_EQ( 333 host_connection_->StartVideoStream(
304 client_video_renderer_.GetFrameConsumer()->received_frames().size(), 334 base::WrapUnique(new TestScreenCapturer()));
305 1U);
306 EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(),
307 0U);
308 } else {
309 EXPECT_EQ(
310 client_video_renderer_.GetFrameConsumer()->received_frames().size(),
311 0U);
312 EXPECT_EQ(client_video_renderer_.GetVideoStub()->received_packets().size(),
313 1U);
314 }
315 335
336 WaitFirstVideoFrame();
316 } 337 }
317 338
318 } // namespace protocol 339 } // namespace protocol
319 } // namespace remoting 340 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/fake_session.h » ('j') | remoting/protocol/webrtc_frame_scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698