blob: 4936568dd1b6fd04c5b4e96787b0c46508428127 [file] [log] [blame]
kthelgasonfb143122017-07-25 07:55:58 -07001/*
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 "WebRTC/RTCVideoCodec.h"
12
13#import "NSString+StdString.h"
14#import "RTCVideoCodec+Private.h"
15#import "WebRTC/RTCVideoCodecFactory.h"
16
17@implementation RTCVideoCodecInfo
18
19@synthesize payload = _payload;
20@synthesize name = _name;
21@synthesize parameters = _parameters;
22
andersc81bc5232017-08-18 06:34:09 -070023- (instancetype)initWithName:(NSString *)name
24 parameters:(nullable NSDictionary<NSString *, NSString *> *)parameters {
kthelgasonfb143122017-07-25 07:55:58 -070025 if (self = [super init]) {
andersc81bc5232017-08-18 06:34:09 -070026 _payload = 0;
kthelgasonfb143122017-07-25 07:55:58 -070027 _name = name;
andersc81bc5232017-08-18 06:34:09 -070028 _parameters = (parameters ? parameters : @{});
kthelgasonfb143122017-07-25 07:55:58 -070029 }
30
31 return self;
32}
33
magjed8eab09c2017-07-31 02:56:35 -070034- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec {
kthelgasonfb143122017-07-25 07:55:58 -070035 NSMutableDictionary *params = [NSMutableDictionary dictionary];
36 for (auto it = videoCodec.params.begin(); it != videoCodec.params.end(); ++it) {
37 [params setObject:[NSString stringForStdString:it->second]
38 forKey:[NSString stringForStdString:it->first]];
39 }
40 return [self initWithPayload:videoCodec.id
41 name:[NSString stringForStdString:videoCodec.name]
42 parameters:params];
43}
44
andersc81bc5232017-08-18 06:34:09 -070045- (instancetype)initWithPayload:(NSInteger)payload
46 name:(NSString *)name
47 parameters:(NSDictionary<NSString *, NSString *> *)parameters {
48 if (self = [self initWithName:name parameters:parameters]) {
49 _payload = payload;
50 }
51
52 return self;
53}
54
magjed8eab09c2017-07-31 02:56:35 -070055- (cricket::VideoCodec)nativeVideoCodec {
kthelgasonfb143122017-07-25 07:55:58 -070056 cricket::VideoCodec codec([NSString stdStringForString:_name]);
57 for (NSString *paramKey in _parameters.allKeys) {
58 codec.SetParam([NSString stdStringForString:paramKey],
59 [NSString stdStringForString:_parameters[paramKey]]);
60 }
61
62 return codec;
63}
64
65@end
magjed5dfac332017-08-01 08:07:59 -070066
67@implementation RTCVideoEncoderQpThresholds
68
69@synthesize low = _low;
70@synthesize high = _high;
71
72- (instancetype)initWithThresholdsLow:(NSInteger)low high:(NSInteger)high {
73 if (self = [super init]) {
74 _low = low;
75 _high = high;
76 }
77 return self;
78}
79
80@end