Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 <Foundation/Foundation.h> |
| 12 | |
| 13 | #import "RTCCodecSpecificInfo.h" |
| 14 | #import "RTCEncodedImage.h" |
| 15 | #import "RTCMacros.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 16 | #import "RTCVideoEncoderQpThresholds.h" |
| 17 | #import "RTCVideoEncoderSettings.h" |
| 18 | #import "RTCVideoFrame.h" |
| 19 | |
| 20 | NS_ASSUME_NONNULL_BEGIN |
| 21 | |
| 22 | /** Callback block for encoder. */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 23 | typedef BOOL (^RTCVideoEncoderCallback)(RTC_OBJC_TYPE(RTCEncodedImage) * frame, |
Niels Möller | a805dd8 | 2020-11-17 15:38:33 +0100 | [diff] [blame] | 24 | id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> info); |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 25 | |
| 26 | /** Protocol for encoder implementations. */ |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 27 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 28 | @protocol RTC_OBJC_TYPE |
| 29 | (RTCVideoEncoder)<NSObject> |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 30 | |
Peter Hanspers | 74cc9ea | 2021-06-11 15:52:57 +0200 | [diff] [blame] | 31 | - (void)setCallback:(nullable RTCVideoEncoderCallback)callback; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 32 | - (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 33 | numberOfCores:(int)numberOfCores; |
| 34 | - (NSInteger)releaseEncoder; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 35 | - (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame |
| 36 | codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 37 | frameTypes:(NSArray<NSNumber *> *)frameTypes; |
| 38 | - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate; |
| 39 | - (NSString *)implementationName; |
| 40 | |
| 41 | /** Returns QP scaling settings for encoder. The quality scaler adjusts the resolution in order to |
| 42 | * keep the QP from the encoded images within the given range. Returning nil from this function |
| 43 | * disables quality scaling. */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 44 | - (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 45 | |
Peter Hanspers | 5981bf2 | 2021-06-01 07:31:00 +0200 | [diff] [blame] | 46 | /** Resolutions should be aligned to this value. */ |
| 47 | @property(nonatomic, readonly) NSInteger resolutionAlignment; |
| 48 | |
| 49 | /** If enabled, resolution alignment is applied to all simulcast layers simultaneously so that when |
| 50 | scaled, all resolutions comply with 'resolutionAlignment'. */ |
| 51 | @property(nonatomic, readonly) BOOL applyAlignmentToAllSimulcastLayers; |
| 52 | |
Niels Möller | be74b80 | 2022-03-18 14:10:15 +0100 | [diff] [blame] | 53 | /** If YES, the receiver is expected to resample/scale the source texture to the expected output |
Peter Hanspers | 7f854bc | 2021-08-04 17:15:49 +0200 | [diff] [blame] | 54 | size. */ |
| 55 | @property(nonatomic, readonly) BOOL supportsNativeHandle; |
| 56 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 57 | @end |
| 58 | |
| 59 | NS_ASSUME_NONNULL_END |