Chromium Code Reviews| 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 "media/capture/video/fake_video_capture_device.h" | 5 #include "media/capture/video/fake_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 class FakeVideoCaptureDeviceTest | 266 class FakeVideoCaptureDeviceTest |
| 267 : public FakeVideoCaptureDeviceBase, | 267 : public FakeVideoCaptureDeviceBase, |
| 268 public ::testing::WithParamInterface< | 268 public ::testing::WithParamInterface< |
| 269 ::testing::tuple<VideoPixelFormat, | 269 ::testing::tuple<VideoPixelFormat, |
| 270 FakeVideoCaptureDeviceMaker::DeliveryMode, | 270 FakeVideoCaptureDeviceMaker::DeliveryMode, |
| 271 float>> {}; | 271 float>> {}; |
| 272 | 272 |
| 273 // Tests that a frame is delivered with the expected settings. | 273 // Tests that a frame is delivered with the expected settings. |
| 274 // Sweeps through a fixed set of requested/expected resolutions. | 274 // Sweeps through a fixed set of requested/expected resolutions. |
| 275 TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) { | 275 TEST_P(FakeVideoCaptureDeviceTest, CaptureUsing) { |
| 276 if (testing::get<1>(GetParam()) == FakeVideoCaptureDeviceMaker::DeliveryMode:: | |
| 277 USE_CLIENT_PROVIDED_BUFFERS && | |
| 278 testing::get<0>(GetParam()) == media::PIXEL_FORMAT_MJPEG) { | |
| 279 // Unsupported case | |
| 280 return; | |
| 281 } | |
|
mcasas
2017/02/17 18:35:47
If you add a TODO to add support for Client
buffe
chfremer
2017/02/22 17:28:42
Currently not planning a TODO. See my other commen
| |
| 282 | |
| 276 const std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 283 const std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( |
| 277 EnumerateDevices()); | 284 EnumerateDevices()); |
| 278 ASSERT_FALSE(descriptors->empty()); | 285 ASSERT_FALSE(descriptors->empty()); |
| 279 | 286 |
| 280 auto device = FakeVideoCaptureDeviceMaker::MakeInstance( | 287 auto device = FakeVideoCaptureDeviceMaker::MakeInstance( |
| 281 testing::get<0>(GetParam()), testing::get<1>(GetParam()), | 288 testing::get<0>(GetParam()), testing::get<1>(GetParam()), |
| 282 testing::get<2>(GetParam())); | 289 testing::get<2>(GetParam())); |
| 283 ASSERT_TRUE(device); | 290 ASSERT_TRUE(device); |
| 284 | 291 |
| 285 // First: Requested, Second: Expected | 292 // First: Requested, Second: Expected |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 305 EXPECT_EQ(resolution.second.height(), last_format().frame_size.height()); | 312 EXPECT_EQ(resolution.second.height(), last_format().frame_size.height()); |
| 306 EXPECT_EQ(last_format().pixel_format, testing::get<0>(GetParam())); | 313 EXPECT_EQ(last_format().pixel_format, testing::get<0>(GetParam())); |
| 307 EXPECT_EQ(last_format().frame_rate, testing::get<2>(GetParam())); | 314 EXPECT_EQ(last_format().frame_rate, testing::get<2>(GetParam())); |
| 308 device->StopAndDeAllocate(); | 315 device->StopAndDeAllocate(); |
| 309 } | 316 } |
| 310 } | 317 } |
| 311 | 318 |
| 312 INSTANTIATE_TEST_CASE_P( | 319 INSTANTIATE_TEST_CASE_P( |
| 313 , | 320 , |
| 314 FakeVideoCaptureDeviceTest, | 321 FakeVideoCaptureDeviceTest, |
| 315 Combine(Values(PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_ARGB), | 322 Combine(Values(PIXEL_FORMAT_I420, |
| 323 PIXEL_FORMAT_Y16, | |
| 324 PIXEL_FORMAT_ARGB, | |
| 325 PIXEL_FORMAT_MJPEG), | |
| 316 Values(FakeVideoCaptureDeviceMaker::DeliveryMode:: | 326 Values(FakeVideoCaptureDeviceMaker::DeliveryMode:: |
| 317 USE_DEVICE_INTERNAL_BUFFERS, | 327 USE_DEVICE_INTERNAL_BUFFERS, |
| 318 FakeVideoCaptureDeviceMaker::DeliveryMode:: | 328 FakeVideoCaptureDeviceMaker::DeliveryMode:: |
| 319 USE_CLIENT_PROVIDED_BUFFERS), | 329 USE_CLIENT_PROVIDED_BUFFERS), |
| 320 Values(20, 29.97, 30, 50, 60))); | 330 Values(20, 29.97, 30, 50, 60))); |
| 321 | 331 |
| 322 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { | 332 TEST_F(FakeVideoCaptureDeviceTest, GetDeviceSupportedFormats) { |
| 323 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 333 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 324 switches::kUseFakeDeviceForMediaStream, "device-count=3"); | 334 switches::kUseFakeDeviceForMediaStream, "device-count=4"); |
| 325 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( | 335 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors( |
| 326 EnumerateDevices()); | 336 EnumerateDevices()); |
| 327 ASSERT_EQ(3u, descriptors->size()); | 337 ASSERT_EQ(4u, descriptors->size()); |
| 328 | 338 |
| 329 for (const auto& descriptors_iterator : *descriptors) { | 339 for (const auto& descriptors_iterator : *descriptors) { |
| 330 VideoCaptureFormats supported_formats; | 340 VideoCaptureFormats supported_formats; |
| 331 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, | 341 video_capture_device_factory_->GetSupportedFormats(descriptors_iterator, |
| 332 &supported_formats); | 342 &supported_formats); |
| 333 ASSERT_EQ(5u, supported_formats.size()); | 343 ASSERT_EQ(5u, supported_formats.size()); |
| 334 const std::string device_id = descriptors_iterator.device_id; | |
| 335 VideoPixelFormat expected_format = | 344 VideoPixelFormat expected_format = |
| 336 (device_id == "/dev/video1") ? PIXEL_FORMAT_Y16 : PIXEL_FORMAT_I420; | 345 FakeVideoCaptureDeviceFactory::GetPixelFormatFromDeviceId( |
| 346 descriptors_iterator.device_id); | |
| 337 EXPECT_EQ(96, supported_formats[0].frame_size.width()); | 347 EXPECT_EQ(96, supported_formats[0].frame_size.width()); |
| 338 EXPECT_EQ(96, supported_formats[0].frame_size.height()); | 348 EXPECT_EQ(96, supported_formats[0].frame_size.height()); |
| 339 EXPECT_EQ(expected_format, supported_formats[0].pixel_format); | 349 EXPECT_EQ(expected_format, supported_formats[0].pixel_format); |
| 340 EXPECT_GE(supported_formats[0].frame_rate, 20.0); | 350 EXPECT_GE(supported_formats[0].frame_rate, 20.0); |
| 341 EXPECT_EQ(320, supported_formats[1].frame_size.width()); | 351 EXPECT_EQ(320, supported_formats[1].frame_size.width()); |
| 342 EXPECT_EQ(240, supported_formats[1].frame_size.height()); | 352 EXPECT_EQ(240, supported_formats[1].frame_size.height()); |
| 343 EXPECT_EQ(expected_format, supported_formats[1].pixel_format); | 353 EXPECT_EQ(expected_format, supported_formats[1].pixel_format); |
| 344 EXPECT_GE(supported_formats[1].frame_rate, 20.0); | 354 EXPECT_GE(supported_formats[1].frame_rate, 20.0); |
| 345 EXPECT_EQ(640, supported_formats[2].frame_size.width()); | 355 EXPECT_EQ(640, supported_formats[2].frame_size.width()); |
| 346 EXPECT_EQ(480, supported_formats[2].frame_size.height()); | 356 EXPECT_EQ(480, supported_formats[2].frame_size.height()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 1u, | 581 1u, |
| 572 {PIXEL_FORMAT_I420}}, | 582 {PIXEL_FORMAT_I420}}, |
| 573 CommandLineTestData{"fps=60,device-count=2", | 583 CommandLineTestData{"fps=60,device-count=2", |
| 574 60, | 584 60, |
| 575 2u, | 585 2u, |
| 576 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16}}, | 586 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16}}, |
| 577 CommandLineTestData{"fps=1000,device-count=-1", | 587 CommandLineTestData{"fps=1000,device-count=-1", |
| 578 60, | 588 60, |
| 579 1u, | 589 1u, |
| 580 {PIXEL_FORMAT_I420}}, | 590 {PIXEL_FORMAT_I420}}, |
| 581 CommandLineTestData{ | 591 CommandLineTestData{"device-count=4", |
| 582 "device-count=3", | 592 20, |
| 583 20, | 593 4u, |
| 584 3u, | 594 |
| 585 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_I420}}, | 595 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, |
| 586 CommandLineTestData{ | 596 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, |
| 587 "device-count=3,ownership=client", | 597 CommandLineTestData{"device-count=4,ownership=client", |
| 588 20, | 598 20, |
| 589 3u, | 599 4u, |
| 590 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, PIXEL_FORMAT_I420}}, | 600 |
| 601 {PIXEL_FORMAT_I420, PIXEL_FORMAT_Y16, | |
| 602 PIXEL_FORMAT_MJPEG, PIXEL_FORMAT_I420}}, | |
| 591 CommandLineTestData{"device-count=0", 20, 1u, {PIXEL_FORMAT_I420}})); | 603 CommandLineTestData{"device-count=0", 20, 1u, {PIXEL_FORMAT_I420}})); |
| 592 }; // namespace media | 604 }; // namespace media |
| OLD | NEW |