RTCCVPixelBuffer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2018 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #import <AVFoundation/AVFoundation.h>
  11. #import "RTCMacros.h"
  12. #import "RTCVideoFrameBuffer.h"
  13. NS_ASSUME_NONNULL_BEGIN
  14. /** RTCVideoFrameBuffer containing a CVPixelBufferRef */
  15. RTC_OBJC_EXPORT
  16. @interface RTC_OBJC_TYPE (RTCCVPixelBuffer) : NSObject <RTC_OBJC_TYPE(RTCVideoFrameBuffer)>
  17. @property(nonatomic, readonly) CVPixelBufferRef pixelBuffer;
  18. @property(nonatomic, readonly) int cropX;
  19. @property(nonatomic, readonly) int cropY;
  20. @property(nonatomic, readonly) int cropWidth;
  21. @property(nonatomic, readonly) int cropHeight;
  22. + (NSSet<NSNumber *> *)supportedPixelFormats;
  23. - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
  24. - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
  25. adaptedWidth:(int)adaptedWidth
  26. adaptedHeight:(int)adaptedHeight
  27. cropWidth:(int)cropWidth
  28. cropHeight:(int)cropHeight
  29. cropX:(int)cropX
  30. cropY:(int)cropY;
  31. - (BOOL)requiresCropping;
  32. - (BOOL)requiresScalingToWidth:(int)width height:(int)height;
  33. - (int)bufferSizeForCroppingAndScalingToWidth:(int)width height:(int)height;
  34. /** The minimum size of the |tmpBuffer| must be the number of bytes returned from the
  35. * bufferSizeForCroppingAndScalingToWidth:height: method.
  36. * If that size is 0, the |tmpBuffer| may be nil.
  37. */
  38. - (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer
  39. withTempBuffer:(nullable uint8_t *)tmpBuffer;
  40. @end
  41. NS_ASSUME_NONNULL_END