1/*
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 RTC_OBJC_TYPE (RTCVideoCodecInfo)
16(Private)
17
18    - (instancetype)initWithNativeSdpVideoFormat : (webrtc::SdpVideoFormat)format {
19  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
39