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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 #endif | 273 #endif |
274 | 274 |
275 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { | 275 TEST_F(VideoCaptureDeviceTest, MAYBE_OpenInvalidDevice) { |
276 #if defined(OS_WIN) | 276 #if defined(OS_WIN) |
277 VideoCaptureDevice::Name::CaptureApiType api_type = | 277 VideoCaptureDevice::Name::CaptureApiType api_type = |
278 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() | 278 VideoCaptureDeviceFactoryWin::PlatformSupportsMediaFoundation() |
279 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION | 279 ? VideoCaptureDevice::Name::MEDIA_FOUNDATION |
280 : VideoCaptureDevice::Name::DIRECT_SHOW; | 280 : VideoCaptureDevice::Name::DIRECT_SHOW; |
281 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); | 281 VideoCaptureDevice::Name device_name("jibberish", "jibberish", api_type); |
282 #elif defined(OS_MACOSX) | 282 #elif defined(OS_MACOSX) |
283 VideoCaptureDevice::Name device_name( | 283 VideoCaptureDevice::Name device_name("jibberish", "jibberish", |
284 "jibberish", "jibberish", AVFoundationGlue::IsAVFoundationSupported() | 284 VideoCaptureDevice::Name::AVFOUNDATION); |
285 ? VideoCaptureDevice::Name::AVFOUNDATION | |
286 : VideoCaptureDevice::Name::QTKIT); | |
287 #else | 285 #else |
288 VideoCaptureDevice::Name device_name("jibberish", "jibberish"); | 286 VideoCaptureDevice::Name device_name("jibberish", "jibberish"); |
289 #endif | 287 #endif |
290 scoped_ptr<VideoCaptureDevice> device = | 288 scoped_ptr<VideoCaptureDevice> device = |
291 video_capture_device_factory_->Create(device_name); | 289 video_capture_device_factory_->Create(device_name); |
| 290 |
292 #if !defined(OS_MACOSX) | 291 #if !defined(OS_MACOSX) |
293 EXPECT_TRUE(device == NULL); | 292 EXPECT_TRUE(device == NULL); |
294 #else | 293 #else |
295 if (AVFoundationGlue::IsAVFoundationSupported()) { | 294 // The presence of the actual device is only checked on AllocateAndStart() |
296 EXPECT_TRUE(device == NULL); | 295 // and not on creation. |
297 } else { | 296 EXPECT_CALL(*client_, OnError(_, _)).Times(1); |
298 // The presence of the actual device is only checked on AllocateAndStart() | |
299 // and not on creation for QTKit API in Mac OS X platform. | |
300 EXPECT_CALL(*client_, OnError(_, _)).Times(1); | |
301 | 297 |
302 VideoCaptureParams capture_params; | 298 VideoCaptureParams capture_params; |
303 capture_params.requested_format.frame_size.SetSize(640, 480); | 299 capture_params.requested_format.frame_size.SetSize(640, 480); |
304 capture_params.requested_format.frame_rate = 30; | 300 capture_params.requested_format.frame_rate = 30; |
305 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; | 301 capture_params.requested_format.pixel_format = PIXEL_FORMAT_I420; |
306 device->AllocateAndStart(capture_params, std::move(client_)); | 302 device->AllocateAndStart(capture_params, std::move(client_)); |
307 device->StopAndDeAllocate(); | 303 device->StopAndDeAllocate(); |
308 } | |
309 #endif | 304 #endif |
310 } | 305 } |
311 | 306 |
312 TEST_P(VideoCaptureDeviceTest, CaptureWithSize) { | 307 TEST_P(VideoCaptureDeviceTest, CaptureWithSize) { |
313 names_ = EnumerateDevices(); | 308 names_ = EnumerateDevices(); |
314 if (names_->empty()) { | 309 if (names_->empty()) { |
315 VLOG(1) << "No camera available. Exiting test."; | 310 VLOG(1) << "No camera available. Exiting test."; |
316 return; | 311 return; |
317 } | 312 } |
318 | 313 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // GetDeviceSupportedFormats(). | 484 // GetDeviceSupportedFormats(). |
490 scoped_ptr<VideoCaptureDevice::Name> name = | 485 scoped_ptr<VideoCaptureDevice::Name> name = |
491 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); | 486 GetFirstDeviceNameSupportingPixelFormat(PIXEL_FORMAT_MAX); |
492 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else | 487 // Verify no camera returned for PIXEL_FORMAT_MAX. Nothing else |
493 // to test here | 488 // to test here |
494 // since we cannot forecast the hardware capabilities. | 489 // since we cannot forecast the hardware capabilities. |
495 ASSERT_FALSE(name); | 490 ASSERT_FALSE(name); |
496 } | 491 } |
497 | 492 |
498 }; // namespace media | 493 }; // namespace media |
OLD | NEW |