2018-08-30 09:30:29 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright 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 "RTCVideoCodecInfo+Private.h"
|
|
|
|
|
|
2024-08-27 09:52:58 +02:00
|
|
|
#include "api/video_codecs/scalability_mode.h"
|
|
|
|
|
#include "api/video_codecs/scalability_mode_helper.h"
|
2022-05-13 14:46:42 +00:00
|
|
|
#import "helpers/NSString+StdString.h"
|
2018-08-30 09:30:29 +02:00
|
|
|
|
2020-05-04 16:14:32 +02:00
|
|
|
@implementation RTC_OBJC_TYPE (RTCVideoCodecInfo)
|
|
|
|
|
(Private)
|
2018-08-30 09:30:29 +02:00
|
|
|
|
2020-05-04 16:14:32 +02:00
|
|
|
- (instancetype)initWithNativeSdpVideoFormat : (webrtc::SdpVideoFormat)format {
|
2024-08-27 09:52:58 +02:00
|
|
|
NSMutableDictionary* params = [NSMutableDictionary dictionary];
|
|
|
|
|
for (const auto& [key, value] : format.parameters) {
|
|
|
|
|
[params setObject:[NSString stringForStdString:value] forKey:[NSString stringForStdString:key]];
|
2018-08-30 09:30:29 +02:00
|
|
|
}
|
2024-08-27 09:52:58 +02:00
|
|
|
|
|
|
|
|
NSMutableArray<NSString*>* scalabilityModes =
|
|
|
|
|
[NSMutableArray arrayWithCapacity:format.scalability_modes.size()];
|
|
|
|
|
for (webrtc::ScalabilityMode mode : format.scalability_modes) {
|
|
|
|
|
[scalabilityModes addObject:[NSString stringForAbslStringView:ScalabilityModeToString(mode)]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [self initWithName:[NSString stringForStdString:format.name]
|
|
|
|
|
parameters:params
|
|
|
|
|
scalabilityModes:scalabilityModes];
|
2018-08-30 09:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (webrtc::SdpVideoFormat)nativeSdpVideoFormat {
|
|
|
|
|
std::map<std::string, std::string> parameters;
|
|
|
|
|
for (NSString *paramKey in self.parameters.allKeys) {
|
2022-05-13 14:46:42 +00:00
|
|
|
std::string key = [NSString stdStringForString:paramKey];
|
|
|
|
|
std::string value = [NSString stdStringForString:self.parameters[paramKey]];
|
2018-08-30 09:30:29 +02:00
|
|
|
parameters[key] = value;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 09:52:58 +02:00
|
|
|
absl::InlinedVector<webrtc::ScalabilityMode, webrtc::kScalabilityModeCount> scalability_modes;
|
|
|
|
|
for (NSString* mode_name in self.scalabilityModes) {
|
2024-08-29 13:00:40 +00:00
|
|
|
std::optional<webrtc::ScalabilityMode> mode =
|
2024-08-27 09:52:58 +02:00
|
|
|
webrtc::ScalabilityModeStringToEnum([NSString stdStringForString:mode_name]);
|
|
|
|
|
if (mode.has_value()) {
|
|
|
|
|
scalability_modes.push_back(*mode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return webrtc::SdpVideoFormat(
|
|
|
|
|
[NSString stdStringForString:self.name], parameters, scalability_modes);
|
2018-08-30 09:30:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|