blob: fe7e690517b8711e938908b266f370d9ef9f8ceb [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;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020028 self.maxFramerate = videoCodec->maxFramerate;
29 self.qpMax = videoCodec->qpMax;
30 self.mode = (RTCVideoCodecMode)videoCodec->mode;
31 }
32 }
33
34 return self;
35}
36
37- (webrtc::VideoCodec)nativeVideoCodec {
38 webrtc::VideoCodec videoCodec;
39 videoCodec.width = self.width;
40 videoCodec.height = self.height;
41 videoCodec.startBitrate = self.startBitrate;
42 videoCodec.maxBitrate = self.maxBitrate;
43 videoCodec.minBitrate = self.minBitrate;
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020044 videoCodec.maxBitrate = self.maxBitrate;
45 videoCodec.qpMax = self.qpMax;
46 videoCodec.mode = (webrtc::VideoCodecMode)self.mode;
47
48 return videoCodec;
49}
50
51@end