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

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 83633008: Reland: Reorganize media::VideoCapture* types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 void OnBufferFilledDispatch(int device_id, 194 void OnBufferFilledDispatch(int device_id,
195 int buffer_id, 195 int buffer_id,
196 base::Time timestamp, 196 base::Time timestamp,
197 const media::VideoCaptureFormat& frame_format) { 197 const media::VideoCaptureFormat& frame_format) {
198 base::SharedMemory* dib = filled_dib_[buffer_id]; 198 base::SharedMemory* dib = filled_dib_[buffer_id];
199 ASSERT_TRUE(dib != NULL); 199 ASSERT_TRUE(dib != NULL);
200 if (dump_video_) { 200 if (dump_video_) {
201 if (!format_.IsValid()) { 201 if (!format_.IsValid()) {
202 dumper_.StartDump(frame_format.width, frame_format.height); 202 dumper_.StartDump(frame_format.frame_size.width(),
203 frame_format.frame_size.height());
203 format_ = frame_format; 204 format_ = frame_format;
204 } 205 }
205 ASSERT_EQ(format_.width, frame_format.width) 206 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width())
206 << "Dump format does not handle variable resolution."; 207 << "Dump format does not handle variable resolution.";
207 ASSERT_EQ(format_.height, frame_format.height) 208 ASSERT_EQ(format_.frame_size.height(), frame_format.frame_size.height())
208 << "Dump format does not handle variable resolution.";; 209 << "Dump format does not handle variable resolution.";
209 dumper_.NewVideoFrame(dib->memory()); 210 dumper_.NewVideoFrame(dib->memory());
210 } 211 }
211 212
212 OnBufferFilled(device_id, buffer_id, timestamp, frame_format); 213 OnBufferFilled(device_id, buffer_id, timestamp, frame_format);
213 if (return_buffers_) { 214 if (return_buffers_) {
214 VideoCaptureHost::OnReceiveEmptyBuffer(device_id, buffer_id); 215 VideoCaptureHost::OnReceiveEmptyBuffer(device_id, buffer_id);
215 } 216 }
216 } 217 }
217 218
218 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { 219 void OnStateChangedDispatch(int device_id, VideoCaptureState state) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 EXPECT_CALL(*host_, OnNewBufferCreated(kDeviceId, _, _, _)) 341 EXPECT_CALL(*host_, OnNewBufferCreated(kDeviceId, _, _, _))
341 .Times(AnyNumber()).WillRepeatedly(Return()); 342 .Times(AnyNumber()).WillRepeatedly(Return());
342 343
343 base::RunLoop run_loop; 344 base::RunLoop run_loop;
344 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _)) 345 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _))
345 .Times(AnyNumber()).WillOnce(ExitMessageLoop( 346 .Times(AnyNumber()).WillOnce(ExitMessageLoop(
346 message_loop_, run_loop.QuitClosure())); 347 message_loop_, run_loop.QuitClosure()));
347 348
348 media::VideoCaptureParams params; 349 media::VideoCaptureParams params;
349 params.requested_format = media::VideoCaptureFormat( 350 params.requested_format = media::VideoCaptureFormat(
350 352, 288, 30, media::ConstantResolutionVideoCaptureDevice); 351 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
351 params.session_id = opened_session_id_; 352 host_->OnStartCapture(kDeviceId, opened_session_id_, params);
352 host_->OnStartCapture(kDeviceId, params);
353 run_loop.Run(); 353 run_loop.Run();
354 } 354 }
355 355
356 void StartStopCapture() { 356 void StartStopCapture() {
357 // Quickly start and then stop capture, without giving much chance for 357 // Quickly start and then stop capture, without giving much chance for
358 // asynchronous start operations to complete. 358 // asynchronous start operations to complete.
359 InSequence s; 359 InSequence s;
360 base::RunLoop run_loop; 360 base::RunLoop run_loop;
361 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)); 361 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED));
362 media::VideoCaptureParams params; 362 media::VideoCaptureParams params;
363 params.requested_format = media::VideoCaptureFormat( 363 params.requested_format = media::VideoCaptureFormat(
364 352, 288, 30, media::ConstantResolutionVideoCaptureDevice); 364 gfx::Size(352, 288), 30, media::PIXEL_FORMAT_I420);
365 params.session_id = opened_session_id_; 365 host_->OnStartCapture(kDeviceId, opened_session_id_, params);
366 host_->OnStartCapture(kDeviceId, params);
367 host_->OnStopCapture(kDeviceId); 366 host_->OnStopCapture(kDeviceId);
368 run_loop.RunUntilIdle(); 367 run_loop.RunUntilIdle();
369 } 368 }
370 369
371 #ifdef DUMP_VIDEO 370 #ifdef DUMP_VIDEO
372 void CaptureAndDumpVideo(int width, int height, int frame_rate) { 371 void CaptureAndDumpVideo(int width, int height, int frame_rate) {
373 InSequence s; 372 InSequence s;
374 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _)) 373 EXPECT_CALL(*host_.get(), OnNewBufferCreated(kDeviceId, _, _, _))
375 .Times(AnyNumber()).WillRepeatedly(Return()); 374 .Times(AnyNumber()).WillRepeatedly(Return());
376 375
377 base::RunLoop run_loop; 376 base::RunLoop run_loop;
378 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _)) 377 EXPECT_CALL(*host_, OnBufferFilled(kDeviceId, _, _, _))
379 .Times(AnyNumber()) 378 .Times(AnyNumber())
380 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); 379 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure()));
381 380
382 media::VideoCaptureParams params; 381 media::VideoCaptureParams params;
383 params.requested_format = media::VideoCaptureFormat( 382 params.requested_format =
384 width, height, frame_rate, media::ConstantResolutionVideoCaptureDevice); 383 media::VideoCaptureFormat(gfx::Size(width, height), frame_rate);
385 params.session_id = opened_session_id_;
386 host_->SetDumpVideo(true); 384 host_->SetDumpVideo(true);
387 host_->OnStartCapture(kDeviceId, params); 385 host_->OnStartCapture(kDeviceId, opened_session_id_, params);
388 run_loop.Run(); 386 run_loop.Run();
389 } 387 }
390 #endif 388 #endif
391 389
392 void StopCapture() { 390 void StopCapture() {
393 base::RunLoop run_loop; 391 base::RunLoop run_loop;
394 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED)) 392 EXPECT_CALL(*host_, OnStateChanged(kDeviceId, VIDEO_CAPTURE_STATE_STOPPED))
395 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure())); 393 .WillOnce(ExitMessageLoop(message_loop_, run_loop.QuitClosure()));
396 394
397 host_->OnStopCapture(kDeviceId); 395 host_->OnStopCapture(kDeviceId);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 #ifdef DUMP_VIDEO 481 #ifdef DUMP_VIDEO
484 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 482 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
485 CaptureAndDumpVideo(640, 480, 30); 483 CaptureAndDumpVideo(640, 480, 30);
486 } 484 }
487 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 485 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
488 CaptureAndDumpVideo(1280, 720, 30); 486 CaptureAndDumpVideo(1280, 720, 30);
489 } 487 }
490 #endif 488 #endif
491 489
492 } // namespace content 490 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host.cc ('k') | content/browser/renderer_host/media/video_capture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698