diff --git a/VERSION b/VERSION index 7c202b46..2c6ece95 100644 --- a/VERSION +++ b/VERSION @@ -2,10 +2,10 @@ CCACHE_VERSION=4.8.3 # WebRTC doesn't have its own versioning, so we use Chromium versions: # https://chromiumdash.appspot.com/releases -WEBRTC_VERSION=129.0.6668.100 +WEBRTC_VERSION=130.0.6723.58 # Look for the concrete revision for WebRTC in: # https://chromium.googlesource.com/chromium/src/+/refs/tags//DEPS -WEBRTC_COMMIT=21508e08e7545a03c8c35a9299923279e3def319 +WEBRTC_COMMIT=28b793b4dd275bf2b901b87e01c0ee8d4f5732fc # Additional revision of the `WEBRTC_VERSION` added as `-rN` suffix to it, and # tracking additional changes applied on top of it. diff --git a/build.windows.ps1 b/build.windows.ps1 index f186e4cc..89a5b99f 100644 --- a/build.windows.ps1 +++ b/build.windows.ps1 @@ -120,7 +120,6 @@ Exec { git apply --ignore-space-change -v $PATCH_DIR\fix_disable_proxy_trace_eve Exec { git apply --ignore-space-change -v $PATCH_DIR\webrtc_voice_engine.patch } Exec { git apply --ignore-space-change -v $PATCH_DIR\win_dynamic_crt.patch } Exec { git apply --ignore-space-change -v $PATCH_DIR\windows_fix_abseil.patch } -Exec { git apply --ignore-space-change -v $PATCH_DIR\borning_ssl_missing_string_header.patch } Pop-Location Get-PSDrive diff --git a/build/common.mk b/build/common.mk index f5827466..0ba347cf 100644 --- a/build/common.mk +++ b/build/common.mk @@ -36,8 +36,7 @@ common-patch: && patch -p1 < $(PATCH_DIR)/nacl_armv6_2.patch \ && patch -p2 < $(PATCH_DIR)/add_licenses.patch \ && patch -p2 < $(PATCH_DIR)/4k.patch \ - && patch -p2 < $(PATCH_DIR)/fix_disable_proxy_trace_events.patch \ - && patch -p2 < $(PATCH_DIR)/borning_ssl_missing_string_header.patch + && patch -p2 < $(PATCH_DIR)/fix_disable_proxy_trace_events.patch .PHONY: common-package common-package: copy diff --git a/build/ios/Makefile b/build/ios/Makefile index f2feaf82..11a1c656 100644 --- a/build/ios/Makefile +++ b/build/ios/Makefile @@ -34,7 +34,6 @@ package: # `objc/api/peerconnection/RTCRtpCodecCapability.h`. patch: common-patch cd $(SRC_DIR) && \ - patch -p2 < $(PATCH_DIR)/enable_ios_scalability_mode.patch && \ patch -p2 < $(PATCH_DIR)/fix_ios_capability.patch && \ patch -p2 < $(PATCH_DIR)/add_yuv_helper_ios_mac.patch diff --git a/instrumentisto-libwebrtc-bin.podspec b/instrumentisto-libwebrtc-bin.podspec index 27b561a4..21aa1792 100644 --- a/instrumentisto-libwebrtc-bin.podspec +++ b/instrumentisto-libwebrtc-bin.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "instrumentisto-libwebrtc-bin" - spec.version = "129.0.6668.100" + spec.version = "130.0.6723.58" spec.summary = "Pre-compiled `libwebrtc` library for Darwin used by Medea Flutter-WebRTC." spec.homepage = "https://github.com/instrumentisto/libwebrtc-bin" @@ -8,7 +8,7 @@ Pod::Spec.new do |spec| spec.author = { 'Instrumentisto Team' => 'developer@instrumentisto.com' } spec.ios.deployment_target = '10.0' - spec.source = { :http => "https://github.com/instrumentisto/libwebrtc-bin/releases/download/129.0.6668.100/libwebrtc-ios.zip" } + spec.source = { :http => "https://github.com/instrumentisto/libwebrtc-bin/releases/download/130.0.6723.58/libwebrtc-ios.zip" } spec.vendored_frameworks = "WebRTC.xcframework" spec.pod_target_xcconfig = { diff --git a/patch/borning_ssl_missing_string_header.patch b/patch/borning_ssl_missing_string_header.patch deleted file mode 100644 index 275dd50f..00000000 --- a/patch/borning_ssl_missing_string_header.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/third_party/boringssl/src/pki/string_util.h -+++ b/src/third_party/boringssl/src/pki/string_util.h -@@ -6,6 +6,7 @@ - #define BSSL_PKI_STRING_UTIL_H_ - - #include -+#include - #include - #include - diff --git a/patch/enable_android_scalability_mode.patch b/patch/enable_android_scalability_mode.patch index c0a4f1ee..f68de985 100644 --- a/patch/enable_android_scalability_mode.patch +++ b/patch/enable_android_scalability_mode.patch @@ -1,5 +1,5 @@ diff --git a/src/sdk/android/BUILD.gn b/src/sdk/android/BUILD.gn -index 82aabac..3856891 100644 +index 38b75c62a7..545f2477df 100644 --- a/src/sdk/android/BUILD.gn +++ b/src/sdk/android/BUILD.gn @@ -196,6 +196,8 @@ if (is_android) { @@ -11,7 +11,7 @@ index 82aabac..3856891 100644 "api/org/webrtc/VideoCodecStatus.java", "api/org/webrtc/VideoDecoder.java", "api/org/webrtc/VideoDecoderFactory.java", -@@ -1330,6 +1332,8 @@ if (current_os == "linux" || is_android) { +@@ -1323,6 +1325,8 @@ if (current_os == "linux" || is_android) { "api/org/webrtc/JavaI420Buffer.java", "api/org/webrtc/TimestampAligner.java", "api/org/webrtc/VideoCodecInfo.java", @@ -22,7 +22,7 @@ index 82aabac..3856891 100644 "api/org/webrtc/VideoDecoderFactory.java", diff --git a/src/sdk/android/api/org/webrtc/CodecSupport.java b/src/sdk/android/api/org/webrtc/CodecSupport.java new file mode 100644 -index 0000000..6100236 +index 0000000000..61002368b3 --- /dev/null +++ b/src/sdk/android/api/org/webrtc/CodecSupport.java @@ -0,0 +1,12 @@ @@ -40,7 +40,7 @@ index 0000000..6100236 +} diff --git a/src/sdk/android/api/org/webrtc/CodecSupportUtils.java b/src/sdk/android/api/org/webrtc/CodecSupportUtils.java new file mode 100644 -index 0000000..41545de +index 0000000000..41545de307 --- /dev/null +++ b/src/sdk/android/api/org/webrtc/CodecSupportUtils.java @@ -0,0 +1,13 @@ @@ -58,11 +58,11 @@ index 0000000..41545de + } +} diff --git a/src/sdk/android/api/org/webrtc/DefaultVideoEncoderFactory.java b/src/sdk/android/api/org/webrtc/DefaultVideoEncoderFactory.java -index 76896b6..9be1c7e 100644 +index 76896b6b2d..9be1c7e012 100644 --- a/src/sdk/android/api/org/webrtc/DefaultVideoEncoderFactory.java +++ b/src/sdk/android/api/org/webrtc/DefaultVideoEncoderFactory.java @@ -53,4 +53,13 @@ public class DefaultVideoEncoderFactory implements VideoEncoderFactory { - + return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]); } + @@ -76,7 +76,7 @@ index 76896b6..9be1c7e 100644 + } } diff --git a/src/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/src/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java -index d43fc27..9876b77 100644 +index d43fc27fa0..9876b7707f 100644 --- a/src/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java +++ b/src/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java @@ -13,6 +13,7 @@ package org.webrtc; @@ -84,7 +84,7 @@ index d43fc27..9876b77 100644 import static org.webrtc.MediaCodecUtils.INTEL_PREFIX; import static org.webrtc.MediaCodecUtils.QCOM_PREFIX; +import static org.webrtc.MediaCodecUtils.getCodecScalabilityMode; - + import android.media.MediaCodecInfo; import android.media.MediaCodecList; @@ -143,17 +144,28 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { @@ -94,16 +94,16 @@ index d43fc27..9876b77 100644 - name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true))); + name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true), getCodecScalabilityMode(type))); } - + supportedCodecInfos.add(new VideoCodecInfo( - name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ false))); + name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ false), getCodecScalabilityMode(type))); } } - + return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]); } - + +@Override + public CodecSupport queryCodecSupport(VideoCodecInfo format, String scalability_mode) { + VideoCodecMimeType type = VideoCodecMimeType.valueOf(format.getName()); @@ -119,7 +119,7 @@ index d43fc27..9876b77 100644 for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { MediaCodecInfo info = null; diff --git a/src/sdk/android/api/org/webrtc/RtpParameters.java b/src/sdk/android/api/org/webrtc/RtpParameters.java -index 9ca8311..1fcffe7 100644 +index 9ca8311610..1fcffe7cad 100644 --- a/src/sdk/android/api/org/webrtc/RtpParameters.java +++ b/src/sdk/android/api/org/webrtc/RtpParameters.java @@ -73,6 +73,8 @@ public class RtpParameters { @@ -151,7 +151,7 @@ index 9ca8311..1fcffe7 100644 @@ -154,6 +157,12 @@ public class RtpParameters { return numTemporalLayers; } - + + @Nullable + @CalledByNative("Encoding") + String getScalabilityMode() { @@ -162,30 +162,30 @@ index 9ca8311..1fcffe7 100644 @CalledByNative("Encoding") Double getScaleResolutionDownBy() { diff --git a/src/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java b/src/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java -index ad19b4c..ad754ed 100644 +index ad19b4c8c1..ad754ed3f7 100644 --- a/src/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java +++ b/src/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java @@ -49,6 +49,11 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory { return nativeGetSupportedCodecs(nativeFactory).toArray(new VideoCodecInfo[0]); } - + + @Override + public CodecSupport queryCodecSupport(VideoCodecInfo format, String scalability_mode) { + return nativeQueryCodecSupport(nativeFactory, format, scalability_mode); + } + private static native long nativeCreateFactory(); - + private static native boolean nativeIsSupported(long factory, VideoCodecInfo info); @@ -56,4 +61,6 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory { private static native long nativeCreate(long factory, long webrtcEnvRef, VideoCodecInfo info); - + private static native List nativeGetSupportedCodecs(long factory); + + private static native CodecSupport nativeQueryCodecSupport(long factory, VideoCodecInfo format, String scalability_mode); } diff --git a/src/sdk/android/api/org/webrtc/VideoCodecInfo.java b/src/sdk/android/api/org/webrtc/VideoCodecInfo.java -index 4f97cf7..715ec6c 100644 +index 4f97cf74cf..715ec6ce85 100644 --- a/src/sdk/android/api/org/webrtc/VideoCodecInfo.java +++ b/src/sdk/android/api/org/webrtc/VideoCodecInfo.java @@ -14,6 +14,7 @@ import androidx.annotation.Nullable; @@ -193,16 +193,16 @@ index 4f97cf7..715ec6c 100644 import java.util.Locale; import java.util.Map; +import java.util.List; - + /** * Represent a video codec as encoded in SDP. @@ -34,20 +35,23 @@ public class VideoCodecInfo { - + public final String name; public final Map params; + public final List scalabilityMods; @Deprecated public final int payload; - + @CalledByNative - public VideoCodecInfo(String name, Map params) { + public VideoCodecInfo(String name, Map params, List scalabilityMods) { @@ -211,7 +211,7 @@ index 4f97cf7..715ec6c 100644 this.params = params; + this.scalabilityMods = scalabilityMods; } - + @Deprecated - public VideoCodecInfo(int payload, String name, Map params) { + public VideoCodecInfo(int payload, String name, Map params, List scalabilityMods) { @@ -220,7 +220,7 @@ index 4f97cf7..715ec6c 100644 this.params = params; + this.scalabilityMods = scalabilityMods; } - + @Override @@ -83,4 +87,9 @@ public class VideoCodecInfo { Map getParams() { @@ -233,13 +233,13 @@ index 4f97cf7..715ec6c 100644 + } } diff --git a/src/sdk/android/api/org/webrtc/VideoEncoderFactory.java b/src/sdk/android/api/org/webrtc/VideoEncoderFactory.java -index 2a46662..1cfde1f 100644 +index 2a46662d14..1cfde1f717 100644 --- a/src/sdk/android/api/org/webrtc/VideoEncoderFactory.java +++ b/src/sdk/android/api/org/webrtc/VideoEncoderFactory.java @@ -51,6 +51,13 @@ public interface VideoEncoderFactory { */ @CalledByNative VideoCodecInfo[] getSupportedCodecs(); - + + /** + * Query whether the specifed format is supported or not and if it will be + * power efficient, which is currently interpreted as if there is support for @@ -251,7 +251,7 @@ index 2a46662..1cfde1f 100644 * Enumerates the list of supported video codecs that can also be tagged with * implementation information. This method will only be called once and the diff --git a/src/sdk/android/instrumentationtests/src/org/webrtc/AndroidVideoDecoderInstrumentationTest.java b/src/sdk/android/instrumentationtests/src/org/webrtc/AndroidVideoDecoderInstrumentationTest.java -index 6f44812..e85b275 100644 +index 6f448124e8..e85b275a7d 100644 --- a/src/sdk/android/instrumentationtests/src/org/webrtc/AndroidVideoDecoderInstrumentationTest.java +++ b/src/sdk/android/instrumentationtests/src/org/webrtc/AndroidVideoDecoderInstrumentationTest.java @@ -48,7 +48,7 @@ public final class AndroidVideoDecoderInstrumentationTest { @@ -264,7 +264,7 @@ index 6f44812..e85b275 100644 this.useEglContext = useEglContext; } diff --git a/src/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java b/src/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java -index fe608c7..313ca8c 100644 +index 86978c993b..a53ca3242d 100644 --- a/src/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java +++ b/src/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java @@ -47,7 +47,7 @@ public class DefaultVideoEncoderFactoryTest { @@ -276,33 +276,24 @@ index fe608c7..313ca8c 100644 VideoEncoderFactory hwFactory = new CustomHardwareVideoEncoderFactory(hwVp8Encoder); DefaultVideoEncoderFactory defFactory = new DefaultVideoEncoderFactory(hwFactory); VideoCodecInfo[] supportedCodecs = defFactory.getSupportedCodecs(); -@@ -62,7 +62,7 @@ public class DefaultVideoEncoderFactoryTest { - public void getSupportedCodecs_hwVp8WithDifferentParams_twoVp8() { - VideoCodecInfo hwVp8Encoder = new VideoCodecInfo("VP8", new HashMap() { - { put("param", "value"); } -- }); -+ }, new ArrayList()); - VideoEncoderFactory hwFactory = new CustomHardwareVideoEncoderFactory(hwVp8Encoder); - DefaultVideoEncoderFactory defFactory = new DefaultVideoEncoderFactory(hwFactory); - VideoCodecInfo[] supportedCodecs = defFactory.getSupportedCodecs(); @@ -74,4 +74,9 @@ public class DefaultVideoEncoderFactoryTest { assertEquals(1, supportedCodecs[3].params.size()); assertEquals("value", supportedCodecs[3].params.get("param")); } + -+ @Override ++ @Override + public CodecSupport queryCodecSupport(VideoCodecInfo format, String scalability_mode) { + return new CodecSupport(false, false); + } } diff --git a/src/sdk/android/instrumentationtests/src/org/webrtc/RtpCapabilitiesTest.java b/src/sdk/android/instrumentationtests/src/org/webrtc/RtpCapabilitiesTest.java -index e04b236..5c667a7 100644 +index e04b2361dd..5c667a7f7a 100644 --- a/src/sdk/android/instrumentationtests/src/org/webrtc/RtpCapabilitiesTest.java +++ b/src/sdk/android/instrumentationtests/src/org/webrtc/RtpCapabilitiesTest.java @@ -82,8 +82,8 @@ public class RtpCapabilitiesTest { .setNativeLibraryName(TestConstants.NATIVE_LIBRARY) .createInitializationOptions()); - + - VideoCodecInfo vp8Codec = new VideoCodecInfo("VP8", new HashMap<>()); - VideoCodecInfo h264Codec = new VideoCodecInfo("H264", new HashMap<>()); + VideoCodecInfo vp8Codec = new VideoCodecInfo("VP8", new HashMap<>(), new ArrayList()); @@ -311,21 +302,21 @@ index e04b236..5c667a7 100644 supportedCodecs.add(vp8Codec); supportedCodecs.add(h264Codec); @@ -227,4 +227,9 @@ public class RtpCapabilitiesTest { - + return rtpMaps; } + -+ @Override ++ @Override + public CodecSupport queryCodecSupport(VideoCodecInfo format, String scalability_mode) { + return new CodecSupport(false, false); + } } diff --git a/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoDecoderFactoryTest.java b/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoDecoderFactoryTest.java -index 8a5d978..ed9eeb4 100644 +index 8a5d9788ee..ed9eeb40e6 100644 --- a/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoDecoderFactoryTest.java +++ b/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoDecoderFactoryTest.java @@ -14,6 +14,7 @@ import static com.google.common.truth.Truth.assertThat; - + import androidx.annotation.Nullable; import androidx.test.filters.SmallTest; +import java.util.ArrayList; @@ -342,11 +333,11 @@ index 8a5d978..ed9eeb4 100644 assertThat(decoder).isNull(); } diff --git a/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoEncoderFactoryTest.java b/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoEncoderFactoryTest.java -index 696b423..c5fce8f 100644 +index 696b423cde..c5fce8f3ba 100644 --- a/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoEncoderFactoryTest.java +++ b/src/sdk/android/instrumentationtests/src/org/webrtc/SoftwareVideoEncoderFactoryTest.java @@ -14,6 +14,7 @@ import static com.google.common.truth.Truth.assertThat; - + import androidx.annotation.Nullable; import androidx.test.filters.SmallTest; +import java.util.ArrayList; @@ -363,31 +354,31 @@ index 696b423..c5fce8f 100644 assertThat(encoder).isNull(); } diff --git a/src/sdk/android/src/java/org/webrtc/H264Utils.java b/src/sdk/android/src/java/org/webrtc/H264Utils.java -index abb79c6..a5bd34a 100644 +index abb79c6582..a5bd34a21a 100644 --- a/src/sdk/android/src/java/org/webrtc/H264Utils.java +++ b/src/sdk/android/src/java/org/webrtc/H264Utils.java @@ -11,6 +11,7 @@ package org.webrtc; - + import java.util.Map; +import java.util.ArrayList; import java.util.HashMap; - + /** Container for static helper functions related to dealing with H264 codecs. */ @@ -38,9 +39,9 @@ class H264Utils { } - + public static VideoCodecInfo DEFAULT_H264_BASELINE_PROFILE_CODEC = - new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ false)); + new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ false), new ArrayList()); public static VideoCodecInfo DEFAULT_H264_HIGH_PROFILE_CODEC = - new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ true)); + new VideoCodecInfo("H264", getDefaultH264Params(/* isHighProfile= */ true), new ArrayList()); - + public static boolean isSameH264Profile( Map params1, Map params2) { diff --git a/src/sdk/android/src/java/org/webrtc/MediaCodecUtils.java b/src/sdk/android/src/java/org/webrtc/MediaCodecUtils.java -index 5417fec..39ed078 100644 +index 5417fec4d4..39ed078382 100644 --- a/src/sdk/android/src/java/org/webrtc/MediaCodecUtils.java +++ b/src/sdk/android/src/java/org/webrtc/MediaCodecUtils.java @@ -15,7 +15,9 @@ import android.media.MediaCodecInfo; @@ -398,13 +389,13 @@ index 5417fec..39ed078 100644 import java.util.HashMap; +import java.util.List; import java.util.Map; - + /** Container class for static constants and helpers used with MediaCodec. */ @@ -54,6 +56,55 @@ class MediaCodecUtils { MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar, MediaCodecInfo.CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar, MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m}; -+ ++ + // All possible scalability Modes. + static final List kAllScalabilityModes = Arrays.asList( + "L1T1", @@ -453,13 +444,13 @@ index 5417fec..39ed078 100644 + "L1T1", + "L1T2", + "L1T3"); - + // Color formats supported by texture mode encoding - in order of preference. static final int[] TEXTURE_COLOR_FORMATS = @@ -94,6 +145,21 @@ class MediaCodecUtils { } } - + + static List getCodecScalabilityMode(VideoCodecMimeType type) { + switch (type) { + case VP8: @@ -479,15 +470,15 @@ index 5417fec..39ed078 100644 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { return isHardwareAcceleratedQOrHigher(info); diff --git a/src/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java b/src/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java -index 9a73bc4..a14383d 100644 +index 9a73bc49ff..a14383d5ef 100644 --- a/src/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java +++ b/src/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java @@ -12,6 +12,7 @@ package org.webrtc; - + import static org.webrtc.MediaCodecUtils.EXYNOS_PREFIX; import static org.webrtc.MediaCodecUtils.QCOM_PREFIX; +import static org.webrtc.MediaCodecUtils.getCodecScalabilityMode; - + import android.media.MediaCodecInfo; import android.media.MediaCodecInfo.CodecCapabilities; @@ -72,11 +73,11 @@ class MediaCodecVideoDecoderFactory implements VideoDecoderFactory { @@ -497,15 +488,15 @@ index 9a73bc4..a14383d 100644 - name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true))); + name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true), getCodecScalabilityMode(type))); } - + supportedCodecInfos.add(new VideoCodecInfo( - name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ false))); + name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ false), getCodecScalabilityMode(type))); } } - + diff --git a/src/sdk/android/src/jni/pc/rtp_parameters.cc b/src/sdk/android/src/jni/pc/rtp_parameters.cc -index 4bd9ee0..1f5957b 100644 +index 4bd9ee0e1d..1f5957b61e 100644 --- a/src/sdk/android/src/jni/pc/rtp_parameters.cc +++ b/src/sdk/android/src/jni/pc/rtp_parameters.cc @@ -52,6 +52,7 @@ ScopedJavaLocalRef NativeToJavaRtpEncodingParameter( @@ -529,12 +520,12 @@ index 4bd9ee0..1f5957b 100644 Java_Encoding_getScaleResolutionDownBy(jni, j_encoding_parameters); encoding.scale_resolution_down_by = diff --git a/src/sdk/android/src/jni/software_video_decoder_factory.cc b/src/sdk/android/src/jni/software_video_decoder_factory.cc -index 08e94a9..d75c5c7 100644 +index 08e94a964f..d75c5c79da 100644 --- a/src/sdk/android/src/jni/software_video_decoder_factory.cc +++ b/src/sdk/android/src/jni/software_video_decoder_factory.cc @@ -11,7 +11,6 @@ #include - + #include "api/environment/environment.h" -#include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/video_decoder.h" @@ -549,10 +540,10 @@ index 08e94a9..d75c5c7 100644 +#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h" +#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h" +#include "api/video_codecs/video_decoder_factory_template_open_h264_adapter.h" - + namespace webrtc { namespace jni { - + static jlong JNI_SoftwareVideoDecoderFactory_CreateFactory(JNIEnv* env) { + std::unique_ptr video_decoder_factory = + std::make_unique video_encoder_factory = + std::make_unique +JNI_SoftwareVideoEncoderFactory_QueryCodecSupport( + JNIEnv* env, @@ -621,7 +612,7 @@ index a2d44d9..19aa60a 100644 + const auto video_format = + webrtc::jni::VideoCodecInfoToSdpVideoFormat(env, j_video_codec_info); + -+ absl::optional scalability_mode; ++ std::optional scalability_mode; + if (!IsNull(env, j_scalability_mode)) { + scalability_mode = JavaToNativeString(env, j_scalability_mode); + } @@ -635,7 +626,7 @@ index a2d44d9..19aa60a 100644 } // namespace jni } // namespace webrtc diff --git a/src/sdk/android/src/jni/video_codec_info.cc b/src/sdk/android/src/jni/video_codec_info.cc -index a218a1d..c5d4cf3 100644 +index a218a1d23f..c5d4cf3529 100644 --- a/src/sdk/android/src/jni/video_codec_info.cc +++ b/src/sdk/android/src/jni/video_codec_info.cc @@ -13,15 +13,36 @@ @@ -645,10 +636,10 @@ index a218a1d..c5d4cf3 100644 +#include "absl/container/inlined_vector.h" +#include "absl/types/optional.h" +#include "api/video_codecs/scalability_mode.h" - + namespace webrtc { namespace jni { - + SdpVideoFormat VideoCodecInfoToSdpVideoFormat(JNIEnv* jni, const JavaRef& j_info) { + absl::InlinedVector scalability_modes; @@ -674,7 +665,7 @@ index a218a1d..c5d4cf3 100644 + std::string s = {sv.begin(), sv.end()}; + return NativeToJavaString(jni, s); } - + ScopedJavaLocalRef SdpVideoFormatToVideoCodecInfo( @@ -29,8 +50,10 @@ ScopedJavaLocalRef SdpVideoFormatToVideoCodecInfo( const SdpVideoFormat& format) { @@ -686,10 +677,10 @@ index a218a1d..c5d4cf3 100644 - jni, NativeToJavaString(jni, format.name), j_params); + jni, NativeToJavaString(jni, format.name), j_params, j_scala); } - + } // namespace jni diff --git a/src/sdk/android/src/jni/video_encoder_factory_wrapper.cc b/src/sdk/android/src/jni/video_encoder_factory_wrapper.cc -index 78aa145..42b63f5 100644 +index 709fa5894e..26fb12239f 100644 --- a/src/sdk/android/src/jni/video_encoder_factory_wrapper.cc +++ b/src/sdk/android/src/jni/video_encoder_factory_wrapper.cc @@ -14,6 +14,7 @@ @@ -703,10 +694,10 @@ index 78aa145..42b63f5 100644 @@ -127,5 +128,27 @@ VideoEncoderFactoryWrapper::GetEncoderSelector() const { return std::make_unique(jni, selector); } - + +VideoEncoderFactory::CodecSupport VideoEncoderFactoryWrapper::QueryCodecSupport( + const SdpVideoFormat& format, -+ absl::optional scalability_mode) const { ++ std::optional scalability_mode) const { + JNIEnv* jni = AttachCurrentThreadIfNeeded(); + + ScopedJavaLocalRef j_codec_info = @@ -729,15 +720,15 @@ index 78aa145..42b63f5 100644 } // namespace jni } // namespace webrtc diff --git a/src/sdk/android/src/jni/video_encoder_factory_wrapper.h b/src/sdk/android/src/jni/video_encoder_factory_wrapper.h -index 9b383a8..4aeb0db 100644 +index 9b383a88e9..4aeb0db63c 100644 --- a/src/sdk/android/src/jni/video_encoder_factory_wrapper.h +++ b/src/sdk/android/src/jni/video_encoder_factory_wrapper.h @@ -41,6 +41,9 @@ class VideoEncoderFactoryWrapper : public VideoEncoderFactory { - + std::unique_ptr GetEncoderSelector() const override; - + + CodecSupport QueryCodecSupport(const SdpVideoFormat& format, -+ absl::optional scalability_mode) const override; ++ std::optional scalability_mode) const override; + private: const ScopedJavaGlobalRef encoder_factory_; diff --git a/patch/enable_ios_scalability_mode.patch b/patch/enable_ios_scalability_mode.patch deleted file mode 100644 index 6f6639ac..00000000 --- a/patch/enable_ios_scalability_mode.patch +++ /dev/null @@ -1,1008 +0,0 @@ -diff --git a/src/sdk/BUILD.gn b/src/sdk/BUILD.gn -index 683d8e5829..5c22265dbf 100644 ---- a/src/sdk/BUILD.gn -+++ b/src/sdk/BUILD.gn -@@ -96,6 +96,8 @@ if (is_ios || is_mac) { - "objc/base/RTCCodecSpecificInfo.h", - "objc/base/RTCEncodedImage.h", - "objc/base/RTCEncodedImage.m", -+ "objc/base/RTCCodecSupport.h", -+ "objc/base/RTCCodecSupport.m", - "objc/base/RTCI420Buffer.h", - "objc/base/RTCLogging.h", - "objc/base/RTCLogging.mm", -@@ -724,6 +726,7 @@ if (is_ios || is_mac) { - ":vp8", - ":vp9", - ":vpx_codec_constants", -+ ":wrapped_native_codec_objc", - ] - - defines = [] -@@ -764,6 +767,7 @@ if (is_ios || is_mac) { - deps = [ - ":base_objc", - ":wrapped_native_codec_objc", -+ "../media:rtc_media_base", - "../modules/video_coding:webrtc_vp8", - ] - } -@@ -781,6 +785,7 @@ if (is_ios || is_mac) { - deps = [ - ":base_objc", - ":wrapped_native_codec_objc", -+ "../media:rtc_media_base", - "../modules/video_coding:webrtc_vp9", - ] - } -@@ -812,6 +817,7 @@ if (is_ios || is_mac) { - deps = [ - ":base_objc", - ":wrapped_native_codec_objc", -+ "../media:rtc_media_base", - "../modules/video_coding/codecs/av1:libaom_av1_encoder", - ] - } -@@ -1273,6 +1279,7 @@ if (is_ios || is_mac) { - "objc/base/RTCVideoDecoder.h", - "objc/base/RTCVideoDecoderFactory.h", - "objc/base/RTCVideoEncoder.h", -+ "objc/base/RTCCodecSupport.h", - "objc/base/RTCVideoEncoderFactory.h", - "objc/base/RTCVideoEncoderQpThresholds.h", - "objc/base/RTCVideoEncoderSettings.h", -@@ -1350,6 +1357,7 @@ if (is_ios || is_mac) { - "objc/api/video_codec/RTCVideoEncoderAV1.h", - "objc/api/video_frame_buffer/RTCNativeI420Buffer.h", - "objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h", -+ "objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.h", - ] - - if (!build_with_chromium) { -@@ -1376,6 +1384,7 @@ if (is_ios || is_mac) { - ":native_api", - ":native_video", - ":peerconnectionfactory_base_objc", -+ ":wrapped_native_codec_objc", - ":videocapture_objc", - ":videocodec_objc", - ":videotoolbox_objc", -@@ -1477,6 +1486,7 @@ if (is_ios || is_mac) { - "objc/base/RTCVideoDecoder.h", - "objc/base/RTCVideoDecoderFactory.h", - "objc/base/RTCVideoEncoder.h", -+ "objc/base/RTCCodecSupport.h", - "objc/base/RTCVideoEncoderFactory.h", - "objc/base/RTCVideoEncoderQpThresholds.h", - "objc/base/RTCVideoEncoderSettings.h", -@@ -1513,6 +1523,7 @@ if (is_ios || is_mac) { - ":native_api", - ":native_video", - ":peerconnectionfactory_base_objc", -+ ":wrapped_native_codec_objc", - ":videocapture_objc", - ":videocodec_objc", - ":videotoolbox_objc", -@@ -1551,6 +1562,10 @@ if (is_ios || is_mac) { - "objc/api/video_codec/RTCNativeVideoEncoder.h", - "objc/api/video_codec/RTCNativeVideoEncoder.mm", - "objc/api/video_codec/RTCNativeVideoEncoderBuilder+Native.h", -+ "objc/api/video_codec/RTCWrappedNativeVideoEncoder.h", -+ "objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm", -+ "objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.h", -+ "objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.mm", - ] - - configs += [ "..:common_objc" ] -@@ -1561,8 +1576,12 @@ if (is_ios || is_mac) { - ":helpers_objc", - "../api/environment", - "../api/video_codecs:video_codecs_api", -+ "../api/video_codecs:video_encoder_factory_template", - "../media:codec", - "../rtc_base:checks", -+ ":videocodec_objc", -+ ":videotoolbox_objc", -+ ":base_native_additions_objc", - ] - } - -diff --git a/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h b/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h -index 07f6b7a39c..d055115ae2 100644 ---- a/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h -+++ b/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h -@@ -51,6 +51,10 @@ RTC_OBJC_EXPORT - */ - @property(nonatomic, copy, nullable) NSNumber *numTemporalLayers; - -+/** A case-sensitive identifier of the scalability mode to be used for this stream. -+ https://w3c.github.io/webrtc-svc/#rtcrtpencodingparameters */ -+@property(nonatomic, copy, nullable) NSString *scalabilityMode; -+ - /** Scale the width and height down by this factor for video. If nil, - * implementation default scaling factor will be used. - */ -diff --git a/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm b/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm -index d6087dafb0..5fc7670857 100644 ---- a/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm -+++ b/src/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm -@@ -20,6 +20,7 @@ - @synthesize minBitrateBps = _minBitrateBps; - @synthesize maxFramerate = _maxFramerate; - @synthesize numTemporalLayers = _numTemporalLayers; -+@synthesize scalabilityMode = _scalabilityMode; - @synthesize scaleResolutionDownBy = _scaleResolutionDownBy; - @synthesize ssrc = _ssrc; - @synthesize bitratePriority = _bitratePriority; -@@ -52,6 +53,10 @@ - if (nativeParameters.num_temporal_layers) { - _numTemporalLayers = [NSNumber numberWithInt:*nativeParameters.num_temporal_layers]; - } -+ if (nativeParameters.scalability_mode) { -+ _scalabilityMode = [NSString -+ stringWithUTF8String:nativeParameters.scalability_mode->c_str()]; -+ } - if (nativeParameters.scale_resolution_down_by) { - _scaleResolutionDownBy = - [NSNumber numberWithDouble:*nativeParameters.scale_resolution_down_by]; -@@ -85,6 +90,10 @@ - if (_numTemporalLayers != nil) { - parameters.num_temporal_layers = absl::optional(_numTemporalLayers.intValue); - } -+ if (_scalabilityMode != nil) { -+ parameters.scalability_mode = -+ absl::optional(std::string([_scalabilityMode UTF8String])); -+ } - if (_scaleResolutionDownBy != nil) { - parameters.scale_resolution_down_by = - absl::optional(_scaleResolutionDownBy.doubleValue); -diff --git a/src/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm b/src/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm -index 2eb8d366d2..5cc28aafa7 100644 ---- a/src/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm -+++ b/src/sdk/objc/api/peerconnection/RTCVideoCodecInfo+Private.mm -@@ -12,6 +12,9 @@ - - #import "helpers/NSString+StdString.h" - -+#include "api/video_codecs/scalability_mode.h" -+#include "absl/container/inlined_vector.h" -+ - @implementation RTC_OBJC_TYPE (RTCVideoCodecInfo) - (Private) - -@@ -21,10 +24,36 @@ - [params setObject:[NSString stringForStdString:it->second] - forKey:[NSString stringForStdString:it->first]]; - } -- return [self initWithName:[NSString stringForStdString:format.name] parameters:params]; -+ -+ NSMutableArray* scalability_modes = -+ [NSMutableArray array]; -+ for (auto it = format.scalability_modes.begin(); -+ it != format.scalability_modes.end(); ++it) { -+ auto mode = webrtc::ScalabilityModeToString(*it); -+ std::string mode_string = {mode.begin(), mode.end()}; -+ NSString* scalability_mode = [NSString stringForStdString:mode_string]; -+ [scalability_modes addObject:scalability_mode]; -+ } -+ -+ return [self initWithName:[NSString stringForStdString:format.name] parameters:params scalabiltyModes: scalability_modes]; - } - - - (webrtc::SdpVideoFormat)nativeSdpVideoFormat { -+ absl::InlinedVector -+ scalability_modes; -+ for (NSString* scalabiltyMode in self.scalabiltyModes) { -+ for (size_t j = 0; j < webrtc::kScalabilityModeCount; ++j) { -+ auto mode = -+ webrtc::ScalabilityModeToString(webrtc::kAllScalabilityModes[j]); -+ std::string mode_string = {mode.begin(), mode.end()}; -+ std::string self_mode_string = -+ [NSString stdStringForString:scalabiltyMode]; -+ if (mode_string == self_mode_string) { -+ scalability_modes.push_back(webrtc::kAllScalabilityModes[j]); -+ } -+ } -+ } -+ - std::map parameters; - for (NSString *paramKey in self.parameters.allKeys) { - std::string key = [NSString stdStringForString:paramKey]; -@@ -32,7 +61,8 @@ - parameters[key] = value; - } - -- return webrtc::SdpVideoFormat([NSString stdStringForString:self.name], parameters); -+ return webrtc::SdpVideoFormat([NSString stdStringForString:self.name], -+ parameters, scalability_modes); - } - - @end -diff --git a/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h -new file mode 100644 -index 0000000000..d639eaee31 ---- /dev/null -+++ b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.h -@@ -0,0 +1,21 @@ -+/* -+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+#import -+#import "RTCNativeVideoEncoder.h" -+#import "base/RTCMacros.h" -+#import "base/RTCVideoEncoder.h" -+#include "api/video_codecs/video_encoder_factory.h" -+#include "api/video_codecs/sdp_video_format.h" -+#include "api/video_codecs/video_encoder.h" -+#include "media/base/codec.h" -+ -+@interface RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoder) : NSObject -++ (id)wrap:(std::shared_ptr)factory :(webrtc::SdpVideoFormat)format; -+@end -diff --git a/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm -new file mode 100644 -index 0000000000..4b9ef7cc67 ---- /dev/null -+++ b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoder.mm -@@ -0,0 +1,45 @@ -+/* -+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+#import "base/RTCLogging.h" -+#import -+#import "RTCWrappedNativeVideoEncoder.h" -+#import "RTCMacros.h" -+#import "RTCNativeVideoEncoder.h" -+#import "RTCNativeVideoEncoderBuilder+Native.h" -+ -+@interface RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoderBuilder) -+ : RTC_OBJC_TYPE(RTCNativeVideoEncoder) -+@end -+ -+ @implementation RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoderBuilder){ -+ std::shared_ptr _factory; -+ std::optional _format; -+ } -+ -+ -(id)initWithParams:(std::shared_ptr)factory :(webrtc::SdpVideoFormat)format -+ { -+ if(self = [super init]) { -+ _factory = factory; -+ _format = format; -+ } -+ -+ return self; -+ } -+ -+ - (std::unique_ptr)build:(const webrtc::Environment&)env { -+ return _factory->Create(env, _format.value()); -+ } -+ @end -+ -+ @implementation RTC_OBJC_TYPE (RTCWrappedNativeVideoEncoder) -+ + (id)wrap:(std::shared_ptr)factory :(webrtc::SdpVideoFormat)format { -+ return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoderBuilder) alloc] initWithParams:factory:format]; -+ } -+ @end -diff --git a/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.h b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.h -new file mode 100644 -index 0000000000..ae4b2f5a16 ---- /dev/null -+++ b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.h -@@ -0,0 +1,30 @@ -+/* -+ * Copyright 2013 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+ -+#import -+ -+#import "RTCMacros.h" -+#import "RTCVideoEncoderFactory.h" -+#import "components/video_codec/RTCVideoEncoderFactoryH264.h" -+ -+NS_ASSUME_NONNULL_BEGIN -+ -+/** This encoder factory include support for all codecs bundled with WebRTC. If -+ * using custom codecs, create custom implementations of RTCVideoEncoderFactory. -+ */ -+RTC_OBJC_EXPORT -+@interface RTC_OBJC_TYPE (RTCWrapperNativeVideoEncoderFactory) : NSObject -+@property(nonatomic, strong) RTC_OBJC_TYPE(RTCVideoEncoderFactoryH264) *HWVideoEncoderFactory; -+ -+- (instancetype)initWithTemplateFactory; -+ -+@end -+ -+NS_ASSUME_NONNULL_END -diff --git a/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.mm b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.mm -new file mode 100644 -index 0000000000..be788495fd ---- /dev/null -+++ b/src/sdk/objc/api/video_codec/RTCWrappedNativeVideoEncoderFactory.mm -@@ -0,0 +1,158 @@ -+/* -+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+ -+#import "RTCWrappedNativeVideoEncoderFactory.h" -+ -+#import -+ -+#import "base/RTCLogging.h" -+#import "RTCWrappedNativeVideoEncoder.h" -+#include "absl/container/inlined_vector.h" -+#import "api/peerconnection/RTCVideoCodecInfo+Private.h" -+#import "api/video_codec/RTCVideoCodecConstants.h" -+#include "api/video_codecs/scalability_mode.h" -+#include "api/video_codecs/video_encoder_factory.h" -+#include "api/video_codecs/video_encoder_factory_template.h" -+#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h" -+#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h" -+#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h" -+#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h" -+#include "api/environment/environment_factory.h" -+#import "base/RTCMacros.h" -+#import "base/RTCVideoCodecInfo.h" -+#import "helpers/NSString+StdString.h" -+#import "components/video_codec/RTCH264ProfileLevelId.h" -+ -+@implementation RTC_OBJC_TYPE (RTCWrapperNativeVideoEncoderFactory) { -+ std::shared_ptr _wrappedFactory; -+ std::unique_ptr _env; -+} -+@synthesize HWVideoEncoderFactory = _HWVideoEncoderFactory; -+ -+- (instancetype)initWithTemplateFactory { -+ if (self = [super init]) { -+ _wrappedFactory = std::make_shared>(); -+ _env = std::make_unique(webrtc::CreateEnvironment()); -+ } -+ _HWVideoEncoderFactory = [[RTC_OBJC_TYPE(RTCVideoEncoderFactoryH264) alloc] init]; -+ return self; -+} -+ -+#pragma mark - RTC_OBJC_TYPE(RTCVideoEncoderFactory) -+ -+- (nullable id)createEncoder: -+ (RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { -+ RTCLogError("RTCWrapperNativeVideoEncoderFactory::createEncoder call"); -+ -+ if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { -+ return [_HWVideoEncoderFactory createEncoder:info]; -+ } -+ -+ absl::InlinedVector -+ scalability_modes; -+ for (NSString* scalabiltyMode in info.scalabiltyModes) { -+ for (size_t j = 0; j < webrtc::kScalabilityModeCount; ++j) { -+ auto mode = -+ webrtc::ScalabilityModeToString(webrtc::kAllScalabilityModes[j]); -+ std::string mode_string = {mode.begin(), mode.end()}; -+ std::string self_mode_string = -+ [NSString stdStringForString:scalabiltyMode]; -+ if (mode_string == self_mode_string) { -+ scalability_modes.push_back(webrtc::kAllScalabilityModes[j]); -+ } -+ } -+ } -+ -+ std::map parameters; -+ for (NSString* paramKey in info.parameters.allKeys) { -+ std::string key = [NSString stdStringForString:paramKey]; -+ std::string value = [NSString stdStringForString:info.parameters[paramKey]]; -+ parameters[key] = value; -+ } -+ -+ auto format = webrtc::SdpVideoFormat([NSString stdStringForString:info.name], -+ parameters, scalability_modes); -+ -+ return [RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) wrap:_wrappedFactory:format]; -+} -+ -+- (NSArray*)supportedCodecs { -+ auto formats = _wrappedFactory->GetSupportedFormats(); -+ -+ NSMutableArray *result = [@[] mutableCopy]; -+ auto HWSupportedCodecs = [_HWVideoEncoderFactory supportedCodecs]; -+ -+ NSUInteger i; -+ for (i = 0; i < [HWSupportedCodecs count]; i++) { -+ [result addObject:[HWSupportedCodecs objectAtIndex:i]]; -+ } -+ -+ for (size_t i = 0; i < formats.size(); ++i) { -+ RTC_OBJC_TYPE(RTCVideoCodecInfo)* info = [[RTC_OBJC_TYPE(RTCVideoCodecInfo) -+ alloc] initWithNativeSdpVideoFormat:formats[i]]; -+ -+ [result addObject:info]; -+ } -+ return result; -+} -+ -+- (RTC_OBJC_TYPE(RTCCodecSupport*)) -+ queryCodecSupport:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info -+ :(NSString*)scalabilityMode { -+ absl::InlinedVector -+ scalability_modes; -+ for (NSString* scalabiltyMode in info.scalabiltyModes) { -+ for (size_t j = 0; j < webrtc::kScalabilityModeCount; ++j) { -+ auto mode = -+ webrtc::ScalabilityModeToString(webrtc::kAllScalabilityModes[j]); -+ std::string mode_string = {mode.begin(), mode.end()}; -+ std::string self_mode_string = -+ [NSString stdStringForString:scalabiltyMode]; -+ if (mode_string == self_mode_string) { -+ scalability_modes.push_back(webrtc::kAllScalabilityModes[j]); -+ } -+ } -+ } -+ -+ std::map parameters; -+ for (NSString* paramKey in info.parameters.allKeys) { -+ std::string key = [NSString stdStringForString:paramKey]; -+ std::string value = [NSString stdStringForString:info.parameters[paramKey]]; -+ parameters[key] = value; -+ } -+ -+ auto format = webrtc::SdpVideoFormat([NSString stdStringForString:info.name], -+ parameters, scalability_modes); -+ absl::optional scalability_mode; -+ -+ if (!scalabilityMode) { -+ std::string scalability = [NSString stdStringForString:scalabilityMode]; -+ scalability_mode = scalability; -+ } -+ -+ RTC_OBJC_TYPE(RTCCodecSupport)* codecSupport = -+ [[RTC_OBJC_TYPE(RTCCodecSupport) alloc] init]; -+ -+ auto HWCodecSupport = [_HWVideoEncoderFactory queryCodecSupport:info:scalabilityMode]; -+ if (HWCodecSupport.isSupported) { -+ return HWCodecSupport; -+ } -+ -+ auto support = _wrappedFactory->QueryCodecSupport(format, scalability_mode); -+ codecSupport.isSupported = support.is_supported; -+ codecSupport.isPowerEfficient = support.is_power_efficient; -+ return codecSupport; -+} -+ -+@end -diff --git a/src/sdk/objc/base/RTCCodecSupport.h b/src/sdk/objc/base/RTCCodecSupport.h -new file mode 100644 -index 0000000000..e20bf4e4d3 ---- /dev/null -+++ b/src/sdk/objc/base/RTCCodecSupport.h -@@ -0,0 +1,24 @@ -+/* -+ * Copyright 2023 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+ -+#import -+ -+#import "RTCMacros.h" -+ -+NS_ASSUME_NONNULL_BEGIN -+ -+RTC_OBJC_EXPORT -+@interface RTC_OBJC_TYPE (RTCCodecSupport) : NSObject -+ -+@property(nonatomic, assign) BOOL isSupported; -+@property(nonatomic, assign) BOOL isPowerEfficient; -+@end -+ -+NS_ASSUME_NONNULL_END -diff --git a/src/sdk/objc/base/RTCCodecSupport.m b/src/sdk/objc/base/RTCCodecSupport.m -new file mode 100644 -index 0000000000..2d98044449 ---- /dev/null -+++ b/src/sdk/objc/base/RTCCodecSupport.m -@@ -0,0 +1,18 @@ -+/* -+ * Copyright 2023 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+ -+#import "RTCCodecSupport.h" -+ -+@implementation RTC_OBJC_TYPE (RTCCodecSupport) -+ -+@synthesize isSupported = _isSupported; -+@synthesize isPowerEfficient = _isPowerEfficient; -+ -+@end -diff --git a/src/sdk/objc/base/RTCVideoCodecInfo.h b/src/sdk/objc/base/RTCVideoCodecInfo.h -index fa28958f25..18b6d613e6 100644 ---- a/src/sdk/objc/base/RTCVideoCodecInfo.h -+++ b/src/sdk/objc/base/RTCVideoCodecInfo.h -@@ -24,12 +24,14 @@ RTC_OBJC_EXPORT - - - (instancetype)initWithName:(NSString *)name - parameters:(nullable NSDictionary *)parameters -+ scalabiltyModes:(nullable NSArray *)scalabiltyModes - NS_DESIGNATED_INITIALIZER; - - - (BOOL)isEqualToCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info; - - @property(nonatomic, readonly) NSString *name; - @property(nonatomic, readonly) NSDictionary *parameters; -+@property(nonatomic, readonly) NSArray *scalabiltyModes; - - @end - -diff --git a/src/sdk/objc/base/RTCVideoCodecInfo.m b/src/sdk/objc/base/RTCVideoCodecInfo.m -index ce26ae1de3..27a2b3594d 100644 ---- a/src/sdk/objc/base/RTCVideoCodecInfo.m -+++ b/src/sdk/objc/base/RTCVideoCodecInfo.m -@@ -14,16 +14,21 @@ - - @synthesize name = _name; - @synthesize parameters = _parameters; -+@synthesize scalabiltyModes = _scalabiltyModes; - - - (instancetype)initWithName:(NSString *)name { -- return [self initWithName:name parameters:nil]; -+ return [self initWithName:name parameters:nil scalabiltyModes:nil]; - } - --- (instancetype)initWithName:(NSString *)name -- parameters:(nullable NSDictionary *)parameters { -+- (instancetype)initWithName:(NSString*)name -+ parameters: -+ (nullable NSDictionary*)parameters -+ scalabiltyModes:(nullable NSArray*)scalabiltyModes { - if (self = [super init]) { - _name = name; - _parameters = (parameters ? parameters : @{}); -+ _scalabiltyModes = -+ (scalabiltyModes ? scalabiltyModes : (NSArray*)(@{})); - } - - return self; -@@ -54,12 +59,14 @@ - - - (instancetype)initWithCoder:(NSCoder *)decoder { - return [self initWithName:[decoder decodeObjectForKey:@"name"] -- parameters:[decoder decodeObjectForKey:@"parameters"]]; -+ parameters:[decoder decodeObjectForKey:@"parameters"] -+ scalabiltyModes:[decoder decodeObjectForKey:@"scalabiltyModes"]]; - } - - - (void)encodeWithCoder:(NSCoder *)encoder { - [encoder encodeObject:_name forKey:@"name"]; - [encoder encodeObject:_parameters forKey:@"parameters"]; -+ [encoder encodeObject:_scalabiltyModes forKey:@"scalabiltyModes"]; - } - - @end -diff --git a/src/sdk/objc/base/RTCVideoEncoderFactory.h b/src/sdk/objc/base/RTCVideoEncoderFactory.h -index a73cd77990..39c09f1072 100644 ---- a/src/sdk/objc/base/RTCVideoEncoderFactory.h -+++ b/src/sdk/objc/base/RTCVideoEncoderFactory.h -@@ -13,6 +13,7 @@ - #import "RTCMacros.h" - #import "RTCVideoCodecInfo.h" - #import "RTCVideoEncoder.h" -+#import "RTCCodecSupport.h" - - NS_ASSUME_NONNULL_BEGIN - -@@ -43,6 +44,10 @@ RTC_OBJC_EXPORT - - (NSArray *) - supportedCodecs; // TODO(andersc): "supportedFormats" instead? - -+- (RTC_OBJC_TYPE(RTCCodecSupport*))queryCodecSupport -+: (RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info -+: (NSString *)scalabilityMode; -+ - @optional - - (NSArray *)implementations; - - (nullable id)encoderSelector; -diff --git a/src/sdk/objc/components/video_codec/MediaCodecUtils.h b/src/sdk/objc/components/video_codec/MediaCodecUtils.h -new file mode 100644 -index 0000000000..76aee1ad8b ---- /dev/null -+++ b/src/sdk/objc/components/video_codec/MediaCodecUtils.h -@@ -0,0 +1,59 @@ -+/* -+ * Copyright 2023 The WebRTC project authors. All Rights Reserved. -+ * -+ * Use of this source code is governed by a BSD-style license -+ * that can be found in the LICENSE file in the root of the source -+ * tree. An additional intellectual property rights grant can be found -+ * in the file PATENTS. All contributing project authors may -+ * be found in the AUTHORS file in the root of the source tree. -+ */ -+ -+ -+#define ALL_SCALABILITY_MODES [NSArray arrayWithObjects: \ -+ @"L1T1", \ -+ @"L1T2", \ -+ @"L1T3", \ -+ @"L2T1", \ -+ @"L2T1h", \ -+ @"L2T1_KEY", \ -+ @"L2T2", \ -+ @"L2T2h", \ -+ @"L2T2_KEY", \ -+ @"L2T2_KEY_SHIFT", \ -+ @"L2T3", \ -+ @"L2T3h", \ -+ @"L2T3_KEY", \ -+ @"L3T1", \ -+ @"L3T1h", \ -+ @"L3T1_KEY", \ -+ @"L3T2", \ -+ @"L3T2h", \ -+ @"L3T2_KEY", \ -+ @"L3T3", \ -+ @"L3T3h", \ -+ @"L3T3_KEY", \ -+ @"S2T1", \ -+ @"S2T1h", \ -+ @"S2T2", \ -+ @"S2T2h", \ -+ @"S2T3", \ -+ @"S2T3h", \ -+ @"S3T1", \ -+ @"S3T1h", \ -+ @"S3T2", \ -+ @"S3T2h", \ -+ @"S3T3", \ -+ @"S3T3h", \ -+ nil] -+ -+#define VP8_SCALABILITY_MODES [NSArray arrayWithObjects: \ -+ @"L1T1", \ -+ @"L1T2", \ -+ @"L1T3", \ -+ nil] -+ -+#define H264_SCALABILITY_MODES [NSArray arrayWithObjects: \ -+ @"L1T1", \ -+ @"L1T2", \ -+ @"L1T3", \ -+ nil] -diff --git a/src/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m b/src/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m -index 6e3baa8750..34f41df595 100644 ---- a/src/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m -+++ b/src/sdk/objc/components/video_codec/RTCDefaultVideoDecoderFactory.m -@@ -16,6 +16,7 @@ - #import "api/video_codec/RTCVideoDecoderVP8.h" - #import "api/video_codec/RTCVideoDecoderVP9.h" - #import "base/RTCVideoCodecInfo.h" -+#import "MediaCodecUtils.h" - - #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) - #import "api/video_codec/RTCVideoDecoderAV1.h" // nogncheck -@@ -31,7 +32,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name -- parameters:constrainedHighParams]; -+ parameters:constrainedHighParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - - NSDictionary *constrainedBaselineParams = @{ - @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, -@@ -40,7 +42,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name -- parameters:constrainedBaselineParams]; -+ parameters:constrainedBaselineParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - - RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name]; -diff --git a/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h b/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h -index 92ab40c95b..e0344d0f97 100644 ---- a/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h -+++ b/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.h -@@ -12,6 +12,7 @@ - - #import "RTCMacros.h" - #import "RTCVideoEncoderFactory.h" -+#import "api/video_codec/RTCWrappedNativeVideoEncoderFactory.h" - - NS_ASSUME_NONNULL_BEGIN - -@@ -23,8 +24,9 @@ RTC_OBJC_EXPORT - @interface RTC_OBJC_TYPE (RTCDefaultVideoEncoderFactory) : NSObject - - @property(nonatomic, retain) RTC_OBJC_TYPE(RTCVideoCodecInfo) *preferredCodec; -+@property(nonatomic, strong) RTC_OBJC_TYPE(RTCWrapperNativeVideoEncoderFactory) *factory; - --+ (NSArray *)supportedCodecs; -+- (NSArray *)supportedCodecs; - - @end - -diff --git a/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m b/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m -index 8de55bde4a..0cd6379f73 100644 ---- a/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m -+++ b/src/sdk/objc/components/video_codec/RTCDefaultVideoEncoderFactory.m -@@ -10,93 +10,31 @@ - - #import "RTCDefaultVideoEncoderFactory.h" - --#import "RTCH264ProfileLevelId.h" --#import "RTCVideoEncoderH264.h" --#import "api/video_codec/RTCVideoCodecConstants.h" --#import "api/video_codec/RTCVideoEncoderVP8.h" --#import "api/video_codec/RTCVideoEncoderVP9.h" --#import "base/RTCVideoCodecInfo.h" -- --#if defined(RTC_USE_LIBAOM_AV1_ENCODER) --#import "api/video_codec/RTCVideoEncoderAV1.h" // nogncheck --#endif -- - @implementation RTC_OBJC_TYPE (RTCDefaultVideoEncoderFactory) - - @synthesize preferredCodec; -+@synthesize factory = _factory; - --+ (NSArray *)supportedCodecs { -- NSDictionary *constrainedHighParams = @{ -- @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedHigh, -- @"level-asymmetry-allowed" : @"1", -- @"packetization-mode" : @"1", -- }; -- RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = -- [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name -- parameters:constrainedHighParams]; -- -- NSDictionary *constrainedBaselineParams = @{ -- @"profile-level-id" : kRTCMaxSupportedH264ProfileLevelConstrainedBaseline, -- @"level-asymmetry-allowed" : @"1", -- @"packetization-mode" : @"1", -- }; -- RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = -- [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecH264Name -- parameters:constrainedBaselineParams]; -- -- RTC_OBJC_TYPE(RTCVideoCodecInfo) *vp8Info = -- [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp8Name]; -- -- NSMutableArray *result = [@[ -- constrainedHighInfo, -- constrainedBaselineInfo, -- vp8Info, -- ] mutableCopy]; -- -- if ([RTC_OBJC_TYPE(RTCVideoEncoderVP9) isSupported]) { -- [result -- addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecVp9Name]]; -+- (instancetype)init { -+ if (self = [super init]) { -+ _factory = [[RTC_OBJC_TYPE(RTCWrapperNativeVideoEncoderFactory) alloc] -+ initWithTemplateFactory]; - } -+ return self; -+} - --#if defined(RTC_USE_LIBAOM_AV1_ENCODER) -- [result addObject:[[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:kRTCVideoCodecAv1Name]]; --#endif -- -- return result; -+- (NSArray *)supportedCodecs { -+ return [_factory supportedCodecs]; - } - - - (id)createEncoder:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { -- if ([info.name isEqualToString:kRTCVideoCodecH264Name]) { -- return [[RTC_OBJC_TYPE(RTCVideoEncoderH264) alloc] initWithCodecInfo:info]; -- } else if ([info.name isEqualToString:kRTCVideoCodecVp8Name]) { -- return [RTC_OBJC_TYPE(RTCVideoEncoderVP8) vp8Encoder]; -- } else if ([info.name isEqualToString:kRTCVideoCodecVp9Name] && -- [RTC_OBJC_TYPE(RTCVideoEncoderVP9) isSupported]) { -- return [RTC_OBJC_TYPE(RTCVideoEncoderVP9) vp9Encoder]; -- } -- --#if defined(RTC_USE_LIBAOM_AV1_ENCODER) -- if ([info.name isEqualToString:kRTCVideoCodecAv1Name]) { -- return [RTC_OBJC_TYPE(RTCVideoEncoderAV1) av1Encoder]; -- } --#endif -- -- return nil; -+ return [_factory createEncoder:info]; - } - --- (NSArray *)supportedCodecs { -- NSMutableArray *codecs = -- [[[self class] supportedCodecs] mutableCopy]; -- -- NSMutableArray *orderedCodecs = [NSMutableArray array]; -- NSUInteger index = [codecs indexOfObject:self.preferredCodec]; -- if (index != NSNotFound) { -- [orderedCodecs addObject:[codecs objectAtIndex:index]]; -- [codecs removeObjectAtIndex:index]; -- } -- [orderedCodecs addObjectsFromArray:codecs]; -- -- return [orderedCodecs copy]; -+- (RTC_OBJC_TYPE(RTCCodecSupport*)) -+ queryCodecSupport:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info -+ :(NSString*)scalabilityMode { -+ return [_factory queryCodecSupport:info:scalabilityMode]; - } - - @end -diff --git a/src/sdk/objc/components/video_codec/RTCVideoDecoderFactoryH264.m b/src/sdk/objc/components/video_codec/RTCVideoDecoderFactoryH264.m -index bdae19d687..f38e9624cf 100644 ---- a/src/sdk/objc/components/video_codec/RTCVideoDecoderFactoryH264.m -+++ b/src/sdk/objc/components/video_codec/RTCVideoDecoderFactoryH264.m -@@ -12,6 +12,7 @@ - - #import "RTCH264ProfileLevelId.h" - #import "RTCVideoDecoderH264.h" -+#import "MediaCodecUtils.h" - - @implementation RTC_OBJC_TYPE (RTCVideoDecoderFactoryH264) - -@@ -26,7 +27,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:codecName -- parameters:constrainedHighParams]; -+ parameters:constrainedHighParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - [codecs addObject:constrainedHighInfo]; - - NSDictionary *constrainedBaselineParams = @{ -@@ -36,7 +38,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:codecName -- parameters:constrainedBaselineParams]; -+ parameters:constrainedBaselineParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - [codecs addObject:constrainedBaselineInfo]; - - return [codecs copy]; -diff --git a/src/sdk/objc/components/video_codec/RTCVideoEncoderFactoryH264.m b/src/sdk/objc/components/video_codec/RTCVideoEncoderFactoryH264.m -index 9843849307..33229d4598 100644 ---- a/src/sdk/objc/components/video_codec/RTCVideoEncoderFactoryH264.m -+++ b/src/sdk/objc/components/video_codec/RTCVideoEncoderFactoryH264.m -@@ -12,6 +12,7 @@ - - #import "RTCH264ProfileLevelId.h" - #import "RTCVideoEncoderH264.h" -+#import "MediaCodecUtils.h" - - @implementation RTC_OBJC_TYPE (RTCVideoEncoderFactoryH264) - -@@ -26,7 +27,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedHighInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:codecName -- parameters:constrainedHighParams]; -+ parameters:constrainedHighParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - [codecs addObject:constrainedHighInfo]; - - NSDictionary *constrainedBaselineParams = @{ -@@ -36,7 +38,8 @@ - }; - RTC_OBJC_TYPE(RTCVideoCodecInfo) *constrainedBaselineInfo = - [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:codecName -- parameters:constrainedBaselineParams]; -+ parameters:constrainedBaselineParams -+ scalabiltyModes: H264_SCALABILITY_MODES]; - [codecs addObject:constrainedBaselineInfo]; - - return [codecs copy]; -@@ -46,4 +49,15 @@ - return [[RTC_OBJC_TYPE(RTCVideoEncoderH264) alloc] initWithCodecInfo:info]; - } - -+- (RTC_OBJC_TYPE(RTCCodecSupport*)) -+ queryCodecSupport:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info -+ :(NSString*)scalabilityMode { -+ RTC_OBJC_TYPE(RTCCodecSupport)* codecSupport = -+ [[RTC_OBJC_TYPE(RTCCodecSupport) alloc] init]; -+ codecSupport.isSupported = -+ [H264_SCALABILITY_MODES containsObject:scalabilityMode]; -+ codecSupport.isPowerEfficient = true; -+ return codecSupport; -+} -+ - @end -diff --git a/src/sdk/objc/native/src/objc_video_encoder_factory.h b/src/sdk/objc/native/src/objc_video_encoder_factory.h -index d74e4933d2..f16d617537 100644 ---- a/src/sdk/objc/native/src/objc_video_encoder_factory.h -+++ b/src/sdk/objc/native/src/objc_video_encoder_factory.h -@@ -35,6 +35,9 @@ class ObjCVideoEncoderFactory : public VideoEncoderFactory { - std::unique_ptr Create(const Environment& env, - const SdpVideoFormat& format) override; - std::unique_ptr GetEncoderSelector() const override; -+ VideoEncoderFactory::CodecSupport QueryCodecSupport( -+ const SdpVideoFormat& format, -+ absl::optional scalability_mode) const override; - - private: - id encoder_factory_; -diff --git a/src/sdk/objc/native/src/objc_video_encoder_factory.mm b/src/sdk/objc/native/src/objc_video_encoder_factory.mm -index 1085cb8cb4..44948b70f3 100644 ---- a/src/sdk/objc/native/src/objc_video_encoder_factory.mm -+++ b/src/sdk/objc/native/src/objc_video_encoder_factory.mm -@@ -207,4 +207,23 @@ std::unique_ptr - return nullptr; - } - -+VideoEncoderFactory::CodecSupport ObjCVideoEncoderFactory::QueryCodecSupport( -+ const SdpVideoFormat& format, -+ absl::optional scalability_mode) const { -+ RTC_OBJC_TYPE(RTCVideoCodecInfo)* info = [[RTC_OBJC_TYPE(RTCVideoCodecInfo) -+ alloc] initWithNativeSdpVideoFormat:format]; -+ NSString* scalabilityMode = nil; -+ -+ if (scalability_mode.has_value()) { -+ scalabilityMode = -+ [NSString stringWithUTF8String:scalability_mode.value().c_str()]; -+ } -+ -+ RTC_OBJC_TYPE(RTCCodecSupport*) -+ support = [encoder_factory_ queryCodecSupport:info:scalabilityMode]; -+ -+ return VideoEncoderFactory::CodecSupport{[support isSupported], -+ [support isPowerEfficient]}; -+} -+ - } // namespace webrtc -diff --git a/src/sdk/objc/unittests/objc_video_encoder_factory_tests.mm b/src/sdk/objc/unittests/objc_video_encoder_factory_tests.mm -index a04e797672..60eee24095 100644 ---- a/src/sdk/objc/unittests/objc_video_encoder_factory_tests.mm -+++ b/src/sdk/objc/unittests/objc_video_encoder_factory_tests.mm -@@ -37,7 +37,9 @@ id CreateEncoderFactoryReturning(int retu - - id encoderFactoryMock = OCMProtocolMock(@protocol(RTC_OBJC_TYPE(RTCVideoEncoderFactory))); - RTC_OBJC_TYPE(RTCVideoCodecInfo)* supported = -- [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:@"H264" parameters:nil]; -+ [[RTC_OBJC_TYPE(RTCVideoCodecInfo) alloc] initWithName:@"H264" -+ parameters:nil -+ scalabiltyModes:nil]; - OCMStub([encoderFactoryMock supportedCodecs]).andReturn(@[ supported ]); - OCMStub([encoderFactoryMock implementations]).andReturn(@[ supported ]); - OCMStub([encoderFactoryMock createEncoder:[OCMArg any]]).andReturn(encoderMock);