blob: 3246371c232df1acdabef2db6f79317c3d973963 [file] [log] [blame]
skvlad79b4b872016-04-08 17:28:55 -07001/*
2 * Copyright 2016 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 "RTCRtpEncodingParameters+Private.h"
12
13@implementation RTCRtpEncodingParameters
14
15@synthesize isActive = _isActive;
16@synthesize maxBitrateBps = _maxBitrateBps;
Rasmus Brandta3e69e62018-06-05 10:55:56 +020017@synthesize minBitrateBps = _minBitrateBps;
Rasmus Brandt3c769412018-09-27 09:53:11 +020018@synthesize maxFramerate = _maxFramerate;
deadbeef8014c752017-01-06 16:53:00 -080019@synthesize ssrc = _ssrc;
skvlad79b4b872016-04-08 17:28:55 -070020
skvlad79b4b872016-04-08 17:28:55 -070021- (instancetype)init {
22 return [super init];
23}
24
25- (instancetype)initWithNativeParameters:
26 (const webrtc::RtpEncodingParameters &)nativeParameters {
27 if (self = [self init]) {
28 _isActive = nativeParameters.active;
deadbeefe702b302017-02-04 12:09:01 -080029 if (nativeParameters.max_bitrate_bps) {
skvlad79b4b872016-04-08 17:28:55 -070030 _maxBitrateBps =
deadbeefe702b302017-02-04 12:09:01 -080031 [NSNumber numberWithInt:*nativeParameters.max_bitrate_bps];
skvlad79b4b872016-04-08 17:28:55 -070032 }
Rasmus Brandta3e69e62018-06-05 10:55:56 +020033 if (nativeParameters.min_bitrate_bps) {
34 _minBitrateBps =
35 [NSNumber numberWithInt:*nativeParameters.min_bitrate_bps];
36 }
Rasmus Brandt3c769412018-09-27 09:53:11 +020037 if (nativeParameters.max_framerate) {
38 _maxFramerate = [NSNumber numberWithInt:*nativeParameters.max_framerate];
39 }
deadbeef8014c752017-01-06 16:53:00 -080040 if (nativeParameters.ssrc) {
41 _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc];
42 }
skvlad79b4b872016-04-08 17:28:55 -070043 }
44 return self;
45}
46
47- (webrtc::RtpEncodingParameters)nativeParameters {
48 webrtc::RtpEncodingParameters parameters;
49 parameters.active = _isActive;
50 if (_maxBitrateBps != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020051 parameters.max_bitrate_bps = absl::optional<int>(_maxBitrateBps.intValue);
skvlad79b4b872016-04-08 17:28:55 -070052 }
Rasmus Brandta3e69e62018-06-05 10:55:56 +020053 if (_minBitrateBps != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020054 parameters.min_bitrate_bps = absl::optional<int>(_minBitrateBps.intValue);
Rasmus Brandta3e69e62018-06-05 10:55:56 +020055 }
Rasmus Brandt3c769412018-09-27 09:53:11 +020056 if (_maxFramerate != nil) {
57 parameters.max_framerate = absl::optional<int>(_maxFramerate.intValue);
58 }
deadbeef8014c752017-01-06 16:53:00 -080059 if (_ssrc != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020060 parameters.ssrc = absl::optional<uint32_t>(_ssrc.unsignedLongValue);
deadbeef8014c752017-01-06 16:53:00 -080061 }
skvlad79b4b872016-04-08 17:28:55 -070062 return parameters;
63}
64
65@end