blob: f5638d27cf4b63cc2e486a2cfbfb6c8c590630a8 [file] [log] [blame]
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001/*
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
11#import <AVFoundation/AVFoundation.h>
12#import <Foundation/Foundation.h>
13
14#import "RTCMacros.h"
15
16NS_ASSUME_NONNULL_BEGIN
17
18typedef NS_ENUM(NSInteger, RTCVideoRotation) {
19 RTCVideoRotation_0 = 0,
20 RTCVideoRotation_90 = 90,
21 RTCVideoRotation_180 = 180,
22 RTCVideoRotation_270 = 270,
23};
24
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020025@protocol RTC_OBJC_TYPE
26(RTCVideoFrameBuffer);
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020027
28// RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame.
Mirko Bonadeie8d57242018-09-17 10:22:56 +020029RTC_OBJC_EXPORT
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020030@interface RTC_OBJC_TYPE (RTCVideoFrame) : NSObject
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020031
32/** Width without rotation applied. */
33@property(nonatomic, readonly) int width;
34
35/** Height without rotation applied. */
36@property(nonatomic, readonly) int height;
37@property(nonatomic, readonly) RTCVideoRotation rotation;
38
39/** Timestamp in nanoseconds. */
40@property(nonatomic, readonly) int64_t timeStampNs;
41
42/** Timestamp 90 kHz. */
43@property(nonatomic, assign) int32_t timeStamp;
44
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020045@property(nonatomic, readonly) id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)> buffer;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020046
47- (instancetype)init NS_UNAVAILABLE;
48- (instancetype) new NS_UNAVAILABLE;
49
50/** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp.
51 * Deprecated - initialize with a RTCCVPixelBuffer instead
52 */
53- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
54 rotation:(RTCVideoRotation)rotation
55 timeStampNs:(int64_t)timeStampNs
56 DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
57
58/** Initialize an RTCVideoFrame from a pixel buffer combined with cropping and
59 * scaling. Cropping will be applied first on the pixel buffer, followed by
60 * scaling to the final resolution of scaledWidth x scaledHeight.
61 */
62- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
63 scaledWidth:(int)scaledWidth
64 scaledHeight:(int)scaledHeight
65 cropWidth:(int)cropWidth
66 cropHeight:(int)cropHeight
67 cropX:(int)cropX
68 cropY:(int)cropY
69 rotation:(RTCVideoRotation)rotation
70 timeStampNs:(int64_t)timeStampNs
71 DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
72
73/** Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp.
74 */
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020075- (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)frameBuffer
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020076 rotation:(RTCVideoRotation)rotation
77 timeStampNs:(int64_t)timeStampNs;
78
79/** Return a frame that is guaranteed to be I420, i.e. it is possible to access
80 * the YUV data on it.
81 */
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020082- (RTC_OBJC_TYPE(RTCVideoFrame) *)newI420VideoFrame;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020083
84@end
85
86NS_ASSUME_NONNULL_END