kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 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 "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 | |
andersc | 81bc523 | 2017-08-18 06:34:09 -0700 | [diff] [blame] | 23 | - (instancetype)initWithName:(NSString *)name |
| 24 | parameters:(nullable NSDictionary<NSString *, NSString *> *)parameters { |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 25 | if (self = [super init]) { |
andersc | 81bc523 | 2017-08-18 06:34:09 -0700 | [diff] [blame] | 26 | _payload = 0; |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 27 | _name = name; |
andersc | 81bc523 | 2017-08-18 06:34:09 -0700 | [diff] [blame] | 28 | _parameters = (parameters ? parameters : @{}); |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | return self; |
| 32 | } |
| 33 | |
magjed | 8eab09c | 2017-07-31 02:56:35 -0700 | [diff] [blame] | 34 | - (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec { |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 35 | 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 | |
andersc | 81bc523 | 2017-08-18 06:34:09 -0700 | [diff] [blame] | 45 | - (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 | |
magjed | 8eab09c | 2017-07-31 02:56:35 -0700 | [diff] [blame] | 55 | - (cricket::VideoCodec)nativeVideoCodec { |
kthelgason | fb14312 | 2017-07-25 07:55:58 -0700 | [diff] [blame] | 56 | 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 |
magjed | 5dfac33 | 2017-08-01 08:07:59 -0700 | [diff] [blame] | 66 | |
| 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 |