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