Commit 6e8652cd authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Mac zero copy capture: Enable IOSurfaces behind flag

Add a AVFoundationCaptureV2ZeroCopy feature flag to control exporting
IOSurfaces directly out of VideoCaptureDeviceAVFoundation. This flag
will do nothing unless AVFoundationCaptureV2 is also specified.

Bug: 1125879
Change-Id: If18c797ad2cdb6abab73679df7ef9b150fc39f61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425084Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarMarkus Handell <handellm@google.com>
Commit-Queue: Markus Handell <handellm@google.com>
Cr-Commit-Position: refs/heads/master@{#809725}
parent f07f3f8c
...@@ -664,6 +664,11 @@ const base::Feature MEDIA_EXPORT kMediaFoundationVP8Decoding{ ...@@ -664,6 +664,11 @@ const base::Feature MEDIA_EXPORT kMediaFoundationVP8Decoding{
const base::Feature MEDIA_EXPORT kAVFoundationCaptureV2{ const base::Feature MEDIA_EXPORT kAVFoundationCaptureV2{
"AVFoundationCaptureV2", base::FEATURE_DISABLED_BY_DEFAULT}; "AVFoundationCaptureV2", base::FEATURE_DISABLED_BY_DEFAULT};
// Controls whether or not the V2 capturer exports IOSurfaces for zero-copy.
// This feature only has any effect if kAVFoundationCaptureV2 is also enabled.
const base::Feature MEDIA_EXPORT kAVFoundationCaptureV2ZeroCopy{
"AVFoundationCaptureV2ZeroCopy", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature MEDIA_EXPORT kVideoToolboxVp9Decoding{ const base::Feature MEDIA_EXPORT kVideoToolboxVp9Decoding{
"VideoToolboxVp9Decoding", base::FEATURE_DISABLED_BY_DEFAULT}; "VideoToolboxVp9Decoding", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_MAC) #endif // defined(OS_MAC)
......
...@@ -226,6 +226,7 @@ MEDIA_EXPORT extern const base::Feature kMediaFoundationVP8Decoding; ...@@ -226,6 +226,7 @@ MEDIA_EXPORT extern const base::Feature kMediaFoundationVP8Decoding;
#if defined(OS_MAC) #if defined(OS_MAC)
MEDIA_EXPORT extern const base::Feature kAVFoundationCaptureV2; MEDIA_EXPORT extern const base::Feature kAVFoundationCaptureV2;
MEDIA_EXPORT extern const base::Feature kAVFoundationCaptureV2ZeroCopy;
MEDIA_EXPORT extern const base::Feature kVideoToolboxVp9Decoding; MEDIA_EXPORT extern const base::Feature kVideoToolboxVp9Decoding;
#endif #endif
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "media/base/media_switches.h"
#include "media/base/timestamp_constants.h" #include "media/base/timestamp_constants.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
#import "media/capture/video/mac/video_capture_device_avfoundation_utils_mac.h" #import "media/capture/video/mac/video_capture_device_avfoundation_utils_mac.h"
...@@ -654,9 +655,8 @@ AVCaptureDeviceFormat* FindBestCaptureFormat( ...@@ -654,9 +655,8 @@ AVCaptureDeviceFormat* FindBestCaptureFormat(
DCHECK_EQ(pixelBufferPixelFormat, sampleBufferPixelFormat); DCHECK_EQ(pixelBufferPixelFormat, sampleBufferPixelFormat);
// First preference is to use an NV12 IOSurface as a GpuMemoryBuffer. // First preference is to use an NV12 IOSurface as a GpuMemoryBuffer.
// TODO(https://crbug.com/1125879): This path cannot be used in software static const bool kEnableGpuMemoryBuffers =
// mode yet, and so it cannot be enabled yet. base::FeatureList::IsEnabled(media::kAVFoundationCaptureV2ZeroCopy);
constexpr bool kEnableGpuMemoryBuffers = false;
if (kEnableGpuMemoryBuffers) { if (kEnableGpuMemoryBuffers) {
IOSurfaceRef ioSurface = CVPixelBufferGetIOSurface(pixelBuffer); IOSurfaceRef ioSurface = CVPixelBufferGetIOSurface(pixelBuffer);
if (ioSurface && videoPixelFormat == media::PIXEL_FORMAT_NV12) { if (ioSurface && videoPixelFormat == media::PIXEL_FORMAT_NV12) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment