blob: cfccfa9e9402fe827f4a91ea77ebc435a1c53398 [file] [log] [blame]
Jon Hjelle78234952016-01-11 09:47:07 -08001/*
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
tkchin7d06a8c2016-04-04 14:10:43 -070011#import <AVFoundation/AVFoundation.h>
Jon Hjelle78234952016-01-11 09:47:07 -080012#import <Foundation/Foundation.h>
13
tkchin9eeb6242016-04-27 01:54:20 -070014#import <WebRTC/RTCMacros.h>
tkchin8b577ed2016-04-19 10:04:41 -070015
Jon Hjelle78234952016-01-11 09:47:07 -080016NS_ASSUME_NONNULL_BEGIN
17
magjed7ee51252017-02-21 04:19:46 -080018typedef NS_ENUM(NSInteger, RTCVideoRotation) {
19 RTCVideoRotation_0 = 0,
20 RTCVideoRotation_90 = 90,
21 RTCVideoRotation_180 = 180,
22 RTCVideoRotation_270 = 270,
23};
24
Anders Carlssone5960ce2017-06-22 15:26:30 +020025@protocol RTCVideoFrameBuffer;
26
nisseacd935b2016-11-11 03:55:13 -080027// RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame.
tkchin8b577ed2016-04-19 10:04:41 -070028RTC_EXPORT
Jon Hjelle78234952016-01-11 09:47:07 -080029@interface RTCVideoFrame : NSObject
30
31/** Width without rotation applied. */
magjed7ee51252017-02-21 04:19:46 -080032@property(nonatomic, readonly) int width;
Jon Hjelle78234952016-01-11 09:47:07 -080033
34/** Height without rotation applied. */
magjed7ee51252017-02-21 04:19:46 -080035@property(nonatomic, readonly) int height;
36@property(nonatomic, readonly) RTCVideoRotation rotation;
Jon Hjelle78234952016-01-11 09:47:07 -080037
tkchin7d06a8c2016-04-04 14:10:43 -070038/** Timestamp in nanoseconds. */
magjedfb372f02016-08-10 07:58:29 -070039@property(nonatomic, readonly) int64_t timeStampNs;
tkchin7d06a8c2016-04-04 14:10:43 -070040
kthelgasonfb143122017-07-25 07:55:58 -070041/** Timestamp 90 kHz. */
42@property(nonatomic, assign) int32_t timeStamp;
43
Anders Carlssone5960ce2017-06-22 15:26:30 +020044@property(nonatomic, readonly) id<RTCVideoFrameBuffer> buffer;
tkchin7d06a8c2016-04-04 14:10:43 -070045
Jon Hjelle32e0c012016-03-08 16:04:46 -080046- (instancetype)init NS_UNAVAILABLE;
Yves Gerey665174f2018-06-19 15:03:05 +020047- (instancetype) new NS_UNAVAILABLE;
magjedc3c46242017-02-21 05:28:48 -080048
49/** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp.
Anders Carlssone5960ce2017-06-22 15:26:30 +020050 * Deprecated - initialize with a RTCCVPixelBuffer instead
magjedc3c46242017-02-21 05:28:48 -080051 */
52- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
53 rotation:(RTCVideoRotation)rotation
Anders Carlssone5960ce2017-06-22 15:26:30 +020054 timeStampNs:(int64_t)timeStampNs
55 DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead");
magjedc3c46242017-02-21 05:28:48 -080056
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
Anders Carlssone5960ce2017-06-22 15:26:30 +020069 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;
Jon Hjelle78234952016-01-11 09:47:07 -080077
magjed7ee51252017-02-21 04:19:46 -080078/** Return a frame that is guaranteed to be I420, i.e. it is possible to access
79 * the YUV data on it.
tkchin7d06a8c2016-04-04 14:10:43 -070080 */
magjed7ee51252017-02-21 04:19:46 -080081- (RTCVideoFrame *)newI420VideoFrame;
tkchin7d06a8c2016-04-04 14:10:43 -070082
Jon Hjelle78234952016-01-11 09:47:07 -080083@end
84
85NS_ASSUME_NONNULL_END