| OLD | NEW |
| (Empty) |
| 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 "RTCVideoCodec+Private.h" | |
| 14 #import "WebRTC/RTCVideoCodecFactory.h" | |
| 15 | |
| 16 #include "webrtc/sdk/objc/Framework/Classes/Common/helpers.h" | |
| 17 | |
| 18 @implementation RTCVideoCodecInfo | |
| 19 | |
| 20 @synthesize payload = _payload; | |
| 21 @synthesize name = _name; | |
| 22 @synthesize parameters = _parameters; | |
| 23 | |
| 24 - (instancetype)initWithPayload:(int)payload | |
| 25 name:(NSString *)name | |
| 26 parameters:(NSDictionary<NSString *, NSString *> *)paramete
rs { | |
| 27 if (self = [super init]) { | |
| 28 _payload = payload; | |
| 29 _name = name; | |
| 30 _parameters = parameters; | |
| 31 } | |
| 32 | |
| 33 return self; | |
| 34 } | |
| 35 | |
| 36 - (instancetype)initWithVideoCodec:(cricket::VideoCodec)videoCodec { | |
| 37 NSMutableDictionary *params = [NSMutableDictionary dictionary]; | |
| 38 for (auto it = videoCodec.params.begin(); it != videoCodec.params.end(); ++it)
{ | |
| 39 [params setObject:webrtc::ios::NSStringFromStdString(it->second) | |
| 40 forKey:webrtc::ios::NSStringFromStdString(it->first)]; | |
| 41 } | |
| 42 return [self initWithPayload:videoCodec.id | |
| 43 name:webrtc::ios::NSStringFromStdString(videoCodec.nam
e) | |
| 44 parameters:params]; | |
| 45 } | |
| 46 | |
| 47 - (cricket::VideoCodec)toCpp { | |
| 48 cricket::VideoCodec codec(webrtc::ios::StdStringFromNSString(_name)); | |
| 49 for (NSString *paramKey in [_parameters allKeys]) { | |
| 50 codec.SetParam(webrtc::ios::StdStringFromNSString(paramKey), | |
| 51 webrtc::ios::StdStringFromNSString(_parameters[paramKey])); | |
| 52 } | |
| 53 | |
| 54 return codec; | |
| 55 } | |
| 56 | |
| 57 @end | |
| 58 | |
| 59 @implementation RTCVideoEncoderSettings | |
| 60 | |
| 61 @synthesize name = _name; | |
| 62 @synthesize width = _width; | |
| 63 @synthesize height = _height; | |
| 64 @synthesize startBitrate = _startBitrate; | |
| 65 @synthesize maxBitrate = _maxBitrate; | |
| 66 @synthesize minBitrate = _minBitrate; | |
| 67 @synthesize targetBitrate = _targetBitrate; | |
| 68 @synthesize maxFramerate = _maxFramerate; | |
| 69 @synthesize qpMax = _qpMax; | |
| 70 | |
| 71 - (instancetype)initWithVideoCodec:(const webrtc::VideoCodec *__nullable)videoCo
dec { | |
| 72 if (self = [super init]) { | |
| 73 if (videoCodec) { | |
| 74 rtc::Optional<const char *> codecName = CodecTypeToPayloadName(videoCodec-
>codecType); | |
| 75 if (codecName) { | |
| 76 _name = [NSString stringWithUTF8String:codecName.value()]; | |
| 77 } | |
| 78 | |
| 79 _width = videoCodec->width; | |
| 80 _height = videoCodec->height; | |
| 81 _startBitrate = videoCodec->startBitrate; | |
| 82 _maxBitrate = videoCodec->maxBitrate; | |
| 83 _minBitrate = videoCodec->minBitrate; | |
| 84 _targetBitrate = videoCodec->targetBitrate; | |
| 85 _maxFramerate = videoCodec->maxFramerate; | |
| 86 _qpMax = videoCodec->qpMax; | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 return self; | |
| 91 } | |
| 92 | |
| 93 - (webrtc::VideoCodec *)toCpp { | |
| 94 webrtc::VideoCodec *codecSettings = new webrtc::VideoCodec; | |
| 95 | |
| 96 rtc::Optional<webrtc::VideoCodecType> codecType = | |
| 97 webrtc::PayloadNameToCodecType(webrtc::ios::StdStringFromNSString(_name)); | |
| 98 if (codecType) { | |
| 99 codecSettings->codecType = codecType.value(); | |
| 100 } | |
| 101 | |
| 102 codecSettings->width = _width; | |
| 103 codecSettings->height = _height; | |
| 104 codecSettings->startBitrate = _startBitrate; | |
| 105 codecSettings->maxBitrate = _maxBitrate; | |
| 106 codecSettings->minBitrate = _minBitrate; | |
| 107 codecSettings->targetBitrate = _targetBitrate; | |
| 108 codecSettings->maxFramerate = _maxFramerate; | |
| 109 codecSettings->qpMax = _qpMax; | |
| 110 | |
| 111 return codecSettings; | |
| 112 } | |
| 113 | |
| 114 @end | |
| OLD | NEW |