RTCVideoFrame.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2015 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 <Foundation/Foundation.h>
  12. #import "RTCMacros.h"
  13. NS_ASSUME_NONNULL_BEGIN
  14. typedef NS_ENUM(NSInteger, RTCVideoRotation) {
  15. RTCVideoRotation_0 = 0,
  16. RTCVideoRotation_90 = 90,
  17. RTCVideoRotation_180 = 180,
  18. RTCVideoRotation_270 = 270,
  19. };
  20. @protocol RTCVideoFrameBuffer;
  21. // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame.
  22. RTC_OBJC_EXPORT
  23. @interface RTCVideoFrame : NSObject
  24. /** Width without rotation applied. */
  25. @property(nonatomic, readonly) int width;
  26. /** Height without rotation applied. */
  27. @property(nonatomic, readonly) int height;
  28. @property(nonatomic, readonly) RTCVideoRotation rotation;
  29. /** Timestamp in nanoseconds. */
  30. @property(nonatomic, readonly) int64_t timeStampNs;
  31. /** Timestamp 90 kHz. */
  32. @property(nonatomic, assign) int32_t timeStamp;
  33. @property(nonatomic, readonly) id<RTCVideoFrameBuffer> buffer;
  34. - (instancetype)init NS_UNAVAILABLE;
  35. - (instancetype) new NS_UNAVAILABLE;
  36. /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp.
  37. * Deprecated - initialize with a RTCCVPixelBuffer instead
  38. */
  39. - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
  40. rotation:(RTCVideoRotation)rotation
  41. timeStampNs:(int64_t)timeStampNs
  42. DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
  43. /** Initialize an RTCVideoFrame from a pixel buffer combined with cropping and
  44. * scaling. Cropping will be applied first on the pixel buffer, followed by
  45. * scaling to the final resolution of scaledWidth x scaledHeight.
  46. */
  47. - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
  48. scaledWidth:(int)scaledWidth
  49. scaledHeight:(int)scaledHeight
  50. cropWidth:(int)cropWidth
  51. cropHeight:(int)cropHeight
  52. cropX:(int)cropX
  53. cropY:(int)cropY
  54. rotation:(RTCVideoRotation)rotation
  55. timeStampNs:(int64_t)timeStampNs
  56. DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
  57. /** Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp.
  58. */
  59. - (instancetype)initWithBuffer:(id<RTCVideoFrameBuffer>)frameBuffer
  60. rotation:(RTCVideoRotation)rotation
  61. timeStampNs:(int64_t)timeStampNs;
  62. /** Return a frame that is guaranteed to be I420, i.e. it is possible to access
  63. * the YUV data on it.
  64. */
  65. - (RTCVideoFrame *)newI420VideoFrame;
  66. @end
  67. NS_ASSUME_NONNULL_END