blob: 6fb81dbb8aff9162c1e04d6c636c7250f3c33cb1 [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 "RTCVideoEncoderSettings+Private.h"
12
13#import "helpers/NSString+StdString.h"
14
15@implementation RTCVideoEncoderSettings (Private)
16
17- (instancetype)initWithNativeVideoCodec:(const webrtc::VideoCodec *)videoCodec {
18 if (self = [super init]) {
19 if (videoCodec) {
20 const char *codecName = CodecTypeToPayloadString(videoCodec->codecType);
21 self.name = [NSString stringWithUTF8String:codecName];
22
23 self.width = videoCodec->width;
24 self.height = videoCodec->height;
25 self.startBitrate = videoCodec->startBitrate;
26 self.maxBitrate = videoCodec->maxBitrate;
27 self.minBitrate = videoCodec->minBitrate;
28 self.targetBitrate = videoCodec->targetBitrate;
29 self.maxFramerate = videoCodec->maxFramerate;
30 self.qpMax = videoCodec->qpMax;
31 self.mode = (RTCVideoCodecMode)videoCodec->mode;
32 }
33 }
34
35 return self;
36}
37
38- (webrtc::VideoCodec)nativeVideoCodec {
39 webrtc::VideoCodec videoCodec;
40 videoCodec.width = self.width;
41 videoCodec.height = self.height;
42 videoCodec.startBitrate = self.startBitrate;
43 videoCodec.maxBitrate = self.maxBitrate;
44 videoCodec.minBitrate = self.minBitrate;
45 videoCodec.targetBitrate = self.targetBitrate;
46 videoCodec.maxBitrate = self.maxBitrate;
47 videoCodec.qpMax = self.qpMax;
48 videoCodec.mode = (webrtc::VideoCodecMode)self.mode;
49
50 return videoCodec;
51}
52
53@end