RTCVideoFrame.h 3.0 KB

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