From 2cc5c2e6bbc26a41f03ca83e8a561580fd3459b7 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 6 Jan 2023 17:30:45 +0900 Subject: [PATCH 01/21] expose scalabilityMode --- sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h | 4 ++++ sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h index 07f6b7a39c..af0c6993bc 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.h @@ -69,6 +69,10 @@ RTC_OBJC_EXPORT https://w3c.github.io/webrtc-extensions/#dom-rtcrtpencodingparameters-adaptiveptime */ @property(nonatomic, assign) BOOL adaptiveAudioPacketTime; +/** 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; + - (instancetype)init; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm index d6087dafb0..aecb88b6f6 100644 --- a/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpEncodingParameters.mm @@ -25,6 +25,7 @@ @implementation RTC_OBJC_TYPE (RTCRtpEncodingParameters) @synthesize bitratePriority = _bitratePriority; @synthesize networkPriority = _networkPriority; @synthesize adaptiveAudioPacketTime = _adaptiveAudioPacketTime; +@synthesize scalabilityMode = _scalabilityMode; - (instancetype)init { webrtc::RtpEncodingParameters nativeParameters; @@ -59,6 +60,9 @@ - (instancetype)initWithNativeParameters: if (nativeParameters.ssrc) { _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; } + if (nativeParameters.scalability_mode) { + _scalabilityMode = [NSString stringWithUTF8String:nativeParameters.scalability_mode->c_str()]; + } _bitratePriority = nativeParameters.bitrate_priority; _networkPriority = [RTC_OBJC_TYPE(RTCRtpEncodingParameters) priorityFromNativePriority:nativeParameters.network_priority]; @@ -92,6 +96,9 @@ - (instancetype)initWithNativeParameters: if (_ssrc != nil) { parameters.ssrc = absl::optional(_ssrc.unsignedLongValue); } + if (_scalabilityMode != nil) { + parameters.scalability_mode = absl::optional(std::string([_scalabilityMode UTF8String])); + } parameters.bitrate_priority = _bitratePriority; parameters.network_priority = [RTC_OBJC_TYPE(RTCRtpEncodingParameters) nativePriorityFromPriority:_networkPriority]; From 6dcf8a9a8fdbb2e617900ad9aa7907751462e3eb Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 6 Jan 2023 20:23:50 +0900 Subject: [PATCH 02/21] expose AV1 codec name --- sdk/objc/api/peerconnection/RTCRtpCodecParameters.h | 1 + sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm | 1 + 2 files changed, 2 insertions(+) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.h b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.h index 6135223720..4d24d3ccd6 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.h @@ -30,6 +30,7 @@ RTC_EXTERN const NSString *const kRTCComfortNoiseCodecName; RTC_EXTERN const NSString *const kRTCVp8CodecName; RTC_EXTERN const NSString *const kRTCVp9CodecName; RTC_EXTERN const NSString *const kRTCH264CodecName; +RTC_EXTERN const NSString *const kRTCAv1CodecName; /** Defined in https://www.w3.org/TR/webrtc/#idl-def-rtcrtpcodecparameters */ RTC_OBJC_EXPORT diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm index 753667b635..2b3b7c4110 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecParameters.mm @@ -33,6 +33,7 @@ const NSString * const kRTCVp8CodecName = @(cricket::kVp8CodecName); const NSString * const kRTCVp9CodecName = @(cricket::kVp9CodecName); const NSString * const kRTCH264CodecName = @(cricket::kH264CodecName); +const NSString * const kRTCAv1CodecName = @(cricket::kAv1CodecName); @implementation RTC_OBJC_TYPE (RTCRtpCodecParameters) From a2acca91e55316947468edb49b21c7fb4b7cc706 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 6 Jan 2023 20:24:47 +0900 Subject: [PATCH 03/21] sender / receiver capabilities --- sdk/BUILD.gn | 5 ++ .../peerconnection/RTCPeerConnectionFactory.h | 7 +++ .../RTCPeerConnectionFactory.mm | 31 ++++++++++++ .../RTCRtpCodecCapability+Private.h | 27 ++++++++++ .../peerconnection/RTCRtpCodecCapability.h | 26 ++++++++++ .../peerconnection/RTCRtpCodecCapability.mm | 49 +++++++++++++++++++ 6 files changed, 145 insertions(+) create mode 100644 sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h create mode 100644 sdk/objc/api/peerconnection/RTCRtpCodecCapability.h create mode 100644 sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index ef8fcae1da..ef8779fa9a 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -1059,6 +1059,9 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCRtcpParameters+Private.h", "objc/api/peerconnection/RTCRtcpParameters.h", "objc/api/peerconnection/RTCRtcpParameters.mm", + "objc/api/peerconnection/RTCRtpCodecCapability.h", + "objc/api/peerconnection/RTCRtpCodecCapability.mm", + "objc/api/peerconnection/RTCRtpCodecCapability+Private.h", "objc/api/peerconnection/RTCRtpCodecParameters+Private.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpCodecParameters.mm", @@ -1382,6 +1385,7 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCPeerConnectionFactory.h", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h", "objc/api/peerconnection/RTCRtcpParameters.h", + "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpEncodingParameters.h", "objc/api/peerconnection/RTCRtpHeaderExtension.h", @@ -1503,6 +1507,7 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCPeerConnectionFactory.h", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h", "objc/api/peerconnection/RTCRtcpParameters.h", + "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpEncodingParameters.h", "objc/api/peerconnection/RTCRtpHeaderExtension.h", diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 2d750b95b0..380cf26018 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN @class RTC_OBJC_TYPE(RTCVideoTrack); @class RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions); @class RTC_OBJC_TYPE(RTCAudioDeviceModule); +@class RTC_OBJC_TYPE(RTCRtpCodecCapability); + +typedef NS_ENUM(NSInteger, RTCRtpMediaType); @protocol RTC_OBJC_TYPE (RTCPeerConnectionDelegate); @@ -54,6 +57,10 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) RTCAudioDeviceModule *audioDeviceModule; +- (NSArray *)rtpSenderCapabilities:(RTCRtpMediaType)mediaType; + +- (NSArray *)rtpReceiverCapabilities:(RTCRtpMediaType)mediaType; + /** Initialize an RTCAudioSource with constraints. */ - (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: (nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 89d71cd55b..79993309e3 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -24,6 +24,9 @@ #import "RTCPeerConnection+Private.h" #import "RTCVideoSource+Private.h" #import "RTCVideoTrack+Private.h" +#import "RTCRtpReceiver+Private.h" +#import "RTCRtpCodecCapability.h" +#import "RTCRtpCodecCapability+Private.h" #import "base/RTCLogging.h" #import "base/RTCVideoDecoderFactory.h" #import "base/RTCVideoEncoderFactory.h" @@ -113,6 +116,34 @@ - (instancetype)init { #endif } +- (NSArray *)rtpSenderCapabilities:(RTCRtpMediaType)mediaType { + + NSMutableArray *result = [NSMutableArray array]; + + webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpSenderCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); + + for (auto & element : capabilities.codecs) { + RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; + [result addObject: object]; + } + + return result; +} + +- (NSArray *)rtpReceiverCapabilities:(RTCRtpMediaType)mediaType { + + NSMutableArray *result = [NSMutableArray array]; + + webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpReceiverCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); + + for (auto & element : capabilities.codecs) { + RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; + [result addObject: object]; + } + + return result; +} + - (instancetype) initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing encoderFactory:(nullable id)encoderFactory diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h new file mode 100644 index 0000000000..13f99c7057 --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h @@ -0,0 +1,27 @@ +/* + * Copyright 2016 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 "RTCRtpCodecCapability.h" + +#include "api/rtp_parameters.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTC_OBJC_TYPE (RTCRtpCodecCapability) +() + +@property(nonatomic, readonly) webrtc::RtpCodecCapability nativeCodecCapability; + +- (instancetype)initWithNativeCodecCapability:(const webrtc::RtpCodecCapability &)nativeCodecCapability + NS_DESIGNATED_INITIALIZER; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h new file mode 100644 index 0000000000..639f228fc9 --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -0,0 +1,26 @@ +/* + * Copyright 2016 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 (RTCRtpCodecCapability) : NSObject + +@property(nonatomic, readonly) NSString *mimeType; + +@property(nonatomic, copy) NSString *name; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm new file mode 100644 index 0000000000..9956a7b56f --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -0,0 +1,49 @@ +/* + * Copyright 2016 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 "RTCRtpCodecCapability+Private.h" + +#import "RTCMediaStreamTrack.h" +#import "helpers/NSString+StdString.h" + +#include "media/base/media_constants.h" +#include "rtc_base/checks.h" + +@implementation RTC_OBJC_TYPE (RTCRtpCodecCapability) + +@synthesize nativeCodecCapability = _nativeCodecCapability; + +- (instancetype)init { + webrtc::RtpCodecCapability nativeCodecCapability; + return [self initWithNativeCodecCapability:nativeCodecCapability]; +} + +- (instancetype)initWithNativeCodecCapability:(const webrtc::RtpCodecCapability &)nativeCodecCapability { + + if (self = [super init]) { + _nativeCodecCapability = nativeCodecCapability; + } + + return self; +} + +- (NSString *)mimeType { + return [NSString stringWithUTF8String:_nativeCodecCapability.mime_type().c_str()]; +} + +- (NSString *)name { + return [NSString stringWithUTF8String:_nativeCodecCapability.name.c_str()]; +} + +- (void)setName:(NSString *)name { + _nativeCodecCapability.name = std::string([name UTF8String]); +} + +@end From 8c253196c70a720e26c9119d2e27bbc72082209f Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 6 Jan 2023 20:25:20 +0900 Subject: [PATCH 04/21] setCodecPreferences --- .../api/peerconnection/RTCRtpTransceiver.h | 5 +++ .../api/peerconnection/RTCRtpTransceiver.mm | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h index fd59013639..b148a06753 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h @@ -14,6 +14,8 @@ #import "RTCRtpReceiver.h" #import "RTCRtpSender.h" +@class RTC_OBJC_TYPE(RTCRtpCodecCapability); + NS_ASSUME_NONNULL_BEGIN extern NSString *const kRTCRtpTransceiverErrorDomain; @@ -104,6 +106,9 @@ RTC_OBJC_EXPORT */ @property(nonatomic, readonly) RTCRtpTransceiverDirection direction; +// NSArray * +@property(nonatomic, copy) NSArray *codecPreferences; + /** The currentDirection attribute indicates the current direction negotiated * for this transceiver. If this transceiver has never been represented in an * offer/answer exchange, or if the transceiver is stopped, the value is not diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index ae1cf79864..58d34ca922 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -14,6 +14,8 @@ #import "RTCRtpParameters+Private.h" #import "RTCRtpReceiver+Private.h" #import "RTCRtpSender+Private.h" +#import "RTCRtpCodecCapability.h" +#import "RTCRtpCodecCapability+Private.h" #import "base/RTCLogging.h" #import "helpers/NSString+StdString.h" @@ -65,6 +67,35 @@ - (NSString *)mid { } } +- (void)setCodecPreferences:(NSArray *)codecPreferences { + + std::vector objects; + + for (RTCRtpCodecCapability *object in codecPreferences) { + objects.push_back(object.nativeCodecCapability); + } + + webrtc::RTCError e = _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); + + if (!e.ok()) { + [NSException raise:@"WebRTC error" format:[NSString stringWithUTF8String: e.message()]]; + } +} + +- (NSArray *)codecPreferences { + + NSMutableArray *result = [NSMutableArray array]; + + std::vector capabilities = _nativeRtpTransceiver->codec_preferences(); + + for (auto & element : capabilities) { + RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; + [result addObject: object]; + } + + return result; +} + @synthesize sender = _sender; @synthesize receiver = _receiver; From 665e41a03960e8558c46371c9e243bf7e6f74963 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 00:49:17 +0900 Subject: [PATCH 05/21] ref --- sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h | 4 ++-- sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 380cf26018..160c671d47 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -57,9 +57,9 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) RTCAudioDeviceModule *audioDeviceModule; -- (NSArray *)rtpSenderCapabilities:(RTCRtpMediaType)mediaType; +- (NSArray *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType; -- (NSArray *)rtpReceiverCapabilities:(RTCRtpMediaType)mediaType; +- (NSArray *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType; /** Initialize an RTCAudioSource with constraints. */ - (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 79993309e3..2a0db8b40a 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -116,7 +116,7 @@ - (instancetype)init { #endif } -- (NSArray *)rtpSenderCapabilities:(RTCRtpMediaType)mediaType { +- (NSArray *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType { NSMutableArray *result = [NSMutableArray array]; @@ -130,7 +130,7 @@ - (instancetype)init { return result; } -- (NSArray *)rtpReceiverCapabilities:(RTCRtpMediaType)mediaType { +- (NSArray *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType { NSMutableArray *result = [NSMutableArray array]; From 64eb95baef53ea4df64d9e3e016afd2388d9ef9f Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:41:01 +0900 Subject: [PATCH 06/21] RTCRtpCapabilities --- sdk/BUILD.gn | 5 +++ .../peerconnection/RTCPeerConnectionFactory.h | 6 +-- .../RTCPeerConnectionFactory.mm | 35 ++++++++------- .../RTCRtpCapabilities+Private.h | 27 +++++++++++ .../api/peerconnection/RTCRtpCapabilities.h | 34 ++++++++++++++ .../api/peerconnection/RTCRtpCapabilities.mm | 45 +++++++++++++++++++ .../peerconnection/RTCRtpCodecCapability.mm | 3 +- 7 files changed, 135 insertions(+), 20 deletions(-) create mode 100644 sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h create mode 100644 sdk/objc/api/peerconnection/RTCRtpCapabilities.h create mode 100644 sdk/objc/api/peerconnection/RTCRtpCapabilities.mm diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index ef8779fa9a..b138140d5c 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -1059,6 +1059,9 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCRtcpParameters+Private.h", "objc/api/peerconnection/RTCRtcpParameters.h", "objc/api/peerconnection/RTCRtcpParameters.mm", + "objc/api/peerconnection/RTCRtpCapabilities.h", + "objc/api/peerconnection/RTCRtpCapabilities.mm", + "objc/api/peerconnection/RTCRtpCapabilities+Private.h", "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecCapability.mm", "objc/api/peerconnection/RTCRtpCodecCapability+Private.h", @@ -1385,6 +1388,7 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCPeerConnectionFactory.h", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h", "objc/api/peerconnection/RTCRtcpParameters.h", + "objc/api/peerconnection/RTCRtpCapabilities.h", "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpEncodingParameters.h", @@ -1507,6 +1511,7 @@ if (is_ios || is_mac) { "objc/api/peerconnection/RTCPeerConnectionFactory.h", "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h", "objc/api/peerconnection/RTCRtcpParameters.h", + "objc/api/peerconnection/RTCRtpCapabilities.h", "objc/api/peerconnection/RTCRtpCodecCapability.h", "objc/api/peerconnection/RTCRtpCodecParameters.h", "objc/api/peerconnection/RTCRtpEncodingParameters.h", diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 160c671d47..d5b0447a94 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN @class RTC_OBJC_TYPE(RTCVideoTrack); @class RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions); @class RTC_OBJC_TYPE(RTCAudioDeviceModule); -@class RTC_OBJC_TYPE(RTCRtpCodecCapability); +@class RTC_OBJC_TYPE(RTCRtpCapabilities); typedef NS_ENUM(NSInteger, RTCRtpMediaType); @@ -57,9 +57,9 @@ RTC_OBJC_EXPORT @property(nonatomic, readonly) RTCAudioDeviceModule *audioDeviceModule; -- (NSArray *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType; +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType; -- (NSArray *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType; +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType; /** Initialize an RTCAudioSource with constraints. */ - (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints: diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 2a0db8b40a..1fb9773109 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -25,7 +25,7 @@ #import "RTCVideoSource+Private.h" #import "RTCVideoTrack+Private.h" #import "RTCRtpReceiver+Private.h" -#import "RTCRtpCodecCapability.h" +#import "RTCRtpCapabilities+Private.h" #import "RTCRtpCodecCapability+Private.h" #import "base/RTCLogging.h" #import "base/RTCVideoDecoderFactory.h" @@ -116,32 +116,37 @@ - (instancetype)init { #endif } -- (NSArray *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType { +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType { - NSMutableArray *result = [NSMutableArray array]; + // NSMutableArray *result = [NSMutableArray array]; webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpSenderCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); - for (auto & element : capabilities.codecs) { - RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; - [result addObject: object]; - } + return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities]; + + // for (auto & element : capabilities) { + // RTCRtpCapabilities *object = [[RTCRtpCapabilities alloc] initWithNativeCapabilities: element]; + // [result addObject: object]; + // } - return result; + // return result; } -- (NSArray *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType { +- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType { - NSMutableArray *result = [NSMutableArray array]; + // NSArray + // NSMutableArray *result = [NSMutableArray array]; webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpReceiverCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); - for (auto & element : capabilities.codecs) { - RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; - [result addObject: object]; - } + return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities]; + + // for (auto & element : capabilities) { + // RTCRtpCapabilities *object = [[RTCRtpCapabilities alloc] initWithNativeCapabilities: element]; + // [result addObject: object]; + // } - return result; + // return result; } - (instancetype) diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h new file mode 100644 index 0000000000..6c99646d3e --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h @@ -0,0 +1,27 @@ +/* + * Copyright 2016 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 "RTCRtpCapabilities.h" + +#include "api/rtp_parameters.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTC_OBJC_TYPE (RTCRtpCapabilities) +() + +@property(nonatomic, readonly) webrtc::RtpCapabilities nativeCapabilities; + +- (instancetype)initWithNativeCapabilities:(const webrtc::RtpCapabilities &)nativeCapabilities + NS_DESIGNATED_INITIALIZER; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h new file mode 100644 index 0000000000..f6947ebffc --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h @@ -0,0 +1,34 @@ +/* + * Copyright 2016 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" + +@class RTC_OBJC_TYPE(RTCRtpCodecCapability); + +NS_ASSUME_NONNULL_BEGIN + +RTC_OBJC_EXPORT +@interface RTC_OBJC_TYPE (RTCRtpCapabilities) : NSObject + +- (instancetype)init NS_UNAVAILABLE; + +@property(nonatomic, readonly) NSArray *codecs; + +// Not implemented. +// std::vector header_extensions; + +//Not implemented. +// std::vector fec; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm new file mode 100644 index 0000000000..d96ef2c67f --- /dev/null +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm @@ -0,0 +1,45 @@ +/* + * Copyright 2016 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 "RTCRtpCapabilities+Private.h" +#import "RTCRtpCodecCapability+Private.h" + +#import "RTCMediaStreamTrack.h" +#import "helpers/NSString+StdString.h" + +#include "media/base/media_constants.h" +#include "rtc_base/checks.h" + +@implementation RTC_OBJC_TYPE (RTCRtpCapabilities) + +@synthesize nativeCapabilities = _nativeCapabilities; + +- (instancetype)initWithNativeCapabilities:(const webrtc::RtpCapabilities &)nativeCapabilities { + + if (self = [super init]) { + _nativeCapabilities = nativeCapabilities; + } + + return self; +} + +- (NSArray *)codecs { + + NSMutableArray *result = [NSMutableArray array]; + + for (auto & element : _nativeCapabilities.codecs) { + RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; + [result addObject: object]; + } + + return result; +} + +@end diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 9956a7b56f..49b9d8c5a6 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -21,8 +21,7 @@ @implementation RTC_OBJC_TYPE (RTCRtpCodecCapability) @synthesize nativeCodecCapability = _nativeCodecCapability; - (instancetype)init { - webrtc::RtpCodecCapability nativeCodecCapability; - return [self initWithNativeCodecCapability:nativeCodecCapability]; + return [self initWithNativeCodecCapability:webrtc::RtpCodecCapability()]; } - (instancetype)initWithNativeCodecCapability:(const webrtc::RtpCodecCapability &)nativeCodecCapability { From 67ec6ec3e96265239195c2bea5abea51b6253d6a Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:04:54 +0900 Subject: [PATCH 07/21] kind --- .../peerconnection/RTCRtpCodecCapability.h | 29 +++++++++++++++++++ .../peerconnection/RTCRtpCodecCapability.mm | 10 +++++++ 2 files changed, 39 insertions(+) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index 639f228fc9..18c075c11f 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -12,15 +12,44 @@ #import "RTCMacros.h" +typedef NS_ENUM(NSInteger, RTCRtpMediaType); + NS_ASSUME_NONNULL_BEGIN RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE (RTCRtpCodecCapability) : NSObject +// Build MIME "type/subtype" string from `name` and `kind`. @property(nonatomic, readonly) NSString *mimeType; +// Used to identify the codec. Equivalent to MIME subtype. @property(nonatomic, copy) NSString *name; +// The media type of this codec. Equivalent to MIME top-level type. +@property(nonatomic, assign) RTCRtpMediaType kind; + +// Clock rate in Hertz. If unset, the codec is applicable to any clock rate. +// absl::optional clock_rate; + +// Default payload type for this codec. Mainly needed for codecs that use +// that have statically assigned payload types. +// absl::optional preferred_payload_type; + +// The number of audio channels supported. Unused for video codecs. +// absl::optional num_channels; + +// Feedback mechanisms supported for this codec. +// std::vector rtcp_feedback; + +// Codec-specific parameters that must be signaled to the remote party. +// +// Corresponds to "a=fmtp" parameters in SDP. +// +// Contrary to ORTC, these parameters are named using all lowercase strings. +// This helps make the mapping to SDP simpler, if an application is using SDP. +// Boolean values are represented by the string "1". +// std::map parameters; + @end NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 49b9d8c5a6..25abdb5adb 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -10,6 +10,8 @@ #import "RTCRtpCodecCapability+Private.h" +#import "RTCRtpReceiver+Private.h" + #import "RTCMediaStreamTrack.h" #import "helpers/NSString+StdString.h" @@ -45,4 +47,12 @@ - (void)setName:(NSString *)name { _nativeCodecCapability.name = std::string([name UTF8String]); } +- (RTCRtpMediaType)kind { + return [RTCRtpReceiver mediaTypeForNativeMediaType:_nativeCodecCapability.kind]; +} + +- (void)setKind:(RTCRtpMediaType)kind { + _nativeCodecCapability.kind = [RTCRtpReceiver nativeMediaTypeForMediaType:kind]; +} + @end From d7db7936b4ac108a6297e11d8ae9b0fcf3011953 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:05:11 +0900 Subject: [PATCH 08/21] fix compile warnings --- sdk/objc/api/peerconnection/RTCRtpTransceiver.h | 1 - sdk/objc/api/peerconnection/RTCRtpTransceiver.mm | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h index b148a06753..3ffea8efd7 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.h +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.h @@ -106,7 +106,6 @@ RTC_OBJC_EXPORT */ @property(nonatomic, readonly) RTCRtpTransceiverDirection direction; -// NSArray * @property(nonatomic, copy) NSArray *codecPreferences; /** The currentDirection attribute indicates the current direction negotiated diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index 58d34ca922..2c1a216f1c 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -75,10 +75,10 @@ - (void)setCodecPreferences:(NSArray *)c objects.push_back(object.nativeCodecCapability); } - webrtc::RTCError e = _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); + webrtc::RTCError error = _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); - if (!e.ok()) { - [NSException raise:@"WebRTC error" format:[NSString stringWithUTF8String: e.message()]]; + if (!error.ok()) { + [NSException raise:@"setCodecPreferences" format:@"SDK returned error: %@", [NSString stringWithUTF8String: error.message()]]; } } From 3f6a7797f2e24171f91365f3c640718e838b4903 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:07:58 +0900 Subject: [PATCH 09/21] clean up --- .../RTCPeerConnectionFactory.mm | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 1fb9773109..84c6a878c7 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -118,35 +118,16 @@ - (instancetype)init { - (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType { - // NSMutableArray *result = [NSMutableArray array]; - webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpSenderCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities]; - - // for (auto & element : capabilities) { - // RTCRtpCapabilities *object = [[RTCRtpCapabilities alloc] initWithNativeCapabilities: element]; - // [result addObject: object]; - // } - - // return result; } - (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType { - // NSArray - // NSMutableArray *result = [NSMutableArray array]; - webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpReceiverCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]); return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities]; - - // for (auto & element : capabilities) { - // RTCRtpCapabilities *object = [[RTCRtpCapabilities alloc] initWithNativeCapabilities: element]; - // [result addObject: object]; - // } - - // return result; } - (instancetype) From 419ec803376bf9d06198225dfffb0eda73b487bd Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Sat, 7 Jan 2023 03:22:48 +0900 Subject: [PATCH 10/21] lk header --- .../RTCRtpCapabilities+Private.h | 18 ++++++++++++------ .../api/peerconnection/RTCRtpCapabilities.h | 18 ++++++++++++------ .../api/peerconnection/RTCRtpCapabilities.mm | 18 ++++++++++++------ .../RTCRtpCodecCapability+Private.h | 18 ++++++++++++------ .../api/peerconnection/RTCRtpCodecCapability.h | 18 ++++++++++++------ .../peerconnection/RTCRtpCodecCapability.mm | 18 ++++++++++++------ 6 files changed, 72 insertions(+), 36 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h index 6c99646d3e..f9681d3aee 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import "RTCRtpCapabilities.h" diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h index f6947ebffc..63955f5179 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.h +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm index d96ef2c67f..ac6894e977 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import "RTCRtpCapabilities+Private.h" diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h index 13f99c7057..29d544ad7b 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import "RTCRtpCodecCapability.h" diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index 18c075c11f..498f319660 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 25abdb5adb..7267df8c76 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -1,11 +1,17 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 LiveKit * - * 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #import "RTCRtpCodecCapability+Private.h" From 7a744a7423415f8f3e0bb0071d51978cac6884e7 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 00:57:38 +0900 Subject: [PATCH 11/21] clockRate --- .../peerconnection/RTCRtpCodecCapability.h | 2 +- .../peerconnection/RTCRtpCodecCapability.mm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index 498f319660..59a1f5d0cc 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -35,7 +35,7 @@ RTC_OBJC_EXPORT @property(nonatomic, assign) RTCRtpMediaType kind; // Clock rate in Hertz. If unset, the codec is applicable to any clock rate. -// absl::optional clock_rate; +@property(nonatomic, copy, nullable) NSNumber *clockRate; // Default payload type for this codec. Mainly needed for codecs that use // that have statically assigned payload types. diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 7267df8c76..724f02a18d 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -61,4 +61,23 @@ - (void)setKind:(RTCRtpMediaType)kind { _nativeCodecCapability.kind = [RTCRtpReceiver nativeMediaTypeForMediaType:kind]; } +- (NSNumber *)clockRate { + + if (!_nativeCodecCapability.clock_rate) { + return nil; + } + + return [NSNumber numberWithInt: *_nativeCodecCapability.clock_rate]; +} + +- (void)setClockRate:(NSNumber *)clockRate { + + if (clockRate == nil) { + _nativeCodecCapability.clock_rate = absl::optional(); + return; + } + + _nativeCodecCapability.clock_rate = absl::optional(clockRate.intValue); +} + @end From c76b4b4f21e87968a8e19189d60bd4984d12ac93 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:00:30 +0900 Subject: [PATCH 12/21] preferredPayloadType --- .../peerconnection/RTCRtpCodecCapability.h | 2 +- .../peerconnection/RTCRtpCodecCapability.mm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index 59a1f5d0cc..ad814c46dc 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -39,7 +39,7 @@ RTC_OBJC_EXPORT // Default payload type for this codec. Mainly needed for codecs that use // that have statically assigned payload types. -// absl::optional preferred_payload_type; +@property(nonatomic, copy, nullable) NSNumber *preferredPayloadType; // The number of audio channels supported. Unused for video codecs. // absl::optional num_channels; diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 724f02a18d..16fe65a77c 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -80,4 +80,23 @@ - (void)setClockRate:(NSNumber *)clockRate { _nativeCodecCapability.clock_rate = absl::optional(clockRate.intValue); } +- (NSNumber *)preferredPayloadType { + + if (!_nativeCodecCapability.preferred_payload_type) { + return nil; + } + + return [NSNumber numberWithInt: *_nativeCodecCapability.preferred_payload_type]; +} + +- (void)setPreferredPayloadType:(NSNumber *)preferredPayloadType { + + if (preferredPayloadType == nil) { + _nativeCodecCapability.preferred_payload_type = absl::optional(); + return; + } + + _nativeCodecCapability.preferred_payload_type = absl::optional(preferredPayloadType.intValue); +} + @end From 3cffdf652665b8e0feb251d93bc7a40dcdbc300a Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:02:01 +0900 Subject: [PATCH 13/21] numChannels --- .../peerconnection/RTCRtpCodecCapability.h | 2 +- .../peerconnection/RTCRtpCodecCapability.mm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index ad814c46dc..af1415d40d 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -42,7 +42,7 @@ RTC_OBJC_EXPORT @property(nonatomic, copy, nullable) NSNumber *preferredPayloadType; // The number of audio channels supported. Unused for video codecs. -// absl::optional num_channels; +@property(nonatomic, copy, nullable) NSNumber *numChannels; // Feedback mechanisms supported for this codec. // std::vector rtcp_feedback; diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 16fe65a77c..32656628ae 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -99,4 +99,23 @@ - (void)setPreferredPayloadType:(NSNumber *)preferredPayloadType { _nativeCodecCapability.preferred_payload_type = absl::optional(preferredPayloadType.intValue); } +- (NSNumber *)numChannels { + + if (!_nativeCodecCapability.num_channels) { + return nil; + } + + return [NSNumber numberWithInt: *_nativeCodecCapability.num_channels]; +} + +- (void)setNumChannels:(NSNumber *)numChannels { + + if (numChannels == nil) { + _nativeCodecCapability.num_channels = absl::optional(); + return; + } + + _nativeCodecCapability.num_channels = absl::optional(numChannels.intValue); +} + @end From 82149777ee70745b605df19d546095ef49625370 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:14:57 +0900 Subject: [PATCH 14/21] parameters --- .../peerconnection/RTCRtpCodecCapability.h | 1 + .../peerconnection/RTCRtpCodecCapability.mm | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index af1415d40d..6cb513f5cd 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -55,6 +55,7 @@ RTC_OBJC_EXPORT // This helps make the mapping to SDP simpler, if an application is using SDP. // Boolean values are represented by the string "1". // std::map parameters; +@property(nonatomic, copy) NSDictionary *parameters; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm index 32656628ae..f310bf6829 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.mm @@ -32,8 +32,8 @@ - (instancetype)init { return [self initWithNativeCodecCapability:webrtc::RtpCodecCapability()]; } -- (instancetype)initWithNativeCodecCapability:(const webrtc::RtpCodecCapability &)nativeCodecCapability { - +- (instancetype)initWithNativeCodecCapability: + (const webrtc::RtpCodecCapability &)nativeCodecCapability { if (self = [super init]) { _nativeCodecCapability = nativeCodecCapability; } @@ -62,16 +62,14 @@ - (void)setKind:(RTCRtpMediaType)kind { } - (NSNumber *)clockRate { - if (!_nativeCodecCapability.clock_rate) { return nil; } - return [NSNumber numberWithInt: *_nativeCodecCapability.clock_rate]; + return [NSNumber numberWithInt:*_nativeCodecCapability.clock_rate]; } - (void)setClockRate:(NSNumber *)clockRate { - if (clockRate == nil) { _nativeCodecCapability.clock_rate = absl::optional(); return; @@ -81,35 +79,32 @@ - (void)setClockRate:(NSNumber *)clockRate { } - (NSNumber *)preferredPayloadType { - if (!_nativeCodecCapability.preferred_payload_type) { return nil; } - return [NSNumber numberWithInt: *_nativeCodecCapability.preferred_payload_type]; + return [NSNumber numberWithInt:*_nativeCodecCapability.preferred_payload_type]; } - (void)setPreferredPayloadType:(NSNumber *)preferredPayloadType { - if (preferredPayloadType == nil) { _nativeCodecCapability.preferred_payload_type = absl::optional(); return; } - _nativeCodecCapability.preferred_payload_type = absl::optional(preferredPayloadType.intValue); + _nativeCodecCapability.preferred_payload_type = + absl::optional(preferredPayloadType.intValue); } - (NSNumber *)numChannels { - if (!_nativeCodecCapability.num_channels) { return nil; } - return [NSNumber numberWithInt: *_nativeCodecCapability.num_channels]; + return [NSNumber numberWithInt:*_nativeCodecCapability.num_channels]; } - (void)setNumChannels:(NSNumber *)numChannels { - if (numChannels == nil) { _nativeCodecCapability.num_channels = absl::optional(); return; @@ -118,4 +113,26 @@ - (void)setNumChannels:(NSNumber *)numChannels { _nativeCodecCapability.num_channels = absl::optional(numChannels.intValue); } +- (NSDictionary *)parameters { + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + auto _parameters = _nativeCodecCapability.parameters; + for (auto it = _parameters.begin(); it != _parameters.end(); ++it) { + [result setObject:[NSString stringForStdString:it->second] + forKey:[NSString stringForStdString:it->first]]; + } + + return result; +} + +- (void)setParameters:(NSDictionary *)parameters { + std::map _parameters; + for (NSString *paramKey in parameters.allKeys) { + std::string key = [NSString stdStringForString:paramKey]; + std::string value = [NSString stdStringForString:parameters[paramKey]]; + _parameters[key] = value; + } + + _nativeCodecCapability.parameters = _parameters; +} + @end From 2b91875325ddb64e62073933325761dcb16fabc8 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:15:42 +0900 Subject: [PATCH 15/21] Update RTCRtpCodecCapability.h --- sdk/objc/api/peerconnection/RTCRtpCodecCapability.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h index 6cb513f5cd..01f1d7eb46 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability.h @@ -44,9 +44,6 @@ RTC_OBJC_EXPORT // The number of audio channels supported. Unused for video codecs. @property(nonatomic, copy, nullable) NSNumber *numChannels; -// Feedback mechanisms supported for this codec. -// std::vector rtcp_feedback; - // Codec-specific parameters that must be signaled to the remote party. // // Corresponds to "a=fmtp" parameters in SDP. @@ -57,6 +54,10 @@ RTC_OBJC_EXPORT // std::map parameters; @property(nonatomic, copy) NSDictionary *parameters; +// Feedback mechanisms supported for this codec. +// std::vector rtcp_feedback; +// Not implemented. + @end NS_ASSUME_NONNULL_END From 6ff1701c263efe94db9d790994dcc231b2d9ee71 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:23:22 +0900 Subject: [PATCH 16/21] format --- sdk/objc/api/peerconnection/RTCRtpCapabilities.h | 2 +- sdk/objc/api/peerconnection/RTCRtpCapabilities.mm | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h index 63955f5179..7c84732ad1 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.h +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.h @@ -32,7 +32,7 @@ RTC_OBJC_EXPORT // Not implemented. // std::vector header_extensions; -//Not implemented. +// Not implemented. // std::vector fec; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm index ac6894e977..32664e7c9f 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities.mm @@ -28,7 +28,6 @@ @implementation RTC_OBJC_TYPE (RTCRtpCapabilities) @synthesize nativeCapabilities = _nativeCapabilities; - (instancetype)initWithNativeCapabilities:(const webrtc::RtpCapabilities &)nativeCapabilities { - if (self = [super init]) { _nativeCapabilities = nativeCapabilities; } @@ -37,12 +36,12 @@ - (instancetype)initWithNativeCapabilities:(const webrtc::RtpCapabilities &)nati } - (NSArray *)codecs { - NSMutableArray *result = [NSMutableArray array]; - for (auto & element : _nativeCapabilities.codecs) { - RTCRtpCodecCapability *object = [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability: element]; - [result addObject: object]; + for (auto &element : _nativeCapabilities.codecs) { + RTCRtpCodecCapability *object = + [[RTCRtpCodecCapability alloc] initWithNativeCodecCapability:element]; + [result addObject:object]; } return result; From 64d4734172403cc0f319ce6415af66598fba418b Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:25:29 +0900 Subject: [PATCH 17/21] format --- sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h | 4 ++-- sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h index f9681d3aee..d5fff9e016 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCapabilities+Private.h @@ -23,10 +23,10 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCRtpCapabilities) () -@property(nonatomic, readonly) webrtc::RtpCapabilities nativeCapabilities; + @property(nonatomic, readonly) webrtc::RtpCapabilities nativeCapabilities; - (instancetype)initWithNativeCapabilities:(const webrtc::RtpCapabilities &)nativeCapabilities - NS_DESIGNATED_INITIALIZER; + NS_DESIGNATED_INITIALIZER; @end diff --git a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h index 29d544ad7b..43b12d6b7d 100644 --- a/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h +++ b/sdk/objc/api/peerconnection/RTCRtpCodecCapability+Private.h @@ -23,10 +23,10 @@ NS_ASSUME_NONNULL_BEGIN @interface RTC_OBJC_TYPE (RTCRtpCodecCapability) () -@property(nonatomic, readonly) webrtc::RtpCodecCapability nativeCodecCapability; + @property(nonatomic, readonly) webrtc::RtpCodecCapability nativeCodecCapability; -- (instancetype)initWithNativeCodecCapability:(const webrtc::RtpCodecCapability &)nativeCodecCapability - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNativeCodecCapability: + (const webrtc::RtpCodecCapability &)nativeCodecCapability NS_DESIGNATED_INITIALIZER; @end From 81de12ce8b8cf5a25fe6b9101c6208bea6ede054 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:12:43 +0900 Subject: [PATCH 18/21] always include kDependencyDescriptorUri --- media/engine/webrtc_video_engine.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index eb11d15169..31e333420c 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -679,18 +679,19 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { webrtc::RtpExtension::kVideoContentTypeUri, webrtc::RtpExtension::kVideoTimingUri, webrtc::RtpExtension::kColorSpaceUri, webrtc::RtpExtension::kMidUri, - webrtc::RtpExtension::kRidUri, webrtc::RtpExtension::kRepairedRidUri}) { + webrtc::RtpExtension::kRidUri, webrtc::RtpExtension::kRepairedRidUri, + webrtc::RtpExtension::kDependencyDescriptorUri}) { result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kSendRecv); } result.emplace_back(webrtc::RtpExtension::kGenericFrameDescriptorUri00, id++, IsEnabled(trials_, "WebRTC-GenericDescriptorAdvertised") ? webrtc::RtpTransceiverDirection::kSendRecv : webrtc::RtpTransceiverDirection::kStopped); - result.emplace_back( - webrtc::RtpExtension::kDependencyDescriptorUri, id++, - IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised") - ? webrtc::RtpTransceiverDirection::kSendRecv - : webrtc::RtpTransceiverDirection::kStopped); + // result.emplace_back( + // webrtc::RtpExtension::kDependencyDescriptorUri, id++, + // IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised") + // ? webrtc::RtpTransceiverDirection::kSendRecv + // : webrtc::RtpTransceiverDirection::kStopped); result.emplace_back( webrtc::RtpExtension::kVideoLayersAllocationUri, id++, From ae3d70a18c731c8b38bfa1de33208fb46c13f2ec Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:18:15 +0900 Subject: [PATCH 19/21] clean up --- media/engine/webrtc_video_engine.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 31e333420c..e3eadb0d00 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -680,6 +680,7 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { webrtc::RtpExtension::kVideoTimingUri, webrtc::RtpExtension::kColorSpaceUri, webrtc::RtpExtension::kMidUri, webrtc::RtpExtension::kRidUri, webrtc::RtpExtension::kRepairedRidUri, + // "WebRTC-DependencyDescriptorAdvertised" webrtc::RtpExtension::kDependencyDescriptorUri}) { result.emplace_back(uri, id++, webrtc::RtpTransceiverDirection::kSendRecv); } @@ -687,11 +688,6 @@ WebRtcVideoEngine::GetRtpHeaderExtensions() const { IsEnabled(trials_, "WebRTC-GenericDescriptorAdvertised") ? webrtc::RtpTransceiverDirection::kSendRecv : webrtc::RtpTransceiverDirection::kStopped); - // result.emplace_back( - // webrtc::RtpExtension::kDependencyDescriptorUri, id++, - // IsEnabled(trials_, "WebRTC-DependencyDescriptorAdvertised") - // ? webrtc::RtpTransceiverDirection::kSendRecv - // : webrtc::RtpTransceiverDirection::kStopped); result.emplace_back( webrtc::RtpExtension::kVideoLayersAllocationUri, id++, @@ -974,7 +970,7 @@ void WebRtcVideoChannel::RequestEncoderSwitch( void WebRtcVideoChannel::StartReceive(uint32_t ssrc) { RTC_DCHECK_RUN_ON(&thread_checker_); WebRtcVideoReceiveStream* stream = FindReceiveStream(ssrc); - if(!stream) { + if (!stream) { return; } stream->StartStream(); @@ -983,7 +979,7 @@ void WebRtcVideoChannel::StartReceive(uint32_t ssrc) { void WebRtcVideoChannel::StopReceive(uint32_t ssrc) { RTC_DCHECK_RUN_ON(&thread_checker_); WebRtcVideoReceiveStream* stream = FindReceiveStream(ssrc); - if(!stream) { + if (!stream) { return; } stream->StopStream(); @@ -3075,12 +3071,12 @@ void WebRtcVideoChannel::WebRtcVideoReceiveStream::SetRecvParameters( } } -void WebRtcVideoChannel::WebRtcVideoReceiveStream::StartStream(){ +void WebRtcVideoChannel::WebRtcVideoReceiveStream::StartStream() { if (stream_) { stream_->Start(); } } -void WebRtcVideoChannel::WebRtcVideoReceiveStream::StopStream(){ +void WebRtcVideoChannel::WebRtcVideoReceiveStream::StopStream() { if (stream_) { stream_->Stop(); } From 1cbbcc258349c7d28cc39abefc97aff57f3e3ef9 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:12:58 +0900 Subject: [PATCH 20/21] don't throw when setCodecPreferences fails --- sdk/objc/api/peerconnection/RTCRtpTransceiver.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index 2c1a216f1c..e18fd955f3 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -77,9 +77,9 @@ - (void)setCodecPreferences:(NSArray *)c webrtc::RTCError error = _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); - if (!error.ok()) { - [NSException raise:@"setCodecPreferences" format:@"SDK returned error: %@", [NSString stringWithUTF8String: error.message()]]; - } + // if (!error.ok()) { + // [NSException raise:@"setCodecPreferences" format:@"SDK returned error: %@", [NSString stringWithUTF8String: error.message()]]; + // } } - (NSArray *)codecPreferences { From 446e1b5ac9dacd1eae15af4ab159e6d4ab440a37 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:13:43 +0900 Subject: [PATCH 21/21] unused variable --- sdk/objc/api/peerconnection/RTCRtpTransceiver.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm index e18fd955f3..acb1b8032a 100644 --- a/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm +++ b/sdk/objc/api/peerconnection/RTCRtpTransceiver.mm @@ -75,7 +75,8 @@ - (void)setCodecPreferences:(NSArray *)c objects.push_back(object.nativeCodecCapability); } - webrtc::RTCError error = _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); + //webrtc::RTCError error = + _nativeRtpTransceiver->SetCodecPreferences(rtc::ArrayView(objects.data(), objects.size())); // if (!error.ok()) { // [NSException raise:@"setCodecPreferences" format:@"SDK returned error: %@", [NSString stringWithUTF8String: error.message()]];