OLD | NEW |
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 #include "webrtc/video/video_capture_input.h" | 10 #include "webrtc/video/video_capture_input.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 WaitOutputFrame(); | 184 WaitOutputFrame(); |
185 EXPECT_EQ(output_frames_[1]->timestamp(), | 185 EXPECT_EQ(output_frames_[1]->timestamp(), |
186 input_frames_[0]->ntp_time_ms() * 90); | 186 input_frames_[0]->ntp_time_ms() * 90); |
187 } | 187 } |
188 | 188 |
189 TEST_F(VideoCaptureInputTest, TestTextureFrames) { | 189 TEST_F(VideoCaptureInputTest, TestTextureFrames) { |
190 const int kNumFrame = 3; | 190 const int kNumFrame = 3; |
191 for (int i = 0 ; i < kNumFrame; ++i) { | 191 for (int i = 0 ; i < kNumFrame; ++i) { |
192 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); | 192 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); |
193 // Add one to |i| so that width/height > 0. | 193 // Add one to |i| so that width/height > 0. |
194 input_frames_.push_back(new VideoFrame(test::CreateFakeNativeHandleFrame( | 194 input_frames_.push_back(new VideoFrame(test::FakeNativeHandle::CreateFrame( |
195 dummy_handle, i + 1, i + 1, i + 1, i + 1, webrtc::kVideoRotation_0))); | 195 dummy_handle, i + 1, i + 1, i + 1, i + 1, webrtc::kVideoRotation_0))); |
196 AddInputFrame(input_frames_[i]); | 196 AddInputFrame(input_frames_[i]); |
197 WaitOutputFrame(); | 197 WaitOutputFrame(); |
198 EXPECT_EQ(dummy_handle, output_frames_[i]->native_handle()); | 198 EXPECT_EQ(dummy_handle, output_frames_[i]->native_handle()); |
199 } | 199 } |
200 | 200 |
201 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); | 201 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); |
202 } | 202 } |
203 | 203 |
204 TEST_F(VideoCaptureInputTest, TestI420Frames) { | 204 TEST_F(VideoCaptureInputTest, TestI420Frames) { |
205 const int kNumFrame = 4; | 205 const int kNumFrame = 4; |
206 std::vector<const uint8_t*> ybuffer_pointers; | 206 std::vector<const uint8_t*> ybuffer_pointers; |
207 for (int i = 0; i < kNumFrame; ++i) { | 207 for (int i = 0; i < kNumFrame; ++i) { |
208 input_frames_.push_back(CreateVideoFrame(static_cast<uint8_t>(i + 1))); | 208 input_frames_.push_back(CreateVideoFrame(static_cast<uint8_t>(i + 1))); |
209 const VideoFrame* const_input_frame = input_frames_[i]; | 209 const VideoFrame* const_input_frame = input_frames_[i]; |
210 ybuffer_pointers.push_back(const_input_frame->buffer(kYPlane)); | 210 ybuffer_pointers.push_back(const_input_frame->buffer(kYPlane)); |
211 AddInputFrame(input_frames_[i]); | 211 AddInputFrame(input_frames_[i]); |
212 WaitOutputFrame(); | 212 WaitOutputFrame(); |
213 } | 213 } |
214 | 214 |
215 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); | 215 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); |
216 // Make sure the buffer is not copied. | 216 // Make sure the buffer is not copied. |
217 for (int i = 0; i < kNumFrame; ++i) | 217 for (int i = 0; i < kNumFrame; ++i) |
218 EXPECT_EQ(ybuffer_pointers[i], output_frame_ybuffers_[i]); | 218 EXPECT_EQ(ybuffer_pointers[i], output_frame_ybuffers_[i]); |
219 } | 219 } |
220 | 220 |
221 TEST_F(VideoCaptureInputTest, TestI420FrameAfterTextureFrame) { | 221 TEST_F(VideoCaptureInputTest, TestI420FrameAfterTextureFrame) { |
222 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); | 222 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); |
223 input_frames_.push_back(new VideoFrame(test::CreateFakeNativeHandleFrame( | 223 input_frames_.push_back(new VideoFrame(test::FakeNativeHandle::CreateFrame( |
224 dummy_handle, 1, 1, 1, 1, webrtc::kVideoRotation_0))); | 224 dummy_handle, 1, 1, 1, 1, webrtc::kVideoRotation_0))); |
225 AddInputFrame(input_frames_[0]); | 225 AddInputFrame(input_frames_[0]); |
226 WaitOutputFrame(); | 226 WaitOutputFrame(); |
227 EXPECT_EQ(dummy_handle, output_frames_[0]->native_handle()); | 227 EXPECT_EQ(dummy_handle, output_frames_[0]->native_handle()); |
228 | 228 |
229 input_frames_.push_back(CreateVideoFrame(2)); | 229 input_frames_.push_back(CreateVideoFrame(2)); |
230 AddInputFrame(input_frames_[1]); | 230 AddInputFrame(input_frames_[1]); |
231 WaitOutputFrame(); | 231 WaitOutputFrame(); |
232 | 232 |
233 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); | 233 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); |
234 } | 234 } |
235 | 235 |
236 TEST_F(VideoCaptureInputTest, TestTextureFrameAfterI420Frame) { | 236 TEST_F(VideoCaptureInputTest, TestTextureFrameAfterI420Frame) { |
237 input_frames_.push_back(CreateVideoFrame(1)); | 237 input_frames_.push_back(CreateVideoFrame(1)); |
238 AddInputFrame(input_frames_[0]); | 238 AddInputFrame(input_frames_[0]); |
239 WaitOutputFrame(); | 239 WaitOutputFrame(); |
240 | 240 |
241 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); | 241 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); |
242 input_frames_.push_back(new VideoFrame(test::CreateFakeNativeHandleFrame( | 242 input_frames_.push_back(new VideoFrame(test::FakeNativeHandle::CreateFrame( |
243 dummy_handle, 1, 1, 2, 2, webrtc::kVideoRotation_0))); | 243 dummy_handle, 1, 1, 2, 2, webrtc::kVideoRotation_0))); |
244 AddInputFrame(input_frames_[1]); | 244 AddInputFrame(input_frames_[1]); |
245 WaitOutputFrame(); | 245 WaitOutputFrame(); |
246 | 246 |
247 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); | 247 EXPECT_TRUE(EqualFramesVector(input_frames_, output_frames_)); |
248 } | 248 } |
249 | 249 |
250 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2) { | 250 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2) { |
251 if (frame1.native_handle() != NULL || frame2.native_handle() != NULL) | 251 if (frame1.native_handle() != NULL || frame2.native_handle() != NULL) |
252 return EqualTextureFrames(frame1, frame2); | 252 return EqualTextureFrames(frame1, frame2); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 const int kSizeY = width * height * 2; | 296 const int kSizeY = width * height * 2; |
297 uint8_t buffer[kSizeY]; | 297 uint8_t buffer[kSizeY]; |
298 memset(buffer, data, kSizeY); | 298 memset(buffer, data, kSizeY); |
299 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2, | 299 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2, |
300 width / 2); | 300 width / 2); |
301 frame->set_render_time_ms(data); | 301 frame->set_render_time_ms(data); |
302 return frame; | 302 return frame; |
303 } | 303 } |
304 | 304 |
305 } // namespace webrtc | 305 } // namespace webrtc |
OLD | NEW |