OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/video_frame_recorder.h" | 5 #include "remoting/host/video_frame_recorder.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "remoting/codec/video_encoder_verbatim.h" | 10 #include "remoting/codec/video_encoder_verbatim.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // Tear down the recorder, if necessary. | 113 // Tear down the recorder, if necessary. |
114 recorder_.reset(); | 114 recorder_.reset(); |
115 | 115 |
116 // Process any events resulting from recorder teardown. | 116 // Process any events resulting from recorder teardown. |
117 base::RunLoop().RunUntilIdle(); | 117 base::RunLoop().RunUntilIdle(); |
118 } | 118 } |
119 | 119 |
120 void VideoFrameRecorderTest::CreateAndWrapEncoder() { | 120 void VideoFrameRecorderTest::CreateAndWrapEncoder() { |
121 scoped_ptr<VideoEncoder> encoder(new VideoEncoderVerbatim()); | 121 scoped_ptr<VideoEncoder> encoder(new VideoEncoderVerbatim()); |
122 encoder_ = recorder_->WrapVideoEncoder(encoder.Pass()); | 122 encoder_ = recorder_->WrapVideoEncoder(std::move(encoder)); |
123 | 123 |
124 // Encode a dummy frame to bind the wrapper to the TaskRunner. | 124 // Encode a dummy frame to bind the wrapper to the TaskRunner. |
125 EncodeDummyFrame(); | 125 EncodeDummyFrame(); |
126 } | 126 } |
127 | 127 |
128 scoped_ptr<webrtc::DesktopFrame> VideoFrameRecorderTest::CreateNextFrame() { | 128 scoped_ptr<webrtc::DesktopFrame> VideoFrameRecorderTest::CreateNextFrame() { |
129 scoped_ptr<webrtc::DesktopFrame> frame( | 129 scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame( |
130 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kFrameWidth, | 130 webrtc::DesktopSize(kFrameWidth, kFrameHeight))); |
131 kFrameHeight))); | |
132 | 131 |
133 // Fill content, DPI and updated-region based on |frame_count_| so that each | 132 // Fill content, DPI and updated-region based on |frame_count_| so that each |
134 // generated frame is different. | 133 // generated frame is different. |
135 ++frame_count_; | 134 ++frame_count_; |
136 memset(frame->data(), frame_count_, frame->stride() * kFrameHeight); | 135 memset(frame->data(), frame_count_, frame->stride() * kFrameHeight); |
137 frame->set_dpi(webrtc::DesktopVector(frame_count_, frame_count_)); | 136 frame->set_dpi(webrtc::DesktopVector(frame_count_, frame_count_)); |
138 frame->mutable_updated_region()->SetRect( | 137 frame->mutable_updated_region()->SetRect( |
139 webrtc::DesktopRect::MakeWH(frame_count_, frame_count_)); | 138 webrtc::DesktopRect::MakeWH(frame_count_, frame_count_)); |
140 | 139 |
141 return frame.Pass(); | 140 return frame; |
142 } | 141 } |
143 | 142 |
144 void VideoFrameRecorderTest::CreateTestFrames() { | 143 void VideoFrameRecorderTest::CreateTestFrames() { |
145 for (size_t i = 0; i < kTestFrameCount; ++i) { | 144 for (size_t i = 0; i < kTestFrameCount; ++i) { |
146 test_frames_.push_back(CreateNextFrame().release()); | 145 test_frames_.push_back(CreateNextFrame().release()); |
147 } | 146 } |
148 } | 147 } |
149 | 148 |
150 void VideoFrameRecorderTest::EncodeTestFrames() { | 149 void VideoFrameRecorderTest::EncodeTestFrames() { |
151 for (DesktopFrames::iterator i = test_frames_.begin(); | 150 for (DesktopFrames::iterator i = test_frames_.begin(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 EncodeTestFrames(); | 304 EncodeTestFrames(); |
306 | 305 |
307 // Clear the list of expected test frames, since none should be recorded. | 306 // Clear the list of expected test frames, since none should be recorded. |
308 STLDeleteElements(&test_frames_); | 307 STLDeleteElements(&test_frames_); |
309 | 308 |
310 // Verify that the recorded frames match the ones passed to the encoder. | 309 // Verify that the recorded frames match the ones passed to the encoder. |
311 VerifyTestFrames(); | 310 VerifyTestFrames(); |
312 } | 311 } |
313 | 312 |
314 } // namespace remoting | 313 } // namespace remoting |
OLD | NEW |