Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 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 | |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 11 | #import <AVFoundation/AVFoundation.h> |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 12 | #import <Foundation/Foundation.h> |
| 13 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 14 | #import <WebRTC/RTCMacros.h> |
tkchin | 8b577ed | 2016-04-19 10:04:41 -0700 | [diff] [blame] | 15 | |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 16 | NS_ASSUME_NONNULL_BEGIN |
| 17 | |
magjed | 7ee5125 | 2017-02-21 04:19:46 -0800 | [diff] [blame] | 18 | typedef NS_ENUM(NSInteger, RTCVideoRotation) { |
| 19 | RTCVideoRotation_0 = 0, |
| 20 | RTCVideoRotation_90 = 90, |
| 21 | RTCVideoRotation_180 = 180, |
| 22 | RTCVideoRotation_270 = 270, |
| 23 | }; |
| 24 | |
Anders Carlsson | e5960ce | 2017-06-22 15:26:30 +0200 | [diff] [blame] | 25 | @protocol RTCVideoFrameBuffer; |
| 26 | |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 27 | // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame. |
tkchin | 8b577ed | 2016-04-19 10:04:41 -0700 | [diff] [blame] | 28 | RTC_EXPORT |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 29 | @interface RTCVideoFrame : NSObject |
| 30 | |
| 31 | /** Width without rotation applied. */ |
magjed | 7ee5125 | 2017-02-21 04:19:46 -0800 | [diff] [blame] | 32 | @property(nonatomic, readonly) int width; |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 33 | |
| 34 | /** Height without rotation applied. */ |
magjed | 7ee5125 | 2017-02-21 04:19:46 -0800 | [diff] [blame] | 35 | @property(nonatomic, readonly) int height; |
| 36 | @property(nonatomic, readonly) RTCVideoRotation rotation; |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 37 | |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 38 | /** Timestamp in nanoseconds. */ |
magjed | fb372f0 | 2016-08-10 07:58:29 -0700 | [diff] [blame] | 39 | @property(nonatomic, readonly) int64_t timeStampNs; |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 40 | |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 41 | /** Timestamp 90 kHz. */ |
| 42 | @property(nonatomic, assign) int32_t timeStamp; |
| 43 | |
Anders Carlsson | e5960ce | 2017-06-22 15:26:30 +0200 | [diff] [blame] | 44 | @property(nonatomic, readonly) id<RTCVideoFrameBuffer> buffer; |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 45 | |
Jon Hjelle | 32e0c01 | 2016-03-08 16:04:46 -0800 | [diff] [blame] | 46 | - (instancetype)init NS_UNAVAILABLE; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 47 | - (instancetype) new NS_UNAVAILABLE; |
magjed | c3c4624 | 2017-02-21 05:28:48 -0800 | [diff] [blame] | 48 | |
| 49 | /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp. |
Anders Carlsson | e5960ce | 2017-06-22 15:26:30 +0200 | [diff] [blame] | 50 | * Deprecated - initialize with a RTCCVPixelBuffer instead |
magjed | c3c4624 | 2017-02-21 05:28:48 -0800 | [diff] [blame] | 51 | */ |
| 52 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer |
| 53 | rotation:(RTCVideoRotation)rotation |
Anders Carlsson | e5960ce | 2017-06-22 15:26:30 +0200 | [diff] [blame] | 54 | timeStampNs:(int64_t)timeStampNs |
| 55 | DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); |
magjed | c3c4624 | 2017-02-21 05:28:48 -0800 | [diff] [blame] | 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 |
Anders Carlsson | e5960ce | 2017-06-22 15:26:30 +0200 | [diff] [blame] | 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; |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 77 | |
magjed | 7ee5125 | 2017-02-21 04:19:46 -0800 | [diff] [blame] | 78 | /** Return a frame that is guaranteed to be I420, i.e. it is possible to access |
| 79 | * the YUV data on it. |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 80 | */ |
magjed | 7ee5125 | 2017-02-21 04:19:46 -0800 | [diff] [blame] | 81 | - (RTCVideoFrame *)newI420VideoFrame; |
tkchin | 7d06a8c | 2016-04-04 14:10:43 -0700 | [diff] [blame] | 82 | |
Jon Hjelle | 7823495 | 2016-01-11 09:47:07 -0800 | [diff] [blame] | 83 | @end |
| 84 | |
| 85 | NS_ASSUME_NONNULL_END |