xref: /aosp_15_r20/external/webrtc/sdk/objc/base/RTCVideoEncoder.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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"
16 #import "RTCVideoEncoderQpThresholds.h"
17 #import "RTCVideoEncoderSettings.h"
18 #import "RTCVideoFrame.h"
19 
20 NS_ASSUME_NONNULL_BEGIN
21 
22 /** Callback block for encoder. */
23 typedef BOOL (^RTCVideoEncoderCallback)(RTC_OBJC_TYPE(RTCEncodedImage) * frame,
24                                         id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> info);
25 
26 /** Protocol for encoder implementations. */
27 RTC_OBJC_EXPORT
28 @protocol RTC_OBJC_TYPE
29 (RTCVideoEncoder)<NSObject>
30 
31 - (void)setCallback:(nullable RTCVideoEncoderCallback)callback;
32 - (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
33                        numberOfCores:(int)numberOfCores;
34 - (NSInteger)releaseEncoder;
35 - (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
36     codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
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. */
44 - (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings;
45 
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 
53 /** If YES, the receiver is expected to resample/scale the source texture to the expected output
54     size. */
55 @property(nonatomic, readonly) BOOL supportsNativeHandle;
56 
57 @end
58 
59 NS_ASSUME_NONNULL_END
60