skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 1 | /* |
| 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 Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 17 | @synthesize minBitrateBps = _minBitrateBps; |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 18 | @synthesize ssrc = _ssrc; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 19 | |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 20 | - (instancetype)init { |
| 21 | return [super init]; |
| 22 | } |
| 23 | |
| 24 | - (instancetype)initWithNativeParameters: |
| 25 | (const webrtc::RtpEncodingParameters &)nativeParameters { |
| 26 | if (self = [self init]) { |
| 27 | _isActive = nativeParameters.active; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 28 | if (nativeParameters.max_bitrate_bps) { |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 29 | _maxBitrateBps = |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 30 | [NSNumber numberWithInt:*nativeParameters.max_bitrate_bps]; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 31 | } |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 32 | if (nativeParameters.min_bitrate_bps) { |
| 33 | _minBitrateBps = |
| 34 | [NSNumber numberWithInt:*nativeParameters.min_bitrate_bps]; |
| 35 | } |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 36 | if (nativeParameters.ssrc) { |
| 37 | _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; |
| 38 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 39 | } |
| 40 | return self; |
| 41 | } |
| 42 | |
| 43 | - (webrtc::RtpEncodingParameters)nativeParameters { |
| 44 | webrtc::RtpEncodingParameters parameters; |
| 45 | parameters.active = _isActive; |
| 46 | if (_maxBitrateBps != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 47 | parameters.max_bitrate_bps = absl::optional<int>(_maxBitrateBps.intValue); |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 48 | } |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 49 | if (_minBitrateBps != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 50 | parameters.min_bitrate_bps = absl::optional<int>(_minBitrateBps.intValue); |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 51 | } |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 52 | if (_ssrc != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 53 | parameters.ssrc = absl::optional<uint32_t>(_ssrc.unsignedLongValue); |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 54 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 55 | return parameters; |
| 56 | } |
| 57 | |
| 58 | @end |