blob: 21aacf62817c035af3fdcf731d1dcd9e49bc4665 [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
15@implementation RTCVideoCodecInfo (Private)
16
17- (instancetype)initWithNativeSdpVideoFormat:(webrtc::SdpVideoFormat)format {
18 NSMutableDictionary *params = [NSMutableDictionary dictionary];
19 for (auto it = format.parameters.begin(); it != format.parameters.end(); ++it) {
20 [params setObject:[NSString stringForStdString:it->second]
21 forKey:[NSString stringForStdString:it->first]];
22 }
23 return [self initWithName:[NSString stringForStdString:format.name] parameters:params];
24}
25
26- (webrtc::SdpVideoFormat)nativeSdpVideoFormat {
27 std::map<std::string, std::string> parameters;
28 for (NSString *paramKey in self.parameters.allKeys) {
29 std::string key = [NSString stdStringForString:paramKey];
30 std::string value = [NSString stdStringForString:self.parameters[paramKey]];
31 parameters[key] = value;
32 }
33
34 return webrtc::SdpVideoFormat([NSString stdStringForString:self.name], parameters);
35}
36
37@end