mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00

Bug: webrtc:15749 Change-Id: I92f5d5dc5d9eb4d0a60c33ed724a0d3e8b4fa1a8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/333402 Auto-Submit: Karim Ham <karim@karhm.com> Reviewed-by: Florent Castelli <orphis@webrtc.org> Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Florent Castelli <orphis@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41601}
60 lines
2.1 KiB
Text
60 lines
2.1 KiB
Text
/*
|
|
* Copyright 2024 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 "RTCRtpHeaderExtensionCapability+Private.h"
|
|
|
|
#import "base/RTCLogging.h"
|
|
#import "helpers/NSString+StdString.h"
|
|
|
|
@implementation RTC_OBJC_TYPE (RTCRtpCapabilities)
|
|
|
|
@synthesize codecs = _codecs;
|
|
@synthesize headerExtensions = _headerExtensions;
|
|
|
|
- (instancetype)init {
|
|
webrtc::RtpCapabilities nativeRtpCapabilities;
|
|
return [self initWithNativeRtpCapabilities:nativeRtpCapabilities];
|
|
}
|
|
|
|
- (instancetype)initWithNativeRtpCapabilities:
|
|
(const webrtc::RtpCapabilities &)nativeRtpCapabilities {
|
|
if (self = [super init]) {
|
|
NSMutableArray *codecs = [[NSMutableArray alloc] init];
|
|
for (const auto &codec : nativeRtpCapabilities.codecs) {
|
|
[codecs addObject:[[RTC_OBJC_TYPE(RTCRtpCodecCapability) alloc]
|
|
initWithNativeRtpCodecCapability:codec]];
|
|
}
|
|
_codecs = codecs;
|
|
|
|
NSMutableArray *headerExtensions = [[NSMutableArray alloc] init];
|
|
for (const auto &headerExtension : nativeRtpCapabilities.header_extensions) {
|
|
[headerExtensions addObject:[[RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) alloc]
|
|
initWithNativeRtpHeaderExtensionCapability:headerExtension]];
|
|
}
|
|
_headerExtensions = headerExtensions;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (webrtc::RtpCapabilities)nativeRtpCapabilities {
|
|
webrtc::RtpCapabilities rtpCapabilities;
|
|
for (RTC_OBJC_TYPE(RTCRtpCodecCapability) * codec in _codecs) {
|
|
rtpCapabilities.codecs.push_back(codec.nativeRtpCodecCapability);
|
|
}
|
|
for (RTC_OBJC_TYPE(RTCRtpHeaderExtensionCapability) * headerExtension in _headerExtensions) {
|
|
rtpCapabilities.header_extensions.push_back(headerExtension.nativeRtpHeaderExtensionCapability);
|
|
}
|
|
return rtpCapabilities;
|
|
}
|
|
|
|
@end
|