Add supportsNativeHandle to the RTCVideoEncoder protocol.

The simulcast_encoder_adapter expects codecs that specify
supports_native_handle to perform resampling/scaling (through
GetEncoderInfo).
This change adds a method to the RTCVideoEncoder to let objc encoders
specify this rather than relying on the default.

Bug: webrtc:13044
Change-Id: I2efcbd42aa4f2048285f451c7b691fdeca111e62
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227641
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Peter Hanspers <peterhanspers@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34683}
diff --git a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
index ea2a459..6b04d83 100644
--- a/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
+++ b/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm
@@ -79,4 +79,8 @@
   return NO;
 }
 
+- (BOOL)supportsNativeHandle {
+  RTC_NOTREACHED();
+  return NO;
+}
 @end
diff --git a/sdk/objc/base/RTCVideoEncoder.h b/sdk/objc/base/RTCVideoEncoder.h
index 26cf4ec..2b5c952 100644
--- a/sdk/objc/base/RTCVideoEncoder.h
+++ b/sdk/objc/base/RTCVideoEncoder.h
@@ -50,6 +50,10 @@
     scaled, all resolutions comply with 'resolutionAlignment'. */
 @property(nonatomic, readonly) BOOL applyAlignmentToAllSimulcastLayers;
 
+/** If YES, the reciever is expected to resample/scale the source texture to the expected output
+    size. */
+@property(nonatomic, readonly) BOOL supportsNativeHandle;
+
 @end
 
 NS_ASSUME_NONNULL_END
diff --git a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
index 8794849..966eb3e 100644
--- a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
+++ b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
@@ -537,6 +537,10 @@
   return NO;
 }
 
+- (BOOL)supportsNativeHandle {
+  return YES;
+}
+
 #pragma mark - Private
 
 - (NSInteger)releaseEncoder {
diff --git a/sdk/objc/native/src/objc_video_encoder_factory.mm b/sdk/objc/native/src/objc_video_encoder_factory.mm
index b66554b..06515e5 100644
--- a/sdk/objc/native/src/objc_video_encoder_factory.mm
+++ b/sdk/objc/native/src/objc_video_encoder_factory.mm
@@ -91,7 +91,6 @@
 
   VideoEncoder::EncoderInfo GetEncoderInfo() const override {
     EncoderInfo info;
-    info.supports_native_handle = true;
     info.implementation_name = implementation_name_;
 
     RTC_OBJC_TYPE(RTCVideoEncoderQpThresholds) *qp_thresholds = [encoder_ scalingSettings];
@@ -100,6 +99,7 @@
 
     info.requested_resolution_alignment = encoder_.resolutionAlignment > 0 ?: 1;
     info.apply_alignment_to_all_simulcast_layers = encoder_.applyAlignmentToAllSimulcastLayers;
+    info.supports_native_handle = encoder_.supportsNativeHandle;
     info.is_hardware_accelerated = true;
     info.has_internal_source = false;
     return info;