RTCVideoEncoder.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #import <Foundation/Foundation.h>
  11. #import <WebRTC/RTCCodecSpecificInfo.h>
  12. #import <WebRTC/RTCEncodedImage.h>
  13. #import <WebRTC/RTCMacros.h>
  14. #import <WebRTC/RTCVideoEncoderQpThresholds.h>
  15. #import <WebRTC/RTCVideoEncoderSettings.h>
  16. #import <WebRTC/RTCVideoFrame.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** Callback block for encoder. */
  19. typedef BOOL (^RTCVideoEncoderCallback)(RTC_OBJC_TYPE(RTCEncodedImage) * frame,
  20. id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> info);
  21. /** Protocol for encoder implementations. */
  22. RTC_OBJC_EXPORT
  23. @protocol RTC_OBJC_TYPE
  24. (RTCVideoEncoder)<NSObject>
  25. - (void)setCallback : (nullable RTCVideoEncoderCallback)callback;
  26. - (NSInteger)startEncodeWithSettings:(RTC_OBJC_TYPE(RTCVideoEncoderSettings) *)settings
  27. numberOfCores:(int)numberOfCores;
  28. - (NSInteger)releaseEncoder;
  29. - (NSInteger)encode:(RTC_OBJC_TYPE(RTCVideoFrame) *)frame
  30. codecSpecificInfo:(nullable id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)>)info
  31. frameTypes:(NSArray<NSNumber *> *)frameTypes;
  32. - (int)setBitrate:(uint32_t)bitrateKbit framerate:(uint32_t)framerate;
  33. - (NSString *)implementationName;
  34. /** Returns QP scaling settings for encoder. The quality scaler adjusts the resolution in order to
  35. * keep the QP from the encoded images within the given range. Returning nil from this function
  36. * disables quality scaling. */
  37. - (nullable RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *)scalingSettings;
  38. /** Resolutions should be aligned to this value. */
  39. @property(nonatomic, readonly) NSInteger resolutionAlignment;
  40. /** If enabled, resolution alignment is applied to all simulcast layers simultaneously so that when
  41. scaled, all resolutions comply with 'resolutionAlignment'. */
  42. @property(nonatomic, readonly) BOOL applyAlignmentToAllSimulcastLayers;
  43. /** If YES, the receiver is expected to resample/scale the source texture to the expected output
  44. size. */
  45. @property(nonatomic, readonly) BOOL supportsNativeHandle;
  46. @end
  47. NS_ASSUME_NONNULL_END