xref: /aosp_15_r20/external/webrtc/sdk/objc/api/peerconnection/RTCVideoEncoderSettings+Private.mm (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 "RTCVideoEncoderSettings+Private.h"
12
13#import "helpers/NSString+StdString.h"
14
15@implementation RTC_OBJC_TYPE (RTCVideoEncoderSettings)
16(Private)
17
18    - (instancetype)initWithNativeVideoCodec : (const webrtc::VideoCodec *)videoCodec {
19  if (self = [super init]) {
20    if (videoCodec) {
21      const char *codecName = CodecTypeToPayloadString(videoCodec->codecType);
22      self.name = [NSString stringWithUTF8String:codecName];
23
24      self.width = videoCodec->width;
25      self.height = videoCodec->height;
26      self.startBitrate = videoCodec->startBitrate;
27      self.maxBitrate = videoCodec->maxBitrate;
28      self.minBitrate = videoCodec->minBitrate;
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.maxBitrate = self.maxBitrate;
46  videoCodec.qpMax = self.qpMax;
47  videoCodec.mode = (webrtc::VideoCodecMode)self.mode;
48
49  return videoCodec;
50}
51
52@end
53