blob: 26cf4ec03f6bf29dc39f956144dc93b683add23a [file] [log] [blame]
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001/*
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 Carlsson7bca8ca2018-08-30 09:30:29 +020016#import "RTCVideoEncoderQpThresholds.h"
17#import "RTCVideoEncoderSettings.h"
18#import "RTCVideoFrame.h"
19
20NS_ASSUME_NONNULL_BEGIN
21
22/** Callback block for encoder. */
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020023typedef BOOL (^RTCVideoEncoderCallback)(RTC_OBJC_TYPE(RTCEncodedImage) * frame,
Niels Möllera805dd82020-11-17 15:38:33 +010024 id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> info);
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020025
26/** Protocol for encoder implementations. */
Mirko Bonadeie8d57242018-09-17 10:22:56 +020027RTC_OBJC_EXPORT
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020028@protocol RTC_OBJC_TYPE
29(RTCVideoEncoder)<NSObject>
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020030
Peter Hanspers74cc9ea2021-06-11 15:52:57 +020031- (void)setCallback:(nullable RTCVideoEncoderCallback)callback;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020032- (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020033 numberOfCores:(int)numberOfCores;
34- (NSInteger)releaseEncoder;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020035- (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
36 codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020037 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 Bonadeia81e9c82020-05-04 16:14:32 +020044- (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020045
Peter Hanspers5981bf22021-06-01 07:31:00 +020046/** 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
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020053@end
54
55NS_ASSUME_NONNULL_END