| OLD | NEW |
| 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 "media/capture/video/video_capture_device.h" | 5 #include "media/capture/video/video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "media/base/mac/avfoundation_glue.h" | 33 #include "media/base/mac/avfoundation_glue.h" |
| 34 #include "media/capture/video/mac/video_capture_device_factory_mac.h" | 34 #include "media/capture/video/mac/video_capture_device_factory_mac.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if defined(OS_ANDROID) | 37 #if defined(OS_ANDROID) |
| 38 #include "base/android/jni_android.h" | 38 #include "base/android/jni_android.h" |
| 39 #include "media/capture/video/android/video_capture_device_android.h" | 39 #include "media/capture/video/android/video_capture_device_android.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 // Mac/QTKit will always give you the size you ask for and this case will fail. | 43 // Mac will always give you the size you ask for and this case will fail. |
| 44 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 44 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| 45 // We will always get YUYV from the Mac QTKit/AVFoundation implementations. | 45 // We will always get YUYV from the Mac AVFoundation implementations. |
| 46 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg | 46 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg |
| 47 #elif defined(OS_WIN) | 47 #elif defined(OS_WIN) |
| 48 #define MAYBE_AllocateBadSize AllocateBadSize | 48 #define MAYBE_AllocateBadSize AllocateBadSize |
| 49 #define MAYBE_CaptureMjpeg CaptureMjpeg | 49 #define MAYBE_CaptureMjpeg CaptureMjpeg |
| 50 #elif defined(OS_ANDROID) | 50 #elif defined(OS_ANDROID) |
| 51 // TODO(wjia): enable those tests on Android. | 51 // TODO(wjia): enable those tests on Android. |
| 52 // On Android, native camera (JAVA) delivers frames on UI thread which is the | 52 // On Android, native camera (JAVA) delivers frames on UI thread which is the |
| 53 // main thread for tests. This results in no frame received by | 53 // main thread for tests. This results in no frame received by |
| 54 // VideoCaptureAndroid. | 54 // VideoCaptureAndroid. |
| 55 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize | 55 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 #endif | 264 #endif |
| 265 | 265 |
| 266 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { | 266 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { |
| 267 #if defined(OS_WIN) | 267 #if defined(OS_WIN) |
| 268 VideoCaptureDevice::Name::CaptureApiType api_type = | 268 VideoCaptureDevice::Name::CaptureApiType api_type = |
| 269 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() | 269 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() |
| 270 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION | 270 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION |
| 271 : VideoCaptureDevice::Name::DIRECT_SHOW; | 271 : VideoCaptureDevice::Name::DIRECT_SHOW; |
| 272 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); | 272 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); |
| 273 #elif defined(OS_MACOSX) | 273 #elif defined(OS_MACOSX) |
| 274 VideoCaptureDevice::Name device_name( | 274 VideoCaptureDevice::Name device_name("jibberish", "jibberish", |
| 275 "jibberish", "jibberish", AVFoundationGlue::IsAVFoundationSupported() | 275 VideoCaptureDevice::Name::AVFOUNDATION); |
| 276 ? VideoCaptureDevice::Name::AVFOUNDATION | |
| 277 : VideoCaptureDevice::Name::QTKIT); | |
| 278 #else | 276 #else |
| 279 VideoCaptureDevice::Name device_name("jibberish", "jibberish"); | 277 VideoCaptureDevice::Name device_name("jibberish", "jibberish"); |
| 280 #endif | 278 #endif |
| 281 scoped_ptr<VideoCaptureDevice> device = | 279 scoped_ptr<VideoCaptureDevice> device = |
| 282 video_capture_device_factory_->Create(device_name); | 280 video_capture_device_factory_->Create(device_name); |
| 281 |
| 283 #if !defined(OS_MACOSX) | 282 #if !defined(OS_MACOSX) |
| 284 EXPECT_TRUE(device == NULL); | 283 EXPECT_TRUE(device == NULL); |
| 285 #else | 284 #else |
| 286 if (AVFoundationGlue::IsAVFoundationSupported()) { | 285 // The presence of the actual device is only checked on AllocateAndStart() |
| 287 EXPECT_TRUE(device == NULL); | 286 // and not on creation. |
| 288 } else { | 287 EXPECT_CALL(*client_, OnError(_, _)).Times(1); |
| 289 // The presence of the actual device is only checked on AllocateAndStart() | |
| 290 // and not on creation for QTKit API in Mac OS X platform. | |
| 291 EXPECT_CALL(*client_, OnError(_, _)).Times(1); | |
| 292 | 288 |
| 293 VideoCaptureParams capture_params; | 289 VideoCaptureParams capture_params; |
| 294 capture_params.requested_format.frame_size.SetSize(640, 480); | 290 capture_params.requested_format.frame_size.SetSize(640, 480); |
| 295 capture_params.requested_format.frame_rate = 30; | 291 capture_params.requested_format.frame_rate = 30; |
| 296 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 292 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
| 297 device->AllocateAndStart(capture_params, std::move(client_)); | 293 device->AllocateAndStart(capture_params, std::move(client_)); |
| 298 device->StopAndDeAllocate(); | 294 device->StopAndDeAllocate(); |
| 299 } | |
| 300 #endif | 295 #endif |
| 301 } | 296 } |
| 302 | 297 |
| 303 TEST_P(VideoCaptureDeviceTest, CaptureWithSize) { | 298 TEST_P(VideoCaptureDeviceTest, CaptureWithSize) { |
| 304 names_ = EnumerateDevices(); | 299 names_ = EnumerateDevices(); |
| 305 if (names_->empty()) { | 300 if (names_->empty()) { |
| 306 VLOG(1) << "No camera available. Exiting test."; | 301 VLOG(1) << "No camera available. Exiting test."; |
| 307 return; | 302 return; |
| 308 } | 303 } |
| 309 | 304 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // GetDeviceSupportedFormats(). | 475 // GetDeviceSupportedFormats(). |
| 481 scoped_ptr<VideoCaptureDevice::Name> name = | 476 scoped_ptr<VideoCaptureDevice::Name> name = |
| 482 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 477 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
| 483 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else | 478 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else |
| 484 // to test here | 479 // to test here |
| 485 // since we cannot forecast the hardware capabilities. | 480 // since we cannot forecast the hardware capabilities. |
| 486 ASSERT_FALSE(name); | 481 ASSERT_FALSE(name); |
| 487 } | 482 } |
| 488 | 483 |
| 489 }; // namespace media | 484 }; // namespace media |
| OLD | NEW |