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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
130 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kFrameWidth, | 130 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kFrameWidth, |
131 kFrameHeight))); | 131 kFrameHeight))); |
132 | 132 |
133 // Fill content, DPI and updated-region based on |frame_count_| so that each | 133 // Fill content, DPI and updated-region based on |frame_count_| so that each |
134 // generated frame is different. | 134 // generated frame is different. |
| 135 ++frame_count_; |
135 memset(frame->data(), frame_count_, frame->stride() * kFrameHeight); | 136 memset(frame->data(), frame_count_, frame->stride() * kFrameHeight); |
136 frame->set_dpi(webrtc::DesktopVector(frame_count_, frame_count_)); | 137 frame->set_dpi(webrtc::DesktopVector(frame_count_, frame_count_)); |
137 frame->mutable_updated_region()->SetRect( | 138 frame->mutable_updated_region()->SetRect( |
138 webrtc::DesktopRect::MakeWH(frame_count_, frame_count_)); | 139 webrtc::DesktopRect::MakeWH(frame_count_, frame_count_)); |
139 ++frame_count_; | |
140 | 140 |
141 return frame.Pass(); | 141 return frame.Pass(); |
142 } | 142 } |
143 | 143 |
144 void VideoFrameRecorderTest::CreateTestFrames() { | 144 void VideoFrameRecorderTest::CreateTestFrames() { |
145 for (size_t i = 0; i < kTestFrameCount; ++i) { | 145 for (size_t i = 0; i < kTestFrameCount; ++i) { |
146 test_frames_.push_back(CreateNextFrame().release()); | 146 test_frames_.push_back(CreateNextFrame().release()); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void VideoFrameRecorderTest::EncodeTestFrames() { | 150 void VideoFrameRecorderTest::EncodeTestFrames() { |
151 for (DesktopFrames::iterator i = test_frames_.begin(); | 151 for (DesktopFrames::iterator i = test_frames_.begin(); |
152 i != test_frames_.end(); ++i) { | 152 i != test_frames_.end(); ++i) { |
153 ASSERT_TRUE(encoder_->Encode(**i)); | 153 ASSERT_TRUE(encoder_->Encode(**i)); |
154 | 154 |
155 // Process tasks to let the recorder pick up the frame. | 155 // Process tasks to let the recorder pick up the frame. |
156 base::RunLoop().RunUntilIdle(); | 156 base::RunLoop().RunUntilIdle(); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void VideoFrameRecorderTest::EncodeDummyFrame() { | 160 void VideoFrameRecorderTest::EncodeDummyFrame() { |
161 webrtc::BasicDesktopFrame dummy_frame( | 161 webrtc::BasicDesktopFrame dummy_frame( |
162 webrtc::DesktopSize(kFrameWidth, kFrameHeight)); | 162 webrtc::DesktopSize(kFrameWidth, kFrameHeight)); |
| 163 dummy_frame.mutable_updated_region()->SetRect( |
| 164 webrtc::DesktopRect::MakeWH(kFrameWidth, kFrameHeight)); |
163 ASSERT_TRUE(encoder_->Encode(dummy_frame)); | 165 ASSERT_TRUE(encoder_->Encode(dummy_frame)); |
164 base::RunLoop().RunUntilIdle(); | 166 base::RunLoop().RunUntilIdle(); |
165 } | 167 } |
166 | 168 |
167 void VideoFrameRecorderTest::StartRecording() { | 169 void VideoFrameRecorderTest::StartRecording() { |
168 // Start the recorder and pump events to let things initialize. | 170 // Start the recorder and pump events to let things initialize. |
169 recorder_->SetEnableRecording(true); | 171 recorder_->SetEnableRecording(true); |
170 base::RunLoop().RunUntilIdle(); | 172 base::RunLoop().RunUntilIdle(); |
171 } | 173 } |
172 | 174 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 EncodeTestFrames(); | 305 EncodeTestFrames(); |
304 | 306 |
305 // Clear the list of expected test frames, since none should be recorded. | 307 // Clear the list of expected test frames, since none should be recorded. |
306 STLDeleteElements(&test_frames_); | 308 STLDeleteElements(&test_frames_); |
307 | 309 |
308 // Verify that the recorded frames match the ones passed to the encoder. | 310 // Verify that the recorded frames match the ones passed to the encoder. |
309 VerifyTestFrames(); | 311 VerifyTestFrames(); |
310 } | 312 } |
311 | 313 |
312 } // namespace remoting | 314 } // namespace remoting |
OLD | NEW |