blob: 7d1a7afd7f4e11172f1b52a2bc4b830499115217 [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"
16#import "RTCRtpFragmentationHeader.h"
17#import "RTCVideoEncoderQpThresholds.h"
18#import "RTCVideoEncoderSettings.h"
19#import "RTCVideoFrame.h"
20
21NS_ASSUME_NONNULL_BEGIN
22
23/** Callback block for encoder. */
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020024typedef BOOL (^RTCVideoEncoderCallback)(RTC_OBJC_TYPE(RTCEncodedImage) * frame,
25 id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> info,
26 RTC_OBJC_TYPE(RTCRtpFragmentationHeader) * header);
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020027
28/** Protocol for encoder implementations. */
Mirko Bonadeie8d57242018-09-17 10:22:56 +020029RTC_OBJC_EXPORT
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020030@protocol RTC_OBJC_TYPE
31(RTCVideoEncoder)<NSObject>
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020032
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020033 - (void)setCallback : (RTCVideoEncoderCallback)callback;
34- (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020035 numberOfCores:(int)numberOfCores;
36- (NSInteger)releaseEncoder;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020037- (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
38 codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020039 frameTypes:(NSArray<NSNumber *> *)frameTypes;
40- (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate;
41- (NSString *)implementationName;
42
43/** Returns QP scaling settings for encoder. The quality scaler adjusts the resolution in order to
44 * keep the QP from the encoded images within the given range. Returning nil from this function
45 * disables quality scaling. */
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020046- (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020047
48@end
49
50NS_ASSUME_NONNULL_END