blob: 2eb8d366d2d34bb9275ed5dc60f3cb5fd4f29324 [file] [log] [blame]
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001/*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#import "RTCVideoCodecInfo+Private.h"
12
13#import "helpers/NSString+StdString.h"
14
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020015@implementation RTC_OBJC_TYPE (RTCVideoCodecInfo)
16(Private)
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020017
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020018 - (instancetype)initWithNativeSdpVideoFormat : (webrtc::SdpVideoFormat)format {
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020019 NSMutableDictionary *params = [NSMutableDictionary dictionary];
20 for (auto it = format.parameters.begin(); it != format.parameters.end(); ++it) {
21 [params setObject:[NSString stringForStdString:it->second]
22 forKey:[NSString stringForStdString:it->first]];
23 }
24 return [self initWithName:[NSString stringForStdString:format.name] parameters:params];
25}
26
27- (webrtc::SdpVideoFormat)nativeSdpVideoFormat {
28 std::map<std::string, std::string> parameters;
29 for (NSString *paramKey in self.parameters.allKeys) {
30 std::string key = [NSString stdStringForString:paramKey];
31 std::string value = [NSString stdStringForString:self.parameters[paramKey]];
32 parameters[key] = value;
33 }
34
35 return webrtc::SdpVideoFormat([NSString stdStringForString:self.name], parameters);
36}
37
38@end